|
23 | 23 | import nipype.pipeline.engine as pe # pypeline engine
|
24 | 24 | import nipype.interfaces.mrtrix as mrtrix #<---- The important new part!
|
25 | 25 | import nipype.interfaces.fsl as fsl
|
26 |
| -import nibabel as nb |
| 26 | +import nipype.algorithms.misc as misc |
27 | 27 | import os, os.path as op # system functions
|
28 | 28 |
|
29 |
| -""" |
30 |
| -We import the voxel-, data-, and affine-grabbing functions from the Camino DTI processing workflow |
31 |
| -""" |
32 |
| - |
33 |
| -from nipype.workflows.camino.diffusion import get_vox_dims, get_data_dims, get_affine |
34 |
| - |
35 | 29 | """
|
36 | 30 | This needs to point to the fdt folder you can find after extracting
|
37 | 31 |
|
|
50 | 44 | infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id']), name="infosource")
|
51 | 45 | infosource.iterables = ('subject_id', subject_list)
|
52 | 46 |
|
53 |
| -info = dict(dwi=[['subject_id', 'dwi']], |
| 47 | +info = dict(dwi=[['subject_id', 'data']], |
54 | 48 | bvecs=[['subject_id','bvecs']],
|
55 | 49 | bvals=[['subject_id','bvals']])
|
56 | 50 |
|
|
65 | 59 |
|
66 | 60 | datasource.inputs.template = "%s/%s"
|
67 | 61 | datasource.inputs.base_directory = data_dir
|
68 |
| -datasource.inputs.field_template = dict(dwi='%s/%s.nii') |
| 62 | +datasource.inputs.field_template = dict(dwi='%s/%s.nii.gz') |
69 | 63 | datasource.inputs.template_args = info
|
70 | 64 |
|
71 | 65 | """
|
|
99 | 93 | * Apparent diffusion coefficient
|
100 | 94 | * Fractional anisotropy
|
101 | 95 | """
|
102 |
| - |
| 96 | +gunzip = pe.Node(interface=misc.Gunzip(), name='gunzip') |
103 | 97 | dwi2tensor = pe.Node(interface=mrtrix.DWI2Tensor(),name='dwi2tensor')
|
104 | 98 | tensor2vector = pe.Node(interface=mrtrix.Tensor2Vector(),name='tensor2vector')
|
105 | 99 | tensor2adc = pe.Node(interface=mrtrix.Tensor2ApparentDiffusion(),name='tensor2adc')
|
|
179 | 173 |
|
180 | 174 | tractography.connect([(inputnode, fsl2mrtrix, [("bvecs", "bvec_file"),
|
181 | 175 | ("bvals", "bval_file")])])
|
182 |
| -tractography.connect([(inputnode, dwi2tensor,[("dwi","in_file")])]) |
| 176 | +tractography.connect([(inputnode, gunzip,[("dwi","in_file")])]) |
| 177 | +tractography.connect([(gunzip, dwi2tensor,[("out_file","in_file")])]) |
183 | 178 | tractography.connect([(fsl2mrtrix, dwi2tensor,[("encoding_file","encoding_file")])])
|
184 | 179 |
|
185 | 180 | tractography.connect([(dwi2tensor, tensor2vector,[['tensor','in_file']]),
|
|
193 | 188 | fractional anisotropy image, and thresholds it to get the single-fiber voxels.
|
194 | 189 | """
|
195 | 190 |
|
196 |
| -tractography.connect([(inputnode, MRconvert,[("dwi","in_file")])]) |
| 191 | +tractography.connect([(gunzip, MRconvert,[("out_file","in_file")])]) |
197 | 192 | tractography.connect([(MRconvert, threshold_b0,[("converted","in_file")])])
|
198 | 193 | tractography.connect([(threshold_b0, median3d,[("out_file","in_file")])])
|
199 | 194 | tractography.connect([(median3d, erode_mask_firstpass,[("out_file","in_file")])])
|
|
206 | 201 | Here the thresholded white matter mask is created for seeding the tractography.
|
207 | 202 | """
|
208 | 203 |
|
209 |
| -tractography.connect([(inputnode, bet,[("dwi","in_file")])]) |
210 |
| -tractography.connect([(inputnode, gen_WM_mask,[("dwi","in_file")])]) |
| 204 | +tractography.connect([(gunzip, bet,[("out_file","in_file")])]) |
| 205 | +tractography.connect([(gunzip, gen_WM_mask,[("out_file","in_file")])]) |
211 | 206 | tractography.connect([(bet, gen_WM_mask,[("mask_file","binary_mask")])])
|
212 | 207 | tractography.connect([(fsl2mrtrix, gen_WM_mask,[("encoding_file","encoding_file")])])
|
213 | 208 | tractography.connect([(gen_WM_mask, threshold_wmmask,[("WMprobabilitymap","in_file")])])
|
|
216 | 211 | Next we estimate the fiber response distribution.
|
217 | 212 | """
|
218 | 213 |
|
219 |
| -tractography.connect([(inputnode, estimateresponse,[("dwi","in_file")])]) |
| 214 | +tractography.connect([(gunzip, estimateresponse,[("out_file","in_file")])]) |
220 | 215 | tractography.connect([(fsl2mrtrix, estimateresponse,[("encoding_file","encoding_file")])])
|
221 | 216 | tractography.connect([(threshold_FA, estimateresponse,[("out_file","mask_image")])])
|
222 | 217 |
|
223 | 218 | """
|
224 | 219 | Run constrained spherical deconvolution.
|
225 | 220 | """
|
226 | 221 |
|
227 |
| -tractography.connect([(inputnode, csdeconv,[("dwi","in_file")])]) |
| 222 | +tractography.connect([(gunzip, csdeconv,[("out_file","in_file")])]) |
228 | 223 | tractography.connect([(gen_WM_mask, csdeconv,[("WMprobabilitymap","mask_image")])])
|
229 | 224 | tractography.connect([(estimateresponse, csdeconv,[("response","response_file")])])
|
230 | 225 | tractography.connect([(fsl2mrtrix, csdeconv,[("encoding_file","encoding_file")])])
|
|
236 | 231 | tractography.connect([(threshold_wmmask, probCSDstreamtrack,[("out_file","seed_file")])])
|
237 | 232 | tractography.connect([(csdeconv, probCSDstreamtrack,[("spherical_harmonics_image","in_file")])])
|
238 | 233 | tractography.connect([(probCSDstreamtrack, tracks2prob,[("tracked","in_file")])])
|
239 |
| -tractography.connect([(inputnode, tracks2prob,[("dwi","template_file")])]) |
| 234 | +tractography.connect([(gunzip, tracks2prob,[("out_file","template_file")])]) |
| 235 | + |
| 236 | +tractography.connect([(gunzip, tck2trk,[("out_file","image_file")])]) |
| 237 | +tractography.connect([(probCSDstreamtrack, tck2trk,[("tracked","in_file")])]) |
240 | 238 |
|
241 | 239 | """
|
242 | 240 | Finally, we create another higher-level workflow to connect our tractography workflow with the info and datagrabbing nodes
|
|
0 commit comments