Skip to content
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

NF Add functions to project volume data to surface while dealing with NaNs. #539

Merged
merged 2 commits into from
May 21, 2024

Conversation

mvdoc
Copy link
Contributor

@mvdoc mvdoc commented May 21, 2024

These new functions can be used to project data from the volume to any arbitrary surface via a combination of pycortex mappers and mri_surf2surf. The projection deals with nans similar to quickshow and nanproject=True.

Example code:

import cortex
from cortex.mapper import vol2surf
import numpy as np

subject = ...  # anonymized
xfm = ...  # anonymized

vol = cortex.Volume.random(subject, xfm, mask="thick")
mask = cortex.db.get_mask(subject, xfm)
data = vol.data[mask]
data[np.random.randn(*data.shape) > 0] = np.nan

new_volume = cortex.Volume(data, subject, xfm, mask="thick")
surface = cortex.Vertex(vol2surf(data, subject, xfm), subject)
fsaverage = cortex.Vertex(vol2surf(data, subject, xfm, target_surface="fsaverage"), "fsaverage")

fig = cortex.quickshow(new_volume, with_colorbar=False, with_curvature=True, with_rois=False, with_labels=False, nanmean=False,)
fig.suptitle("volume, nanmean=False", fontsize=24)
fig = cortex.quickshow(new_volume, with_colorbar=False, with_curvature=True, with_rois=False, with_labels=False, nanmean=True,)
fig.suptitle("volume, nanmean=True", fontsize=24)
fig = cortex.quickshow(surface, with_colorbar=False, with_curvature=True, with_rois=False, with_labels=False,)
fig.suptitle("vol2surf", fontsize=24)
fig = cortex.quickshow(fsaverage, with_colorbar=False, with_curvature=True, with_rois=False, with_labels=False,)
fig.suptitle("fsaverage", fontsize=24)

Outputs:
image
image
image
image

@mvdoc mvdoc merged commit d942fc0 into main May 21, 2024
9 checks passed
@mvdoc mvdoc deleted the project branch May 21, 2024 20:45
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.

1 participant