Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4717e23

Browse files
committed
RF: Avoid repeated linspace and hstack calls
1 parent f4a2390 commit 4717e23

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎nipype/algorithms/confounds.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,12 +1190,13 @@ def _make_cosine_regressors(ntimepoints, timestep, period_cut):
11901190

11911191

11921192
def _make_legendre_regressors(ntimepoints, degree):
1193-
X = np.ones((ntimepoints, 1)) # quick way to calc degree 0
1194-
for i in range(degree):
1195-
polynomial_func = Legendre.basis(i + 1)
1196-
value_array = np.linspace(-1, 1, ntimepoints)
1197-
X = np.hstack((X, polynomial_func(value_array)[:, np.newaxis]))
1198-
return X
1193+
support = np.linspace([-1], [1], ntimepoints)
1194+
return np.hstack(
1195+
[
1196+
np.ones((ntimepoints, 1)), # Degree 0 is a constant
1197+
*(Legendre.basis(i + 1)(support) for i in range(degree)),
1198+
]
1199+
)
11991200

12001201

12011202
def _high_pass_filter(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /