Skip to content

Patch for crash when applying 3D transform to 4D image #236

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

Merged
merged 1 commit into from
May 31, 2025

Conversation

coryshain
Copy link
Contributor

When applying a 3D transform to a 4D image (intended: applying the same transform to every time slice), I get the following crash (relevant traceback only):

  File "/home/corys/parcellate/parcellate/model.py", line 253, in sample
    atlas_nii = nt.resampling.apply(
  File "/home/corys/anaconda3/envs/meg/lib/python3.9/site-packages/nitransforms/resampling.py", line 277, in apply
    resampled = asyncio.run(
  File "/home/corys/anaconda3/envs/meg/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/corys/anaconda3/envs/meg/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/corys/anaconda3/envs/meg/lib/python3.9/site-packages/nitransforms/resampling.py", line 111, in _apply_serial
    xfm_t = transform if n_resamplings == 1 else transform[t]
  File "/home/corys/anaconda3/envs/meg/lib/python3.9/site-packages/nitransforms/manip.py", line 64, in __getitem__
    return self.transforms[i]
IndexError: list index out of range

This patch tries to catch this use case by avoiding indexing into self.transform when the transform is 3D.

Copy link

codecov bot commented May 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.10%. Comparing base (4c69fb4) to head (09e9248).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #236      +/-   ##
==========================================
- Coverage   95.32%   95.10%   -0.23%     
==========================================
  Files          28       28              
  Lines        2954     2939      -15     
==========================================
- Hits         2816     2795      -21     
- Misses        138      144       +6     
Flag Coverage Δ
unittests 95.10% <100.00%> (+0.02%) ⬆️

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.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Lgtm. Thanks!

@effigies effigies merged commit e92e164 into nipy:master May 31, 2025
2 of 4 checks passed
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.

2 participants