Skip to content

Commit 983cee1

Browse files
committed
fixed several bugs. tested in practice
1 parent edb7faf commit 983cee1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

nipype/algorithms/misc.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,12 @@ def merge_rois(in_files, in_idxs, in_ref,
13811381
rsh = ref.get_shape()
13821382
del ref
13831383
npix = rsh[0] * rsh[1] * rsh[2]
1384-
ndirs = nb.load(in_files[0]).get_shape()[-1]
1384+
fcdata = nb.load(in_files[0]).get_data()
1385+
1386+
if fcdata.ndim == 4:
1387+
ndirs = fcdata.shape[-1]
1388+
else:
1389+
ndirs = 1
13851390
newshape = (rsh[0], rsh[1], rsh[2], ndirs)
13861391
hdr.set_data_dtype(dtype)
13871392
hdr.set_xyzt_units('mm', 'sec')
@@ -1394,7 +1399,12 @@ def merge_rois(in_files, in_idxs, in_ref,
13941399
cdata = nb.load(cname).get_data().reshape(-1, ndirs)
13951400
nels = len(idxs)
13961401
idata = (idxs, )
1397-
data[idata, ...] = cdata[0:nels, ...]
1402+
try:
1403+
data[idata, ...] = cdata[0:nels, ...]
1404+
except:
1405+
print(data.shape, cdata.shape)
1406+
raise
1407+
13981408
hdr.set_data_shape(newshape)
13991409

14001410
nb.Nifti1Image(data.reshape(newshape).astype(dtype),

nipype/interfaces/fsl/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,15 @@ def _list_outputs(self):
367367
for k in multi_out:
368368
outputs[k] = []
369369

370-
for i in xrange(1, self.inputs.n_fibres + 1):
371-
outputs['dyads'].append(self._gen_fname('dyads%d' % i,
372-
cwd=out_dir))
370+
for i in xrange(self.inputs.n_fibres + 1):
373371
outputs['fsamples'].append(self._gen_fname('f%dsamples' % i,
374372
cwd=out_dir))
375373
outputs['mean_fsamples'].append(self._gen_fname(('mean_f%d'
376374
'samples') % i, cwd=out_dir))
375+
376+
for i in xrange(1, self.inputs.n_fibres + 1):
377+
outputs['dyads'].append(self._gen_fname('dyads%d' % i,
378+
cwd=out_dir))
377379
outputs['phsamples'].append(self._gen_fname('ph%dsamples' % i,
378380
cwd=out_dir))
379381
outputs['thsamples'].append(self._gen_fname('th%dsamples' % i,

0 commit comments

Comments
 (0)