|
33 | 33 | traits, File, Bunch, BaseInterfaceInputSpec,
|
34 | 34 | isdefined)
|
35 | 35 | from ..utils.filemanip import filename_to_list
|
| 36 | +from ..utils.misc import normalize_mc_params |
36 | 37 | from .. import config, logging
|
37 | 38 | iflogger = logging.getLogger('interface')
|
38 | 39 |
|
@@ -187,7 +188,7 @@ class SpecifyModelInputSpec(BaseInterfaceInputSpec):
|
187 | 188 | realignment_parameters = InputMultiPath(File(exists=True),
|
188 | 189 | desc="Realignment parameters returned by motion correction algorithm",
|
189 | 190 | copyfile=False)
|
190 |
| - parameter_source = traits.Enum("SPM", "FSL", "AFNI", "NiPy", "FSFAST", |
| 191 | + parameter_source = traits.Enum("SPM", "FSL", "AFNI", "FSFAST", |
191 | 192 | desc="Source of motion parameters")
|
192 | 193 | outlier_files = InputMultiPath(File(exists=True),
|
193 | 194 | desc="Files containing scan outlier indices that should be tossed",
|
@@ -377,16 +378,16 @@ def _generate_standard_design(self, infolist,
|
377 | 378 | def _generate_design(self, infolist=None):
|
378 | 379 | """Generate design specification for a typical fmri paradigm
|
379 | 380 | """
|
380 |
| - par_selection = slice(6) |
381 |
| - if isdefined(self.inputs.parameter_source): |
382 |
| - source = self.inputs.parameter_source |
383 |
| - if source == 'FSFAST': |
384 |
| - par_selection = slice(1, 7) |
385 | 381 | realignment_parameters = []
|
386 | 382 | if isdefined(self.inputs.realignment_parameters):
|
| 383 | + source = self.inputs.parameter_source |
387 | 384 | for parfile in self.inputs.realignment_parameters:
|
388 |
| - realignment_parameters.append( |
389 |
| - np.loadtxt(parfile)[:, par_selection]) |
| 385 | + mpars = np.loadtxt(parfile) |
| 386 | + if isdefined(source): |
| 387 | + mpars = np.apply_along_axis(func1d=normalize_mc_params, |
| 388 | + axis=1, arr=mpars, |
| 389 | + source=source) |
| 390 | + realignment_parameters.append(mpars) |
390 | 391 | outliers = []
|
391 | 392 | if isdefined(self.inputs.outlier_files):
|
392 | 393 | for filename in self.inputs.outlier_files:
|
@@ -428,6 +429,8 @@ def _list_outputs(self):
|
428 | 429 | class SpecifySPMModelInputSpec(SpecifyModelInputSpec):
|
429 | 430 | concatenate_runs = traits.Bool(False, usedefault=True,
|
430 | 431 | desc="Concatenate all runs to look like a single session.")
|
| 432 | + parameter_source = traits.Enum("SPM", "FSL", "AFNI", "FSFAST", usedefault=True, |
| 433 | + desc="Source of motion parameters") |
431 | 434 | output_units = traits.Enum('secs', 'scans', usedefault=True,
|
432 | 435 | desc="Units of design event onsets and durations (secs or scans)")
|
433 | 436 |
|
@@ -539,7 +542,9 @@ def _generate_design(self, infolist=None):
|
539 | 542 | if isdefined(self.inputs.realignment_parameters):
|
540 | 543 | realignment_parameters = []
|
541 | 544 | for parfile in self.inputs.realignment_parameters:
|
542 |
| - mc = np.loadtxt(parfile) |
| 545 | + mc = np.apply_along_axis(func1d=normalize_mc_params, |
| 546 | + axis=1, arr=np.loadtxt(parfile), |
| 547 | + source=source) |
543 | 548 | if not realignment_parameters:
|
544 | 549 | realignment_parameters.insert(0, mc)
|
545 | 550 | else:
|
|
0 commit comments