# Plot t-value on head-scalp for fNIRS data

**URL:** <https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273>\
**Category:** Support & Discussions\
**Created:** [June 17, 2021, 12:56pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273 "2021-06-17T12:56:02Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 17, 2021, 12:56pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/1 "2021-06-17T12:56:02Z")

</div>

- MNE-Python version: 0.21
- operating system: Ubuntu

I have fNIRS data of 106 channels in two experimental conditions, and computed t-statistic (106 t-values) in each channel basis. I want to plot these 106 t-values on scalp of head, but I am clueless how I can plot these t-value on scalp. I would appreciate any suggestions or help.  
Thanks

---

<div class="post-metadata">

**Author:** ![rob-luke](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/rob-luke/32/21_2.png) [@rob-luke](https://mne.discourse.group/u/rob-luke)\
**Post date:** [June 17, 2021, 10:22pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/2 "2021-06-17T22:22:11Z")

</div>

Very cool dataset you have Prasenjit. Did you compute the t-values with MNE-NIRS? If so, can you post in here the code?

Is it group level results from MNE-NIRS? if so, you can use the group level topo function [mne\_nirs.visualisation.plot\_glm\_group\_topo — MNE-NIRS 0.0.6 dev documentation](https://mne.tools/mne-nirs/master/generated/mne_nirs.visualisation.plot_glm_group_topo.html) and specify the `value` parameter to be the t-statistic.

Alternatively, you may be interested in [mne\_nirs.visualisation.plot\_nirs\_source\_detector — MNE-NIRS 0.0.6 dev documentation](https://mne.tools/mne-nirs/master/generated/mne_nirs.visualisation.plot_nirs_source_detector.html)

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 18, 2021, 10:08am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/3 "2021-06-18T10:08:38Z")

</div>

![diagram](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/432ab167eabfae9f8f84f7bb68e17c53b3dbde23.jpeg)

Thanks Robert!  
I would explain a little bit about the steps that I followed. We have two conditions in our data described in the above figure. I have done the preprocessing of fNIRS signal using MNE-NIRS. In each channel, we took the average of last 10 sec data for Event\_1 (v1,avg). Similarly, we computed the average of first 20 sec for Event\_2 (v2,avg). Then, we computed the difference between these two averages (d1=v2,avg-v1,avg). In our whole data-set, we have 20 such occurrences (i.e., d1, d2, …, d20). Now, on each channel basis, we have computed t-statistic on these difference values (Null hypothesis: H0=0, Alternate Hypothesis: Ha!=0) whether the difference is zero or not. So, we have 106 t-values for 106 channels. This calculation is done outside of MNE by taking the data (raw.get\_data()).

I plot these values on 2D head model using MNE (mne.viz.plot\_topomap()). I want to plot these t-values on scalp of head. But, I could not figure out how to do it as most of the scalp figures in MNE tutorials deal with ‘stc’ file.

Any help would be really appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![rob-luke](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/rob-luke/32/21_2.png) [@rob-luke](https://mne.discourse.group/u/rob-luke)\
**Post date:** [June 18, 2021, 10:30am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/4 "2021-06-18T10:30:59Z")

</div>

Your processing sounds great. Very interesting work. I’m glad the functions are working well for you so far.

If the topoplots are working well then that means your data is in the right format.

There is currently no convenient way to create the plot you desire that I am aware of. I am almost have that functionality working in this pull request, but can’t merge it as I’m fighting to get the continuous integration to work… But maybe the code here can help you get started. [WIP: Plot GLM results on cortical surface by rob-luke · Pull Request #287 · mne-tools/mne-nirs · GitHub](https://github.com/mne-tools/mne-nirs/pull/287)

Can you share a version of your script here? Im curious about you pipeline.

If you get the 3d plot working please report back here so we can learn together. And it will be a nice resource for future users.

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 18, 2021, 3:08pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/5 "2021-06-18T15:08:36Z")

</div>

```python
import os
import numpy as np
import matplotlib.pyplot as plt
import mne
from scipy.stats import ttest_1samp

def get_data(fnirs_data, d_type, t_tup):
        # return the hbo data belong to the time interval specified by the tuple
        
        return fnirs_data.pick_types(fnirs=d_type).crop(tmin=t_tup[0], tmax=t_tup[1], 
        include_tmax=True).get_data()

def get_diff_talking_base_data(raw, t, t_b=10, t_a=20):
	# This function takes the raw data, time instant, duration before event (t_a), duration after event 
        # (t_a) as input. It will collect the data t_b sec before and t_a sec after the specified time instant.
	# Then take the average of these data before and after time instance specified by t. 
        # Then compute the difference of this two averages.
	
        d_type='hbo' # type of fNIRS data (hbo/hbr)
        base_data=get_data(raw.copy(), d_type, (t-t_b, t)).mean(axis=1)
        event2_data=get_data(raw.copy(), d_type, (t, t+t_a)).mean(axis=1)
        diff=event2_data-base_data        
        return diff[:, np.newaxis]

baseFolder='path for data'
run_2='xxxx' # folder name

data_path=os.path.join(baseFolder, run_2)

# Reading fNIRS data
fnirs_data=mne.io.read_raw_nirx(data_path, preload=True, verbose=None)

### converting raw intensity to optical intensity
fnirs_data_od=mne.preprocessing.nirs.optical_density(fnirs_data)

### Converting from optical density to haemoglobin
fnirs_data_haemo=mne.preprocessing.nirs.beer_lambert_law(fnirs_data_od)

## Removing heart rate from signal
l_freq=0.01 # lower cut off frequency
h_freq=0.1 # higher cut off frequency
fnirs_filt= fnirs_data_haemo.filter(l_freq=l_freq, h_freq=h_freq, method='fir', phase='zero-double')

## Get the difference data from the particular intervals
time_inst=[399.68, 466.54, 772.73, 1018.89, 1102.38] ## Specify the time instants where you want to compare
t_b=10 # time duration before an event you want to average (for event_1)
t_a=20 # Time duration after an event you want to average (for event_2)
diff_data=[]
diff_data=[get_diff_talking_base_data(fnirs_filt.copy(), t, t_b, t_a) for t in time_inst] # Get the difference between average data from two events
diff_data=np.hstack(diff_data) # list to 2-D array

## Compute t-static of the difference values
info_data=fnirs_filt.pick_types(fnirs='hbo').info
t_diff, p_diff=ttest_1samp(diff_data, 0, axis=1)
fig, ax=plt.subplots(1,1)
mne.viz.plot_topomap(t_diff, info_data, colorbar=True, sensors=True, vmin=-5, vmax=5, outlines='head', contours=0)
ax.set_title('T-statitstic between Talking time and Before Talking intervals', fontweight='bold')
### End of 2D plotting t-values

data_path='/data2/pdhara/mne_data/MNE-sample-data'
subjects_dir = data_path + '/subjects'

## This function is working for plotting source and detector pairs (106 channels) in 3D head model
fig = mne.viz.create_3d_figure(size=(800, 600), bgcolor='white')
fig = mne.viz.plot_alignment(fnirs_filt.info, show_axes=True,
							 subject='fsaverage', coord_frame='mri',
							 trans='fsaverage', surfaces=['brain'],
							 fnirs=['channels', 'pairs',
									'sources', 'detectors'],
							 subjects_dir=subjects_dir, fig=fig)
mne.viz.set_3d_view(figure=fig, azimuth=20, elevation=60, distance=0.4,
					focalpoint=(0., -0.01, 0.02))

### This function is not working ***
mne_nirs.visualisation.plot_nirs_source_detector(t_diff, info_data, radius=0.001, subject='fsaverage', subjects_dir=subjects_dir, surfaces='head', cmap=True)

```

I have attached the code above. It took longer a bit as I need to eliminate unnecessary stuffs. Anyways,  
I tried to plot source and detector pairs in head, and it is working fine (second last). But, I tried to plot t-values as a data matrix ([106x1]), but not working.

---

<div class="post-metadata">

**Author:** ![rob-luke](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/rob-luke/32/21_2.png) [@rob-luke](https://mne.discourse.group/u/rob-luke)\
**Post date:** [June 20, 2021, 12:04am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/6 "2021-06-20T00:04:37Z")

</div>

When you say not working, please provide the error. How else do you expect us to help you?

---

<div class="post-metadata">

**Author:** ![rob-luke](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/rob-luke/32/21_2.png) [@rob-luke](https://mne.discourse.group/u/rob-luke)\
**Post date:** [June 20, 2021, 12:09am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/7 "2021-06-20T00:09:23Z")

</div>

Just looking at the code could it be because t\_diff is computed on all channels, but the info field has been subset to just hbo?

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 20, 2021, 7:36am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/8 "2021-06-20T07:36:26Z")

</div>

Sorry Robert. I tried to run the following line:

data\_path=’/path\_to\_mne\_data/mne\_data/MNE-sample-data’ # mne dataset in different directory than the default one.  
subjects\_dir = data\_path + ‘/subjects’  
mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, fnirs\_filt.pick\_types(fnirs=‘hbo’).info, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)

I have copied the mne\_data folder into another path, and I think the files related to head model are missing. The error is following:  
mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, fnirs\_filt.info, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)  
Traceback (most recent call last):

File “”, line 1, in   
mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, fnirs\_filt.info, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)

File “/\*\*/anaconda3/envs/mne21nirs/lib/python3.8/site-packages/mne\_nirs/visualisation/\_plot\_nirs\_source\_detector.py”, line 127, in plot\_nirs\_source\_detector  
fig = plot\_alignment(

File “”, line 24, in plot\_alignment

File “/\*\*/anaconda3/envs/mne21nirs/lib/python3.8/site-packages/mne/viz/\_3d.py”, line 742, in plot\_alignment  
raise IOError('No head surface found for subject ’

OSError: No head surface found for subject fsaverage after trying:  
/path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/outer\_skin.surf  
/path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/flash/outer\_skin.surf  
/path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/fsaverage-head.fif

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 21, 2021, 9:12am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/9 "2021-06-21T09:12:03Z")

</div>

/path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/outer\_skin.surf  
/path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/flash/outer\_skin.surf  
/path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/fsaverage-head.fif

I searched for these three files in mne\_data folder (downloaded earlier), but I could not find it. I downloaded it again in my machine to ensure that the mne\_data folder is intact. But these files are not available in the mentioned path. Would you help me where do I get these files? Thanks.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [June 22, 2021, 4:08pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/10 "2021-06-22T16:08:04Z")

</div>

> [@Prasenjit1989](#):
>
> OSError: No head surface found for subject fsaverage after trying:  
> /path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/outer\_skin.surf  
> /path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/flash/outer\_skin.surf  
> /path\_to\_mne\_data/mne\_data/MNE-sample-data/subjects/fsaverage/bem/fsaverage-head.fif

is your data really stored at the location `/path_to_mne_data/mne_data/`? What is the output of `mne.get_config('MNE_DATASETS_SAMPLE_PATH')`?

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 22, 2021, 6:28pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/11 "2021-06-22T18:28:31Z")

</div>

We have limited storage in the server, therefore, I have copied the mne\_data folder into another path. I checked the path (/mne\_data/MNE-sample-data/subjects/fsaverage/bem/) mentioned in above three lines, and could not find these three files. I have attached the screenshot of that folder.

 ![server](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/a8d63cb3a3fae97706aa878db8346ac9dd2f3f14.jpeg)

Also, I checked in another machine where I downloaded mne\_data folder (using codes in mne tutorials). There, too, I checked the same path, could not find these three files. I attached another screenshot.

 ![local_pc](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/e9fc00b4c1b890f01cfef97d5effd9277b80fd70.png)

If I run the mne.get\_config(‘MNE\_DATASETS\_SAMPLE\_PATH’) line in my local machine. I get the path for mne\_data (’/home/user\_name/mne\_data’)

I would be thankful if you could tell me where do I get these files. Thanks .

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [June 23, 2021, 3:45pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/12 "2021-06-23T15:45:14Z")

</div>

Your script above contains the following lines:

```python
data_path='/data2/pdhara/mne_data/MNE-sample-data'
subjects_dir = data_path + '/subjects'

```

Can you try with this instead?

```python
subjects_dir = mne.datasets.fsaverage.data_path()

```

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 23, 2021, 10:33pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/13 "2021-06-23T22:33:17Z")

</div>

I run this line: subjects\_dir = mne.datasets.fsaverage.data\_path()

But I got the following error.  
subjects\_dir = mne.datasets.fsaverage.data\_path()  
AttributeError: module ‘mne.datasets’ has no attribute ‘fsaverage’

I have checked in another path (/data2/pdhara/mne\_data/MNE-sample-data/subjects/sample/bem) where I find the files of similar names (attached in below picture).

 ![server](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/6c4675eacd86c82d683e5282e1f2c23b06865f64.png)

I do not want to change these path in mne built-in function as these additional path (i.e., subjects\_dir+ /fsaverage/bem/) are added by built-in functions, and don not want to create mess in built-in functions.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [June 23, 2021, 10:41pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/14 "2021-06-23T22:41:55Z")

</div>

oops, `subjects_dir = mne.datasets.fsaverage.data_path()` is wrong. To get the fsaverage files you do `mne.datasets.fetch_fsaverage()`. The `subjects_dir` that you pass to that function needs to be the same one you pass to `plot_nirs_source_detector()` otherwise the plotting function will be looking in the wrong place for the files.

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 24, 2021, 3:52pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/15 "2021-06-24T15:52:37Z")

</div>

I run this line: mne.datasets.fetch\_fsaverage(). I got another directory, named _MNE-fsaverage-data_, in mne\_data folder. I attached a screenshot.

 ![fsaverage_dir](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/f44014e0edad5db591ed248e68165458d7b4024f.png)

Then I run the following lines

subjects\_dir = mne.datasets.sample.data\_path() + ‘/subjects’

mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, fnirs\_filt.pick\_types(fnirs=‘hbo’).info, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)

