Skip to content

Commit 75f919b

Browse files
committed
Base files for new epi interfaces
Added base classes for interfaces fsl_prepare_fieldmap, topup and applytopup
1 parent b08c195 commit 75f919b

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,154 @@
2525
warnings.filterwarnings('always', category=UserWarning)
2626

2727

28+
class PrepareFieldmapInputSpec(FSLCommandInputSpec):
29+
scanner = traits.String('SIEMENS', desc='must be SIEMENS', position=0, usedefault=True)
30+
in_phase = File( exists=True, desc='Phase difference map, in SIEMENS format range from 0-4096 or 0-8192 )',
31+
position=1, mandatory=True )
32+
in_magnitude = File(exists=True,
33+
position=2,
34+
desc='Magnitude difference map, brain extracted',
35+
mandatory=True
36+
)
37+
out_fieldmap = File()
38+
delta_TE = traits.Float(2.46,desc='echo time difference of the fielmap sequence in ms. (usually 2.46ms in Siemens)',
39+
usedefault=True )
40+
nocheck = traits.Bool(False,desc='do not perform sanity checks for image size/range/dimensions',
41+
argstr='--nocheck' )
42+
43+
class PrepareFieldmapOutputSpec( FSLCommandOutputSpec ):
44+
out_fieldmap = File( exists=True )
45+
46+
class PrepareFieldmap(FSLCommand):
47+
""" Interface for the fsl_prepare_fielmap script
48+
49+
Prepares a fieldmap suitable for FEAT from SIEMENS data - saves output in rad/s format
50+
e.g. fsl_prepare_fieldmap SIEMENS images_3_gre_field_mapping images_4_gre_field_mapping fmap_rads 2.65
51+
52+
53+
Examples
54+
--------
55+
>>> prepare = PrepareFieldmap()
56+
>>> prepare.inputs.in_phase = "phase.nii"
57+
>>> prepare.inputs.in_magnitude = "magnitude.nii"
58+
>>> res = prepare.run() # doctest: +SKIP
59+
60+
61+
"""
62+
_cmd = 'fsl_prepare_fieldmap'
63+
input_spec = PrepareFieldmapInputSpec
64+
output_spec = PrepareFieldmapOutputSpec
65+
66+
def _list_outputs(self):
67+
outputs = self.output_spec().get()
68+
69+
return outputs
70+
71+
72+
class TOPUPInputSpec( FSLCommandInputSpec ):
73+
in_file = File( exists=True, mandatory=True, desc='name of 4D file with images', argstr='--imain %s' )
74+
encoding_file = File( exists=True, mandatory=True, desc='name of text file with PE directions/times', argstr='--datain %s' )
75+
out_base = File( desc='base-name of output files (spline coefficients (Hz) and movement parameters)', argstr='--out %s' )
76+
out_field = File( argstr='--fout %s', desc='name of image file with field (Hz)' )
77+
out_corrected = File( argstr='--iout %s', desc='name of 4D image file with unwarped images' )
78+
out_logfile = File( argstr='--logout %s', desc='name of log-file' )
79+
warp_res = traits.Float( 10.0, argstr='--warpres %f', desc='(approximate) resolution (in mm) of warp basis for the different sub-sampling levels' )
80+
subsamp = traits.Int( 1, argstr='--subsamp %d', desc='sub-sampling scheme, default 1' )
81+
fwhm = traits.Float( 8.0, argstr='--fwhm %f', desc='FWHM (in mm) of gaussian smoothing kernel' )
82+
config = File( desc='Name of config file specifying command line arguments', argstr='--config %s' )
83+
max_iter = traits.Int( 5, argstr='--miter %d', desc='max # of non-linear iterations')
84+
#lambda Weight of regularisation, default depending on --ssqlambda and --regmod switches. See user documetation.
85+
#ssqlambda If set (=1), lambda is weighted by current ssq, default 1
86+
#regmod Model for regularisation of warp-field [membrane_energy bending_energy], default bending_energy
87+
estmov = traits.Either( (0,1), desc='estimate movements if set', argstr='--estmov %d' )
88+
minmet = traits.Either( (0,1), desc='Minimisation method 0=Levenberg-Marquardt, 1=Scaled Conjugate Gradient', argstr='--minmet %d' )
89+
splineorder = traits.Int( 3, argstr='--splineorder %d', desc='order of spline, 2->Qadratic spline, 3->Cubic spline' )
90+
numprec = traits.Either( ('float','double'), argstr='--numprec %s', desc='Precision for representing Hessian, double or float.' )
91+
interp = traits.Either( ('linear','spline'), argstr='--interp %s', desc='Image interpolation model, linear or spline.' )
92+
scale = traits.Either( (0,1), argstr='--scale %d', desc='If set (=1), the images are individually scaled to a common mean' )
93+
regrid = traits.Either( (0,1), argstr='--regrid %d', desc='If set (=1), the calculations are done in a different grid' )
94+
95+
96+
97+
class TOPUPOutputSpec( FSLCommandOutputSpec ):
98+
out_field = File( argstr='--fout %s', desc='name of image file with field (Hz)' )
99+
out_corrected = File( argstr='--iout %s', desc='name of 4D image file with unwarped images' )
100+
out_logfile = File( argstr='--logout %s', desc='name of log-file' )
101+
102+
103+
104+
class TOPUP( FSLCommand ):
105+
""" Interface for FSL topup, a tool for estimating and correcting susceptibility induced distortions
106+
Reference: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TOPUP
107+
Example: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ExampleTopupFollowedByApplytopup
108+
109+
topup --imain=<some 4D image> --datain=<text file> --config=<text file with parameters> --coutname=my_field
110+
111+
112+
Examples
113+
--------
114+
>>> topup = TOPUP()
115+
>>> topup.inputs.in_file = "dwi_combined.nii"
116+
>>> topup.inputs.encoding_file = "encoding.txt"
117+
>>> res = topup.run() # doctest: +SKIP
118+
119+
"""
120+
_cmd = 'topup'
121+
input_spec = TOPUPInputSpec
122+
output_spec = TOPUPOutputSpec
123+
124+
def _list_outputs(self):
125+
outputs = self.output_spec().get()
126+
127+
return outputs
128+
129+
130+
131+
class ApplyTOPUPInputSpec( FSLCommandInputSpec ):
132+
in_file = File( exists=True, mandatory=True, desc='name of 4D file with images', argstr='--imain %s' )
133+
encoding_file = File( exists=True, mandatory=True, desc='name of text file with PE directions/times', argstr='--datain %s' )
134+
in_index = traits.List( argstr='-x %s', mandatory=True, desc='comma separated list of indicies into --datain of the input image (to be corrected)' )
135+
in_topup = File( mandatory=True, desc='basename of field/movements (from topup)', argstr='-t %s' )
136+
137+
out_base = File( desc='basename for output (warped) image', argstr='-o %s' )
138+
method = traits.Either( ('jac','lsr'), argstr='-m %s', desc='use jacobian modulation (jac) or least-squares resampling (lsr)' )
139+
interp = traits.Either( ('trilinear','spline'), argstr='-n %s', desc='interpolation method' )
140+
datatype = traits.Either( ('char', 'short', 'int', 'float', 'double' ), argstr='-d %s', desc='force output data type' )
141+
142+
143+
class ApplyTOPUPOutputSpec( FSLCommandOutputSpec ):
144+
out_corrected = File( argstr='--iout %s', desc='name of 4D image file with unwarped images' )
145+
out_logfile = File( argstr='--logout %s', desc='name of log-file' )
146+
147+
class ApplyTOPUP( FSLCommand ):
148+
""" Interface for FSL topup, a tool for estimating and correcting susceptibility induced distortions
149+
Reference: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ApplytopupUsersGuide
150+
Example: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup/ExampleTopupFollowedByApplytopup
151+
152+
topup --imain=<some 4D image> --datain=<text file> --config=<text file with parameters> --coutname=my_field
153+
154+
155+
Examples
156+
--------
157+
>>> applytopup = ApplyTOPUP()
158+
>>> applytopup.inputs.in_file = "dwi_combined.nii"
159+
>>> applytopup.inputs.encoding_file = "encoding.txt"
160+
>>> applytopup.inputs.in_index = 1,2
161+
>>> applytopup.inputs.in_topup = "my_topup_results"
162+
>>> res = applytopup.run() # doctest: +SKIP
163+
164+
"""
165+
_cmd = 'topup'
166+
input_spec = ApplyTOPUPInputSpec
167+
output_spec = ApplyTOPUPOutputSpec
168+
169+
def _list_outputs(self):
170+
outputs = self.output_spec().get()
171+
172+
return outputs
173+
174+
175+
28176

29177

30178

0 commit comments

Comments
 (0)