issue with TFCE and permutation_cluster_1samp_test

External Email - Use Caution

Hello,

I encountered a mistake when running permutation_cluster_1samp_test with TFCE.

clu = permutation_cluster_1samp_test(X, n_permutations = n_permutations,
                                            connectivity = connectivity,
                                            threshold=threshold, tail=tails,
                                            out_type = 'indices')
=> File "C:\Users\XX\Anaconda3\lib\site-packages\mne\stats\cluster_level.py", line 385, in _find_clusters

    threshold['step'], float)
ValueError: arange: cannot compute length

X is shape (n subjects x n sources). This mistake actually comes from the T-value computation. It seems that the activity of some of the sources is 0 for all subjects, hence creating nans when computing the t value :

  t = np.mean(X, axis=0) / np.sqrt(var / X.shape[0])

with var =[8.09150634e-43 5.30338813e-43 5.90491142e-43 ... 0.00000000e+00

0.00000000e+00 0.00000000e+00]

Then, in function _find_clusters, mne tries to set the stop limit of TFCE as np.max(np.abs(tvalues)), hence generating the error at this line:
thresholds = np.arange(threshold['start'], stop, threshold['step'], float)

Does anyone has a solution for this issue?
Thanks in advance,
Fleur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200416/e753c39f/attachment-0001.html

External Email - Use Caution

As a first step, we could do
`np.max(np.abs(tvalues[np.isfinite(tvalues)]))`. Can you try it with your
data? If you could make a PR to implement this it would be great!

Eric

External Email - Use Caution

I tried that, it solved the problem. I'm sorry, I'm not sure how to make a PR (I'm a M2 student).

Fleur