Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This App aims at apply to MEG signals temporal filtering (lowpass, highpass, or bandpass) , and optionally a notch filter and a resamplingon epoched or continuous data. To do so, the MNE Python functions raw.filter, raw and Epoch.notch_filter, and raw.resample are used.This App is supposed to be applied on MEG signals preprocessed beforehand with MaxFilter

Info

The filter function is the same for epoched and raw data but the value of the pad parameter is not the same if the data is continuous or epoched.

GitHub repository

https://github.com/AuroreBussalb/app-temporal-filtering

...

Files

Format

Description

Optional

MEG signals

.fifData to

process. MaxFilter was applied beforehand on this dataThe data can be continuous or epoched. Notch filtering and resampling can have been applied beforehand.

No

Outputs of the App:

Files

Format

Description

MEG signals

.fif

Data after filtering

Report

.html

Visualization in time and frequency domains

Steps

The python file temporal_filtering.py is composed of several functions:

  • Function temporal_filtering()

  1. Apply a lowpass, highpass, or bandpass filter

  2. Optionally apply a notch filter

  3. Optionally resample the data

  4. Save file

  • Function _compute_snr()

Computes a SNR before and after MaxFilter. The steps of that function are described here.

...

  1. Plot data in time domain

  2. Plot data in frequency domain

  3. Create info about raw data

  4. Display SNR values

  5. Save report

View file
namereport_filtering.html

  • Function main()

  1. Parse the config.json

  2. Raise an exception if both l_freq and h_freq are None

  3. Apply temporal_filtering()

  4. Display info message about the filtering applied

  5. Apply _compute_snr()

  6. Apply _generate_report()

Parameters of the App

The parameters of the App correspond to the parameters passed to the Python functions used in the App. They are listed in the Their default values proposed in Brainlife or in config.json.example when you test your App locally, then when you register you App on Brainlife, you enter them and a config.json is created by Brainlife.

For app-temporal-filtering, the user will be able to choose the following parameters (a default parameter will be proposed). Three different MNE Python functions are used in this App:

  1. Function raw.filter()

  • l_freq

    • NUMBER

      • optional

      • default: 0.5

  • h_freq

    • NUMBER

      • optional

      • default: 150

Some parameters are in the “Advanced” section because it’s best to keep their default values:

  • picks

    • STRING

      • either meg, eeg, [“meg”, “eeg”], mag, grad, a list of channels names, or None (i.e. all channels except for the bad ones)

      • default: None

  • filter_length

    • STRING

      • default: auto

  • l_trans_bandwidth

    • STRING

      • default: auto

      • Read only

  • h_trans_bandwidth

    • STRING

      • default: auto

      • Read only

  • n_jobs

    • NUMBER

      • default: 1

  • method

    • ENUM

      • either fir or iir

      • default: fir

  • iir_params

    • STRING

      • optional

      • default: None

  • phase

    • ENUM

      • either zero or zero-double

      • default: zero

  • fir_window

    • ENUM

      • either hamming, hann, or blackman

      • default: hamming

  • fir_design

    • ENUM

      • either firwin or firwin2

      • default: firwin

  • skip_by_annotation

    • ENUM

      • either ["edge", "bad_acq_skip"], ["edge"], ["bad_acq_skip"], or []

  • pad

    • ENUM

      • either reflect_limited or any value of numpy.pad()

      • default: reflect_limited

2. Function raw.filter_notch()

  • param_apply_notch

    • BOOLEAN

      • default: True

  • param_notch_freqs_start

    • NUMBER

      • default: 50 (in Europe power line artifact is at 50Hz, in the US it’s at 60Hz)

  • param_notch_freqs_stop

    • NUMBER

      • default: 251 (in Europe, if MEG signals were recorded in the US, change it to 241)

  • param_notch_freqs_step

    • NUMBER

      • default: 50 (in Europe, if MEG signals were recorded in the US, change it to 60)

Some parameters are in the “Advanced” section because it’s best to keep their default values:

  • picks

    • STRING either meg, eeg, [“meg”, “eeg”], mag, grad, or None (i.e. all channels except for the bad ones)

      • default: None

  • filter_length

    • STRING

      • default: auto

  • notch_widths

    • NUMBER

      • optional

      • default: None

  • trans_bandwidth

    • NUMBER

      • default: 1

  • n_jobs

    • NUMBER

      • default: 1

  • method

    • ENUM

      • either fir or iir

      • default: fir

  • iir_params

    • STRING

      • optional

      • default: None

  • mt_bandwidth

    • NUMBER

      • default: None

  • p_value

    • NUMBER

      • default: 0.05

  • phase

    • ENUM

      • either zero or zero-double

      • default: zero

  • fir_window

    • ENUM

      • either hamming, hann, or blackman

      • default: hamming

  • fir_design

    • ENUM

      • either firwin or firwin2

      • default: firwin

  • pad

    • ENUM

      • either reflect_limited or any value of numpy.pad()

      • default: reflect_limited

3. Function raw.resample()

  • apply_resample

    • BOOLEAN

      • Default: False

  • sfreq

    • NUMBER

Some parameters are in the “Advanced” section because it’s best to keep their default values:

  • npad

    • STRING

      • Read only

      • default: auto

  • window

    • ENUM

      • see choices in scipy.signal.get_window

      • default: boxcar

  • stim_picks

    • STRING

      • optional

      • default: None

  • n_jobs

    • NUMBER

      • default: 1

  • events

    • NUMBER

      • optional

      • default: None

  • pad

    • ENUM

      • either reflect_limited or any value of numpy.pad()

      • default: reflect_limited

  • See if it’s possible in BL to put a default STRING value in a NUMBER parameter

  • iir_params must be a dictionary, to see how to write it for BL

  • see how to write an array of floats in BL

Note

The parameters' list along with their default values correspond to the 0.22.0 version of MNE.

Info Add parameters for plot, to let user choose how he wants the data to be plotted. correspond to the default values of MNE Python 0.23.

Note

The parameter iir_params can’t be used on BL (it’s set to “READ ONLY”) because it is a dictionary and BL doesn’t handle Python dictionaries as parameter values and no conversion script has been written in the app (see Parameters conversion to make an App run on BL).

Next improvements

  • Be able to use the iir_params: register this parameter as a STRING in BL and convert it into a Python dict in temporal_filtering.py

  • Allow user to change the plot parameters for the plots in the HTML report?