neuralib.locomotion.position
- class neuralib.locomotion.position.CircularPosition[source]
Position information in circular environment.
Dimension parameters:
P = Number of position points (after interpolation)
T = Number of trial(lap)
- t: ndarray
1D time array in s. Array[float, P]
- p: ndarray
1D position array in cm. Array[float, P]
- d: ndarray
1D displacement array in cm. Array[float, P]
- v: ndarray
1D velocity array in cm/s. Array[float, P]
- trial_time_index: ndarray
1D time index for every trial. Array[int, T]
- with_time_range(t0, t1)[source]
With specific time range
- Parameters:
t0 (float) – time start
t1 (float) – time end
- Returns:
A new instance of the class with updated subset of attributes (t, p, d, v) based on the time range.
- Return type:
Self
- with_run_mask1d(**kwargs)[source]
With only the running epoch. Note that shape will be changed (stationary epoch excluded)
- Parameters:
kwargs – Additional keyword arguments to pass to running_mask1d function.
- Returns:
A new instance of the class with updated subset of attributes (t, p, d, v) based on the mask generated.
- Return type:
Self
- property trial_array: ndarray
Trial number array as same shape as P
- Returns:
Array[int, P]
- static __new__(_cls, t, p, d, v, trial_time_index)
Create new instance of CircularPosition(t, p, d, v, trial_time_index)
- Parameters:
t (ndarray)
p (ndarray)
d (ndarray)
v (ndarray)
trial_time_index (ndarray)
- neuralib.locomotion.position.interp_pos1d(time, pos, *, sampling_rate=1000, norm_max_value=150, remove_nan=True, renew_trial_value=-100)[source]
Interpolate the raw position data
Dimension parameters:
P = Number of position points (Raw)
- Parameters:
time (ndarray) – An array of time stamps corresponding to positional data. Array[float, P].
pos (ndarray) – An array of positional data (a.u, encoder or other hardware readout). Array[float, P].
sampling_rate (float) – The rate at which data points should be sampled, defaults to 1000.
norm_max_value (float) – The value by which to normalize the positional data, defaults to 150 (cm).
remove_nan (bool) – Flag indicating whether to remove NaN values from interpolated data, defaults to True.
renew_trial_value (float) – The value used to detect the overflow index which signifies trial renewals, defaults to -100.
- Returns:
CircularPosition- Return type:
- neuralib.locomotion.position.speed_2d(xy, dt=1.0)[source]
Compute speed 2D movement
- Parameters:
xy (ndarray) – 2D array coordinates in xy. Array[float, [N, 2]]
dt (float) – Time period between samples (for smoothing)
- Returns:
Speed. Array[float, N]
- Return type:
ndarray
- neuralib.locomotion.position.direction_2d(xy, dt=1.0)[source]
Compute direction 2D movement
- Parameters:
xy (ndarray) – 2D array coordinates in xy. Array[float, [N, 2]]
dt (float) – Time period between samples (for smoothing)
- Returns:
Movement direction. Array[float, N]
- Return type:
ndarray
- neuralib.locomotion.position.interp_gap2d(t, xy, duration)[source]
UNSTABLE.
Interpolate over gaps in position record.
- Parameters:
t (ndarray) – Time Vector. Array[float, N]
xy (ndarray) – 2D array coordinates in xy. Array[float, [N, 2]]
duration (float) – Maximum duration of a gap that should be interpolated over. same unit as
t
- Returns:
Corrected x,y coordinates. Array[float, [N, 2]]
- Return type:
ndarray