Behavior#
Extensions that are used for basic interaction and viewing of the dataframe.
Accessor: behavior
- class animal_soup.BehaviorDataFrameExtension(df)#
- view(start_index=0, ethogram_view=True, ethogram_mode='inference')#
View behavior with or without ethograms.
- Parameters:
start_index (int, default 0) – Row index to start visualization from.
ethogram_view (bool, default True) – Indicates if ethograms should be viewed along with behavior or not. Set to false if you just want to view your behavior videos in the current dataframe.
ethogram_mode (str, default 'inference') –
- One of [‘ground’, ‘inference’]. Indicates where you want to load ethograms from. In ‘ground’ mode,
ethograms will be looked for in the current dataframe. In ‘inference’ mode, ethograms will be looked for in output files saved on disk.
- Returns:
Object that contains the datagrid of trials in the dataframe as well as behavior viewer and, if applicable, an ethogram viewer plot.
- Return type:
container
- clean_ethograms(start_index=0, ethogram_mode='inference')#
Clean ethograms.
- Parameters:
start_index (int, default 0) – Row index to start visualization from.
ethogram_mode (str, default 'inference') –
- One of [‘ground’, ‘inference’]. Indicates where you want to load ethograms from. In ‘ground’ mode,
ethograms will be looked for in the current dataframe. In ‘inference’ mode, ethograms will be looked for in output files saved on disk.
- Returns:
Object that contains the datagrid of trials in the dataframe as well as behavior viewer and ethogram cleaner plot.
- Return type:
container
- manual_ethograms(start_index=0)#
Manually annotate ethograms for training the classifier.
- Parameters:
start_index (int, default 0) – Row index to start visualization from
- Returns:
Object that contains the datagrid of trials in the dataframe as behavior viewer and ethogram plot for manual behavior annotation.
- Return type:
container
- add_item(animal_id, session_id=None, trial_id=None, exp_type=None)#
Add item to dataframe. If animal_id/’session_id’/’trial_id’ already exists, will raise ValueError. Can add all sessions for an animal, a single session, or a single trial within a given session.
- Parameters:
animal_id (str) – Animal to add to the dataframe.
session_id (str, default None) – Session to be added for a given animal. If None, will attempt to add all sessions for the given animal.
trial_id (int, default None) – Trial to be added for given animal/session. If None, will add all trials for the given session. Should be an integer representing the trial #.
exp_type (str, default None) – Type of experiment, either ‘table’ or ‘pez’. Default as None, can be set later.
- remove_item(row_ix=None, animal_id=None, session_id=None, trial_id=None)#
Remove item(s) from dataframe.
- Parameters:
row_ix (int, default None) – Row index to remove from dataframe, takes precedence over other arguments passed in.
animal_id (str, default None) – Animal to remove from dataframe.
session_id (str, default None) – Session to remove from dataframe. If None, will remove all sessions for the provided animal.
trial_id (int, default None) – Trial to remove from dataframe
- save_to_disk(max_index_diff=0)#
Saves DataFrame to disk, copies to a backup before overwriting existing file.
- Parameters:
max_index_diff (int, default 0) – Max difference in the number of indices between the current dataframe and the dataframe stored on disk. If index difference exceeds max, will raise IndexError.
- class animal_soup.BehaviorSeriesExtensions(s)#
Pandas series extensions for inference.
- Parameters:
s (Series) –
- infer(mode='fast', gpu_id=0)#
Run feature extractor inference and sequence inference together for a given
mode. This method will use all default model parameters. If you would like to specify other model weight paths for the flow generator, feature extractor, or sequence model than the pre-trained ones, please call feature extraction and sequence inference separately.See the User Guide for more details on model customization.
- Parameters:
mode (str, default 'fast') –
One of [‘slow’, ‘medium’, ‘fast’]. Determines which pairing of models to use for the feature extractor and sequence model reconstruction. See table below for model details.
mode
flow model
feature model
sequence model
slow
TinyMotionNet
ResNet3D-34
TGMJ
medium
MotionNet
ResNet50
TGMJ
fast
TinyMotionNet3D
ResNet18
TGMJ
gpu_id (int, default 0) – Integer id of GPU to be used for inference. By default, assumes only one available GPU.