Comprehensive Preprocessing with MNE-based Classes#

This example demonstrates the various preprocessing classes available in Braindecode that wrap MNE-Python functionality. These classes provide a convenient and type-safe way to preprocess EEG data.

# Authors: Bruno Aristimunha <b.aristimunha@gmail.com>
#
# License: BSD (3-clause)

import mne

from braindecode.datasets import MOABBDataset
from braindecode.preprocessing import (
    Anonymize,
    ApplyHilbert,
    Crop,
    Filter,
    Pick,
    Resample,
    SetEEGReference,
    SetMontage,
    preprocess,
)

Load a sample dataset#

We’ll use a small MOABB dataset for demonstration

dataset = MOABBDataset(dataset_name="BNCI2014_001", subject_ids=[1])
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'bnci-horizon-2020.eu'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'lampx.tugraz.at'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(

  0%|                                              | 0.00/42.8M [00:00<?, ?B/s]
  0%|                                     | 8.19k/42.8M [00:00<13:57, 51.1kB/s]
  0%|                                      | 56.3k/42.8M [00:00<03:39, 195kB/s]
  0%|▏                                      | 153k/42.8M [00:00<01:53, 377kB/s]
  1%|▎                                      | 352k/42.8M [00:00<00:59, 713kB/s]
  2%|▋                                     | 736k/42.8M [00:00<00:32, 1.30MB/s]
  4%|█▎                                   | 1.51M/42.8M [00:00<00:16, 2.47MB/s]
  7%|██▋                                  | 3.06M/42.8M [00:01<00:08, 4.76MB/s]
 12%|████▌                                | 5.26M/42.8M [00:01<00:04, 7.56MB/s]
 17%|██████▏                              | 7.18M/42.8M [00:01<00:04, 8.88MB/s]
 22%|███████▉                             | 9.22M/42.8M [00:01<00:03, 10.0MB/s]
 27%|█████████▊                           | 11.4M/42.8M [00:01<00:02, 11.1MB/s]
 31%|███████████▌                         | 13.4M/42.8M [00:01<00:02, 11.5MB/s]
 37%|█████████████▌                       | 15.6M/42.8M [00:02<00:02, 12.1MB/s]
 41%|███████████████▎                     | 17.8M/42.8M [00:02<00:02, 12.4MB/s]
 47%|█████████████████▎                   | 20.0M/42.8M [00:02<00:01, 12.8MB/s]
 52%|███████████████████                  | 22.1M/42.8M [00:02<00:01, 12.9MB/s]
 57%|████████████████████▉                | 24.3M/42.8M [00:02<00:01, 13.0MB/s]
 62%|██████████████████████▊              | 26.4M/42.8M [00:02<00:01, 13.0MB/s]
 67%|████████████████████████▋            | 28.5M/42.8M [00:03<00:01, 13.1MB/s]
 72%|██████████████████████████▍          | 30.6M/42.8M [00:03<00:00, 13.1MB/s]
 77%|████████████████████████████▎        | 32.8M/42.8M [00:03<00:00, 13.2MB/s]
 82%|██████████████████████████████▏      | 35.0M/42.8M [00:03<00:00, 13.3MB/s]
 85%|███████████████████████████████▍     | 36.3M/42.8M [00:03<00:00, 11.4MB/s]
 89%|████████████████████████████████▊    | 37.9M/42.8M [00:03<00:00, 11.2MB/s]
 94%|██████████████████████████████████▊  | 40.3M/42.8M [00:04<00:00, 12.3MB/s]
 99%|████████████████████████████████████▊| 42.5M/42.8M [00:04<00:00, 12.8MB/s]
  0%|                                              | 0.00/42.8M [00:00<?, ?B/s]
100%|██████████████████████████████████████| 42.8M/42.8M [00:00<00:00, 209GB/s]
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'bnci-horizon-2020.eu'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'lampx.tugraz.at'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(

  0%|                                              | 0.00/43.8M [00:00<?, ?B/s]
  0%|                                     | 8.19k/43.8M [00:00<14:19, 50.9kB/s]
  0%|                                      | 48.1k/43.8M [00:00<04:23, 166kB/s]
  0%|                                       | 128k/43.8M [00:00<02:18, 315kB/s]
  1%|▎                                      | 289k/43.8M [00:00<01:14, 582kB/s]
  1%|▌                                     | 608k/43.8M [00:00<00:39, 1.08MB/s]
  3%|█                                    | 1.24M/43.8M [00:00<00:20, 2.04MB/s]
  6%|██▏                                  | 2.52M/43.8M [00:01<00:10, 3.95MB/s]
 12%|████▎                                | 5.06M/43.8M [00:01<00:05, 7.68MB/s]
 19%|███████▏                             | 8.48M/43.8M [00:01<00:02, 11.9MB/s]
 25%|█████████▎                           | 11.1M/43.8M [00:01<00:02, 13.1MB/s]
 31%|███████████▍                         | 13.6M/43.8M [00:01<00:02, 13.8MB/s]
 38%|██████████████                       | 16.6M/43.8M [00:01<00:01, 15.3MB/s]
 44%|████████████████▍                    | 19.4M/43.8M [00:02<00:01, 15.9MB/s]
 50%|██████████████████▋                  | 22.1M/43.8M [00:02<00:01, 16.0MB/s]
 57%|█████████████████████                | 24.9M/43.8M [00:02<00:01, 16.4MB/s]
 64%|███████████████████████▌             | 27.9M/43.8M [00:02<00:00, 17.1MB/s]
 71%|██████████████████████████▏          | 30.9M/43.8M [00:02<00:00, 17.5MB/s]
 77%|████████████████████████████▌        | 33.8M/43.8M [00:02<00:00, 17.5MB/s]
 85%|███████████████████████████████▌     | 37.3M/43.8M [00:03<00:00, 18.8MB/s]
 92%|██████████████████████████████████▏  | 40.5M/43.8M [00:03<00:00, 19.1MB/s]
100%|████████████████████████████████████▊| 43.6M/43.8M [00:03<00:00, 19.0MB/s]
  0%|                                              | 0.00/43.8M [00:00<?, ?B/s]
100%|██████████████████████████████████████| 43.8M/43.8M [00:00<00:00, 270GB/s]

Signal Processing#

Apply common signal processing operations

# 1. Resample to reduce computational load
print(f"Original sampling frequency: {dataset.datasets[0].raw.info['sfreq']} Hz")
preprocessors_signal = [
    Resample(sfreq=100),  # Downsample to 100 Hz
]
preprocess(dataset, preprocessors_signal)
print(f"After resampling: {dataset.datasets[0].raw.info['sfreq']} Hz")

# 2. Remove power line noise and apply bandpass filter
preprocessors_filtering = [
    Filter(l_freq=4, h_freq=30),  # Bandpass filter 4-30 Hz
]
preprocess(dataset, preprocessors_filtering)
print("Applied bandpass filter 4-30 Hz")
Original sampling frequency: 250.0 Hz
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
After resampling: 100.0 Hz
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 165 samples (1.650 s)

Applied bandpass filter 4-30 Hz

Channel Management#

Select and manipulate channels

# 3. Pick only EEG channels
preprocessors_channels = [
    Pick(picks="eeg"),  # Select only EEG channels
]
print(f"Channels before pick: {len(dataset.datasets[0].raw.ch_names)}")
preprocess(dataset, preprocessors_channels)
print(f"Channels after pick: {len(dataset.datasets[0].raw.ch_names)}")

# 4. Rename channels (example - just for demonstration)
original_names = dataset.datasets[0].raw.ch_names[:3]
print(f"Original channel names (first 3): {original_names}")
# Note: We won't actually rename to avoid breaking the example,
# but this is how you would do it:
# preprocessors_rename = [
#     RenameChannels(mapping={'C3': 'C3_renamed', 'C4': 'C4_renamed'}),
# ]
# preprocess(dataset, preprocessors_rename)
Channels before pick: 26
Channels after pick: 22
Original channel names (first 3): ['Fz', 'FC3', 'FC1']

Reference & Montage#

Set reference and channel positions

# 5. Set EEG reference to average
preprocessors_reference = [
    SetEEGReference(ref_channels="average"),
]
preprocess(dataset, preprocessors_reference)
print("Set EEG reference to average")

# 6. Set montage for proper channel positions
montage = mne.channels.make_standard_montage("standard_1020")
preprocessors_montage = [
    SetMontage(montage=montage, match_case=False, on_missing="ignore"),
]
preprocess(dataset, preprocessors_montage)
print(
    f"Set montage, number of positions: {len(dataset.datasets[0].raw.get_montage().get_positions()['ch_pos'])}"
)
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Set EEG reference to average
Set montage, number of positions: 22

Data Transformation#

Apply transformations to the data

# 7. Crop data to specific time range
preprocessors_crop = [
    Crop(tmin=0, tmax=60),  # Keep only first 60 seconds
]
print(f"Data duration before crop: {dataset.datasets[0].raw.times[-1]:.1f} s")
preprocess(dataset, preprocessors_crop)
print(f"Data duration after crop: {dataset.datasets[0].raw.times[-1]:.1f} s")
Data duration before crop: 386.9 s
Data duration after crop: 60.0 s

Metadata & Configuration#

Modify metadata and configuration

# 8. Anonymize measurement information
preprocessors_anonymize = [
    Anonymize(),
]
preprocess(dataset, preprocessors_anonymize)
print("Anonymized measurement information")
Anonymized measurement information

Advanced: Envelope Extraction#

Extract signal envelope using Hilbert transform

# 9. Compute envelope (useful for some analyses)
# Note: This modifies the data, so use carefully
preprocessors_envelope = [
    ApplyHilbert(envelope=True),
]
preprocess(dataset, preprocessors_envelope)
print("Computed signal envelope")
Computed signal envelope

Combining Multiple Preprocessing Steps#

You can combine multiple preprocessing steps in a single pipeline

print("\n" + "=" * 60)
print("Complete Preprocessing Pipeline Example")
print("=" * 60)

# Reload dataset for complete pipeline demonstration
dataset_complete = MOABBDataset(dataset_name="BNCI2014_001", subject_ids=[1])

# Set montage first (needed for interpolation)
montage = mne.channels.make_standard_montage("standard_1020")

complete_pipeline = [
    # 1. Set montage
    SetMontage(montage=montage, match_case=False, on_missing="ignore"),
    # 2. Set reference
    SetEEGReference(ref_channels="average"),
    # 3. Bandpass filter
    Filter(l_freq=4, h_freq=30),
    # 4. Downsample
    Resample(sfreq=100),
    # 5. Select only EEG channels
    Pick(picks="eeg"),
    # 6. Crop to region of interest
    Crop(tmin=0, tmax=60),
    # 7. Anonymize
    Anonymize(),
]

print(
    f"Original: {dataset_complete.datasets[0].raw.info['sfreq']} Hz, "
    f"{dataset_complete.datasets[0].raw.times[-1]:.1f} s, "
    f"{len(dataset_complete.datasets[0].raw.ch_names)} channels"
)

preprocess(dataset_complete, complete_pipeline)

print(
    f"After preprocessing: {dataset_complete.datasets[0].raw.info['sfreq']} Hz, "
    f"{dataset_complete.datasets[0].raw.times[-1]:.1f} s, "
    f"{len(dataset_complete.datasets[0].raw.ch_names)} channels"
)

print("\nPreprocessing complete!")
============================================================
Complete Preprocessing Pipeline Example
============================================================
Original: 250.0 Hz, 386.9 s, 26 channels
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
EEG channel type selected for re-referencing
Applying average reference.
Applying a custom ('EEG',) reference.
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 4 - 30 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 4.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 3.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 413 samples (1.652 s)

Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
Finding events on: stim
48 events found on stim channel stim
Event IDs: [1 2 3 4]
After preprocessing: 100.0 Hz, 60.0 s, 22 channels

Preprocessing complete!

Summary#

Braindecode provides 45 preprocessing classes that wrap MNE-Python functionality:

Signal Processing: Resample, Filter, NotchFilter, SavgolFilter, ApplyHilbert, Rescale, OversampledTemporalProjection

Channel Management: Pick, PickChannels, PickTypes, DropChannels, AddChannels, CombineChannels, RenameChannels, ReorderChannels, SetChannelTypes, InterpolateBads, InterpolateTo, InterpolateBridgedElectrodes, ComputeBridgedElectrodes, EqualizeChannels

Reference & Montage: SetEEGReference, AddReferenceChannels, SetMontage

SSP Projections: AddProj, ApplyProj, DelProj

Data Transformation: Crop, CropByAnnotations, ComputeCurrentSourceDensity, FixStimArtifact, MaxwellFilter, RealignRaw, RegressArtifact

Artifact Detection & Annotation: AnnotateAmplitude, AnnotateBreak, AnnotateMovement, AnnotateMuscleZscore, AnnotateNan

Metadata & Configuration: Anonymize, SetAnnotations, SetMeasDate, AddEvents, FixMagCoilTypes, ApplyGradientCompensation

See the API documentation for details on each class and their parameters.

Total running time of the script: (0 minutes 22.232 seconds)

Estimated memory usage: 1524 MB

Gallery generated by Sphinx-Gallery