osl_ephys.preprocessing.mne_wrappers#
Wrappers for MNE functions to perform preprocessing.
We have run_mne_anonymous which tries to run a method directly on a target object (typically an mne Raw or Epochs object).
In addition, there are a set of wrapper functions for MNE methods which need a bit more option processing than the default - for example, converting input strings into arrays of frequencies
Wrapper functions have priority and will be run rather than the direct method call if a wrapper is present. If no wrapper is present then we fall back to the direct method call.
Most wrapper functions run on the `` object in dataset by default
and the function docstrings assume this - but is most cases mne.io.Raw can
be replaced with mne.Epochs (or dataset[‘raw’] by dataset[‘epochs’] and
the function will still work, e.g. mne.Epochs.pick.
In order to apply the method to an object different from mne.Raw, the target
argument can be specified in userargs. For example, target: ‘epochs’ can be
specified in the userargs to apply the method to dataset[‘epochs’] instead of
dataset[‘raw’].
Attributes#
Functions#
Module Contents#
- osl_ephys.preprocessing.mne_wrappers.run_mne_anonymous(dataset, userargs, method)[source]#
OSL-Batch function which runs a method directly on a target MNE object in
dataset, typically anmne.io.Rawormne.Epochsobject.OSL Batch will first look for OSL/MNE wrapper functions for the method, and otherwise will try to run the method directly on the target object.
- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Contains user arguments for the function.
method (str) – See
mne.io.Rawandmne.Epochsfor the available methods.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_notch_filter(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.io.Raw.notch_filter.This function calls
notch_filteron an MNE object indataset. Additional arguments on the MNE function can be specified as a dictionary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.notch_filter.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_pick(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.io.Raw.pick.This function calls
pickon an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.pick.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
Notes
In MNE-Batch, an example call would look like
>>> preproc: >>> - pick: {picks: 'meg'}
By default, the
mne.io.Raw.pickwill be called ondataset['raw'], you can specify another options by specifyingtargetinuserargs. For example:>>> preproc: >>> - pick: {picks: 'meg', target: 'epochs'}
Then the function or method will be called on
dataset['epochs']instead.
- osl_ephys.preprocessing.mne_wrappers.run_mne_pick_channels(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.io.Raw.pick_channels.This function calls
pick_channelson an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.pick_channels.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_pick_types(dataset, userargs)[source]#
OSL-Batch wrapper for
raw.pick_types.This function calls
pick_typeson an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.pick_types.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_resample(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.io.Raw.resample.This function calls
resampleon an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.resample.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_set_channel_types(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.io.Raw.set_channel_types.This function calls
set_channel_typeson an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.set_channel_types.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_interpolate_bads(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.io.Raw.interpolate_bads.This function calls
interpolate_badson an MNE object indataset. Importantly, it setsreset_badsto False by default. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.io.Raw.set_channel_types.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_drop_bad(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.Epochs.drop_bad.This function calls
drop_badon an MNEEpochsobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
rawandepochs.userargs (dict) – Dictionary of additional arguments to be passed to
mne.Epochs.drop_bad.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_apply_baseline(dataset, userargs)[source]#
OSL-Batch wrapper for
epochs.apply_baseline.This function calls
mne.Epochs.apply_baselineon an MNEEpochsobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the keys
rawandepochs.userargs (dict) – Dictionary of additional arguments to be passed to
mne.Epochs.apply_baseline.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_find_events(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.find_events.This function calls
find_eventson an MNERawobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.find_events.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_epochs(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.Epochs.This function calls
mne.Epochson theraw,events, andevent-idkeys indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the keys
raw,events, andevent-id.userargs (dict) – Dictionary of additional arguments to be passed to
mne.Epochs.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_annotate_amplitude(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.annotate_amplitude.This function calls
annotate_amplitudeon an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.annotate_amplitude.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_annotate_muscle_zscore(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.annotate_muscle_zscore.This function calls
annotate_muscle_zscoreon an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.annotate_muscle_zscore.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_find_bad_channels_maxwell(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.find_bad_channels_maxwell.This function calls
find_bad_channels_maxwellon an MNERawobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.find_bad_channels_maxwell.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_maxwell_filter(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.maxwell_filter.This function calls
maxwell_filteron an MNERawobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.maxwell_filter.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_compute_current_source_density(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.compute_current_source_density.This function calls
compute_current_source_densityon an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.compute_current_source_density.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_tfr_multitaper(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.time_frequency.tfr_multitaper.This function calls
tfr_multitaperon an MNEEpochsorEvokedobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the keys
raw, andevokedorepochs.userargs (dict) – Dictionary of additional arguments to be passed to
mne.time_frequency.tfr_multitaper.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_tfr_morlet(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.time_frequency.tfr_morlet.This function calls
tfr_morleton an MNEEpochsorEvokedobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the keys
raw, andevokedorepochs.userargs (dict) – Dictionary of additional arguments to be passed to
mne.time_frequency.tfr_morlet.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_tfr_stockwell(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.time_frequency.tfr_stockwell.This function calls
tfr_stockwellon an MNEEpochsorEvokedobject indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the keys
raw, andevokedorepochs.userargs (dict) – Dictionary of additional arguments to be passed to
mne.time_frequency.tfr_stockwell.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_ica_raw(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.ICA.This function creates class
ICAand fits it to an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary. Therawobject indatasetis filtered (1 Hz high pass) before fitting the ICA.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.ICA,mne.preprocessing.ICA.fit, andmne.io.Raw.filter.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_ica_autoreject(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.ICA.find_bads_ecgandmne.preprocessing.ICA.find_bads_eog.This function identifies IC’s that are deemed to correspond to ECG or EOG artifacts, as found by
find_bads_ecgandfind_bads_eogon therawandicaobjects indataset. Additional arguments on the MNE functions can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.ICA.find_bads_ecgandmne.preprocessing.ICA.find_bads_eog.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict
- osl_ephys.preprocessing.mne_wrappers.run_mne_apply_ica(dataset, userargs)[source]#
OSL-Batch wrapper for
mne.preprocessing.ICA.apply.This function creates class
mne.preprocessing.ICA.applyand fits it to an MNE object indataset. Additional arguments on the MNE function can be specified as a dictonary.- Parameters:
dataset (dict) – Dictionary containing at least an MNE object with the key
raw.userargs (dict) – Dictionary of additional arguments to be passed to
mne.preprocessing.ICA.apply.
- Returns:
dataset – Input dictionary containing MNE objects that have been modified in place.
- Return type:
dict