Skip to content

Commit 73b9a0e

Browse files
author
Shoshana Berleant
committed
debug tcompcor, add log messages and tests
1 parent 91802ba commit 73b9a0e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

nipype/algorithms/confounds.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,13 @@ def _run_interface(self, runtime):
420420
threshold_index = int(num_voxels * (1. - self.inputs.percentile_threshold))
421421
threshold_std = sortSTD[threshold_index]
422422
mask = tSTD >= threshold_std
423-
mask = mask.astype(int)
423+
mask = mask.astype(int).T
424424

425425
# save mask
426426
mask_file = 'mask.nii'
427427
nb.nifti1.save(nb.Nifti1Image(mask, np.eye(4)), mask_file)
428+
IFLOG.debug('tCompcor computed and saved mask of shape {} to mask_file {}'
429+
.format(mask.shape, mask_file))
428430
self.inputs.mask_file = mask_file
429431

430432
super(TCompCor, self)._run_interface(runtime)
@@ -513,6 +515,8 @@ def regress_poly(degree, data, remove_mean=True, axis=-1):
513515
If remove_mean is True (default), the data is demeaned (i.e. degree 0).
514516
If remove_mean is false, the data is not.
515517
'''
518+
IFLOG.debug('Performing polynomial regression on data of shape ' + str(data.shape))
519+
516520
datashape = data.shape
517521
timepoints = datashape[axis]
518522

nipype/algorithms/tests/test_compcor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ def test_compcor_no_regress_poly(self):
7474
['-0.5367548139', '0.0059943226'],
7575
['-0.0520809054', '0.2940637551']])
7676

77+
def test_tcompcor_asymmetric_dim(self):
78+
asymmetric_shape = (2, 3, 4, 5)
79+
asymmetric_data = utils.save_toy_nii(np.zeros(asymmetric_shape), 'asymmetric.nii')
80+
81+
TCompCor(realigned_file=asymmetric_data).run()
82+
83+
self.assertEqual(nb.load('mask.nii').get_data().shape, asymmetric_shape[:3])
84+
7785
def run_cc(self, ccinterface, expected_components):
7886
# run
7987
ccresult = ccinterface.run()

0 commit comments

Comments
 (0)