I found the same error.

Traceback (most recent call last):  
File “fnirs\_processing.py”, line 91, in   
mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, fnirs\_filt.pick\_types(fnirs=‘hbo’).info, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)  
File “/home/user\_name/anaconda3/envs/mne21/lib/python3.8/site-packages/mne\_nirs/visualisation/\_plot\_nirs\_source\_detector.py”, line 127, in plot\_nirs\_source\_detector  
fig = plot\_alignment(  
File “”, line 21, in plot\_alignment  
File “/home/user\_name/anaconda3/envs/mne21/lib/python3.8/site-packages/mne/viz/\_3d.py”, line 742, in plot\_alignment  
raise IOError('No head surface found for subject ’  
OSError: No head surface found for subject fsaverage after trying:  
/home/user\_name/mne\_data/MNE-sample-data/subjects/fsaverage/bem/outer\_skin.surf  
/home/user\_name/mne\_data/MNE-sample-data/subjects/fsaverage/bem/flash/outer\_skin.surf  
/home/user\_name/mne\_data/MNE-sample-data/subjects/fsaverage/bem/fsaverage-head.fif

I think the additional data downloaded into the folder mne\_data/MNE-fsaverage-data/, and do not changes anything in the directory /home/user\_name/mne\_data/MNE-sample-data/subjects/fsaverage/bem/. But this function (mne\_nirs.visualisation.plot\_nirs\_source\_detector) is looking into the later path.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [June 24, 2021, 5:28pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/16 "2021-06-24T17:28:00Z")

</div>

As noted above:

> [@drammock](#):
>
> The `subjects_dir` that you pass to that function needs to be the same one you pass to `plot_nirs_source_detector()` otherwise the plotting function will be looking in the wrong place for the files.

where “that function” is `fetch_fsaverage()`. if you did `fetch_fsaverage()` with no arguments, then it will have used the default `subjects_dir`, so you are passing a _different_ subjects\_dir to `plot_nirs_source_detector()`.

---

<div class="post-metadata">

**Author:** ![Prasenjit1989](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/prasenjit1989/32/583_2.png) [@Prasenjit1989](https://mne.discourse.group/u/Prasenjit1989)\
**Post date:** [June 25, 2021, 12:31pm UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/17 "2021-06-25T12:31:15Z")

</div>

Thank you Dan. The problem of missing files related to head surface got solved. Thanks again. Those files are used by mne\_nirs.visualisation.plot\_nirs\_source\_detector function. Though the problem of missing files got solved, but I encounter another error related to length of ‘colors’ variable, given below.

Run the following line:  
mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, info\_data, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)

I got the following error:

mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, info\_data, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)  
Using outer\_skin.surf for head surface.  
Traceback (most recent call last):

File “”, line 1, in   
mne\_nirs.visualisation.plot\_nirs\_source\_detector(t\_diff, info\_data, radius=0.001, subject=‘fsaverage’, subjects\_dir=subjects\_dir, surfaces=‘head’, cmap=True)

File “/home/user\_name/anaconda3/envs/mne21nirs/lib/python3.8/site-packages/mne\_nirs/visualisation/\_plot\_nirs\_source\_detector.py”, line 146, in plot\_nirs\_source\_detector  
renderer.tube(origin=[np.array([locs[3], locs[4], locs[5]])],

File “/home/user\_name/anaconda3/envs/mne21nirs/lib/python3.8/site-packages/mne/viz/backends/\_pyvista.py”, line 460, in tube  
cmap = \_get\_colormap\_from\_array(colormap, normalized\_colormap)

File “/home/user\_name/anaconda3/envs/mne21nirs/lib/python3.8/site-packages/mne/viz/backends/\_utils.py”, line 32, in \_get\_colormap\_from\_array  
cmap = ListedColormap(np.array(colormap) / 255.0)

File “/home/user\_name/anaconda3/envs/mne21nirs/lib/python3.8/site-packages/matplotlib/colors.py”, line 893, in **init**  
N = len(colors)

TypeError: object of type ‘numpy.float64’ has no len()

---

<div class="post-metadata">

**Author:** ![rob-luke](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/rob-luke/32/21_2.png) [@rob-luke](https://mne.discourse.group/u/rob-luke)\
**Post date:** [July 1, 2021, 3:22am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/18 "2021-07-01T03:22:25Z")

</div>

This could be an actual bug or mistake in the documentation. I’ll check and report back here.

---

<div class="post-metadata">

**Author:** ![rob-luke](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/rob-luke/32/21_2.png) [@rob-luke](https://mne.discourse.group/u/rob-luke)\
**Post date:** [July 1, 2021, 3:25am UTC](https://mne.discourse.group/t/plot-t-value-on-head-scalp-for-fnirs-data/3273/19 "2021-07-01T03:25:08Z")

</div>

According to the documentation cmap should be a string. Can you remove this argument so it uses the default and try again.

[https://mne.tools/mne-nirs/master/generated/mne\_nirs.visualisation.plot\_nirs\_source\_detector.html#mne\_nirs.visualisation.plot\_nirs\_source\_detector](https://mne.tools/mne-nirs/master/generated/mne_nirs.visualisation.plot_nirs_source_detector.html#mne_nirs.visualisation.plot_nirs_source_detector)

Please let me know if this works or not. I can add more examples and expand the documentation if we resolve this.
