niivue / ipyniivue

A WebGL-powered Jupyter Widget for Niivue based on anywidget
BSD 2-Clause "Simplified" License
25 stars 8 forks source link

MNE source files are not displayed #23

Closed christian-oreilly closed 6 months ago

christian-oreilly commented 1 year ago

The following example:

import numpy as np
import matplotlib.pyplot as plt

import mne
from mne.datasets import sample, fetch_hcp_mmp_parcellation
from mne.minimum_norm import apply_inverse, read_inverse_operator
from mne import read_evokeds

data_path = sample.data_path()
meg_path = data_path / 'MEG' / 'sample'
subjects_dir = data_path / 'subjects'

fname_evoked = meg_path / 'sample_audvis-ave.fif'
fname_stc = meg_path / 'sample_audvis-meg'
fetch_hcp_mmp_parcellation(subjects_dir)

nv = ipyniivue.Niivue(crosshair_color=[0,1,0,1])
nv.add_volume(str(fname_stc) + "-lh.stc")

fails to display the sources stored in the .stc format. According to https://github.com/niivue/niivue, NiiVue supports this format. Here is the results from this code when ran on Google Colab:

image

christian-oreilly commented 1 year ago

@hanayik Do you (or whoever you think is best placed to test this) could check if that shows fine with NiiVue, so that we know if the issue is on ipyniivue's side?

neurolabusc commented 1 year ago

@christian-oreilly add_volume adds a voxel-based image (e.g. NIfTI, DICOM, NRRD). An STC file contains the per-vertex values for a mesh. So you would want to add your desired triangular mesh (e.g. left-hemisphere mesh) and then load your STC file as a layer attached to the mesh. Note that you can have multiple meshes open at once (e.g. left and right hemisphere simultaneously) each with its own layer(s). The mesh 4D live demo illustrates the process.

christian-oreilly commented 1 year ago

Thanks @neurolabusc for this info. Right, that makes sense. I had in mind that these files embedded the meshes as other MNE structures do (like the source model and the forward model if I am not mistaken)... but you are right, they don't. I'll cycle back to this when I have a moment to try to finish the demo with ipyniivue given this info.