API Reference#

Pipelines and steps#

Pipeline(steps, *[, copy])

A sequence of named processing steps.

Step()

Base class for all processing steps.

process(pipeline, sources, root, *[, desc, ...])

Process each recording with its own copy of a pipeline and save the results.

Dataset(root, *[, datatype, subjects, ...])

The MEG/EEG recordings of a BIDS dataset, selected by entity.

process_dataset(dataset, root, *, preprocessing)

Process a whole dataset: each run, then the epochs of each session.

BatchResult(records)

Outcome of process_dataset(): one record per run and stage, and per group.

Processing steps (meeg_utils.steps)#

steps.Filter(l_freq, h_freq, *[, picks, ...])

Band-pass, high-pass or low-pass filter the data.

steps.Resample(sfreq, *[, npad, window, ...])

Resample the data.

steps.LineNoise([method, fline, n_remove, ...])

Remove power-line noise.

steps.BadChannels([method, ransac, psd, ...])

Detect bad channels and mark them in info["bads"].

steps.Interpolate([method, origin, ...])

Interpolate the channels marked bad.

steps.Reference([eeg, projection, ctf_grade])

Set the EEG reference and, for CTF MEG, the gradient compensation grade.

steps.ICA([n_components, picks, method, ...])

Decompose the data with ICA, label components and remove artifacts.

steps.HeadAlign(destination, *[, origin, mode])

Map MEG data to a common head position (device-to-head transform).

steps.Maxwell(*[, st_duration, ...])

Signal space separation (SSS) and its temporal extension (tSSS).

steps.ByChannelType(branches, *[, on_missing])

Process channel types with separate steps, like scikit-learn's ColumnTransformer.

steps.HFC([order, accuracy])

Remove environmental fields from OPM data by a homogeneous or harmonic field model.

steps.Regression([artifact, picks])

Remove what reference or artifact channels record from the data, by linear regression.

steps.BadSegments([methods, reject, flat, ...])

Mark bad stretches of a recording with BAD_* annotations.

steps.ASR([cutoff, picks, window_length, ...])

Artifact subspace reconstruction: repair high-amplitude bursts in continuous EEG.

steps.SNS([n_neighbors, skip, n_iter])

Sensor noise suppression: replace each channel by its projection on its neighbours.

steps.BridgedElectrodes(*[, lm_cutoff, ...])

Detect bridged EEG electrodes and interpolate them.

steps.DropChannels(ch_names, *[, on_missing])

Remove channels, e.g. mastoid electrodes before re-referencing.

steps.Epoch([event_id, tmin, tmax, ...])

Cut the recording into epochs around events.

steps.FixedLengthEpochs([duration, overlap, ...])

Cut a continuous recording into consecutive epochs of equal length (e.g. resting state).

steps.Baseline([baseline, mode, scale, ...])

Baseline correction of epochs or evoked data.

steps.AutoReject([method, n_interpolate, ...])

Reject or repair bad epochs with thresholds learned from the data.

epochs.combine(epochs_list, *[, bads, ...])

Concatenate the epochs of several runs of one session.

Reading and writing (meeg_utils.io)#

io.read(path, *[, preload])

Read a recording into memory, using BIDS metadata when available.

io.save_derivative(inst, source, root, *[, ...])

Save processed data as a BIDS derivative, with a provenance sidecar.

io.existing_derivatives(source, root, *[, desc])

Return the derivative files already written for source, if any.

io.detect_system(inst)

Detect the acquisition system of a recording.

io.get_datatypes(inst)

Return the modalities ("meg" and/or "eeg") present in a recording.

io.average_dev_head_t(sources)

Average device-to-head transform of several MEG recordings.

Quality control (meeg_utils.qc)#

qc.inspect(raw[, checks])

Run acquisition-quality checks on a recording.

qc.inspect_dataset(sources[, checks, ...])

Run the quality checks on every recording of a dataset.

qc.find_recordings(root)

Return every MEG and EEG recording of a BIDS dataset.

qc.QCReport(checks, skipped[, source])

The results of several checks on one recording.

qc.DatasetQC(reports, errors, *[, ...])

Quality-check results of many recordings.

qc.Finding(check, metric, value, level, message)

One evaluated quality criterion.

qc.Check()

Base class of acquisition-quality checks.

qc.Amplitude(*[, min_flat_duration, ...])

Flat signals, clipping (amplifier saturation) and missing samples.

qc.Bridging(*[, lm_cutoff, epoch_threshold, ...])

Electrode bridging: neighbouring electrodes shorted by gel or sweat.

qc.Impedance(*[, impedances, warn_kohm])

Electrode impedances measured before or during the recording.

qc.OutlierChannels(*[, n_neighbors, ...])

Channels whose signal is unlike that of the other channels (LOF).

qc.NarrowbandNoise(*[, fline, fmin, fmax, ...])

Power-line noise and other narrowband noise in the raw spectrum.

qc.Muscle(*[, threshold, filter_freq, ...])

Share of the recording contaminated by muscle activity.

qc.Blinks(*[, min_rate])

Blink rate from the EOG channel(s), a test that the EOG works.

qc.HeartRate(*[, min_bpm, max_bpm, ...])

Heart rate from the ECG channel (or MEG magnetometers), a test of the ECG.

qc.HeadMovement(*[, head_pos, warn_mm, ...])

Head movement during an MEG recording, from continuous head localization.

qc.Digitization()

Electrode positions, head digitization and head-to-sensor distance.

qc.Events(*[, expected, stim_channel, ...])

Event counts and timing, compared with what the experiment should produce.

qc.SquidJumps(*[, cutoff, min_shift])

Flux jumps of SQUID sensors: sudden, lasting steps in an MEG channel.

qc.ChpiSNR(*[, max_drop_db])

Signal-to-noise ratio of the continuous head-position (cHPI) coils.

qc.EmptyRoom(*[, empty_room, band, max_days])

The empty-room recording of the session: sensor noise and noisy sensors.

qc.BidsMetadata()

Whether the BIDS sidecar describes the recording correctly.

qc.Photodiode(channel, *[, events, ...])

Delay and jitter between the triggers and what the screen showed.

report.build([pipeline, inst, qc, title])

Build an mne.Report with every metric and figure.

report.from_derivative(fname, *[, title])

Build a report of a derivative saved by meeg_utils.io.save_derivative().

report.summarize(root, *[, desc, min_files])

Collect the QC metrics of every derivative under root.

report.DerivativesSummary(table, warnings_, *)

QC metrics of every derivative in a folder, with outlying files flagged.

Presets (meeg_utils.presets)#

presets.available()

Return the preset names with the first line of their description.

presets.get(name, **kwargs)

Build the pipeline of a preset.

presets.options(name)

Return the options a preset accepts.

Logging and testing#

setup_logging([level, log_file, file_level, ...])

Show meeg-utils log messages on the console and/or in a file.

teardown_logging()

Remove the handlers added by setup_logging() and silence meeg-utils again.

log_to_file(log_file[, level])

Write meeg-utils log messages to a file for the duration of a with block.

testing.check_step(step, inst)

Check that a step honours the meeg-utils step contract.

testing.check_check(check, raw)

Check that a quality check honours the meeg-utils check contract.