remove_intervals#
- pypillometry.remove_intervals(intervals)#
Pipeline step for
remove_intervals()(d | pp.remove_intervals(...)).Remove the data in the given periods (e.g., breaks) and join the rest.
The samples in the periods are deleted. Gaps between the remaining data are closed: the data after a removed period are shifted back in time, so that they continue where the removed period started (the time vector has no gap). Removing data at the beginning or end does not change the times, so removing everything before start and after end is the same as
crop(). Event onsets are shifted with the data; events within removed periods are deleted. Stored blinks and excluded periods are moved to the new positions. The removed periods are added toparams["removed_intervals"], in the original time (the time before any periods were removed; a period across a gap closed by an earlier call is split at the gap).params["removed_shifts"]holds the shifts between the current and the original time.To remove the periods marked with
exclude_intervals(), used.remove_intervals(d.get_excluded()).Filters or interpolation applied after joining treat the data on both sides of a removed period as neighbors; apply them before, or use
split_excluded()to process the parts separately.- Parameters:
intervals (Intervals, Epochs or list of tuple) – the periods to remove: an
Intervalsobject (in time units or sample indices),Epochsor a list of(start, end)tuples (in ms, or with units, e.g.,[(10 * u.min, 12 * u.min)];"<start>"and"<end>"stand for the start and end of the recording); ends are exclusiveinplace (bool or None, optional) – if True, make change in-place and return the object; if False, make and return copy before making changes; if None, use the object-level setting (specified in the constructor)
- Return type:
- Returns:
the object without the removed periods (self or a copy, depending on inplace)
- Raises:
ValueError – if all samples would be removed
See also
cropkeep only the data between two times
split_excludedsplit the data at the excluded periods
Examples
>>> breaks = d.get_intervals(start="break_start", end="break_end", units="ms") >>> d = d.remove_intervals(breaks) >>> d = d.remove_intervals(d.get_excluded())