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:
- data
mne.io.BaseRaw
ormne.Epochs
The EEG data to crop.
- tmin
float
orNone
,default
None
Start time in seconds. If None, uses the start of the data.
- tmax
float
orNone
,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.
- data
- Returns:
- cropped_data
mne.io.BaseRaw
ormne.Epochs
Data cropped to the specified time range.
- cropped_data
- 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