basic_ops.crop_data#

autoclean.functions.preprocessing.basic_ops.crop_data(data, tmin=None, tmax=None, include_tmax=True)[source]#

Crop EEG data to a specific time range.

This function crops continuous (Raw) or epoched EEG data to a specified time window. Useful for focusing analysis on specific time periods or removing unwanted segments.

Parameters:
datamne.io.BaseRaw or mne.Epochs

The EEG data to crop.

tminfloat or None, default None

Start time in seconds. If None, uses the start of the data.

tmaxfloat or None, default None

End time in seconds. If None, uses the end of the data.

include_tmaxbool, default True

Whether to include the tmax time point.

Returns:
cropped_datamne.io.BaseRaw or mne.Epochs

Data cropped to the specified time range.

Raises:
TypeError

If data is not an MNE Raw or Epochs object.

ValueError

If tmin >= tmax or times are outside data range.

Examples

Crop to specific time window:

>>> from autoclean import crop_data
>>> cropped = crop_data(raw, tmin=10.0, tmax=60.0)  # Keep 10-60 seconds

Crop from beginning:

>>> cropped = crop_data(raw, tmax=30.0)  # Keep first 30 seconds

Crop to end:

>>> cropped = crop_data(raw, tmin=5.0)  # Remove first 5 seconds