FZJ-INM1-BDA / siibra-python

Software interfaces for interacting with brain atlases - Python client
Apache License 2.0
48 stars 10 forks source link

fix: volume._pointsinside resample img to template #565

Closed AhmetNSimsek closed 7 months ago

AhmetNSimsek commented 7 months ago

During the intersection calculation of a volume and a pointset, Volume._points_inside determines the points laying inside the volume. However, some regional masks can have different shapes than the template. This can cause points to be extracted wrongly. At the moment, this only occurs during BigBrain intensity profile queries with a region that is defined on Julich Brain 2.9 on BigBrain.

To reproduce the issue:

import matplotlib.pyplot as plt
import siibra
from nilearn import plotting

mask29 = siibra.get_region('julich 2.9', 'hoc1 left').get_regional_map('bigbrain').fetch()
tmp = siibra.get_template('bigbrain').fetch(resolution_mm=max(mask29.header.get_zooms()))
cf = siibra.features.get(
    siibra.get_region('julich 2.9', 'hoc1 left'),
    'BigBrainIntensityProfile'
)[0]
pts = cf.anchor.location.as_list()
print(len(pts))
display = plotting.plot_roi(mask29, bg_img=tmp)
display.add_markers(pts, marker_size=5)
plt.show()

(to test that it works otherwise, use cf = siibra.features.get(siibra.get_region('julich 3', 'hoc1 left'), 'BigBrainIntensityProfile')[0])

TODO:

codecov-commenter commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 53.46%. Comparing base (5a0e6b3) to head (3ae88ab). Report is 406 commits behind head on main.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #565 +/- ## =========================================== + Coverage 36.81% 53.46% +16.64% =========================================== Files 61 69 +8 Lines 5421 6646 +1225 =========================================== + Hits 1996 3553 +1557 + Misses 3425 3093 -332 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

AhmetNSimsek commented 7 months ago

This PR, in fact, does not solve the actual source of the bug. #566 solves the issue. The example here will be committed there.