Skip to content

Commit 435f34c

Browse files
committed
FIX: Define variables in all cases
1 parent 226fc8a commit 435f34c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

nipype/algorithms/confounds.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -842,19 +842,18 @@ def cosine_filter(data, timestep, remove_mean=False, axis=-1):
842842
data = data.reshape((-1, timepoints))
843843

844844
frametimes = timestep * np.arange(timepoints)
845-
design_matrix = _full_rank(_cosine_drift(128, frametimes))[0]
845+
X = _full_rank(_cosine_drift(128, frametimes))[0]
846+
non_constant_regressors = X[:, :-1]
846847

847-
betas = np.linalg.lstsq(design_matrix, data.T)[0]
848+
betas = np.linalg.lstsq(X, data.T)[0]
848849

849850
if not remove_mean:
850-
X = design_matrix[:, :-1]
851+
X = X[:, :-1]
851852
betas = betas[:-1]
852853

853854
residuals = data - X.dot(betas).T
854855

855-
# Return non-constant regressors
856-
return residuals.reshape(datashape), design_matrix[:, :-1]
857-
856+
return residuals.reshape(datashape), non_constant_regressors
858857

859858

860859
def regress_poly(degree, data, remove_mean=True, axis=-1):

0 commit comments

Comments
 (0)