mne-tools / mne-bids-pipeline

Automatically process entire electrophysiological datasets using MNE-Python.
https://mne.tools/mne-bids-pipeline/
BSD 3-Clause "New" or "Revised" License
141 stars 67 forks source link

Add more docu to rest_epochs_duration #1020

Open skjerns opened 3 days ago

skjerns commented 3 days ago

Currently my pipeline fails with this error

│13:19:55│  sub-01 A critical error occurred. The error message was: unsupported operand type(s) for -: 'float' and 'NoneType'
Starting post-mortem debugger.
<traceback object at 0x7fb746892300>
> /home/anaconda3/lib/python3.11/site-packages/mne_bids_pipeline/_import_data.py(56)make_epochs()
-> stop = raw.times[-1] - rest_epochs_duration

However, from the documentation it is not clear to me what this parameter actually does. Maybe that could be added?

Additionally, it would be nice if the pipeline would detect the missing parameter already at the start and not at the moment it encounters the error.


My current pipeline's should simply preprocess all FIF files in our dataset without epoching, i.e. apply ICA, filtering and downsampling and output the files to derivatives, from where I will deal with them outside of the pipeline. The epoching is done in a separate script, therefore, I treat all data as "rest"

``pipeline_preproc.conf

config ```Python ############################################################################### ### Preprocessing pipeline settings for mne-bids-pipeline | ############################################################################### from collections.abc import Callable, Sequence from typing import Annotated, Any, Literal from annotated_types import Ge, Interval, Len, MinLen from mne import Covariance from mne_bids import BIDSPath from mne_bids_pipeline.typing import ( # ArbitraryContrast, # DigMontageType, # FloatArrayLike, PathLike, ) # %%05 # # General settings # Configuration file for mne-bids-pipeline from typing import Sequence, Literal, Optional from mne import Covariance from mne_bids import BIDSPath # %% # General Settings bids_root: PathLike | None = '/data/fastreplay/Fast-Replay-MEG-bids/' deriv_root: PathLike = f"{bids_root}/derivatives/" # Save all processed data under /derivatives/ subjects_dir: Optional[PathLike] = f"{deriv_root}/freesurfer/subjects/" # Path to FreeSurfer subject reconstructions interactive: bool = False # Disable interactive elements # sessions: Literal["all"] = "all" # Process all sessions # task: str = "" # Process all tasks by leaving empty task_is_rest: bool = True # Treat data as resting-state, disable epoching # runs: Literal["all"] = "all" # Process all runs exclude_runs: Optional[dict[str, list[str]]] = None # No excluded runs subjects: Sequence[str] | Literal["all"] = "all" # Analyze all subjects exclude_subjects: Sequence[str] = ['23'] # No excluded subjects process_empty_room: bool = True # Preprocess empty-room data process_rest: bool = True # Preprocess resting-state data ch_types: Sequence[Literal["meg"]] = ["meg"] # Include MEG and EEG channels data_type: Literal["meg", "eeg"] = "meg" # Data type is MEG eog_channels: Sequence[str] = ["BIO0002", "BIO0003"] # Specify EOG channels ecg_channel: str = "BIO0001" # Specify ECG channel spatial_filter: Literal["ica"] = "ica" # Use ICA for artifact removal ica_n_components: int = 50 # Number of ICA components ica_algorithm: str = 'picard' # %% # Preprocessing raw_resample_sfreq: float = 100.0 # Resample data to 100 Hz l_freq: float = 0.1 # Apply high-pass filter at 0.1 Hz h_freq: Optional[float] = None # Disable low-pass filter notch_freq: Sequence[float] = [50.0] # Apply notch filter at 50 Hz notch_trans_bandwidth: float = 1.0 # Set notch filter transition bandwidth to 1 Hz # %% # Artifact Removal via ICA # The pipeline will automatically identify and remove ICA components related to EOG and ECG. # %% # Source-level Analysis run_source_estimation: bool = True # Enable source-level analysis inverse_method: Literal["dSPM"] = "dSPM" # Use dSPM as the inverse solution method loose: float = 0.2 # Weigh parallel dipole components by 0.2 depth: float = 0.8 # Set depth weighting exponent to 0.8 noise_cov = "emptyroom" # Use resting-state recording for noise covariance # %% # FreeSurfer recon-all Settings recon_all: bool = True # Enable FreeSurfer's recon-all freesurfer_verbose: bool = True # print the complete recon-all pipeline # %% # Parallelization n_jobs: int = 4 # Use all available CPU cores parallel_backend: Literal["loky"] = "loky" # Use 'loky' backend for parallel processing # %% # Logging log_level: Literal["info"] = "info" # Set pipeline logging verbosity to 'info' mne_log_level: Literal["error"] = "error" # Set MNE-Python logging verbosity to 'error' # %% # Error Handling on_error: Literal["abort"] = "abort" # Abort processing on errors config_validation: Literal["raise"] = "raise" # Raise exceptions on config validation issues ```
larsoner commented 3 days ago

Before we use this variable we should raise an informative error telling people to set this value. Presumably no default is set (e.g., like 1.) because we want the end-user to make a conscious decision about what the duration should be.