Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	simba/sandbox/unsupervised/cluster_frequentist_stats.py
  • Loading branch information
sronilsson committed Dec 26, 2024
2 parents 10ff973 + 850a7f7 commit 281dbd7
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 32 deletions.
8 changes: 5 additions & 3 deletions simba/mixins/statistics_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions simba/sandbox/bg_remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions simba/sandbox/bout_aggregator.py
Original file line number Diff line number Diff line change
@@ -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],
Expand Down
1 change: 0 additions & 1 deletion simba/sandbox/direction_reversals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np



def direction_switches(x: np.ndarray, switch_degree: int = 180):

idx = 0
Expand Down
20 changes: 12 additions & 8 deletions simba/sandbox/felzenszwalb.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 5 additions & 2 deletions simba/sandbox/gibbs_sampler.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 0 additions & 1 deletion simba/sandbox/img_edge_distance_flexible.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np



def img_edge_distances_flexible(data: np.ndarray,
edge_distances: np.ndarray,
pixels_per_mm: float,
Expand Down
5 changes: 3 additions & 2 deletions simba/sandbox/preferred_turning_direction.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions simba/sandbox/radial_dispersion.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions simba/sandbox/radial_eccentricity.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 4 additions & 1 deletion simba/sandbox/regression_errors.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
14 changes: 10 additions & 4 deletions simba/sandbox/sliding_descriptive_statistics_cuda.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 4 additions & 3 deletions simba/sandbox/sliding_preferred_turning_direction.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 2 additions & 0 deletions simba/sandbox/snap.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 281dbd7

Please sign in to comment.