mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.74k stars 1.33k forks source link

Error in "Spatiotemporal permutation F-test on full sensor data" tutorial #12927

Open joebathelt opened 1 month ago

joebathelt commented 1 month ago

Proposed documentation enhancement

First, thank you for developing MNE-Python and for all the work that went into creating such comprehensive and useful tutorials.

I recently completed the spatiotemporal clustering tutorial for full sensor data using MNE version 1.8. However, when I reached the clustering step, I encountered an error at Line 312 that prevented the clustering from completing successfully:

Exception ignored in: 'scipy.sparse.csgraph._traversal._connected_components_undirected'
Traceback (most recent call last):
  File "/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py", line 304, in _get_components
    _, components = connected_components(adjacency)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long'

It seems the issue is related to the format or type of the adjacency matrix, but I’m unsure how to resolve it. Could you please advise on what might be causing this error and any steps I could take to fix it?

welcome[bot] commented 1 month ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

larsoner commented 1 month ago

Can you paste the full traceback and also the output of mne sys_info? I suspect that this is a SciPy bug having to do with connected_components but to replicate and investigate I need a bit more info!

joebathelt commented 1 month ago

Hi @larsoner,

Thank you for the swift response.

Here is the full traceback:

stat_fun(H1): min=6.752417666025855e-07 max=38.40836555950498
Running initial clustering …
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long'
Exception ignored in: 'scipy.sparse.csgraph._traversal._connected_components_undirected'
Traceback (most recent call last):
  File "/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py", line 304, in _get_components
    _, components = connected_components(adjacency)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long'
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
File /Users/joebathelt/Downloads/Spatiotemporal F-test full sensor (1).py:15
     [12](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:12) tfr_threshold = 15.0
     [14](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:14) # run cluster based permutation analysis
---> [15](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:15) cluster_stats = spatio_temporal_cluster_test(
     [16](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:16)     X,
     [17](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:17)     n_permutations=1000,
     [18](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:18)     threshold=tfr_threshold,
     [19](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:19)     tail=1,
     [20](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:20)     n_jobs=None,
     [21](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:21)     buffer_size=None,
     [22](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:22)     adjacency=tfr_adjacency,
     [23](https://file+.vscode-resource.vscode-cdn.net/Users/joebathelt/Downloads/Spatiotemporal%20F-test%20full%20sensor%20(1).py:23) )

File <decorator-gen-306>:12, in spatio_temporal_cluster_test(X, threshold, n_permutations, tail, stat_fun, adjacency, n_jobs, seed, max_step, spatial_exclude, step_down_p, t_power, out_type, check_disjoint, buffer_size, verbose)

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1548, in spatio_temporal_cluster_test(X, threshold, n_permutations, tail, stat_fun, adjacency, n_jobs, seed, max_step, spatial_exclude, step_down_p, t_power, out_type, check_disjoint, buffer_size, verbose)
   [1546](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1546) else:
   [1547](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1547)     exclude = None
-> [1548](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1548) return permutation_cluster_test(
   [1549](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1549)     X,
   [1550](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1550)     threshold=threshold,
   [1551](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1551)     stat_fun=stat_fun,
   [1552](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1552)     tail=tail,
   [1553](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1553)     n_permutations=n_permutations,
   [1554](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1554)     adjacency=adjacency,
   [1555](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1555)     n_jobs=n_jobs,
   [1556](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1556)     seed=seed,
   [1557](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1557)     max_step=max_step,
   [1558](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1558)     exclude=exclude,
   [1559](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1559)     step_down_p=step_down_p,
   [1560](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1560)     t_power=t_power,
   [1561](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1561)     out_type=out_type,
   [1562](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1562)     check_disjoint=check_disjoint,
   [1563](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1563)     buffer_size=buffer_size,
   [1564](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1564) )

File <decorator-gen-303>:12, in permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun, adjacency, n_jobs, seed, max_step, exclude, step_down_p, t_power, out_type, check_disjoint, buffer_size, verbose)

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1242, in permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun, adjacency, n_jobs, seed, max_step, exclude, step_down_p, t_power, out_type, check_disjoint, buffer_size, verbose)
   [1182](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1182) """Cluster-level statistical permutation test.
   [1183](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1183) 
   [1184](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1184) For a list of :class:`NumPy arrays <numpy.ndarray>` of data,
   (...)
   [1239](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1239) .. footbibliography::
   [1240](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1240) """
   [1241](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1241) stat_fun, threshold = _check_fun(X, stat_fun, threshold, tail, "between")
-> [1242](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1242) return _permutation_cluster_test(
   [1243](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1243)     X=X,
   [1244](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1244)     threshold=threshold,
   [1245](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1245)     n_permutations=n_permutations,
   [1246](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1246)     tail=tail,
   [1247](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1247)     stat_fun=stat_fun,
   [1248](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1248)     adjacency=adjacency,
   [1249](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1249)     n_jobs=n_jobs,
   [1250](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1250)     seed=seed,
   [1251](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1251)     max_step=max_step,
   [1252](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1252)     exclude=exclude,
   [1253](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1253)     step_down_p=step_down_p,
   [1254](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1254)     t_power=t_power,
   [1255](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1255)     out_type=out_type,
   [1256](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1256)     check_disjoint=check_disjoint,
   [1257](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1257)     buffer_size=buffer_size,
   [1258](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1258) )

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:987, in _permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun, adjacency, n_jobs, seed, max_step, exclude, step_down_p, t_power, out_type, check_disjoint, buffer_size)
    [985](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:985)     partitions = None
    [986](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:986) logger.info("Running initial clustering …")
