diff --git a/simba/mixins/statistics_mixin.py b/simba/mixins/statistics_mixin.py index fead3e9a5..62bb56cc6 100644 --- a/simba/mixins/statistics_mixin.py +++ b/simba/mixins/statistics_mixin.py @@ -18,13 +18,15 @@ types) from scipy import stats from scipy.stats.distributions import chi2 -from statsmodels.stats.libqsturng import psturng -from statsmodels.stats.multicomp import pairwise_tukeyhsd from sklearn.covariance import EllipticEnvelope from sklearn.ensemble import IsolationForest +from statsmodels.stats.libqsturng import psturng +from statsmodels.stats.multicomp import pairwise_tukeyhsd from simba.mixins.feature_extraction_mixin import FeatureExtractionMixin -from simba.utils.checks import (check_float, check_int, check_str, check_valid_array, check_valid_dataframe, check_valid_lst) +from simba.utils.checks import (check_float, check_int, check_str, + check_valid_array, check_valid_dataframe, + check_valid_lst) from simba.utils.data import bucket_data, fast_mean_rank from simba.utils.enums import Formats, Options from simba.utils.errors import CountError, InvalidInputError diff --git a/simba/sandbox/bg_remover.py b/simba/sandbox/bg_remover.py index cca3d78d0..e41d2fa19 100644 --- a/simba/sandbox/bg_remover.py +++ b/simba/sandbox/bg_remover.py @@ -4,17 +4,20 @@ import cv2 import numpy as np + try: from typing import Literal except: from typing_extensions import Literal -from simba.utils.checks import (check_file_exist_and_readable,check_if_dir_exists) +from simba.utils.checks import (check_file_exist_and_readable, + check_if_dir_exists) from simba.utils.enums import Formats from simba.utils.printing import SimbaTimer, stdout_success -from simba.utils.read_write import (get_fn_ext, get_video_meta_data) +from simba.utils.read_write import get_fn_ext, get_video_meta_data from simba.video_processors.video_processing import create_average_frm + def video_bg_subtraction(video_path: Union[str, os.PathLike], bg_video_path: Optional[Union[str, os.PathLike]] = None, bg_start_frm: Optional[int] = None, diff --git a/simba/sandbox/bout_aggregator.py b/simba/sandbox/bout_aggregator.py index 2bf64a7ef..860bf5e63 100644 --- a/simba/sandbox/bout_aggregator.py +++ b/simba/sandbox/bout_aggregator.py @@ -1,17 +1,22 @@ import os from copy import deepcopy -from typing import Literal, Optional, List, Union +from typing import List, Literal, Optional, Union + try: from typing import Literal except: from typing_extensions import Literal + import pandas as pd -from simba.utils.checks import check_valid_lst, check_int, check_str, check_valid_dataframe, check_instance -from simba.utils.read_write import find_core_cnt, read_video_info -from simba.utils.printing import SimbaTimer -from simba.utils.enums import Formats + +from simba.utils.checks import (check_instance, check_int, check_str, + check_valid_dataframe, check_valid_lst) from simba.utils.data import detect_bouts, read_df +from simba.utils.enums import Formats from simba.utils.errors import InvalidInputError +from simba.utils.printing import SimbaTimer +from simba.utils.read_write import find_core_cnt, read_video_info + def video_bout_aggregator(data: Union[str, os.PathLike, pd.DataFrame], clfs: List[str], diff --git a/simba/sandbox/direction_reversals.py b/simba/sandbox/direction_reversals.py index fd59217cc..9157b7ab6 100644 --- a/simba/sandbox/direction_reversals.py +++ b/simba/sandbox/direction_reversals.py @@ -1,7 +1,6 @@ import numpy as np - def direction_switches(x: np.ndarray, switch_degree: int = 180): idx = 0 diff --git a/simba/sandbox/felzenszwalb.py b/simba/sandbox/felzenszwalb.py index 79ac1fbaf..945782bec 100644 --- a/simba/sandbox/felzenszwalb.py +++ b/simba/sandbox/felzenszwalb.py @@ -1,16 +1,20 @@ -from typing import Union, Optional, List, Tuple -import os -import numpy as np -import cv2 - -from simba.utils.read_write import (get_video_meta_data, find_core_cnt, get_fn_ext, read_frm_of_video, concatenate_videos_in_folder) +import functools #from simba.utils.checks import import multiprocessing -import functools -from simba.utils.enums import Defaults, Formats +import os +from typing import List, Optional, Tuple, Union + +import cv2 +import numpy as np from skimage.color import label2rgb from skimage.segmentation import felzenszwalb + +from simba.utils.enums import Defaults, Formats from simba.utils.printing import SimbaTimer +from simba.utils.read_write import (concatenate_videos_in_folder, + find_core_cnt, get_fn_ext, + get_video_meta_data, read_frm_of_video) + def _felzenszwalb_helper(frm_range: Tuple[int, List[int]], scale: int, diff --git a/simba/sandbox/gibbs_sampler.py b/simba/sandbox/gibbs_sampler.py index f874ef171..4e55188af 100644 --- a/simba/sandbox/gibbs_sampler.py +++ b/simba/sandbox/gibbs_sampler.py @@ -1,10 +1,13 @@ import os -from typing import Union, Tuple +from typing import Tuple, Union + import numpy as np import pandas as pd +from simba.utils.checks import (check_float, check_if_dir_exists, check_int, + check_valid_array) from simba.utils.printing import SimbaTimer, stdout_success -from simba.utils.checks import check_valid_array, check_float, check_int, check_if_dir_exists + class GibbSampler(): def __init__(self, diff --git a/simba/sandbox/img_edge_distance_flexible.py b/simba/sandbox/img_edge_distance_flexible.py index 8244b103b..f5704237b 100644 --- a/simba/sandbox/img_edge_distance_flexible.py +++ b/simba/sandbox/img_edge_distance_flexible.py @@ -1,7 +1,6 @@ import numpy as np - def img_edge_distances_flexible(data: np.ndarray, edge_distances: np.ndarray, pixels_per_mm: float, diff --git a/simba/sandbox/preferred_turning_direction.py b/simba/sandbox/preferred_turning_direction.py index d6dea8709..36cb67c76 100644 --- a/simba/sandbox/preferred_turning_direction.py +++ b/simba/sandbox/preferred_turning_direction.py @@ -1,9 +1,10 @@ import numpy as np + +from simba.mixins.circular_statistics import CircularStatisticsMixin from simba.utils.checks import check_valid_array +from simba.utils.data import get_mode from simba.utils.enums import Formats from simba.utils.errors import InvalidInputError -from simba.mixins.circular_statistics import CircularStatisticsMixin -from simba.utils.data import get_mode def preferred_turning_direction(x: np.ndarray) -> int: diff --git a/simba/sandbox/radial_dispersion.py b/simba/sandbox/radial_dispersion.py index f6318440e..ba1851483 100644 --- a/simba/sandbox/radial_dispersion.py +++ b/simba/sandbox/radial_dispersion.py @@ -1,8 +1,10 @@ import numpy as np + from simba.mixins.statistics_mixin import Statistics from simba.utils.checks import check_valid_array from simba.utils.enums import Formats + def radial_dispersion_index(x: np.ndarray, reference_point: np.ndarray) -> float: """ Compute the Radial Dispersion Index (RDI) for a set of points relative to a reference point. diff --git a/simba/sandbox/radial_eccentricity.py b/simba/sandbox/radial_eccentricity.py index 68656904a..fdf6cd220 100644 --- a/simba/sandbox/radial_eccentricity.py +++ b/simba/sandbox/radial_eccentricity.py @@ -1,8 +1,10 @@ import numpy as np + from simba.mixins.statistics_mixin import Statistics from simba.utils.checks import check_valid_array from simba.utils.enums import Formats + def radial_eccentricity(x: np.ndarray, reference_point: np.ndarray): """ Compute the radial eccentricity of a set of points relative to a reference point. diff --git a/simba/sandbox/regression_errors.py b/simba/sandbox/regression_errors.py index 14c4f4d21..cf1659c4e 100644 --- a/simba/sandbox/regression_errors.py +++ b/simba/sandbox/regression_errors.py @@ -1,8 +1,11 @@ from typing import Optional + import numpy as np -from simba.utils.checks import check_valid_array, check_float + +from simba.utils.checks import check_float, check_valid_array from simba.utils.enums import Formats + def mean_absolute_percentage_error(y_true: np.ndarray, y_pred: np.ndarray, epsilon=1e-10, diff --git a/simba/sandbox/sliding_descriptive_statistics_cuda.py b/simba/sandbox/sliding_descriptive_statistics_cuda.py index f4453a7f8..101f30a44 100644 --- a/simba/sandbox/sliding_descriptive_statistics_cuda.py +++ b/simba/sandbox/sliding_descriptive_statistics_cuda.py @@ -1,15 +1,21 @@ +from typing import Tuple + import numpy as np from numba import cuda -from typing import Tuple + try: from typing import Literal except: from typing_extensions import Literal -from simba.utils.checks import check_valid_array, check_valid_tuple, check_float -from simba.utils.enums import Formats -from simba.data_processors.cuda.utils import _cuda_mean + import math +from simba.data_processors.cuda.utils import _cuda_mean +from simba.utils.checks import (check_float, check_valid_array, + check_valid_tuple) +from simba.utils.enums import Formats + + def _cuda_variance(x: np.ndarray): #mean = _cuda_mean(x=x) mean = np.mean(x) diff --git a/simba/sandbox/sliding_preferred_turning_direction.py b/simba/sandbox/sliding_preferred_turning_direction.py index 4ca9ab777..02cfbcfcd 100644 --- a/simba/sandbox/sliding_preferred_turning_direction.py +++ b/simba/sandbox/sliding_preferred_turning_direction.py @@ -1,9 +1,10 @@ import numpy as np -from simba.utils.checks import check_valid_array, check_float -from simba.utils.enums import Formats -from simba.utils.errors import InvalidInputError + from simba.mixins.circular_statistics import CircularStatisticsMixin +from simba.utils.checks import check_float, check_valid_array from simba.utils.data import get_mode +from simba.utils.enums import Formats +from simba.utils.errors import InvalidInputError def sliding_preferred_turning_direction(x: np.ndarray, diff --git a/simba/sandbox/snap.py b/simba/sandbox/snap.py index a1d75d26f..28b6a34b3 100644 --- a/simba/sandbox/snap.py +++ b/simba/sandbox/snap.py @@ -1,6 +1,8 @@ import numpy as np + from simba.utils.read_write import read_df + def snap(x: np.ndarray, sample_rate: float, pixels_per_mm: float): """ :example: