mscheltienne
(Mathieu Scheltienne)
October 11, 2022, 12:19pm
1
Running on current `mne-main`

, letâ€™s summarize the code Iâ€™m using with:

```
raw = read_raw_fif(fname, preload=True)
epochs = make_fixed_length_epochs(raw, duration=4., overlap=0.)
spectrum = epochs.compute_psd(
method="multitaper", adaptive=True, verbose="INFO"
)
```

With some of my files, Iâ€™m greeted by the following warning:

```
RuntimeWarning: Iterative multi-taper PSD computation did not converge.
```

How bad is it? Can I disregard this warning?

It comes from `adaptive=True`

which calls `_psd_from_mt_adaptive`

in `psd_array_multitaper`

:

```
```
parallel, my_psd_from_mt_adaptive, n_jobs = \
parallel_func(_psd_from_mt_adaptive, n_jobs)
n_splits = min(stop - start, n_jobs)
out = parallel(my_psd_from_mt_adaptive(x, eigvals, freq_mask)
for x in np.array_split(x_mt, n_splits))
psd[start:stop] = np.concatenate(out)

`_psd_from_mt_adaptive`

has a `max_iter`

argument. Increasing it does suppress the warningâ€¦ but itâ€™s not exposed in the public API.

```
```
def _psd_from_mt_adaptive(x_mt, eigvals, freq_mask, max_iter=150,
return_weights=False):
r"""Use iterative procedure to compute the PSD from tapered spectra.
.. note:: Modified from NiTime.
Parameters
----------
x_mt : array, shape=(n_signals, n_tapers, n_freqs)
The DFTs of the tapered sequences (only positive frequencies)
eigvals : array, length n_tapers
The eigenvalues of the DPSS tapers
freq_mask : array
Frequency indices to keep
max_iter : int
Maximum number of iterations for weight computation
return_weights : bool
Also return the weights

mscheltienne
(Mathieu Scheltienne)
October 11, 2022, 2:57pm
2
Note that it could also maybe impact `csd_array_multitaper`

, where `adaptive=True`

would also run `_psd_from_mt_adaptive`

without exposing the `max_iter`

argument in the public API.