# How to Visualize fNIRS Data on the Brain Surface and Display Temporal Changes Using mne.viz.plot\_source\_estimates?

**URL:** <https://mne.discourse.group/t/how-to-visualize-fnirs-data-on-the-brain-surface-and-display-temporal-changes-using-mne-viz-plot-source-estimates/10513>\
**Category:** Support & Discussions\
**Tags:** fnirs, epochs\
**Created:** [November 12, 2024, 3:00am UTC](https://mne.discourse.group/t/how-to-visualize-fnirs-data-on-the-brain-surface-and-display-temporal-changes-using-mne-viz-plot-source-estimates/10513 "2024-11-12T03:00:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyq](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/xyq/32/4007_2.png) [@xyq](https://mne.discourse.group/u/xyq)\
**Post date:** [November 12, 2024, 3:00am UTC](https://mne.discourse.group/t/how-to-visualize-fnirs-data-on-the-brain-surface-and-display-temporal-changes-using-mne-viz-plot-source-estimates/10513/1 "2024-11-12T03:00:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xyq](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/xyq/32/4007_2.png) [@xyq](https://mne.discourse.group/u/xyq)\
**Post date:** [November 14, 2024, 11:54am UTC](https://mne.discourse.group/t/how-to-visualize-fnirs-data-on-the-brain-surface-and-display-temporal-changes-using-mne-viz-plot-source-estimates/10513/2 "2024-11-14T11:54:15Z")

</div>

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.

 ![1](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/5/50a5012fe2402cb891ad9697fcba9303c6a4a8ab.jpeg)

---

<div class="post-metadata">

**Author:** ![xyq](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/xyq/32/4007_2.png) [@xyq](https://mne.discourse.group/u/xyq)\
**Post date:** [November 14, 2024, 11:59am UTC](https://mne.discourse.group/t/how-to-visualize-fnirs-data-on-the-brain-surface-and-display-temporal-changes-using-mne-viz-plot-source-estimates/10513/3 "2024-11-14T11:59:44Z")

</div>

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

```python
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()

```
