You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading a .fif file with BAD segments annotated, it is possible to discard bad segments, using reject_by_annotations='omit'.
Under the hood, it will call mne.Raw.get_data(reject_by_annotations='omit'), yielding a numpy array where all data points annotated with "bad" are dropped.
It seems as though this behaviour might be wrong for TDE. Conceptually, timepoints [s_i, s_i+1, BAD,BAD,BAD, s_i+5,s_i+6] will become [s_i, s_i+1, s_i+5, s_i+6]. The time embedding will consider s_i+1 and s_i+5 to be directly adjacent time-wise.
Steps to reproduce
python
import osl_dynamics
from osl_dynamics.data import Data
import numpy as np
import mne
X = np.arange(0,100)*1.0
X[10:15] = np.nan
info = mne.create_info(['ch_1'],1, ch_types='bio')
raw = mne.io.RawArray(X.reshape((1,100)), info)
annots = mne.preprocessing.annotate_nan(raw)
raw.set_annotations(annots)
raw.save('example_raw.fif')
data = Data(['example_raw.fif'], reject_by_annotation='omit')
data.tde(n_embeddings=3)
print(data.arrays[0])
Expected result
We should obtain one TDE for indices [0, 9] and one for [15, 99], since they no longer have any temporal dependency.
Your understanding is correct. In the previous Matlab implementation with HMM-MAR you would pass the indices where the session is discontinuous and it would take this into account in the time-delay embedding.
In the new python package, we found this made no difference in practice so to simplify the implementation, we just assume it's all continuous. Note, it would be straightforward to write a separate script loading the fif files with MNE and saving the continuous segments as numpy files which you can then pass into the Data object if you are concerned about the discontinuities.
Please close the issue if this answers your question.
Description of the problem
When loading a
.fif
file with BAD segments annotated, it is possible to discard bad segments, usingreject_by_annotations='omit'
.Under the hood, it will call
mne.Raw.get_data(reject_by_annotations='omit')
, yielding a numpy array where all data points annotated with "bad" are dropped.It seems as though this behaviour might be wrong for TDE. Conceptually, timepoints [s_i, s_i+1, BAD,BAD,BAD, s_i+5,s_i+6] will become [s_i, s_i+1, s_i+5, s_i+6]. The time embedding will consider s_i+1 and s_i+5 to be directly adjacent time-wise.
Steps to reproduce
Expected result
We should obtain one TDE for indices [0, 9] and one for [15, 99], since they no longer have any temporal dependency.
Actual result
Segments are considered contiguous:
I was wondering if it was by design or is, indeed, a bug?
The text was updated successfully, but these errors were encountered: