Skip to content

Commit 5107714

Browse files
committed
FIX: Normalize constant column to 0th
For Legendre regressors, the ith column is the ith-order polynomial, so the constant column is 0. For the cosine regressors, a constant column was appended to the end, in contradiction of the docstring. This brings both into alignment so columns are sorted from lowest to highest frequency and aligns the DCT behavior with its docstring.
1 parent 4717e23 commit 5107714

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nipype/algorithms/confounds.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,8 @@ def _high_pass_filter(
12201220
betas = np.linalg.pinv(X) @ data.T
12211221

12221222
if not remove_mean:
1223-
X = X[:, :-1]
1224-
betas = betas[:-1]
1223+
X = X[:, 1:]
1224+
betas = betas[1:]
12251225

12261226
residuals = data - (X @ betas).T
12271227
return residuals.reshape(datashape), non_constant_regressors
@@ -1547,9 +1547,9 @@ def _cosine_drift(period_cut, frametimes):
15471547
nfct = np.sqrt(2.0 / len_tim)
15481548

15491549
for k in range(1, order):
1550-
cdrift[:, k - 1] = nfct * np.cos((np.pi / len_tim) * (n_times + 0.5) * k)
1550+
cdrift[:, k] = nfct * np.cos((np.pi / len_tim) * (n_times + 0.5) * k)
15511551

1552-
cdrift[:, order - 1] = 1.0 # or 1./sqrt(len_tim) to normalize
1552+
cdrift[:, 0] = 1.0 # or 1./sqrt(len_tim) to normalize
15531553
return cdrift
15541554

15551555

0 commit comments

Comments
 (0)