Monkeypatch create_cfm to use LPS lesion mask - #1058
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1058 +/- ##
==========================================
+ Coverage 47.13% 47.17% +0.04%
==========================================
Files 66 66
Lines 9836 9857 +21
Branches 1084 1088 +4
==========================================
+ Hits 4636 4650 +14
- Misses 4979 4982 +3
- Partials 221 225 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mattcieslak
approved these changes
Jun 11, 2026
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.
Fixes #1023.
When an anatomical lesion ROI (
*_label-lesion_roi) is provided, QSIPrep incorporates it into the anatomical-to-template registration as a cost-function mask. The mask was applied in the wrong orientation, so it had no effect at the lesion and instead perturbed the registration elsewhere.The bug is in niworkflows'
create_cfm(), which reorients the lesion to RAS but subtracts it from the LPS moving mask (QSIPrep forcesorientation='LPS'), misaligning the voxel arrays. Because QSIPrep pins a released niworkflows, this PR ships the fix immediately as a monkeypatch; the same fix is going upstream in niworkflows (see nipreps/niworkflows#1050).Changes
qsiprep/interfaces/niworkflows.py: add_create_cfm, a corrected copy ofniworkflows.interfaces.norm.create_cfmthat resamples the lesion into the moving mask's voxel grid (resample_from_to(..., order=0)) instead of reorienting it to RAS, and install it overniworkflows.interfaces.norm.create_cfmat import.SpatialNormalizationlooks the function up as a module global, so reassigning it is sufficient — no workflow changes required.qsiprep/tests/test_interfaces_niworkflows.py(new): verifies the patch is installed and that a RAS lesion is excluded at the correct world location whenin_fileis LPS.The patch carries a comment to remove it (plus the
test_create_cfm_patch_installedtest) once the niworkflows pin moves past the release containing the upstream fix.Testing
pytest qsiprep/tests/test_interfaces_niworkflows.py— both tests pass.