--> [987](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:987) out = _find_clusters(
    [988](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:988)     t_obs,
    [989](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:989)     threshold,
    [990](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:990)     tail,
    [991](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:991)     adjacency,
    [992](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:992)     max_step=max_step,
    [993](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:993)     include=include,
    [994](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:994)     partitions=partitions,
    [995](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:995)     t_power=t_power,
    [996](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:996)     show_info=True,
    [997](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:997) )
    [998](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:998) clusters, cluster_stats = out
   [1000](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:1000) # The stat should have the same shape as the samples

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:455, in _find_clusters(x, threshold, tail, adjacency, max_step, include, partitions, t_power, show_info)
    [453](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:453) for x_in in x_ins:
    [454](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:454)     if np.any(x_in):
--> [455](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:455)         out = _find_clusters_1dir_parts(
    [456](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:456)             x, x_in, adjacency, max_step, partitions, t_power, ndimage
    [457](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:457)         )
    [458](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:458)         clusters += out[0]
    [459](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:459)         sums.append(out[1])

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:493, in _find_clusters_1dir_parts(x, x_in, adjacency, max_step, partitions, t_power, ndimage)
    [491](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:491) """Deal with partitions, and pass the work to _find_clusters_1dir."""
    [492](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:492) if partitions is None:
--> [493](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:493)     clusters, sums = _find_clusters_1dir(
    [494](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:494)         x, x_in, adjacency, max_step, t_power, ndimage
    [495](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:495)     )
    [496](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:496) else:
    [497](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:497)     # cluster each partition separately
    [498](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:498)     clusters = list()

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:547, in _find_clusters_1dir(x, x_in, adjacency, max_step, t_power, ndimage)
    [545](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:545)     adjacency = sparse.coo_array(adjacency)
    [546](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:546) if sparse.issparse(adjacency) or adjacency is False:
--> [547](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:547)     clusters = _get_components(x_in, adjacency)
    [548](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:548) elif isinstance(adjacency, list):  # use temporal adjacency
    [549](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:549)     clusters = _get_clusters_st(x_in, adjacency, max_step)

File /opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:311, in _get_components(x_in, adjacency, return_list)
    [309](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:309) mask = np.zeros(len(comp_list), dtype=bool)
    [310](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:310) for ii, comp in enumerate(components):
--> [311](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:311)     comp_list[comp].append(ii)
    [312](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:312)     mask[comp] += x_in[ii]
    [313](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/lib/python3.11/site-packages/mne/stats/cluster_level.py:313) clusters = [np.array(k) for k, m in zip(comp_list, mask) if m]

IndexError: list index out of range

... and here is the output from mne.sys_info():

Platform             macOS-15.0.1-arm64-arm-64bit
Python               3.11.3 | packaged by conda-forge | (main, Apr  6 2023, 08:58:31) [Clang 14.0.6 ]
Executable           [/opt/homebrew/anaconda3/envs/LonelyEEG/bin/python](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/anaconda3/envs/LonelyEEG/bin/python)
CPU                  arm (10 cores)
Memory               16.0 GB

Core
├☑ mne               1.8.0 (latest release)
├☑ numpy             1.24.3 (OpenBLAS 0.3.21 with 10 threads)
├☑ scipy             1.11.1
└☑ matplotlib        3.7.2 (backend=module://matplotlib_inline.backend_inline)

Numerical (optional)
├☑ sklearn           1.3.0
├☑ numba             0.57.1
├☑ nibabel           5.0.1
├☑ nilearn           0.10.1
├☑ dipy              1.7.0
├☑ openmeeg          2.5.6
├☑ pandas            2.0.3
├☑ h5io              0.1.7
├☑ h5py              3.8.0
└☐ unavailable       cupy

Visualization (optional)
├☑ pyvista           0.39.1 (OpenGL 4.1 Metal - 89.3 via Apple M2 Pro)
├☑ pyvistaqt         0.0.0
├☑ vtk               9.2.6
├☑ qtpy              2.2.0 (PyQt5=5.15.6)
├☑ pyqtgraph         0.13.1
├☑ mne-qt-browser    0.5.0
├☑ ipywidgets        7.7.5
├☑ trame_client      3.4.0
├☑ trame_server      2.17.3
├☑ trame_vtk         2.8.11
├☑ trame_vuetify     2.7.1
└☐ unavailable       ipympl

Ecosystem (optional)
├☑ eeglabio          0.0.2-3
├☑ edfio             0.4.4
├☑ mffpy             0.8.0
├☑ pybv              0.7.5
└☐ unavailable       mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo