My sample folders are organized in this way.
I use Philips fMRI data from ADNI, and each subject has different imaging date numbers. In other words, multiple subjects with multiple sessions without any rule.
- Myproject
- Dicom2
- 130S4883
- 20120103
- anat
- func
- 20130506
- anat
- func
- 20120103
- 136S4517
- 20140506
- anat
- func
- 20151104
- anat
- func
- 20161107
- anat
- func
- 20140506
- 130S4883
- Dicom2
And I used heudiconv on Linux terminal.
The code I used is attached below.
for subject in $(ls -1 /home/rrt/MyProject/Dicom2/); do
for session in $(ls -1 /home/rrt/MyProject/Dicom2/${subject/}); do
sudo docker run --rm -it
-v /home/rrt/MyProject:/base
nipy/heudiconv:latest
-d /base/Dicom2/{subject}/{session}/* /*.dcm
-o /base/Nifti2_sess2/
-f /base/Nifti2_sess2/code/convertall.py
-s ${subject}
-ss ${session}
-c dcm2niix -b
–overwrite;
done;
done
Error such as “AssertionError: Conflicting study identifiers found [2.16.124.113543.6006.99.06413494192697466191, 2.16.124.113543.6006.99.04058827386078038047].” occured.
What should I do?
Below is the convertall.py file.
def infotodict(seqinfo):
# Section 1: These key definitions should be revised by the user scanner.
data = create_key('run-{item:03d}')
t1w = create_key('sub-{subject}/{session}/anat/sub-{subject}_{session}_T1w')
func_rest = create_key('sub-{subject}/{session}/func/sub-{subject}_{session}_task-rest_bold')
# Section 1b: This data dictionary (below) should be revised by the user.
info = {data: [], t1w: [], func_rest: []}
last_run = len(seqinfo)
# Section 2: These criteria should be revised by user.
for idx, s in enumerate(seqinfo):
if ('MPRAGE' in s.protocol_name) and (s.dim3 == 170):
info[t1w].append(s.series_id)
if ('Resting' in s.protocol_name):
info[func_rest].append(s.series_id)
return info