Skip to content

Conversation

@jhlegarreta
Copy link

@jhlegarreta jhlegarreta commented Nov 1, 2025

Add transform analysis utils.

Transfer contents from the NiFreeze projects so that hey can be reused across projects requiring transform analysis:
https://github.com/nipreps/nifreeze/blob/d27ba7552bbd9095c3c13b46443d87a4b5504c4c/src/nifreeze/analysis/motion.py https://github.com/nipreps/nifreeze/blob/d27ba7552bbd9095c3c13b46443d87a4b5504c4c/src/nifreeze/data/utils.py

Add a fixture to be able to reuse a random number generator across tests.

Fixes #239.

@jhlegarreta
Copy link
Author

I did not dare to create a data module the utils.py module at the root folder, as I do not know well the philosophy in this project, but let me know if it does belong to a data module.

I think the plotting should go to nireports.

@jhlegarreta jhlegarreta force-pushed the enh/add-transform-analysis-utils branch 3 times, most recently from 7fae796 to 73b27ba Compare November 1, 2025 18:19
@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.80%. Comparing base (7845e64) to head (f3236b7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #286      +/-   ##
==========================================
+ Coverage   96.74%   96.80%   +0.06%     
==========================================
  Files          16       17       +1     
  Lines        1994     2034      +40     
  Branches      267      267              
==========================================
+ Hits         1929     1969      +40     
  Misses         41       41              
  Partials       24       24              
Flag Coverage Δ
unittests 96.78% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhlegarreta jhlegarreta force-pushed the enh/add-transform-analysis-utils branch from 73b27ba to 86fa6af Compare November 19, 2025 12:32
@jhlegarreta
Copy link
Author

Pinging @oesteban.

@jhlegarreta jhlegarreta force-pushed the enh/add-transform-analysis-utils branch from 86fa6af to 711146a Compare November 20, 2025 02:31
@oesteban
Copy link
Collaborator

Then should we remove these files from NiFreeze?
https://github.com/nipreps/nifreeze/blob/6723229312850a73cbe9e4f31144ade3502535da/src/nifreeze/data/utils.py
https://github.com/nipreps/nifreeze/blob/6723229312850a73cbe9e4f31144ade3502535da/test/test_data_utils.py

Yes

and use nitransforms.resampling.apply in
https://github.com/nipreps/nifreeze/blob/6723229312850a73cbe9e4f31144ade3502535da/src/nifreeze/registration/utils.py#L74
and
https://github.com/nipreps/nifreeze/blob/6723229312850a73cbe9e4f31144ade3502535da/src/nifreeze/registration/utils.py#L113

No, if you look at it closer, you'll see this is using apply_affine from nibabel.affines, which is not the same (that applies affines to points, our apply in nitransforms and the apply_affines (notice the 's' at the end) in nifreeze apply affines to images (internally to points, but that's not relevant here).

Copy link
Collaborator

@oesteban oesteban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I just realized of a little inconsistency. Other than that, I think this is almost ready.

@jhlegarreta
Copy link
Author

Had a closer look at the apply_affines function: it calls nt.resampling.apply so ultimately its a wrapper around it to write transformed images to a NIfTI file. So, maybe it is useful if we rename/relocate it? Else, are there other nitransforms utils that do that job?

@jhlegarreta jhlegarreta force-pushed the enh/add-transform-analysis-utils branch from 04b0f77 to 8039887 Compare November 20, 2025 12:55
@oesteban
Copy link
Collaborator

Else, are there other nitransforms utils that do that job?

Yes, nitransforms.resampling.apply does the job. We created the apply_transforms wrapper in nifreeze because the multiple-volume resampling was not very well supported in nitransforms, but that changed.

@jhlegarreta jhlegarreta force-pushed the enh/add-transform-analysis-utils branch 2 times, most recently from 825eb5f to b71eac7 Compare November 20, 2025 13:23
Add transform analysis utils.

Transfer contents from the `NiFreeze` projects so that hey can be reused
across projects requiring transform analysis:
https://github.com/nipreps/nifreeze/blob/d27ba7552bbd9095c3c13b46443d87a4b5504c4c/src/nifreeze/analysis/motion.py
https://github.com/nipreps/nifreeze/blob/d27ba7552bbd9095c3c13b46443d87a4b5504c4c/src/nifreeze/data/utils.py

Add a fixture to be able to reuse a random number generator across
tests.

Co-authored-by: Oscar Esteban <code@oscaresteban.es>
@jhlegarreta jhlegarreta force-pushed the enh/add-transform-analysis-utils branch from b71eac7 to f3236b7 Compare November 20, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Framewise displacement calculations, CLI, and perhaps, plotting module

2 participants