Outlier correction
On this page
Location outlier removed
Detect and amend outliers in pose-estimation data based in the location of the body-parts in the current frame relative to the location of the body-part in the preceding frame using heuristic rules.
Uses heuristic rules critera is grabbed from the SimBA project project_config.ini under the [Outlier settings] header.
Note
- param Union[str, os.PathLike] config_path
path to SimBA project config file in Configparser format
- param Optional[Union[str, os.PathLike]] data_dir
The directory storing the input data. If None, then the
outlier_corrected_movementdirectory of the SimBA project.- param Optional[Union[str, os.PathLike]] save_dir
The directory to store the results. If None, then the
outlier_corrected_movement_locationdirectory of the SimBA project.- param Optional[Dict[str, Dict[str, str]]] animal_dict
Dictionary holding the animal names, and the two body-parts to use to measure the mean or median size of the animals. If None, grabs the info from the SimBA project config.
- param Optional[float] criterion
The criterion multiplier. If None, grabs the info from the SimBA project config.
- example
>>> _ = OutlierCorrecterLocation(config_path='MyProjectConfig').run()
Movement outlier remover
Detect and ammend outliers in pose-estimation data based on movement lenghth (Euclidean) of the body-parts in the current frame from preceeding frame. Uses critera stored in the SimBA project project_config.ini under the [Outlier settings] header.
- param str config_path
path to SimBA project config file in Configparser format
- example
>>> outlier_correcter_movement = OutlierCorrecterMovement(config_path='MyProjectConfig')
>>> outlier_correcter_movement.run()
Movement outlier remover: multi-core
Detect and ammend outliers in pose-estimation data based on movement lenghth (Euclidean) of the body-parts in the current frame from preceeding frame. If not passed, then uses critera stored in the SimBA project project_config.ini under the [Outlier settings] headed. Uses multiprocessing.
- param Union[str, os.PathLike] config_path
path to SimBA project config file in Configparser format
- param Optional[Union[str, os.PathLike]] data_dir
The directory storing the input data. If None, then the
input_csvdirectory of the SimBA project.- param Optional[Union[str, os.PathLike]] save_dir
The directory to store the results. If None, then the
outlier_corrected_movementdirectory of the SimBA project.- param Optional[int] core_cnt
The number of cores to use. If -1, then all available cores. Default: -1.
- param Optional[Dict[str, Dict[str, str]]] animal_dict
Dictionary holding the animal names, and the two body-parts to use to measure the mean or median size of the animals. If None, grabs the info from the SimBA project config.
- param Optional[float] criterion
The criterion multiplier. If None, grabs the info from the SimBA project config.
- example
>>> outlier_correcter_movement = OutlierCorrecterMovementMultiProcess(config_path='MyProjectConfig')
>>> outlier_correcter_movement.run()
Location outlier remover: multi-core
Detect and amend outliers in pose-estimation data based in the location of the body-parts in the current frame relative to the location of the body-part in the preceding frame using heuristic rules.
Uses heuristic rules critera is grabbed from the SimBA project project_config.ini under the [Outlier settings] header.
Note
- param Union[str, os.PathLike] config_path
path to SimBA project config file in Configparser format
- param Optional[Union[str, os.PathLike]] data_dir
The directory storing the input data. If None, then the
outlier_corrected_movementdirectory of the SimBA project.- param Optional[Union[str, os.PathLike]] save_dir
The directory to store the results. If None, then the
outlier_corrected_movement_locationdirectory of the SimBA project.- param Optional[int] core_cnt
The number of cores to use. If -1, then all available cores. Default: -1.
- param Optional[Dict[str, Dict[str, str]]] animal_dict
Dictionary holding the animal names, and the two body-parts to use to measure the mean or median size of the animals. If None, grabs the info from the SimBA project config.
- param Optional[float] criterion
The criterion multiplier. If None, grabs the info from the SimBA project config.
- example
>>> _ = OutlierCorrecterLocationMultiprocess(config_path='MyProjectConfig').run()
Advanced movement outlier correction
Performs outlier correction that allows different heuristic outlier criteria for different animals or body-parts. For example, correct some outlier body-parts with a movement heuristic criteria of 2x above the mean movement, and other body-parts with a heuristic critera of 1.5x above the mean movement.
Note
See notebook. for example use-case.
- param str config_path
path to SimBA project config file in Configparser format.
- param str input_dir
Directory containing input files. E.g., project_folder/csv/input_csv directory.
- param Literal[‘animal’, ‘body-part’] type
If the rules are defined on animal or body-part level. E.g., If one heuristic rule per animal then animal. If one heurstic rule prr body-part then body-parts
- param Literal[‘mean’, ‘median’] agg_method
If to use the mean or median to compute criterion.
- param dict criterion_body_parts
The body-parts used to calculate the size of the animals.
- param dict settings
The heuristic multiplier rules to use for each body part or animal.
- example
>>> settings = {'Simon': 1.1, 'JJ': 1.2}
>>> criterion_body_parts = {'Simon': ['Nose_1', 'Tail_base_1'], 'JJ': ['Nose_2', 'Tail_base_2']}
>>> outlier_corrector = OutlierCorrecterMovementAdvanced(config_path='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini', input_dir='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/csv/input_csv', type='animal', agg_method='mean', criterion_body_parts=criterion_body_parts, settings=settings)
>>> outlier_corrector.run()
>>> settings = {'Simon': {'Ear_left_1': 1.1, 'Ear_right_1': 5.1, 'Nose_1': 2.1, 'Center_1': 1.5, 'Lat_left_1': 3.1, 'Lat_right_1': 1.9, 'Tail_base_1': 2.3, 'Tail_end_1': 1.4}, 'JJ': {'Ear_left_2': 1.2, 'Ear_right_2': 1.2, 'Nose_2': 2, 'Center_2': 4.1, 'Lat_left_2': 9, 'Lat_right_2': 1.2, 'Tail_base_2': 1.6, 'Tail_end_2': 2.2}}
>>> outlier_corrector = OutlierCorrecterMovementAdvanced(config_path='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini', input_dir='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/csv/input_csv', type='body-part', agg_method='mean', criterion_body_parts=criterion_body_parts, settings=settings)
Advanced location outlier correction
Performs location outlier correction that allows different heuristic outlier criteria for different animals or body-parts. For example, correct some outlier body-parts with a location heuristic criteria of 4x above the mean movement, and other body-parts with a heuristic critera of 2x above the mean movement.
Note
See notebook. for example use-case.
- param str config_path
path to SimBA project config file in Configparser format.
- param str input_dir
Directory containing input files. E.g., project_folder/csv/input_csv directory.
- param Literal[‘animal’, ‘body-part’] type
If the rules are defined on animal or body-part level. E.g., If one heuristic rule per animal then animal. If one heurstic rule prr body-part then body-parts
- param Literal[‘mean’, ‘median’] agg_method
If to use the mean or median to compute criterion.
- param dict criterion_body_parts
The body-parts used to calculate the size of the animals.
- param dict settings
The heuristic multiplier rules to use for each body part or animal.
- example
>>> settings = {'Simon': 1.1, 'JJ': 1.2}
>>> criterion_body_parts = {'Simon': ['Nose_1', 'Tail_base_1'], 'JJ': ['Nose_2', 'Tail_base_2']}
>>> outlier_corrector = OutlierCorrecterLocationAdvanced(config_path='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini', input_dir='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/csv/input_csv', type='animal', agg_method='mean', criterion_body_parts=criterion_body_parts, settings=settings)
>>> outlier_corrector.run()
>>> settings = {'Simon': {'Ear_left_1': 1.1, 'Ear_right_1': 5.1, 'Nose_1': 2.1, 'Center_1': 1.5, 'Lat_left_1': 3.1, 'Lat_right_1': 1.9, 'Tail_base_1': 2.3, 'Tail_end_1': 1.4}, 'JJ': {'Ear_left_2': 1.2, 'Ear_right_2': 1.2, 'Nose_2': 2, 'Center_2': 4.1, 'Lat_left_2': 9, 'Lat_right_2': 1.2, 'Tail_base_2': 1.6, 'Tail_end_2': 2.2}}
>>> outlier_corrector = OutlierCorrecterLocationAdvanced(config_path='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini', input_dir='/Users/simon/Desktop/envs/troubleshooting/two_black_animals_14bp/project_folder/csv/input_csv', type='body-part', agg_method='mean', criterion_body_parts=criterion_body_parts, settings=settings)
Skipping outlier correction
Skip outlier correction in SimBA projects.
- param Union[str, os.PathLike] config_path
path to SimBA project config file in Configparser format
- example
>>> _ = OutlierCorrectionSkipper(config_path='MyProjectConfig').run()