BatchPreprocessingPipeline#
Batch preprocessing pipeline for processing multiple files in parallel.
- class meeg_utils.preprocessing.BatchPreprocessingPipeline(input_paths, output_dir=None, n_jobs=1, use_cuda=False, random_state=42)[source]#
Bases:
objectBatch preprocessing pipeline for multiple MEG/EEG datasets.
- Parameters:
input_paths (list[str | Path | BIDSPath]) – List of input paths to process.
output_dir (str | Path | None, optional) – Output directory for all datasets. If None, uses BIDS derivatives.
n_jobs (int, optional) – Number of parallel jobs. Default is 1.
use_cuda (bool, optional) – Whether to use CUDA. Default is False.
random_state (int, optional) – Random seed. Default is 42.
- output_dir#
Output directory.
- Type:
Path | None
- __init__(input_paths, output_dir=None, n_jobs=1, use_cuda=False, random_state=42)[source]#
Initialize batch preprocessing pipeline.
- __init__(input_paths, output_dir=None, n_jobs=1, use_cuda=False, random_state=42)[source]#
Initialize batch preprocessing pipeline.
- run(filter_params=None, detect_bad_channels=True, remove_line_noise=True, apply_ica=True, ica_params=None, save_intermediate=False, skip_existing=False, save_logs=True, logging_level='INFO')[source]#
Run batch preprocessing on all datasets.
- Parameters:
filter_params (dict | None, optional) – Filtering parameters.
detect_bad_channels (bool, optional) – Whether to detect bad channels. Default is True.
remove_line_noise (bool, optional) – Whether to remove line noise. Default is True.
apply_ica (bool, optional) – Whether to apply ICA. Default is True.
ica_params (dict | None, optional) – ICA parameters.
save_intermediate (bool, optional) – Whether to save intermediate files. Default is False.
skip_existing (bool, optional) – Whether to skip datasets with existing output. Default is False.
save_logs (bool, optional) – Whether to save log files. Default is True.
logging_level (str, optional) – Logging level for the batch process. Default is “INFO”.
Example Usage#
from meeg_utils.preprocessing import BatchPreprocessingPipeline
from mne_bids import BIDSPath
# Define inputs
bids_paths = [
BIDSPath(subject=f"{i:02d}", session="01", task="rest",
datatype="eeg", root="/data/bids")
for i in range(1, 11)
]
# Create batch pipeline
batch = BatchPreprocessingPipeline(
input_paths=bids_paths,
output_dir="/data/output",
n_jobs=4,
random_state=42
)
# Run batch processing
batch.run(
filter_params={"highpass": 0.1, "lowpass": 100.0},
detect_bad_channels=True,
remove_line_noise=True,
apply_ica=True,
save_logs=True
)