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#

logger

Functions#

run_mne_anonymous(dataset, userargs, method)

OSL-Batch function which runs a method directly on a target MNE object in dataset,

run_mne_notch_filter(dataset, userargs)

OSL-Batch wrapper for mne.io.Raw.notch_filter.

run_mne_pick(dataset, userargs)

OSL-Batch wrapper for mne.io.Raw.pick.

run_mne_pick_channels(dataset, userargs)

OSL-Batch wrapper for mne.io.Raw.pick_channels.

run_mne_pick_types(dataset, userargs)

OSL-Batch wrapper for raw.pick_types.

run_mne_resample(dataset, userargs)

OSL-Batch wrapper for mne.io.Raw.resample.

run_mne_set_channel_types(dataset, userargs)

OSL-Batch wrapper for mne.io.Raw.set_channel_types.

run_mne_interpolate_bads(dataset, userargs)

OSL-Batch wrapper for mne.io.Raw.interpolate_bads.

run_mne_drop_bad(dataset, userargs)

OSL-Batch wrapper for mne.Epochs.drop_bad.

run_mne_apply_baseline(dataset, userargs)

OSL-Batch wrapper for epochs.apply_baseline.

run_mne_find_events(dataset, userargs)

OSL-Batch wrapper for mne.find_events.

run_mne_epochs(dataset, userargs)

OSL-Batch wrapper for mne.Epochs.

run_mne_annotate_amplitude(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.annotate_amplitude.

run_mne_annotate_muscle_zscore(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.annotate_muscle_zscore.

run_mne_find_bad_channels_maxwell(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.find_bad_channels_maxwell.

run_mne_maxwell_filter(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.maxwell_filter.

run_mne_compute_current_source_density(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.compute_current_source_density.

run_mne_tfr_multitaper(dataset, userargs)

OSL-Batch wrapper for mne.time_frequency.tfr_multitaper.

run_mne_tfr_morlet(dataset, userargs)

OSL-Batch wrapper for mne.time_frequency.tfr_morlet.

run_mne_tfr_stockwell(dataset, userargs)

OSL-Batch wrapper for mne.time_frequency.tfr_stockwell.

run_mne_ica_raw(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.ICA.

run_mne_ica_autoreject(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.ICA.find_bads_ecg and mne.preprocessing.ICA.find_bads_eog.

run_mne_apply_ica(dataset, userargs)

OSL-Batch wrapper for mne.preprocessing.ICA.apply.

Module Contents#

osl_ephys.preprocessing.mne_wrappers.logger = None[source]#
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 an mne.io.Raw or mne.Epochs object.

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.Raw and mne.Epochs for 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_filter on an MNE object in dataset. 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 pick on an MNE object in dataset. 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.pick will be called on dataset['raw'], you can specify another options by specifying target in userargs. 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_channels on an MNE object in dataset. 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_types on an MNE object in dataset. 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 resample on an MNE object in dataset. 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_types on an MNE object in dataset. 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_bads on an MNE object in dataset. Importantly, it sets reset_bads to 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_bad on an MNE Epochs object in dataset. 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 and epochs.

  • 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_baseline on an MNE Epochs object in dataset. 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 and epochs.

  • 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_events on an MNE Raw object in dataset. 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.Epochs on the raw, events, and event-id keys in dataset. 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, and event-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_amplitude on an MNE object in dataset. 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_zscore on an MNE object in dataset. Additional arguments on the MNE function can be specified as a dictonary.

Parameters:
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_maxwell on an MNE Raw object in dataset. Additional arguments on the MNE function can be specified as a dictonary.

Parameters:
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_filter on an MNE Raw object in dataset. 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_density on an MNE object in dataset. Additional arguments on the MNE function can be specified as a dictonary.

Parameters:
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_multitaper on an MNE Epochs or Evoked object in dataset. 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, and evoked or epochs.

  • 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_morlet on an MNE Epochs or Evoked object in dataset. 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, and evoked or epochs.

  • 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_stockwell on an MNE Epochs or Evoked object in dataset. 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, and evoked or epochs.

  • 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 ICA and fits it to an MNE object in dataset. Additional arguments on the MNE function can be specified as a dictonary. The raw object in dataset is filtered (1 Hz high pass) before fitting the ICA.

Parameters:
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_ecg and mne.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_ecg and find_bads_eog on the raw and ica objects in dataset. Additional arguments on the MNE functions can be specified as a dictonary.

Parameters:
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.apply and fits it to an MNE object in dataset. 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