Skip to content

Commit 4f27943

Browse files
author
Shoshana Berleant
committed
less mysterious error messages
1 parent e98bd95 commit 4f27943

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

nipype/algorithms/confounds.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ class TCompCor(CompCor):
409409
def _run_interface(self, runtime):
410410
imgseries = nb.load(self.inputs.realigned_file).get_data()
411411

412+
if imgseries.ndim != 4:
413+
raise ValueError('tCompCor expected a 4-D nifti file. Input {} has {} dimensions '
414+
'(shape {})'
415+
.format(self.inputs.realigned_file, imgseries.ndim, imgseries.shape))
416+
412417
# From the paper:
413418
# "For each voxel time series, the temporal standard deviation is
414419
# defined as the standard deviation of the time series after the removal

nipype/algorithms/tests/test_compcor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ def test_tcompcor_asymmetric_dim(self):
8484
def test_compcor_bad_input_shapes(self):
8585
shape_less_than = (1, 2, 2, 5) # dim 0 is < dim 0 of self.mask_file (2)
8686
shape_more_than = (3, 3, 3, 5) # dim 0 is > dim 0 of self.mask_file (2)
87+
bad_dims = (2, 2, 2) # not 4-D
8788

88-
for data_shape in (shape_less_than, shape_more_than):
89+
for data_shape in (shape_less_than, shape_more_than, bad_dims):
8990
data_file = utils.save_toy_nii(np.zeros(data_shape), 'temp.nii')
9091
interface = CompCor(realigned_file=data_file, mask_file=self.mask_file)
9192
self.assertRaisesRegexp(ValueError, "dimensions", interface.run)

0 commit comments

Comments
 (0)