|
15 | 15 | else:
|
16 | 16 | from nipy.labs.mask import compute_mask
|
17 | 17 | from nipy.algorithms.registration import FmriRealign4d as FR4d
|
18 |
| - from nipy import save_image |
| 18 | + from nipy import save_image, load_image |
19 | 19 |
|
20 | 20 | from ..base import (TraitedSpec, BaseInterface, traits,
|
21 | 21 | BaseInterfaceInputSpec, isdefined, File,
|
@@ -69,34 +69,31 @@ def _list_outputs(self):
|
69 | 69 |
|
70 | 70 | class FmriRealign4dInputSpec(BaseInterfaceInputSpec):
|
71 | 71 |
|
| 72 | + |
72 | 73 | in_file = InputMultiPath(exists=True,
|
73 | 74 | mandatory=True,
|
74 | 75 | desc="File to realign")
|
75 | 76 | tr = traits.Float(desc="TR in seconds",
|
76 | 77 | mandatory=True)
|
77 | 78 | slice_order = traits.List(traits.Int(),
|
78 |
| - desc='0 based slice order', |
| 79 | + desc='0 based slice order', |
79 | 80 | requires=["time_interp"])
|
80 |
| - tr_slices = traits.Float(desc="TR slices") |
| 81 | + tr_slices = traits.Float(desc="TR slices", requires=['time_interp']) |
81 | 82 | start = traits.Float(0.0, usedefault=True,
|
82 | 83 | desc="time offset into TR to align slices to")
|
83 | 84 | time_interp = traits.Enum(True, requires=["slice_order"],
|
84 |
| - desc="Assume smooth changes across time e.g.,\ |
| 85 | + desc="Assume smooth changes across time e.g.,\ |
85 | 86 | fmri series. If you don't want slice timing \
|
86 | 87 | correction set this to undefined")
|
87 |
| - loops = traits.Either(traits.Int(5,usedefault=True), |
88 |
| - traits.List(traits.Int), |
89 |
| - usedefault=True, |
90 |
| - desc="loops within each run") |
91 |
| - between_loops = traits.Either(traits.Int(5), |
92 |
| - traits.List(traits.Int), |
93 |
| - usedefault=True, desc="loops used to \ |
| 88 | + loops = InputMultiPath([5], traits.Int, usedefault=True, |
| 89 | + desc="loops within each run") |
| 90 | + between_loops = InputMultiPath([5], traits.Int, |
| 91 | + usedefault=True, desc="loops used to \ |
94 | 92 | realign different \
|
95 | 93 | runs")
|
96 |
| - speedup = traits.Either(traits.Int(5), |
97 |
| - traits.List(traits.Int(5)), |
98 |
| - usedefault=True, |
99 |
| - desc="successive image \ |
| 94 | + speedup = InputMultiPath([5], traits.Int, |
| 95 | + usedefault=True, |
| 96 | + desc="successive image \ |
100 | 97 | sub-sampling factors \
|
101 | 98 | for acceleration")
|
102 | 99 |
|
@@ -139,12 +136,7 @@ class FmriRealign4d(BaseInterface):
|
139 | 136 |
|
140 | 137 | def _run_interface(self, runtime):
|
141 | 138 |
|
142 |
| - all_ims = [] |
143 |
| - |
144 |
| - for image in self.inputs.in_file: |
145 |
| - im = nb.load(image) |
146 |
| - im.affine = im.get_affine() |
147 |
| - all_ims.append(im) |
| 139 | + all_ims = [load_image(fname) for fname in self.inputs.in_file] |
148 | 140 |
|
149 | 141 | if not isdefined(self.inputs.tr_slices):
|
150 | 142 | TR_slices = None
|
|
0 commit comments