24
24
25
25
class ComputeMaskInputSpec (BaseInterfaceInputSpec ):
26
26
mean_volume = File (exists = True , mandatory = True ,
27
- desc = "mean EPI image, used to compute the threshold for the mask" )
27
+ desc = "mean EPI image, used to compute the threshold for the mask" )
28
28
reference_volume = File (exists = True ,
29
- desc = ("reference volume used to compute the mask. "
30
- "If none is give, the mean volume is used." ))
29
+ desc = ("reference volume used to compute the mask. "
30
+ "If none is give, the mean volume is used." ))
31
31
m = traits .Float (desc = "lower fraction of the histogram to be discarded" )
32
32
M = traits .Float (desc = "upper fraction of the histogram to be discarded" )
33
33
cc = traits .Bool (desc = "Keep only the largest connected component" )
@@ -69,7 +69,6 @@ def _list_outputs(self):
69
69
70
70
class FmriRealign4dInputSpec (BaseInterfaceInputSpec ):
71
71
72
-
73
72
in_file = InputMultiPath (exists = True ,
74
73
mandatory = True ,
75
74
desc = "File to realign" )
@@ -144,10 +143,10 @@ def _run_interface(self, runtime):
144
143
TR_slices = self .inputs .tr_slices
145
144
146
145
R = FR4d (all_ims , tr = self .inputs .tr ,
147
- slice_order = self .inputs .slice_order ,
148
- tr_slices = TR_slices ,
149
- time_interp = self .inputs .time_interp ,
150
- start = self .inputs .start )
146
+ slice_order = self .inputs .slice_order ,
147
+ tr_slices = TR_slices ,
148
+ time_interp = self .inputs .time_interp ,
149
+ start = self .inputs .start )
151
150
152
151
R .estimate (loops = self .inputs .loops ,
153
152
between_loops = self .inputs .between_loops ,
@@ -159,11 +158,11 @@ def _run_interface(self, runtime):
159
158
160
159
for j , corr in enumerate (corr_run ):
161
160
self ._out_file_path .append (os .path .abspath ('corr_%s.nii.gz' %
162
- (split_filename (self .inputs .in_file [j ])[1 ])))
161
+ (split_filename (self .inputs .in_file [j ])[1 ])))
163
162
save_image (corr , self ._out_file_path [j ])
164
163
165
164
self ._par_file_path .append (os .path .abspath ('%s.par' %
166
- (os .path .split (self .inputs .in_file [j ])[1 ])))
165
+ (os .path .split (self .inputs .in_file [j ])[1 ])))
167
166
mfile = open (self ._par_file_path [j ], 'w' )
168
167
motion = R ._transforms [j ]
169
168
# nipy does not encode euler angles. return in original form of
@@ -190,19 +189,21 @@ class TrimInputSpec(BaseInterfaceInputSpec):
190
189
exists = True , mandatory = True ,
191
190
desc = "EPI image to trim" )
192
191
begin_index = traits .Int (
193
- 0 ,usedefault = True ,
192
+ 0 , usedefault = True ,
194
193
desc = 'first volume' )
195
194
end_index = traits .Int (
196
- 0 ,usedefault = True ,
195
+ 0 , usedefault = True ,
197
196
desc = 'last volume indexed as in python (and 0 for last)' )
198
197
out_file = File (desc = 'output filename' )
199
198
suffix = traits .Str (
200
- '_trim' ,usedefault = True ,
199
+ '_trim' , usedefault = True ,
201
200
desc = 'suffix for out_file to use if no out_file provided' )
202
201
202
+
203
203
class TrimOutputSpec (TraitedSpec ):
204
204
out_file = File (exists = True )
205
205
206
+
206
207
class Trim (BaseInterface ):
207
208
""" Simple interface to trim a few volumes from a 4d fmri nifti file
208
209
@@ -223,14 +224,14 @@ def _run_interface(self, runtime):
223
224
out_file = self ._list_outputs ()['out_file' ]
224
225
nii = nb .load (self .inputs .in_file )
225
226
if self .inputs .end_index == 0 :
226
- s = slice (self .inputs .begin_index ,nii .shape [3 ])
227
+ s = slice (self .inputs .begin_index , nii .shape [3 ])
227
228
else :
228
- s = slice (self .inputs .begin_index ,self .inputs .end_index )
229
+ s = slice (self .inputs .begin_index , self .inputs .end_index )
229
230
nii2 = nb .Nifti1Image (
230
- nii .get_data ()[...,s ],
231
+ nii .get_data ()[..., s ],
231
232
nii .get_affine (),
232
233
nii .get_header ())
233
- nb .save (nii2 ,out_file )
234
+ nb .save (nii2 , out_file )
234
235
return runtime
235
236
236
237
def _list_outputs (self ):
@@ -243,5 +244,3 @@ def _list_outputs(self):
243
244
suffix = self .inputs .suffix )
244
245
outputs ['out_file' ] = os .path .abspath (outputs ['out_file' ])
245
246
return outputs
246
-
247
-
0 commit comments