Skip to content

Commit

Permalink
RF: Avoid repeated linspace and hstack calls
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed May 30, 2024
1 parent f4a2390 commit 4717e23
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nipype/algorithms/confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,12 +1190,13 @@ def _make_cosine_regressors(ntimepoints, timestep, period_cut):


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


def _high_pass_filter(
Expand Down

0 comments on commit 4717e23

Please sign in to comment.