Conversation
|
Looks like the tests passed here, but not locally for me. Someone else should also try a local test while using nilearn v0.13.1. |
There was a problem hiding this comment.
Pull request overview
Updates mapca to remain compatible with recent nilearn internal API changes by conditionally importing check_niimg_3d / check_niimg_4d from the new location when available.
Changes:
- Add a
nilearnversion gate to importcheck_niimg_3d/check_niimg_4dfromnilearn.imagefornilearn>=0.13.0. - Fall back to the previous import path (
nilearn._utils.niimg_conversions) for oldernilearnversions. - Introduce
packaging.version.Versionusage to compare versions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from nilearn import __version__ as nilearn_version | ||
| from nilearn import masking | ||
| from nilearn._utils.niimg_conversions import check_niimg_3d, check_niimg_4d | ||
| from packaging.version import Version | ||
| from scipy.stats import kurtosis | ||
| from sklearn.decomposition import PCA | ||
| from sklearn.preprocessing import StandardScaler | ||
|
|
||
| if Version(nilearn_version) >= Version("0.13.0"): | ||
| from nilearn.image import check_niimg_3d, check_niimg_4d | ||
| else: | ||
| from nilearn._utils.niimg_conversions import check_niimg_3d, check_niimg_4d |
There was a problem hiding this comment.
packaging is used for Version(...) here, but it is not declared as a direct runtime dependency in pyproject.toml. This can cause an ImportError for users/environments where packaging is not installed. Consider either adding packaging to the project's dependencies, or avoid the extra dependency by using a try/except ImportError import from nilearn.image with a fallback to nilearn._utils.niimg_conversions (which also removes the need to compare versions).
[Update]: I realized we don't want absolute value because we don't want any combination of positive or negative values, we want a consistent flip of the entire matrix. That said, the test is having trouble running locally inside my firewall right now, so also try locally. |
|
I just ran locally (got an SSL issue fixed) and just pushed a fix that passed. It was a bit trickier because not all lines were flipped. I ended up taking the first value of each row and flipping if the signs of the two matrices were different. |
eurunuela
left a comment
There was a problem hiding this comment.
Tests pass locally. I'm happy with the workaround for the signs.
Thank you @handwerkerd!
niilearn moved some functions from
nilearn._utils.niimg_conversionstonilearn.image. We added clause to deal with this in tedana, but this just caused an issue in mapca so I added it here as well.An integration test is now failing. I briefly looked at the failure and it looks like values flipped postive/negative, but I haven't dug more yet.