-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] add support for fitting first levels to numpy arrays directly #4112
base: main
Are you sure you want to change the base?
Conversation
👋 @henrymj Thanks for creating a PR! Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft. Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #4112 +/- ##
==========================================
- Coverage 91.69% 91.25% -0.44%
==========================================
Files 144 144
Lines 16150 16231 +81
Branches 3359 3385 +26
==========================================
+ Hits 14809 14812 +3
- Misses 796 872 +76
- Partials 545 547 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
The img input to fit need to be niimg-like objects to be compatible with the nifti masker. The added code seems to leave masking out to support working with np arrays so this is changing the fit functionality. Wouldn't it be easiest to just add some lines to fit() to cast the numpy array into a niimg-like object? |
I was following @bthirion 's suggestion of making a separate function, but that does sound like it could be easier. Especially if it means it updates self.masker such that compute_contrast and get_voxelwise_attribute would work without modification, and users could just call get_data on the returned object to get back to 2D arrays. Please pardon my ignorance - how would you cast numpy arrays with an arbitrary length along the first dimension (an arbitrary number of ROIs or edges being fit) into a niimg-like object? |
I find it weird to transform arrays into a Nfiti1Image, from which we will extract the data array... It turns out that the GLM does not use any image information than the data array. So I find it better that way. But I'm open to other opinions ! |
@bthirion yes but the fit method in |
Yes, that's the idea. |
Ok I see thanks for clarifying. Then let's go ahead with the original plan @henrymj |
Changes proposed in this pull request:
fit_arrays
to FirstLevelModel; same asfit
, but expects numpy arrays rather than niimgsformat_type
argument to FirstLevelModel.compute_contrast. Ifarray
, it returns contrast results as arrays, rather than imagesTODO