How to Visualize fNIRS Data on the Brain Surface and Display Temporal Changes Using mne.viz.plot_source_estimates?

Hello everyone,

I’m trying to visualize fNIRS data on the brain surface and display how the data changes over time. I attempted to use the MNE function mne_nirs.visualisation.plot_glm_surface_projection, but I found that this function is a convenient wrapper around lower-level functionality and might not fully meet my needs.

I also tried using mne.viz.plot_source_estimates for this purpose, but unfortunately, it didn’t work as expected. I would greatly appreciate any advice or suggestions on how to successfully achieve this.

Thank you in advance for your help!

Best regards,
Xie

I find that the GLM result has no time dimension because the glm_est.to_dataframe() result I output has no time related information, indicating that it is a static regression result. Therefore, we still need to evoked and visualized mne.viz.plot_source_estimates.

I wrote the following test code myself and would appreciate any suggestions for improvement.

def Epoching_3Dbrain(raw_haemo, epochs, event_key):
    evoked = epochs[event_key].average()
    evoked_hbo = epochs[event_key].average(picks='hbo')
    evoked_hbr = epochs[event_key].average(picks='hbr')

    evoked_hbo.data *= 1e6

    subjects_dir = mne.utils.get_subjects_dir(raise_error=True)
    fname_src_fs = os.path.join(
        subjects_dir, "fsaverage", "bem", "fsaverage-ico-5-src.fif"
    )
    src = mne.read_source_spaces(fname_src_fs)
    kwargs = dict(
        evoked=evoked_hbo,
        subject="fsaverage",
        trans="fsaverage",
        distance=0.03,
        mode="weighted",
        surface="pial",
        subjects_dir=subjects_dir,
        src=src,
        project=True,
    )
    stc = mne.stc_near_sensors(picks='hbo', **kwargs, verbose=False)
    clim = dict(kind="value", pos_lims=(0, 10, 17))
    brain = stc.plot(
        src=src,
        subjects_dir=subjects_dir,
        hemi="both",
        surface="pial",
        initial_time=0,
        clim=clim,  # "auto"
        size=800,
        colormap="RdBu_r",
        figure=None,
        background="w",
        colorbar=True,
        verbose=False,
    )
    brain.add_text(0.05, 0.95, f"{event_key}", "title", font_size=16, color="k")
    mlab.show()