Skip to content

Conversation

@EmmaRenauld
Copy link
Contributor

In PR #1102, we changes the padding to nearest. Antoine suggested to add a verification for out-of-bound values. It was not done in PR1102 to keep it simple, but was added as issue #1206. This finishes PR1102.

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.46%. Comparing base (df80acf) to head (0da3d04).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1270   +/-   ##
=======================================
  Coverage   72.45%   72.46%           
=======================================
  Files         293      293           
  Lines       25203    25218   +15     
  Branches     3530     3532    +2     
=======================================
+ Hits        18262    18273   +11     
  Misses       5450     5450           
- Partials     1491     1495    +4     
Flag Coverage Δ
smoketests 69.62% <76.19%> (-0.01%) ⬇️
unittests 13.34% <61.90%> (+0.03%) ⬆️

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

Components Coverage Δ
Scripts 75.27% <71.42%> (-0.02%) ⬇️
Library 69.12% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

quick fix and LGTM

import nibabel as nib
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import map_coordinates
Copy link
Contributor

Choose a reason for hiding this comment

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

still needed ?

import nibabel as nib
from nilearn import plotting
import numpy as np
from scipy.ndimage import map_coordinates
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor

@AntoineTheb AntoineTheb left a comment

Choose a reason for hiding this comment

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

See comment. I would strongly recommend we actually deal with out of bounds coordinates in the function. Otherwise, we'll redo the same logic every time we call our own map_coordinates.

if (np.any(np.logical_or(points[0] < 0, points[0] > data.shape[0])) or
np.any(np.logical_or(points[1] < 0, points[1] > data.shape[1])) or
np.any(np.logical_or(points[2] < 0,points[2] > data.shape[2]))) :
logging.warning("Careful! You are interpolating outside of boundaries "
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this as it deviates from the expected behavior of the function. I would instead try to match the expected behavior of map_coordinates and return a cval if the indices are actually out of bounds instead of logging a message (which may be swallowed).

@AntoineTheb
Copy link
Contributor

image

In this case, we would expect "E" to return an "out-of-bounds" value that the user can choose, not what is in the nearest voxel.

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.

3 participants