Skip to content

Fix get_3d_peaks when using mask #455

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aperezlebel
Copy link

Issue

The get_3d_peaks function from nipy.labs.statistical_mapping throws an error when using it with a mask.

Minimal reproductible example

from nilearn import datasets, masking, image
from nipy.labs.statistical_mapping import get_3d_peaks

template = datasets.load_mni152_template()
mask = masking.compute_gray_matter_mask(template)

imgs = datasets.fetch_neurovault_motor_task()
img = image.resample_to_img(imgs.images[0], template)

get_3d_peaks(img, mask=mask)

Error

Traceback (most recent call last):
  File "minimal.py", line 10, in <module>
    get_3d_peaks(img, mask=mask)
  File ".../venv/lib/python3.7/site-packages/nipy/labs/statistical_mapping.py", line 199, in get_3d_peaks
    ff = field_from_graph_and_data(wgraph_from_3d_grid(xyz, k=18), data)
  File ".../venv/lib/python3.7/site-packages/nipy/algorithms/graph/graph.py", line 527, in wgraph_from_3d_grid
    raise ValueError('xyz should have shape n * 3')
ValueError: xyz should have shape n * 3

Versions

nipy==0.4.2
nilearn==0.5.2

Fix

xyz must be of shape n*3 to be used by wgraph_from_3d_grid, hence the use of the 3D mask array instead of the 1D ravelled mask array in np.where.

xyz must be of shape n*3 to be used by wgraph_from_3d_grid, hence the use of the 3D mask array instead of the 1D ravelled mask array in np.where
@jbpoline
Copy link
Member

jbpoline commented Aug 22, 2019 via email

@aperezlebel
Copy link
Author

Hi, any news ?

@matthew-brett
Copy link
Member

I'm very very sorry to be so slow here - but can you think of a test for this fix? I will honestly get to this very quickly, if you do still have interest.

@aperezlebel
Copy link
Author

No problem! I am not working on this anymore but I can try to have a look in the following weeks.

@matthew-brett
Copy link
Member

That would be kind. I'm very sorry for the delay.

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