Skip to content

Commit

Permalink
[FIX] read only problem with numpy 2 (#4265)
Browse files Browse the repository at this point in the history
* fix read only problem

* Update .github/workflows/numpy2_compatibility.yml
  • Loading branch information
Remi-Gau committed Feb 12, 2024
1 parent 975dca5 commit 58bad49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/numpy2_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
name: Numpy2 compatibility

on:

# Comment before merging in main
# pull_request:
# branches:
# - '*'

schedule:
# Run every day at 8am UTC
- cron: 0 8 * * *
Expand Down
26 changes: 15 additions & 11 deletions nilearn/interfaces/fmriprep/tests/test_load_confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,23 @@ def _simu_img(tmp_path, demean):


def _handle_non_steady(confounds):
"""Simulate non steady state correctly while increase the length."""
"""Simulate non steady state correctly while increase the length.
- The first row is non-steady state,
replace it with the input from the second row.
- Repeat X in length (axis = 0) 10 times to increase
the degree of freedom for numerical stability.
- Put non-steady state volume back at the first sample.
"""
X = confounds.values
# the first row is non-steady state, replace it with the input from the
# second row
non_steady = X[0, :]
X[0, :] = X[1, :]
# repeat X in length (axis = 0) 10 times to increase
# the degree of freedom for numerical stability
X = np.tile(X, (10, 1))
# put non-steady state volume back at the first sample
X[0, :] = non_steady
X = pd.DataFrame(X, columns=confounds.columns)
return X
tmp = np.vstack((X[1, :], X[1:, :]))
tmp = np.tile(tmp, (10, 1))
return pd.DataFrame(
np.vstack((non_steady, tmp[1:, :])), columns=confounds.columns
)


def _regression(confounds, tmp_path):
Expand Down

0 comments on commit 58bad49

Please sign in to comment.