lw_pipeline.Config#

class lw_pipeline.Config(config_file_path=None, verbose=False)[source]#

Bases: object

A class representing the configuration settings.

__init__(config_file_path=None, verbose=False)[source]#

Initialize the Config object.

Parameters:
  • config_file_path (str, optional) – The path to the configuration file. If provided, the configuration settings will be updated based on the variables defined in the file.

  • verbose (bool, optional) – If True, print messages about the configuration file being used. Default is False.

Methods

__init__([config_file_path, verbose])

Initialize the Config object.

ask(message[, default])

Ask to do something, e.g. before potentially deleting data, etc.

check_steps_dir()

Make sure steps dir is absolute.

get_version()

Get a version of the pipeline by getting last commit hash from the git.

set_variable_and_write_to_config_file(...)

Set a variable in this class and write to config file, if not defined there.

setup_logging()

Set up logging based on configuration settings.

Attributes

auto_response

Decide how questions are answered (off/y/n/default)

bids_acquisition

EEG information that should be included in the BIDS file

bids_datatype

BIDS datatype of the data created as derivatives in the pipeline

bids_extension

Extension of the BIDS files in the bids root directory

bids_root

Root directory for BIDS formatted data

config_file_path

The path to an external configuration file.

data_dir

Default data directory

deriv_root

Root directory for derivatives

eeg_path

Path to the eeg data which should be converted to BIDS

log_file

Path to the log file.

log_format

Format string for log messages

log_level

Logging level for the pipeline.

log_to_file

Whether to write logs to a file in addition to console output

n_jobs

Number of parallel jobs to run

output_profiling

Include timing and file size information in sidecar metadata

output_root

Root directory for non-BIDS outputs.

outputs_to_generate

List or dict specifying which outputs to generate.

overwrite

Overwrite existing derivative files, if False they are skipped

overwrite_mode

Overwrite mode for output files.

sessions

List of sessions to include in the pipeline processing.

sidecar_auto_generate

Automatically generate sidecar JSON files for all outputs

steps_dir

Steps directory relative to config file or current working directory if no

subjects

List of subjects to include in the pipeline processing.

tasks

List of tasks to include in the pipeline processing.

ask(message, default='n')[source]#

Ask to do something, e.g. before potentially deleting data, etc.

Make sure to specify options, e.g. (y/n), in the message.

auto_response = 'off'#

Decide how questions are answered (off/y/n/default)

bids_acquisition = None#

EEG information that should be included in the BIDS file

bids_datatype = 'eeg'#

BIDS datatype of the data created as derivatives in the pipeline

bids_extension = '.edf'#

Extension of the BIDS files in the bids root directory

bids_root = '/home/runner/data/bids'#

Root directory for BIDS formatted data

check_steps_dir()[source]#

Make sure steps dir is absolute.

Notes

  • If config_file_path is not None, the relative steps_dir is resolved relative to the directory containing the configuration file.

  • If config_file_path is None, the relative steps_dir is resolved relative to the current working directory.

Parameters:
  • steps_dir (str) – The directory path for steps, which will be converted to an absolute path.

  • config_file_path (str or None) – The path to the configuration file, used to resolve relative paths.

config_file_path = None#

The path to an external configuration file.

data_dir = '/home/runner/data'#

Default data directory

deriv_root = '/home/runner/data/derivatives'#

Root directory for derivatives

eeg_path = {}#

Path to the eeg data which should be converted to BIDS

Structure: subject -> condition -> task -> list of eeg files (runs) File names expected relative to data_dir

get_version()[source]#

Get a version of the pipeline by getting last commit hash from the git.

Cave: This only works if the pipeline is in a git repository. If not, it will return “unknown”.

log_file = None#

Path to the log file. If None and log_to_file is True, defaults to ‘pipeline.log’ in the deriv_root directory.

log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'#

Format string for log messages

log_level = 'INFO'#

Logging level for the pipeline. Options: “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”

log_to_file = True#

Whether to write logs to a file in addition to console output

n_jobs = 1#

Number of parallel jobs to run

output_profiling = False#

Include timing and file size information in sidecar metadata

output_root = None#

Root directory for non-BIDS outputs. If None, defaults to deriv_root.

outputs_to_generate = None#

List or dict specifying which outputs to generate. - None: Generate all outputs enabled by default - List of patterns: Generate outputs matching patterns (e.g., [“plot*”, “stats”]) - Dict: Step-specific patterns (e.g., {“01”: [“plot”], “02”: [“*”]}) Supports wildcards via fnmatch (e.g., “*” for all, “plot*”: all starting with plot)

overwrite = False#

Overwrite existing derivative files, if False they are skipped

overwrite_mode = 'never'#

Overwrite mode for output files. Options: - “always”: Always overwrite existing files - “never”: Never overwrite, skip existing files - “ask”: Prompt user for each file - “ifnewer”: Overwrite if source file is newer than output

sessions = []#

List of sessions to include in the pipeline processing. If empty list, include all sessions

set_variable_and_write_to_config_file(variable, value)[source]#

Set a variable in this class and write to config file, if not defined there.

For safety, only allow to write variables that are not already set.

Parameters:
  • variable (str) – The name of the variable to update.

  • value (mixed) – The value to set the variable to.

setup_logging()[source]#

Set up logging based on configuration settings.

This method configures the root logger with console and optionally file handlers based on the log_level, log_to_file, and log_file settings.

sidecar_auto_generate = True#

Automatically generate sidecar JSON files for all outputs

steps_dir = 'steps/'#

Steps directory relative to config file or current working directory if no

subjects = []#

List of subjects to include in the pipeline processing. If empty list, include all subjects

tasks = []#

List of tasks to include in the pipeline processing. If empty list, include all tasks