Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3796998
Adding in balanced training option into the gui alongside routine to …
SkepticRaven Jul 11, 2023
a06a698
cleanup of new function
SkepticRaven Jul 12, 2023
ad8575c
Adding balance label data to work with classify.py
SkepticRaven Jul 12, 2023
08c3b1d
Adding basic functionality for symmetric training
SkepticRaven Jul 13, 2023
9e2c2f9
Adding std reporting
SkepticRaven Jul 13, 2023
374f7f2
Edits to get all-kfold button operating
SkepticRaven Jul 14, 2023
c95c08d
Adding symmetric button
SkepticRaven Jul 14, 2023
07c35c9
Massive effort to expose feature names in a class method
SkepticRaven Jul 18, 2023
d6aa3d9
Finishing up changes for classify.py to work with new features
SkepticRaven Jul 18, 2023
49c9b10
Updating docs. Also adding an inkscape svg to make future doc updates…
SkepticRaven Jul 20, 2023
bbd364c
Adding feature docs. Adopted from other docs Glen wrote before static…
SkepticRaven Jul 20, 2023
1b1bc9b
Adding in counter for cross validation. Also switching counts to be 1…
SkepticRaven Jul 28, 2023
42ba52f
Fix for the feature names
SkepticRaven Jul 31, 2023
e96d20e
Merge pull request #26 from KumarLabJax/adding-feature-docs
SkepticRaven Sep 20, 2023
0396299
Adjustments to slurm processing to conform to other pipelines. Changes:
SkepticRaven Dec 2, 2022
14e31f6
Adding more comments and adjusting requested resources
SkepticRaven Dec 14, 2022
828df65
Updating to latest version of libraries and running unittests on sing…
SkepticRaven Jul 20, 2023
b3b8518
fixing a failed unittest
SkepticRaven Jul 20, 2023
c7ee06d
Adding a basic definition file for a vm that supports the gui applica…
SkepticRaven May 18, 2022
055e674
Forcing recent merge version of requirements (within rebase)
SkepticRaven Sep 20, 2023
a1e6b3c
Bugfix for shapely to access convex hull centroid
SkepticRaven Jul 20, 2023
39e3e8b
Updating libraries to bullseye from buster
SkepticRaven Jul 20, 2023
e2f9557
First commit for upgrading to pyside2
SkepticRaven Sep 20, 2023
95eefb3
More tweaks for pyside2 -> 6 upgrade
SkepticRaven Jul 24, 2023
72c653e
Specifying numpy.int64 for 1.25 upgrade
SkepticRaven Jul 25, 2023
155afaa
Making no-gui match gui os
SkepticRaven Jul 31, 2023
d996974
Fixing a nullpointer issue
SkepticRaven Aug 1, 2023
f623349
Tweaking language and including the now-merged gui-vm
SkepticRaven Aug 1, 2023
7d90cf8
added conda environment file
anshu957 Apr 24, 2023
9765605
Update README.md
anshu957 Jul 24, 2023
751adad
Merge remote-tracking branch 'origin' into add-balanced-training
SkepticRaven Sep 20, 2023
a876873
Stashing some locations of edits because this may be more complex tha…
SkepticRaven Nov 21, 2023
27be833
Converting base features to return dicts of feature lists instead of …
SkepticRaven Nov 21, 2023
617563c
Expanding dictionary returns to landmark, social, and window
SkepticRaven Nov 21, 2023
cd1b243
Removing name init
SkepticRaven Nov 22, 2023
0134744
Reworking merging of feature objects to produce flattened dicts of ve…
SkepticRaven Nov 22, 2023
7a5ed14
Changing name of lixit feature to be more descriptive
SkepticRaven Nov 24, 2023
3d9f079
Adjusting caching of features to support new structures
SkepticRaven Nov 24, 2023
462c42a
Getting ui train button to work
SkepticRaven Nov 24, 2023
f1bd3bd
Updating train_test_split, even though it doesn't appear to ever be used
SkepticRaven Nov 24, 2023
e227e8f
Cleanup of splitting to be a bit more legible
SkepticRaven Nov 24, 2023
40007c1
Getting classify and stats to work with new feature format
SkepticRaven Nov 24, 2023
5a866a8
Merge branch 'add-balanced-training' into features-to-pandas
SkepticRaven Nov 30, 2023
e1e6468
Merge pull request #34 from KumarLabJax/features-to-pandas
SkepticRaven Nov 30, 2023
7258070
Adjusting symmetric augmentation to use new name field strategy
SkepticRaven Nov 30, 2023
84447c0
Patching downsampling to use pandas
SkepticRaven Nov 30, 2023
6cfa7fa
Updating feature docs based on the internal rework (114 -> 116, remov…
SkepticRaven Dec 1, 2023
b9c01c5
Fixing some docs that came back during one of the merges
SkepticRaven Dec 1, 2023
9dba63e
Bumping all the version
SkepticRaven Dec 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

import numpy as np
import pandas as pd

from src import APP_NAME
from src.classifier import Classifier, ClassifierType
Expand Down Expand Up @@ -109,11 +110,10 @@ def classify_pose(classifier: Classifier, input_pose_file: Path, out_dir: Path,
distance_scale_factor=distance_scale_factor,
extended_features=classifier.extended_features
).get_features(window_size, use_social)
per_frame_features = pd.DataFrame(IdentityFeatures.merge_per_frame_features(features['per_frame'], use_social))
window_features = pd.DataFrame(IdentityFeatures.merge_window_features(features['window'], use_social))

data = Classifier.combine_data(
features['per_frame'],
features['window']
)
data = Classifier.combine_data(per_frame_features, window_features)

if data.shape[0] > 0:
pred = classifier.predict(data)
Expand All @@ -125,8 +125,9 @@ def classify_pose(classifier: Classifier, input_pose_file: Path, out_dir: Path,
# for each row of the pred_prob array we just computed.
pred_prob = pred_prob[np.arange(len(pred_prob)), pred]

prediction_labels[curr_id, features['frame_indexes']] = pred
prediction_prob[curr_id, features['frame_indexes']] = pred_prob
# Only copy out predictions where there was a valid pose
prediction_labels[curr_id, features['frame_indexes']] = pred[features['frame_indexes']]
prediction_prob[curr_id, features['frame_indexes']] = pred_prob[features['frame_indexes']]
cli_progress_bar(len(pose_est.identities), len(pose_est.identities),
complete_as_percent=False, suffix='identities')

Expand Down Expand Up @@ -178,6 +179,8 @@ def train(
f"{__CLASSIFIER_CHOICES[classifier.classifier_type]}")
print(f" Window Size: {training_file['window_size']}")
print(f" Social: {training_file['has_social_features']}")
print(f" Balanced Labels: {training_file['balance_labels']}")
print(f" Symmetric Behavior: {training_file['symmetric']}")
print(f" Distance Unit: {training_file['distance_unit'].name}")

training_features = classifier.combine_data(training_file['per_frame'],
Expand All @@ -190,6 +193,8 @@ def train(
behavior,
training_file['window_size'],
training_file['has_social_features'],
training_file['balance_labels'],
training_file['symmetric'],
training_file['extended_features'],
training_file['distance_unit'],
random_seed=training_file['training_seed']
Expand Down
89 changes: 89 additions & 0 deletions docs/features/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Per-Frame Features

## Egocentric Animal Features

116 features from 12 animal keypoints

* point mask (boolean, 12 values)
* pairwise distances between all points (66 values)
* angles between a subset of connected points (11 values)
* nose, base neck, right front paw
* nose, base neck, left front paw
* right front paw, base neck, center spine
* left front paw, base neck, center spine
* base neck, center spine, base tail
* right rear paw, base tail, center spine
* left rear paw, base tail, center spine
* right rear paw, base tail, mid tail
* left rear paw, base tail, mid tail
* center spine, base tail, mid tail
* base tail, mid tail, tip tail
* angular velocity (using base tail → base neck bearing)
* velocities (each velocity listed below consists of two features – the direction and magnitude components)
* centroid
* 12 keypoints

## Social features (v3 pose files)

21 features from social context

* distance to closest mouse
* distance to closest in field of view (fov)
* fov angle
* pairwise distances (9 values)
* pairwise distances between (nose, base neck, tail) points of subject and closest mouse
* pairwise distances fov (9 values)
* pairwise distances between (nose, base neck, tail) points of subject and closest fov mouse

## Static object features (v5 pose files)

### Arena Corners

2 features from arena corners

* distance to corner using the convex hull center
* bearing to corner using angle of the base neck - nose vector

### Water Spout (Lixit)

1 feature from lixit

* distance from nose to nearest lixit

### Food Hopper

10 features from food hopper

* signed distance from keypoint to food hopper border (positive = inside, negative = outside)
* nose
* left ear
* right ear
* base neck
* left front paw
* right front paw
* center spine
* left rear paw
* right rear paw
* base tail

# Window Features

Window features describe how a specific per-frame feature may be changing over time. We use a centered window around the frame of interest. These calculated features are added to the total feature vector. Window features calculated are different whether or not the per-frame feature is non-circular or circular.

## Non circular measurements

* mean
* median
* standard deviation
* max
* min

## Circular measurements

* circstd
* cirmean

### Circular Feature List

* Angles
* Bearings
Loading