lw_pipeline.Pipeline_MNE_BIDS_Data#
- class lw_pipeline.Pipeline_MNE_BIDS_Data(config, from_bids=False, from_deriv='', from_deriv_dir='', concatenate_runs=False)[source]#
Bases:
Pipeline_Data
Data representation of eeg/ieeg/meg files for the pipeline.
Contains Path or BidsPath objects of files the pipeline should be applied to.
- __init__(config, from_bids=False, from_deriv='', from_deriv_dir='', concatenate_runs=False)[source]#
Initialize the PipelineData object.
- Parameters:
config (Config) – Configuration object.
from_bids (bool) – If True, the data is initialized from BIDS files located in the bids_root directory.
from_deriv (str) – Find bids styled files in the derivatives directory with the description from_deriv.
from_deriv_dir (str) – Ignore the variable config.eeg_path and construct file_paths from the derivatives directory. Requires bids styled files in the derivatives directory.
Methods
__init__
(config[, from_bids, from_deriv, ...])Initialize the PipelineData object.
apply
(function[, subjects, sessions, tasks, ...])Apply a function to each data file individually.
as_df
()Return the file_paths dictionary as a pandas DataFrame.
Concatenate runs of the same task for each subject and session.
copy
()Create a deep copy of the Pipeline_MNE_BIDS_Data object.
get_bids_path
(source, subject, session, ...)Create a BIDSPath without actually doing sth.
get_bids_path_from_bids_root
(source, bids_path)Get BidsPath for raw data from the bids_root directory.
get_raw_from_derivatives
(source, bids_path)Get BidsPath for raw data from the derivatives directory.
Ignore the variable config.eeg_path and construct file_paths from deriv.
Attributes
Configuration of the pipeline.
Dictionary of file paths organized by subject, session, task, and run.
from_deriv
- apply(function, subjects=None, sessions=None, tasks=None, save=True, print_duration=True, suffix='eeg', description='', bids_root=None)[source]#
Apply a function to each data file individually.
Can also save the output to the derivatives directory.
- Parameters:
function (function) – Function to apply to the data with the signature (source, bids_path).
subjects (list) – List of subjects to apply the function to.
sessions (list) – List of sessions to apply the function to.
tasks (list) – List of tasks to apply the function to.
save (bool) – Whether to save the output to the derivatives directory (in case function return a raw object, i.e. subclass of mne.io.BaseRaw or an mne.Annotations instance).
print_duration (bool) – Whether to print the duration of the function.
suffix (str) – Suffix of the output Bidspath. Default is “eeg”. For Anntations one could use “markers”. Only certain values allowed, cf. MNE-BIDS documentation (https://mne.tools/mne-bids/stable/generated/mne_bids.BIDSPath.html#mne_bids.BIDSPath). If suffix is not in [“meg”, “eeg”, “ieeg”], the output file path will not be updated in the file_paths dictionary. Annotations are saved, but not directly passed on to the next step.
description (str) – Description of the output Bidspath for the derivative, if none specified use PipelineStep.short_id + function name instead.
bids_root (str) – Root directory for the destination. If None, the bids derivatives directory from the config is used.
- as_df()[source]#
Return the file_paths dictionary as a pandas DataFrame.
- Returns:
df – DataFrame with columns “Subject”, “Session”, “Task”, “Run”, “Source”.
- Return type:
pd.DataFrame
- concatenate_runs()[source]#
Concatenate runs of the same task for each subject and session.
Creates a new run “99”.
- property config#
Configuration of the pipeline.
- copy()[source]#
Create a deep copy of the Pipeline_MNE_BIDS_Data object.
- Returns:
A deep copy of the current object.
- Return type:
- file_paths = None#
Dictionary of file paths organized by subject, session, task, and run.
- get_bids_path(source, subject, session, task, run)[source]#
Create a BIDSPath without actually doing sth. with the source file.
- get_bids_path_from_bids_root(source, bids_path)[source]#
Get BidsPath for raw data from the bids_root directory.