mne_hfo.LineLengthDetector

class mne_hfo.LineLengthDetector(threshold=3, win_size=100, overlap=0.25, sfreq=None, filter_band=(30, 100), scoring_func='f1', n_jobs=- 1, hfo_name='hfo', verbose=False)[source]

Line-length detection algorithm.

Original paper defines HFOS as “(HFOs), which we collectively term as all activity >40 Hz (including gamma, high-gamma, ripple, and fast ripple oscillations), may have a fundamental role in the generation and spread of focal seizures”

In the paper, data were sampled at 200 Hz and bandpass-filtered (0.1 – 100 Hz) during acquisition. Data were further digitally bandpass-filtered (4th-order Butterworth, forward-backward filtering, 0.1 85 Hz) to minimize potential artifacts due to aliasing. (IIR for forward-backward pass).

Compared to RMS detector, they utilize line-length metric.

Parameters

filter_band : tuple(float, float) | None

Low cut-off frequency at index 0 and high cut-off frequency at index 1.

threshold: float

Number of standard deviations to use as a threshold

win_size: int

Sliding window size in samples

overlap: float

Fraction of the window overlap (0 to 1)

offset: int

Offset which is added to the final detection. This is used when the function is run in separate windows. Default = 0

hfo_name: str

What to name the events detected (i.e. fast ripple if freq_band is (250, 500)).

Notes

For processing, a sliding window is used.

For post-processing, any events that overlap are considered to be the same.

References

1

A. B. Gardner, G. A. Worrell, E. Marsh, D. Dlugos, and B. Litt, “Human and automated detection of high-frequency oscillations in clinical intracranial EEG recordings,” Clin. Neurophysiol., vol. 118, no. 5, pp. 1134–1143, May 2007.

2

Esteller, R. et al. (2001). Line length: an efficient feature for seizure onset detection. In Engineering in Medicine and Biology Society, 2001. Proceedings of the 23rd Annual International Conference of the IEEE (Vol. 2, pp. 1707-1710). IEEE.

Attributes

chs_hfos_dict

Return dictionary of HFO start/end points.

chs_hfos_list

Return list of HFO start/end points for each channel.

h_freq

Higher frequency band for HFO definition.

hfo_df

Return HFO detections as a dataframe.

hfo_event_arr

HFO event array.

hfo_event_df

Return HFO detections as an event.tsv DataFrame.

l_freq

Lower frequency band for HFO definition.

step_size

Step size of each window.

Methods

fit(X[, y])

Fit the model according to the optionally given training data.

fit_predict(X[, y])

Perform fit on X and returns labels for X.

get_params([deep])

Get parameters for this estimator.

predict(X)

Scikit-learn override predict function.

score(X, y[, sample_weight])

Return the score of the HFO prediction.

set_params(**params)

Set the parameters of this estimator.

property chs_hfos_dict

Return dictionary of HFO start/end points.

property chs_hfos_list

Return list of HFO start/end points for each channel.

fit(X, y=None)

Fit the model according to the optionally given training data.

Parameters

X : mne.io.Raw of shape (n_samples, n_features) | pd.DataFrame

Training vector, where n_samples is the number of samples and n_features is the number of features. In MNE-HFO, n_features are the number of time points in the EEG data, and n_samples are the number of channels.

y : array-like of shape (n_samples, n_output)

Target vector relative to X.

Returns

self

Fitted estimator.

Notes

All detectors use a sliding window to compute HFOs in windows.

fit_predict(X, y=None)

Perform fit on X and returns labels for X.

Returns -1 for outliers and 1 for inliers.

Parameters
X{array-like, sparse matrix, dataframe} of shape (n_samples, n_features)

y : Ignored

Not used, present for API consistency by convention.

Returns

y : ndarray of shape (n_samples,)

1 for inliers, -1 for outliers.

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep : bool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params : dict

Parameter names mapped to their values.

property h_freq

Higher frequency band for HFO definition.

property hfo_df

Return HFO detections as a dataframe.

property hfo_event_arr

HFO event array.

Returns

hfo_event_arr : np.ndarray

Array that is (n_chs, n_samples), which has a value of 1 if

property hfo_event_df

Return HFO detections as an event.tsv DataFrame.

property l_freq

Lower frequency band for HFO definition.

predict(X)

Scikit-learn override predict function.

Just directly computes HFOs using fit function.

Parameters

X : mne.io.Raw | pd.DataFrame

Input data.

Returns

ypred : list[list[tuple]]

List of HFO events per channel in order of ch_names of input data. HFO events are stored as list of tuples: onset and offset of the HFO event.

score(X, y, sample_weight=None)

Return the score of the HFO prediction.

Parameters

X : np.ndarray

Channel data to detect HFOs on.

y : pd.DataFrame

Event Dataframe of true labels

sample_weight :
Returns
float
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params : dict

Estimator parameters.

Returns

self : estimator instance

Estimator instance.

property step_size

Step size of each window.

Window increment over the samples of signal.

Examples using mne_hfo.LineLengthDetector