naflow.eeg package

Submodules

naflow.eeg.proc_classification module

class naflow.eeg.proc_classification.BCISimulation(vectorizer, classifier, picks='eeg', dynamic_stopping=False, dynamic_stopping_params={}, transient_state=False)[source]

Bases: BaseEstimator, ClassifierMixin

fit(X, y=None)[source]
predict(X)[source]
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') BCISimulation

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object

class naflow.eeg.proc_classification.TrialClassifier(classifier, vectorizer, dynamic_stopping=False, p_th=0.05, alternative='greater', min_nstims=5, groups='best-second', transient_state=False)[source]

Bases: BaseEstimator, ClassifierMixin

check_nstims(distances, events)[source]
fit(X, y=None)[source]
predict(X)[source]
set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') TrialClassifier

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object

test_distances(distances, events, method='mean')[source]
naflow.eeg.proc_classification.calc_itr(n_classes, accuracy, trial_duration=None)[source]

compute ITR (Information Transfer Rate).

Parameters:
  • n_classes (int) – Number of classes of bci system

  • accuracy (float) – Classification accuracy

  • trial_duration (float, default=None) – Time duration of single trial in minutes. If it’s NOT None, ITR will be returned in unit of (bits/min). Otherwise, it will be (bit/trial). Default value is None.

References

[1] Jonathan R. Wolpaw, Niels Birbaumer, et al.,

BrainЃomputer Interface Technology: A Review of the First International Meeting, IEEE TRANSACTIONS ON REHABILITATION ENGINEERING, VOL. 8, NO. 2, JUNE 2000

naflow.eeg.proc_raw module

class naflow.eeg.proc_raw.ExtractEpochs(l_freq=0.1, h_freq=8, filter_params={'iir_params': {'ftype': 'butter', 'order': 2}, 'method': 'iir', 'n_jobs': -1, 'phase': 'zero'}, tmin=-0.1, tmax=1.2, baseline=None, resample=None, event_names=None, marker_trial=None, marker_tnt=None, add_run=False, remove_misc=True)[source]

Bases: BaseEstimator, TransformerMixin

Extract Epochs from raws

Parameters:
  • l_freq (float, default = 0.1) – cutoff frequency for high-pass filter

  • h_freq (float, default = 8) – cutoff frequency for low-pass filter

  • filter_params (dict, default = {'method': 'iir', 'phase': 'zero', 'iir_params':{'order':2, 'ftype':'butter'}, 'n_jobs': -1}) – pass to filter() method of mne.raw object

  • tmin (float, default = -0.1) – start time of the epochs in seconds relative to the event onset.

  • tmax (float, default = 1.2) – end time of the epochs in seconds relative to the event onset.

  • baseline (None or tuple of length 2, default = None) – time duration for baseline correction. No baseline correction will be applied if None. see details for baseline arguments for mne.Epochs()

  • resample (None or float, default = None) – convert sampling frequency. No resampling will be applied if None.

  • event_names (None or dict, default = None) – name of each event. e.g., if {‘A’:[‘1’, ‘101’], ‘B’: [‘2’, ‘102’]}, event ‘1’ and ‘101’ will be tagged as ‘A’, and event ‘2’ and ‘102’ will be tagged as ‘B’. ‘misc’ will be tagged if there’s no matched element and if not None.

  • marker_trial (None or list) – event id which indecates start of the trial. e.g., if [str(val) for val in range(201, 300)], epochs between event ‘201’ to ‘299’ will be tagged as different trial.

  • marker_tnt (None or dict) – event id for target and nontarget event. dict should have the following structure. {‘target’: list(), ‘nontarget’:list()} e.g., if {‘target’: [str(val) for val in range(101, 200)], ‘nontarget’: [str(val) for val in range(1, 100)]}. events ‘101’ to ‘199’ will be tagged as target and events ‘1’ to ‘99’ will be tagged as nontarget

  • add_run (Bool, default = False) – run number will be tagged if True. if True, raw.info[‘description’] should include run tag, e.g., raw.info[‘description’] = ‘run:1’

  • remove_misc (Bool, default = True) – remove misc event which was not specified with event_names parameter.

fit(X, y=None)[source]
transform(X)[source]
class naflow.eeg.proc_raw.RemoveEOG(l_freq=1.0, len_transition=0.5)[source]

Bases: BaseEstimator, TransformerMixin

Remove EOG artifacts from raw signals.

Parameters:
  • l_freq (float, default = 1.0) – cutoff frequency for the highpass filter applied to raw signal before applying ICA.

  • len_transition (float, default = 0.5) – duration of the taper in second for applying window function before concatenating multiple raws.

find_bad_eog(raw, ica, h_freq=10, threshold=0.9)[source]
Parameters:
  • raw (raw instance contains eog channels.)

  • ica (ica instance)

  • filter (filter range will be used for eog channels)

  • threshold (numerical or 'max':)

Returns:

  • scores (pearson correlation bet. each IC and EOG channel)

  • indices (indices of ICs which should be removed)

fit(X, y=None)[source]
transform(X)[source]
naflow.eeg.proc_raw.concatenate_raws(raws, l_freq, order=2, len_transition=0.5)[source]
naflow.eeg.proc_raw.reconstruct_raw(raw)[source]

Module contents