@@ -10,7 +10,7 @@ structured directory layouts.
10
10
- it's faster than parsesdicomdir or mri_convert if you use dcm2niix option
11
11
- it tracks the provenance of the conversion from DICOM to NIfTI in W3C
12
12
PROV format
13
- - the cmrr_heuristic example shows a conversion to [ BIDS] ( http://bids.neuroimaging.io )
13
+ - the cmrr_heuristic example shows a conversion to [ BIDS] ( http://bids.neuroimaging.io )
14
14
layout structure
15
15
16
16
## Install
@@ -33,18 +33,30 @@ as long as the following dependencies are in your path you can use the script
33
33
- nibabel
34
34
- dcm2niix
35
35
36
+ ## Tutorial with example conversion to BIDS format using Docker
37
+ Please read this tutorial to understand how heudiconv works in practice.
38
+
39
+ [ Slides here] ( http://nipy.org/workshops/2017-03-boston/lectures/bids-heudiconv/#1 )
40
+
41
+ To generate lean BIDS output, consider using both the ` -b ` and the ` --minmeta ` flags
42
+ to your heudiconv command. The ` -b ` flag generates a json file with BIDS keys, while
43
+ the ` --minmeta ` flag restricts the json file to only BIDS keys. Without ` --minmeta ` ,
44
+ the json file and the associated Nifti file contains DICOM metadata extracted using
45
+ dicomstack.
46
+
36
47
## How it works (in some more detail)
37
48
38
49
Call ` heudiconv ` like this:
39
50
40
- heudiconv -d '%s *.tar*' -s xx05 -f ~/myheuristics/convertall.py
51
+ heudiconv -d '{subject} *.tar*' -s xx05 -f ~/myheuristics/convertall.py
41
52
42
- where ` -d '%s*tar*' ` is an expression used to find DICOM files (` %s ` expands to
43
- a subject ID so that the expression will match any ` .tar ` files, compressed
44
- or not that start with the subject ID in their name). ` -s od05 ` specifies a
45
- subject ID for the conversion (this could be a list of multiple IDs), and
46
- ` -f ~/myheuristics/convertall.py ` identifies a heuristic implementation for this
47
- conversion (see below) for details.
53
+ where ` -d '{subject}*tar*' ` is an expression used to find DICOM files
54
+ (` {subject} ` expands to a subject ID so that the expression will match any
55
+ ` .tar ` files, compressed or not that start with the subject ID in their name).
56
+ An additional flag for session (` {session} ` ) can be included in the expression
57
+ as well. ` -s od05 ` specifies a subject ID for the conversion (this could be a
58
+ list of multiple IDs), and ` -f ~/myheuristics/convertall.py ` identifies a
59
+ heuristic implementation for this conversion (see below) for details.
48
60
49
61
This call will locate the DICOMs (in any number of matching tarballs), extract
50
62
them to a temporary directory, search for any DICOM series it can find, and
@@ -70,65 +82,82 @@ soon you'll be able to:
70
82
## The heuristic file
71
83
72
84
The heuristic file controls how information about the dicoms is used to convert
73
- to a file system layout (e.g., BIDS). This is a python file that must have the
85
+ to a file system layout (e.g., BIDS). This is a python file that must have the
74
86
function ` infotodict ` , which takes a single argument ` seqinfo ` .
75
87
76
88
### ` seqinfo ` and the ` s ` variable
77
89
78
- Each item in ` seqinfo ` contains the following ordered elements.
90
+ ` seqinfo ` is a list of namedtuple objects, each containing the following fields:
91
+
92
+ * total_files_till_now
93
+ * example_dcm_file
94
+ * series_id
95
+ * dcm_dir_name
96
+ * unspecified2
97
+ * unspecified3
98
+ * dim1
99
+ * dim2
100
+ * dim3
101
+ * dim4
102
+ * TR
103
+ * TE
104
+ * protocol_name
105
+ * is_motion_corrected
106
+ * is_derived
107
+ * patient_id
108
+ * study_description
109
+ * referring_physician_name
110
+ * series_description
111
+ * image_type
79
112
80
113
```
81
- [total_files_till_now, example_dcm_file, series_number, unspecified, unspecified,
82
- unspecified, dim1, dim2, dim3, dim4, TR, TE, SeriesDescription, MotionCorrectedOrNot]
83
-
84
114
128 125000-1-1.dcm 1 - -
85
115
- 160 160 128 1 0.00315 1.37 AAHScout False
86
116
```
87
117
88
118
### The dictionary returned by ` infotodict `
89
-
119
+
90
120
This dictionary contains as keys a 3-tuple `(template, a tuple of output types,
91
121
annotation classes)`.
92
122
93
123
template - how the file should be relative to the base directory
94
- tuple of output types - what format of output should be created - nii.gz, dicom,
124
+ tuple of output types - what format of output should be created - nii.gz, dicom,
95
125
etc.,.
96
126
annotation classes - unused
97
127
98
128
```
99
- Example: ('func/sub-{subject}_task-face_run-{item:02d}_acq-PA_bold', ('nii.gz',
129
+ Example: ('func/sub-{subject}_task-face_run-{item:02d}_acq-PA_bold', ('nii.gz',
100
130
'dicom'), None)
101
131
```
102
132
103
133
A few fields are defined by default and can be used in the template:
104
134
105
- - item: index within category
106
- - subject: participant id
135
+ - item: index within category
136
+ - subject: participant id
107
137
- seqitem: run number during scanning
108
138
- subindex: sub index within group
109
- - session: session info for multi-session studies and when session has been
139
+ - session: session info for multi-session studies and when session has been
110
140
defined as a parameter for heudiconv
111
141
112
- Additional variables may be added and can be returned in the value of the
142
+ Additional variables may be added and can be returned in the value of the
113
143
dictionary returned from the function.
114
144
115
- ` info[some_3-tuple] = [12, 14, 16] ` would assign dicom sequence groups 12, 14
145
+ ` info[some_3-tuple] = [12, 14, 16] ` would assign dicom sequence groups 12, 14
116
146
and 16 to be converted using the template specified in ` some_3-tuple ` .
117
147
118
- if the template contained a non-sanctioned variable, it would have to be
148
+ if the template contained a non-sanctioned variable, it would have to be
119
149
provided in the values for that key.
120
150
121
151
```
122
- some_3_tuple = ('func/sub-{subject}_task-face_run-{item:02d}_acq-{acq}_bold', ('nii.gz',
152
+ some_3_tuple = ('func/sub-{subject}_task-face_run-{item:02d}_acq-{acq}_bold', ('nii.gz',
123
153
'dicom'), None)
124
154
```
125
155
126
- In the above example ` {acq} ` is not a standard variable. In this case, values
156
+ In the above example ` {acq} ` is not a standard variable. In this case, values
127
157
for this variable needs to be added.
128
158
129
159
```
130
160
info[some_3-tuple] = [{'item': 12, 'acq': 'AP'},
131
161
{'item': 14, 'acq': 'AP'},
132
162
{'item': 16, 'acq': 'PA'}]
133
163
```
134
-
0 commit comments