mne_hfo.HilbertDetector

class mne_hfo.HilbertDetector(threshold=3, filter_band=(30, 100), band_method='linear', n_bands=300, cycle_threshold=1, gap_threshold=1, n_jobs=- 1, offset=0, scoring_func='f1', hfo_name='hfo', verbose=False)[source]

2D HFO hilbert detection used in Kucewicz et al. 2014.

A multi-taper method with: 4 Hz bandwidth, 1 sec sliding window, stepsize 100 ms, for the 1-500 Hz range, no padding, 2 tapers.

Parameters

sfreq: float

Sampling frequency of the signal

l_freq: float

Low cut-off frequency

h_freq: float

High cut-off frequency

threshold: float

Threshold for detection (default=3)

band_method: str

Spacing of hilbert frequency bands - options: ‘linear’ or ‘log’ (default=’linear’). Linear provides better frequency resolution but is slower.

n_bands: int

Number of bands if band_spacing = log (default=300)

cycle_threshold: float

Minimum number of cycles to detect (default=1)

gap_threshold: float

Number of cycles for gaps (default=1)

n_jobs: int

Number of cores to use (default=1)

offset: int

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

References

[1] M. T. Kucewicz, J. Cimbalnik, J. Y. Matsumoto, B. H. Brinkmann, M. Bower, V. Vasoli, V. Sulc, F. Meyer, W. R. Marsh, S. M. Stead, and G. A. Worrell, “High frequency oscillations are associated with cognitive processing in human recognition memory.,” Brain, pp. 1–14, Jun. 2014.

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.HilbertDetector