Skip to content

Commit 69f38a7

Browse files
committed
Merge pull request #411 from satra/fix/realign4d
fix: allow for multiple levels of loops for estimation
2 parents 1e5f7b1 + c07a861 commit 69f38a7

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

nipype/interfaces/nipy/preprocess.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
else:
1616
from nipy.labs.mask import compute_mask
1717
from nipy.algorithms.registration import FmriRealign4d as FR4d
18-
from nipy import save_image
18+
from nipy import save_image, load_image
1919

2020
from ..base import (TraitedSpec, BaseInterface, traits,
2121
BaseInterfaceInputSpec, isdefined, File,
@@ -69,34 +69,31 @@ def _list_outputs(self):
6969

7070
class FmriRealign4dInputSpec(BaseInterfaceInputSpec):
7171

72+
7273
in_file = InputMultiPath(exists=True,
7374
mandatory=True,
7475
desc="File to realign")
7576
tr = traits.Float(desc="TR in seconds",
7677
mandatory=True)
7778
slice_order = traits.List(traits.Int(),
78-
desc='0 based slice order',
79+
desc='0 based slice order',
7980
requires=["time_interp"])
80-
tr_slices = traits.Float(desc="TR slices")
81+
tr_slices = traits.Float(desc="TR slices", requires=['time_interp'])
8182
start = traits.Float(0.0, usedefault=True,
8283
desc="time offset into TR to align slices to")
8384
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.,\
8586
fmri series. If you don't want slice timing \
8687
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 \
9492
realign different \
9593
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 \
10097
sub-sampling factors \
10198
for acceleration")
10299

@@ -139,12 +136,7 @@ class FmriRealign4d(BaseInterface):
139136

140137
def _run_interface(self, runtime):
141138

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]
148140

149141
if not isdefined(self.inputs.tr_slices):
150142
TR_slices = None

0 commit comments

Comments
 (0)