seiz_eeg.clips¶
Functions to extract clips from seizure datasets
- seiz_eeg.clips.make_clips(segments_df: DataFrame[ClipsDF], clip_length: float, clip_stride: float | str | tuple, overlap_action: str = 'ignore', sort_index: bool = False) DataFrame[ClipsDF] ¶
Split annotations dataframe in dataframe of clips
- Parameters:
segments_df (DataFrame[ClipsDF]) – Dataframe containing annotations for EEG segments
clip_length (float) – Lenght of the output clips, in same unit as start_time and end_time of
segments_df
. A negative value returns the segments unchanged, but sort the dataset by index.clip_stride (Union[float, str, tuple]) –
Stride to extract the start times of the clips. Integer or real values give explicit stride. If string or tuple, must be one of the following, with respective parameters.: -
start
: extract one clip per segment, starting at onset/termination label. -pre-ictal
: for each onset time extract the beginning of ictalsegment and the preictal clip ending clip_lenght, or specified sec before onset time. Only pairs of pre-ictal/ictal clips are returned
random
: For each segment, extact a random clip of desired length.
overlap_action (str) –
What to do with clips overlapping segments. Options: -
ignore
: do not include any crossing clips -left
: the label of crossing clips is given by the left(preceding) segment
right
: the label of crossing clips is given by the right(ending) segment
seizure
: the label of crossing clips is given by the ictal
segment. (No more than two segments should be crossing) -
bkgd
: set the label of crossing clips to be 0
- Raises:
ValueError – If
clip_stride
is negative, or an invalid stringValueError – If
overlap_action
is an invalid string
- Returns:
Clips dataframe
- Return type:
DataFrame[ClipsDF]