|
3 | 3 | # @Author: oesteban
|
4 | 4 | # @Date: 2014-08-31 20:32:22
|
5 | 5 | # @Last Modified by: oesteban
|
6 |
| -# @Last Modified time: 2014-09-01 18:12:14 |
| 6 | +# @Last Modified time: 2014-09-02 09:41:46 |
7 | 7 | """
|
8 | 8 | ===================
|
9 | 9 | dMRI: Preprocessing
|
|
23 | 23 |
|
24 | 24 | Import necessary modules from nipype.
|
25 | 25 | """
|
26 |
| - |
| 26 | +import os # system functions |
27 | 27 | import nipype.interfaces.io as nio # Data i/o
|
28 | 28 | import nipype.interfaces.utility as util # utility
|
29 |
| -import nipype.pipeline.engine as pe # pypeline engine |
30 |
| -import nipype.interfaces.fsl as fsl |
31 | 29 | import nipype.algorithms.misc as misc
|
32 |
| -import os # system functions |
| 30 | + |
| 31 | +import nipype.pipeline.engine as pe # pypeline engine |
| 32 | + |
| 33 | +from nipype.interfaces import fsl |
| 34 | +from nipype.interfaces import ants |
| 35 | + |
33 | 36 |
|
34 | 37 |
|
35 | 38 | """
|
|
48 | 51 | """
|
49 | 52 |
|
50 | 53 | info = dict(dwi=[['subject_id', 'dwidata']],
|
51 |
| - bvecs=[['subject_id','bvecs']], |
52 |
| - bvals=[['subject_id','bvals']], |
53 |
| - dwi_rev=[['subject_id','nodif_PA']]) |
| 54 | + bvecs=[['subject_id', 'bvecs']], |
| 55 | + bvals=[['subject_id', 'bvals']], |
| 56 | + dwi_rev=[['subject_id', 'nodif_PA']]) |
54 | 57 |
|
55 | 58 | infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id']),
|
56 | 59 | name="infosource")
|
|
81 | 84 | """
|
82 | 85 |
|
83 | 86 | datasource = pe.Node(nio.DataGrabber(infields=['subject_id'],
|
84 |
| - outfields=info.keys()), name = 'datasource') |
| 87 | + outfields=info.keys()), name='datasource') |
85 | 88 |
|
86 | 89 | datasource.inputs.template = "%s/%s"
|
87 | 90 |
|
88 | 91 | # This needs to point to the fdt folder you can find after extracting
|
89 | 92 | # http://www.fmrib.ox.ac.uk/fslcourse/fsl_course_data2.tar.gz
|
90 | 93 | datasource.inputs.base_directory = os.path.abspath('fdt1')
|
91 |
| -datasource.inputs.field_template = dict(dwi='%s/%s.nii.gz', dwi_rev='%s/%s.nii.gz') |
| 94 | +datasource.inputs.field_template = dict(dwi='%s/%s.nii.gz', |
| 95 | + dwi_rev='%s/%s.nii.gz') |
92 | 96 | datasource.inputs.template_args = info
|
93 | 97 | datasource.inputs.sort_filelist = True
|
94 | 98 |
|
95 | 99 |
|
96 | 100 | """
|
97 |
| -An inputnode is used to pass the data obtained by the data grabber to the actual processing functions |
| 101 | +An inputnode is used to pass the data obtained by the data grabber to the |
| 102 | +actual processing functions |
98 | 103 | """
|
99 | 104 |
|
100 | 105 | inputnode = pe.Node(util.IdentityInterface(fields=["dwi", "bvecs", "bvals",
|
|
106 | 111 | Setup for dMRI preprocessing
|
107 | 112 | ============================
|
108 | 113 |
|
109 |
| -In this section we initialize the appropriate workflow for preprocessing of diffusion images. |
110 |
| -Particularly, we look into the ``acqparams.txt`` file of the selected subject to gather the |
111 |
| -encoding direction, acceleration factor (in parallel sequences it is > 1), and readout time or |
112 |
| -echospacing. |
| 114 | +In this section we initialize the appropriate workflow for preprocessing of |
| 115 | +diffusion images. |
| 116 | +
|
| 117 | +Artifacts correction |
| 118 | +-------------------- |
| 119 | +
|
| 120 | +We will use the combination of ```topup``` and ```eddy``` as suggested by FSL. |
| 121 | +
|
| 122 | +In order to configure the susceptibility distortion correction (SDC), we first |
| 123 | +write the specific parameters of our echo-planar imaging (EPI) images. |
| 124 | +
|
| 125 | +Particularly, we look into the ``acqparams.txt`` file of the selected subject |
| 126 | +to gather the encoding direction, acceleration factor (in parallel sequences |
| 127 | +it is > 1), and readout time or echospacing. |
113 | 128 |
|
114 | 129 | """
|
115 | 130 |
|
|
118 | 133 | prep = all_peb_pipeline(epi_params=epi_AP, altepi_params=epi_PA)
|
119 | 134 |
|
120 | 135 |
|
| 136 | +""" |
| 137 | +
|
| 138 | +Bias field correction |
| 139 | +--------------------- |
| 140 | +
|
| 141 | +Finally, we set up a node to estimate a single multiplicative bias field from |
| 142 | +the *b0* image, as suggested in [Jeurissen2014]_. |
| 143 | +
|
| 144 | +""" |
| 145 | + |
| 146 | +n4 = pe.Node(ants.N4BiasFieldCorrection(dimension=3), name='Bias_b0') |
| 147 | +split = pe.Node(fsl.Split(dimension='t'), name='SplitDWIs') |
| 148 | +merge = pe.Node(niu.Function(input_names=['in_dwi', 'in_bval', 'in_corrected'], |
| 149 | + output_names=['out_file'], function=recompose_dwi), name='MergeDWIs') |
| 150 | + |
121 | 151 | """
|
122 | 152 | Connect nodes in workflow
|
123 | 153 | =========================
|
124 | 154 |
|
125 |
| -We create a higher level workflow to connect the nodes. Please excuse the author for |
126 |
| -writing the arguments of the ``connect`` function in a not-standard fashion with readability |
127 |
| -aims. |
| 155 | +We create a higher level workflow to connect the nodes. Please excuse the |
| 156 | +author for writing the arguments of the ``connect`` function in a not-standard |
| 157 | +style with readability aims. |
128 | 158 | """
|
129 | 159 |
|
130 | 160 | wf = pe.Workflow(name="dMRI_Preprocessing")
|
|
145 | 175 | if __name__ == '__main__':
|
146 | 176 | wf.run()
|
147 | 177 | wf.write_graph()
|
| 178 | + |
| 179 | + |
| 180 | +""" |
| 181 | + |
| 182 | +.. admonition:: References |
| 183 | + |
| 184 | + .. [Jeurissen2014] Jeurissen B. et al., `Multi-tissue constrained spherical deconvolution |
| 185 | + for improved analysis of multi-shell diffusion MRI data |
| 186 | + <http://dx.doi.org/10.1016/j.neuroimage.2014.07.061>`_. NeuroImage (2014). |
| 187 | + doi: 10.1016/j.neuroimage.2014.07.061 |
0 commit comments