neuralib.tracking.facemap.core
- typeddict neuralib.tracking.facemap.core.SVDVariables[source]
SVD output from facemap
- Optional Keys:
filenames (
list[str])save_path (
str)Ly (
list[int])Lx (
list[int])sbin (
int)fullSVD (
bool)save_mat (
bool)Lybin (
ndarray)Lxbin (
ndarray)sybin (
ndarray)sxbin (
ndarray)LYbin (
int)LXbin (
int)avgframe (
list[ndarray])avgmotion (
list[ndarray])avgframe_reshape (
ndarray)avgmotion_reshape (
ndarray)motion (
list[ndarray])motSv (
list[ndarray])movSv (
list[ndarray])motMask (
list[int])movMask (
list[int])motMask_reshape (
list[int])movMask_reshape (
list[int])motSVD (
list[ndarray])movSVD (
list[ndarray])pupil (
list[PupilDict])running (
list[ndarray])blink (
list[ndarray])rois (
list[RoiDict])sy (
ndarray)sx (
ndarray)
- neuralib.tracking.facemap.core.KeyPoint
keypoint name
- final class neuralib.tracking.facemap.core.FaceMapResult[source]
facemap result container
Dimension parameters:
F = number of video frames
K = number of keypoints
- __init__(svd, meta, data, track_type, with_keypoints)[source]
- Parameters:
svd (SVDVariables | None) – SVD processing outputs
meta (KeyPointsMeta | None) – Optional for Keypoints processing (result)
data (Group | None) – Optional for Keypoints processing (config)
track_type (Literal['keypoints', 'pupil']) – {‘keypoints’, ‘pupil’}
with_keypoints (bool) – if has keypoint tracking result
- svd: Final[SVDVariables | None]
- meta: Final[KeyPointsMeta | None]
- data: Final[Group | None]
- track_type: Final[Literal['keypoints', 'pupil']]
- with_keypoints: Final[bool]
- classmethod load(directory, track_type, *, file_pattern='')[source]
Load the facecam result from its output directory
- Parameters:
directory (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – directory contains the possible facemap output files (*.npy, *.pkl, and *.h5)
track_type (Literal['keypoints', 'pupil']) – {‘keypoints’, ‘pupil’}
file_pattern (str) – string prefix pattern to glob the facemap output file
- Returns:
- Return type:
Self
- classmethod launch_facemap_gui(directory, with_keypoints, *, file_pattern='', env_name='neuralib')[source]
DEPRECATED. GUI view via cli.
Note that calling this method will overwrite `filenames` field in *proc.npy
- Parameters:
directory (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – directory contains the possible facemap output files (*.npy, *.pkl, and *.h5), and also the raw video file
with_keypoints (bool) – if has keypoint tracking result
file_pattern (str) – string prefix pattern to glob the facemap output file and raw avi file
env_name (str) – conda env name that installed the facemap package
- Return type:
None
- get_pupil_center_of_mass()[source]
center of mass of pupil tracking. Array[float, [F, 2]]
- Return type:
ndarray
- get_pupil_location_movement()[source]
Calculate the Euclidean distance from the origin for each point in a 2D array. Array[float, F]
- Return type:
ndarray
- property keypoints: list[str]
list of keypoint name
- get(keypoint: str) KeyPointTrack[source]
- get(keypoint: list[str]) list[KeyPointTrack]
get a single or multiple keypoint(s)
- frame_time
- as_array(keypoint=None, with_outlier_filter=True, to_zscore=True, **kwargs)[source]
get keypoint(s) result as an 2D array with shape (K, F, 2). 3rd dim indicates the xy
- Parameters:
keypoint (list[str] | str | None) – keypoint
with_outlier_filter (bool)
to_zscore (bool)
kwargs – pass through
with_outlier_filter()
- Returns:
keypoint in XY. Array[float, [K, F, 2]]
- Return type:
ndarray
- class neuralib.tracking.facemap.core.KeyPointTrack[source]
single keypoint tracked result
- __init__(name, x, y, likelihood)
Method generated by attrs for class KeyPointTrack.
- Parameters:
name (str)
x (ndarray)
y (ndarray)
likelihood (ndarray)
- Return type:
None
- name: str
name of keypoint
- x: ndarray
x loc. Array[float, F]
- y: ndarray
y loc. Array[float, F]
- likelihood: ndarray
tracking likelihood. Array[float, F]
- property mean_xy: ndarray
mean x y loc. Array[float, F]
- with_outlier_filter(filter_window=15, baseline_window=50, max_spike=25, max_diff=25)[source]
x,y with outlier filter (remove jump and do the interpolation)
- Parameters:
filter_window (int) – window size for median filter
baseline_window (int) – window size for baseline estimation
max_spike (int) – maximum spike size
max_diff (int) – maximum difference between baseline and filtered signal
- Returns:
- Return type:
Self