neuralib.locomotion.epoch
- neuralib.locomotion.epoch.running_mask1d(time, velocity, *, threshold=5, merge_gap=0.5, minimal_time=1)[source]
Running epoch mask for linear (1-dimension) locomotion.
Refer to Zaremba et al., 2016. Nature Neuroscience. Selection based on criterion:
Forward locomotion
Velocity > threshold (default greater than 5 cm/s)
Merge the gap period (default 0.5 sec, if animal accidentally slow down)
Each segmented epoch need to longer than (default is 1 second)
Dimension parameters:
P = Number of position points
- Parameters:
time (ndarray) – 1D time array of the position. Array[float, P]
velocity (ndarray) – 1D velocity array. Array[float, P]
threshold (float) – Velocity threshold in cm/s
merge_gap (float) – Merge gap in seconds (i.e., animal accidentally slow down in a short period of time)
minimal_time (float) – Epoch minimal time in seconds
- Returns:
Running epoch mask. Array[bool, P]
- Return type:
ndarray
- neuralib.locomotion.epoch.jump_mask2d(time, xy, jump_size, max_duration=0.1)[source]
UNSTABLE.
Find jump epoch in 2D xy locomotion
- Parameters:
time (ndarray) – A 1D numpy array of time points corresponding to each xy coordinate. Array[bool, N]
xy (ndarray) – A 2D numpy array of x and y coordinates representing positions. Array[float, [N, 2]]
jump_size (float) – A float representing the minimum jump distance to be considered significant between consecutive points. Should be expressed in the same coordinates as xy
max_duration (float) – the maximum duration (in the same units as t) of a jump. If a jump lasts longer the duration, it will not be removed (as it may not actually be a jump)
- Returns:
A tuple containing:
A boolean numpy array indicating which points are part of a detected jump segment. Array[bool, N]
A list of segments, where each segment is represented by a list of two indices [start_idx, end_idx].
- Return type:
tuple[ndarray, ndarray | tuple[float, float] | list[tuple[float, float]]]