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