core.py
PoseGroup
¶
Bases: SpyglassMixin, Manual
Groups one or more entries of keypoint pose information
Source code in src/spyglass/behavior/v1/core.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
create_group(group_name, merge_ids, bodyparts=None)
¶
Create a group of pose information
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_name
|
str
|
Name of the group |
required |
merge_ids
|
List[str]
|
list of keys from PositionOutput to include in the group |
required |
bodyparts
|
List[str]
|
body parts to include in the group, by default None includes all from every set |
None
|
Source code in src/spyglass/behavior/v1/core.py
fetch_pose_datasets(key=None, format_for_moseq=False, normalize=False, anterior_bodyparts=None, posterior_bodyparts=None)
¶
fetch pose information for a group of videos
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
dict
|
group key |
None
|
format_for_moseq
|
bool
|
format for MoSeq, by default False |
False
|
normalize
|
bool
|
whether to normalize the pose datasets by animal length, by default False |
False
|
anterior_bodyparts
|
List[str]
|
list of anterior body parts to use for normalization, required if normalize is True |
None
|
posterior_bodyparts
|
List[str]
|
list of posterior body parts to use for normalization, required if normalize is True |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
dictionary of video name to pose dataset |
Source code in src/spyglass/behavior/v1/core.py
fetch_video_paths(key=None)
¶
fetch video paths for a group of videos
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
dict
|
group key |
None
|
Returns:
| Type | Description |
|---|---|
List[Path]
|
list of video paths |
Source code in src/spyglass/behavior/v1/core.py
normalize_pose_dataset(datasets, anterior_bodyparts, posterior_bodyparts)
¶
Normalize pose datasets by centering and scaling based on the mean position and length of the anterior and posterior body parts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
dict[str, DataFrame]
|
dictionary of video name to pose dataset (as returned by fetch_pose_datasets) |
required |
anterior_bodyparts
|
List[str]
|
list of anterior body parts to use for normalization |
required |
posterior_bodyparts
|
List[str]
|
list of posterior body parts to use for normalization |
required |
Returns:
| Type | Description |
|---|---|
dict[str, DataFrame]
|
normalized pose datasets |
Source code in src/spyglass/behavior/v1/core.py
format_dataset_for_moseq(datasets, bodyparts, coordinate_axes=['x', 'y'])
¶
format pose datasets for MoSeq
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
dict[str, DataFrame]
|
dictionary of video name to pose dataset |
required |
bodyparts
|
List[str]
|
list of body parts to include in the pose |
required |
coordinate_axes
|
List[str]
|
list of coordinate axes to include, by default ["x", "y"] |
['x', 'y']
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, np.ndarray], dict[str, np.ndarray]
|
coordinates and confidences for each video |