Fix pySPFM notebook: switch to Schaefer atlas, fix memory and path issues#73
Open
eurunuela wants to merge 1 commit intoME-ICA:mainfrom
Open
Fix pySPFM notebook: switch to Schaefer atlas, fix memory and path issues#73eurunuela wants to merge 1 commit intoME-ICA:mainfrom
eurunuela wants to merge 1 commit intoME-ICA:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the pySPFM deconvolution tutorial to run in a parcel-wise workflow (Schaefer 1000 atlas) to reduce memory usage, fixes a case-sensitive data path, and adds an .ipynb version of the notebook for builds/caching.
Changes:
- Switch notebook deconvolution from voxel-wise to parcel-wise using
NiftiLabelsMasker+ Schaefer 2018 (1000 ROIs). - Update
../DATAto../datafor Linux/CI compatibility. - Add
content/05_3dMEPFM.ipynbcounterpart to the existing MyST/Jupytext.mdnotebook.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
content/05_3dMEPFM.md |
Refactors the workflow to Schaefer-parcel time series and uses SparseDeconvolution; updates data path and output-writing logic. |
content/05_3dMEPFM.ipynb |
Adds an .ipynb version of the same tutorial content for execution/build purposes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace voxel-wise NiftiMasker with NiftiLabelsMasker + Schaefer 1000-parcel atlas, reducing input matrix from ~218k voxels to 1000 parcels (feasible on a laptop without OOM) - Fix data path: ../DATA → ../data (case-sensitive on Linux/CI) - Remove n_jobs=-1 (pySPFM v2.0 removed that parameter) - Remove unused mask_file and confounds_file variables - Remove unused hrf_matrix assignment - Save parcel-wise activity as out_activity.npy instead of a large 4D NIfTI; add a compact mean-abs summary image (out_activity_mean.nii.gz) for lightweight voxel-space visualization Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
9e43984 to
3851dc0
Compare
Member
|
I'm seeing two possibly related issues:
|
Contributor
Author
|
I'm working on improving the notebook regardless. This is still not ready to be merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
../DATA→../data(case-sensitive path, was silently broken on Linux/CI)n_jobs=-1argument (pySPFM v2.0.1 hardcodedscheduler="synchronous"— a fix has been opened upstream at Wire n_jobs to Dask threaded scheduler in all voxel-wise solvers Paradigm-Free-Mapping/pySPFM#152).ipynboutput so the book build can use the cacheWhy parcel-wise?
Running pySPFM voxel-wise on the full brain mask builds a Dask graph with ~218k delayed objects, holds all results in memory simultaneously, then allocates ~2.6 GB each for the fitted signal and residuals. On a 16 GB machine already under memory pressure this reliably kills the Jupyter kernel.
Using
NiftiLabelsMaskerwith the Schaefer 1000-parcel atlas reduces the input matrix from(1815, 218485)to(1815, 1000)— ~14 MB vs ~1.6 GB. The full multi-echo deconvolution workflow is still demonstrated across the whole brain.Test plan
jupyter execute content/05_3dMEPFM.ipynb)out_activity.nii.gz,out_lambda.npy,out_fitted.npy,out_residuals.npyjb build .passes in CI🤖 Generated with Claude Code