15
15
16
16
import os .path as op
17
17
18
- from ..base import traits , TraitedSpec , File
18
+ from ..base import traits , TraitedSpec , File , Undefined
19
19
from .base import MRTrix3BaseInputSpec , MRTrix3Base
20
20
21
21
@@ -74,108 +74,55 @@ def _list_outputs(self):
74
74
75
75
76
76
class EstimateFODInputSpec (MRTrix3BaseInputSpec ):
77
- in_file = File (exists = True , argstr = '%s' , mandatory = True , position = - 3 ,
78
- desc = 'input diffusion weighted images' )
79
- response = File (
80
- exists = True , argstr = '%s' , mandatory = True , position = - 2 ,
81
- desc = ('a text file containing the diffusion-weighted signal response '
82
- 'function coefficients for a single fibre population' ))
83
- out_file = File (
84
- 'fods.mif' , argstr = '%s' , mandatory = True , position = - 1 ,
85
- usedefault = True , desc = ('the output spherical harmonics coefficients'
86
- ' image' ))
77
+ algorithm = traits .Enum ('csd' ,'msmt_csd' , argstr = '%s' , position = - 8 ,
78
+ mandatory = True , desc = 'FOD algorithm' )
79
+ in_file = File (exists = True , argstr = '%s' , position = - 7 ,
80
+ mandatory = True , desc = 'input DWI image' )
81
+ wm_txt = File (argstr = '%s' , position = - 6 ,
82
+ mandatory = True , desc = 'WM response text file' )
83
+ wm_odf = File ('wm.mif' , argstr = '%s' , position = - 5 , usedefault = True ,
84
+ mandatory = True , desc = 'output WM ODF' )
85
+ gm_txt = File (argstr = '%s' , position = - 4 , desc = 'GM response text file' )
86
+ gm_odf = File ('gm.mif' , argstr = '%s' , position = - 3 , desc = 'output GM ODF' )
87
+ csf_txt = File (argstr = '%s' , position = - 2 , desc = 'CSF response text file' )
88
+ csf_odf = File ('csf.mif' , argstr = '%s' , position = - 1 , desc = 'output CSF ODF' )
89
+ mask_file = File (exists = True , argstr = '-mask %s' , desc = 'mask image' )
87
90
88
91
# DW Shell selection options
89
92
shell = traits .List (traits .Float , sep = ',' , argstr = '-shell %s' ,
90
93
desc = 'specify one or more dw gradient shells' )
91
-
92
- # Spherical deconvolution options
93
94
max_sh = traits .Int (8 , argstr = '-lmax %d' ,
94
95
desc = 'maximum harmonic degree of response function' )
95
- in_mask = File (exists = True , argstr = '-mask %s' ,
96
- desc = 'provide initial mask image' )
97
96
in_dirs = File (
98
97
exists = True , argstr = '-directions %s' ,
99
98
desc = ('specify the directions over which to apply the non-negativity '
100
99
'constraint (by default, the built-in 300 direction set is '
101
100
'used). These should be supplied as a text file containing the '
102
101
'[ az el ] pairs for the directions.' ))
103
- sh_filter = File (
104
- exists = True , argstr = '-filter %s' ,
105
- desc = ('the linear frequency filtering parameters used for the initial '
106
- 'linear spherical deconvolution step (default = [ 1 1 1 0 0 ]). '
107
- 'These should be supplied as a text file containing the '
108
- 'filtering coefficients for each even harmonic order.' ))
109
-
110
- neg_lambda = traits .Float (
111
- 1.0 , argstr = '-neg_lambda %f' ,
112
- desc = ('the regularisation parameter lambda that controls the strength'
113
- ' of the non-negativity constraint' ))
114
- thres = traits .Float (
115
- 0.0 , argstr = '-threshold %f' ,
116
- desc = ('the threshold below which the amplitude of the FOD is assumed '
117
- 'to be zero, expressed as an absolute amplitude' ))
118
-
119
- n_iter = traits .Int (
120
- 50 , argstr = '-niter %d' , desc = ('the maximum number of iterations '
121
- 'to perform for each voxel' ))
122
102
123
103
124
104
class EstimateFODOutputSpec (TraitedSpec ):
125
- out_file = File (exists = True , desc = 'the output response file' )
105
+ wm_odf = File (argstr = '%s' , desc = 'output WM ODF' )
106
+ gm_odf = File (argstr = '%s' , desc = 'output GM ODF' )
107
+ csf_odf = File (argstr = '%s' , desc = 'output CSF ODF' )
126
108
127
109
128
110
class EstimateFOD (MRTrix3Base ):
129
111
130
112
"""
131
- Convert diffusion-weighted images to tensor images
132
-
133
- Note that this program makes use of implied symmetries in the diffusion
134
- profile. First, the fact the signal attenuation profile is real implies
135
- that it has conjugate symmetry, i.e. Y(l,-m) = Y(l,m)* (where * denotes
136
- the complex conjugate). Second, the diffusion profile should be
137
- antipodally symmetric (i.e. S(x) = S(-x)), implying that all odd l
138
- components should be zero. Therefore, this program only computes the even
139
- elements.
140
-
141
- Note that the spherical harmonics equations used here differ slightly from
142
- those conventionally used, in that the (-1)^m factor has been omitted.
143
- This should be taken into account in all subsequent calculations.
144
- The spherical harmonic coefficients are stored as follows. First, since
145
- the signal attenuation profile is real, it has conjugate symmetry, i.e.
146
- Y(l,-m) = Y(l,m)* (where * denotes the complex conjugate). Second, the
147
- diffusion profile should be antipodally symmetric (i.e. S(x) = S(-x)),
148
- implying that all odd l components should be zero. Therefore, only the
149
- even elements are computed.
150
-
151
- Note that the spherical harmonics equations used here differ slightly from
152
- those conventionally used, in that the (-1)^m factor has been omitted.
153
- This should be taken into account in all subsequent calculations.
154
- Each volume in the output image corresponds to a different spherical
155
- harmonic component. Each volume will correspond to the following:
156
-
157
- volume 0: l = 0, m = 0
158
- volume 1: l = 2, m = -2 (imaginary part of m=2 SH)
159
- volume 2: l = 2, m = -1 (imaginary part of m=1 SH)
160
- volume 3: l = 2, m = 0
161
- volume 4: l = 2, m = 1 (real part of m=1 SH)
162
- volume 5: l = 2, m = 2 (real part of m=2 SH)
163
- etc...
164
-
165
-
113
+ Estimate fibre orientation distributions from diffusion data using spherical deconvolution
166
114
167
115
Example
168
116
-------
169
117
170
118
>>> import nipype.interfaces.mrtrix3 as mrt
171
119
>>> fod = mrt.EstimateFOD()
120
+ >>> fod.inputs.algorithm = 'csd'
172
121
>>> fod.inputs.in_file = 'dwi.mif'
173
- >>> fod.inputs.response = 'response.txt'
174
- >>> fod.inputs.in_mask = 'mask.nii.gz'
122
+ >>> fod.inputs.wm_txt = 'wm.txt'
175
123
>>> fod.inputs.grad_fsl = ('bvecs', 'bvals')
176
124
>>> fod.cmdline # doctest: +ELLIPSIS
177
- 'dwi2fod -fslgrad bvecs bvals -mask mask.nii.gz dwi.mif response.txt\
178
- fods.mif'
125
+ 'dwi2fod -fslgrad bvecs bvals csd dwi.mif wm.txt wm.mif'
179
126
>>> fod.run() # doctest: +SKIP
180
127
"""
181
128
@@ -185,5 +132,12 @@ class EstimateFOD(MRTrix3Base):
185
132
186
133
def _list_outputs (self ):
187
134
outputs = self .output_spec ().get ()
188
- outputs ['out_file' ] = op .abspath (self .inputs .out_file )
135
+ outputs ['wm_odf' ] = op .abspath (self .inputs .wm_odf )
136
+ if self .inputs .gm_odf != Undefined :
137
+ outputs ['gm_odf' ] = op .abspath (self .inputs .gm_odf )
138
+ if self .inputs .csf_odf != Undefined :
139
+ outputs ['csf_odf' ] = op .abspath (self .inputs .csf_odf )
189
140
return outputs
141
+
142
+
143
+
0 commit comments