yaqing
March 28, 2025, 11:45am
1
Dear Forum,
I ran into some problem with plotting all-to-all EEG sensor connectivity using the funcion plot_sensors_connectivity(). The connectivity is computed from epoch data and transformed into matrix form:
conn = mne_connectivity.spectral_connectivity_epochs(epochs_fl.get_data(), method='coh', fmin=bands[band][0], fmax=bands[band][1], sfreq=sfreq)
conn_matrix = conn.get_data(output="dense")[:, :, 0]
When I visualize my connectivity matrix it looks fine
However, when I try plot_sensors_connectivity(epochs_fl.info, conn_matrix)
there are only 2 connections with very high connectivity strength:
I have checked my EEG montage using epochs_fl.get_montage().dig
and it seems to have the sensor location info. What could be wrong here?
yaqing
March 28, 2025, 12:33pm
2
The problem seems to be due to the hard-coded minimal distance, and fixed by:
main
β tsbinns:fix_plot_sensors_conn
opened 05:17PM - 01 Aug 24 UTC
Addresses #148, discussed in call with @larsoner.
Have gone with options (2) β¦ & (3) suggested above. This involves:
- An option to specify the minimum distance required between sensors for a connection to be plotted (default was 5 cm, which has been retained).
- A check that if no connections survive the minimum distance requirement, a more descriptive error message is raised.
- The message suggests increasing the number of connections being plotted or decreasing the minimum distance (would help in cases like https://mne.discourse.group/t/problem-with-different-methods-in-sensor-connectivity-example/7548/4)
- The message also suggests checking that the coordinates of channels are not NaNs (would help in cases like https://mne.discourse.group/t/error-while-trying-to-call-plot-sensors-connectivity/9128)
Perhaps this can be merged?
tsbinns
(Thomas)
April 6, 2025, 3:15pm
3
Hello,
Sorry for the late reply, I was away on vacation.
This fix has been merged into the development version of the package which you can install with pip install git+https://github.com/mne-tools/mne-connectivity
. If you want the fix, working with the development version is your best bet. As far as Iβm aware thereβs no set date for when it will be officially released, and itβs stable enough in its current state.
You can find the documentation for the new min_distance
parameter here: mne_connectivity.viz.plot_sensors_connectivity β MNE-Connectivity 0.8.0.dev66+gc7090ac2 documentation
Cheers,
Thomas
1 Like