Skip to content

Commit

Permalink
outlier correction mp
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Nov 9, 2024
1 parent cb352e8 commit 0901665
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 171 deletions.
20 changes: 18 additions & 2 deletions docs/simba.outlier_tools.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
Location outlier methods
Location outlier removed
--------------------------------------------------------

.. automodule:: simba.outlier_tools.outlier_corrector_location.OutlierCorrecterLocation
:members:
:show-inheritance:

Movement outlier methods
Movement outlier remover
--------------------------------------------------------

.. automodule:: simba.outlier_tools.outlier_corrector_movement.OutlierCorrecterMovement
:members:
:show-inheritance:


Movement outlier remover: multi-core
--------------------------------------------------------

.. automodule:: simba.outlier_tools.outlier_corrector_movement_mp.OutlierCorrecterMovementMultiProcess
:members:
:show-inheritance:


Location outlier remover: multi-core
--------------------------------------------------------

.. automodule:: simba.outlier_tools.outlier_corrector_location_mp.OutlierCorrecterLocationMultiprocess
:members:
:show-inheritance:

Advanced movement outlier correction
--------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion simba/SimBA.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def __init__(self, config_path: str):
label_outliercorrection = CreateLabelFrameWithIcon(parent=tab4, header="OUTLIER CORRECTION", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.OUTLIERS_DOC.value)
button_settings_outlier = SimbaButton(parent=label_outliercorrection, txt="SETTINGS", txt_clr='blue', img='settings', font=Formats.FONT_REGULAR.value, cmd=OutlierSettingsPopUp, cmd_kwargs={'config_path': lambda:self.config_path})

button_outliercorrection = SimbaButton(parent=label_outliercorrection, txt="RUN OUTLIER CORRECTION", txt_clr='green', img='rocket', font=Formats.FONT_REGULAR.value, cmd=self.correct_outlier, thread=True)
button_outliercorrection = SimbaButton(parent=label_outliercorrection, txt="RUN OUTLIER CORRECTION", txt_clr='green', img='rocket', font=Formats.FONT_REGULAR.value, cmd=self.correct_outlier, thread=False)
button_skipOC = SimbaButton(parent=label_outliercorrection, txt="SKIP OUTLIER CORRECTION (CAUTION)", txt_clr='red', img='skip_2', font=Formats.FONT_REGULAR.value, cmd=self.initiate_skip_outlier_correction, thread=True)

label_extractfeatures = CreateLabelFrameWithIcon(parent=tab5, header="EXTRACT FEATURES", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.EXTRACT_FEATURES.value)
Expand Down
15 changes: 10 additions & 5 deletions simba/mixins/statistics_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4192,6 +4192,13 @@ def symmetry_index(x: np.ndarray, y: np.ndarray, agg_type: Literal['mean', 'medi
Zero indicates perfect symmetry. Positive values pepresent increasing asymmetry between the two measurements.
The Symmetry Index (SI) is calculated as:
.. math::
SI = \frac{|x_i - y_i|}{0.5 \times (x_i + y_i)} \times 100
where :math:`x_i` and :math:`y_i` are the values of the two measurements at each time point.
:param np.ndarray x: A 1-dimensional array of measurements from one side (e.g., left side), representing a time series or sequence of measurements.
:param np.ndarray y: A 1-dimensional array of measurements from the other side (e.g., right side), of the same length as `x`.
:param Literal['mean', 'median'] agg_type: The aggregation method used to summarize the Symmetry Index across all time points.
Expand All @@ -4201,13 +4208,11 @@ def symmetry_index(x: np.ndarray, y: np.ndarray, agg_type: Literal['mean', 'medi
:example:
>>> x = np.random.randint(0, 155, (100,))
>>>y = np.random.randint(0, 155, (100,))
>>> symmetry_index(x=x, y=y)
>>> Statistics.symmetry_index(x=x, y=y)
"""

check_valid_array(data=x, source=f'{Statistics.symmetry_index.__name__} x', accepted_ndims=(1,), min_axis_0=1,
accepted_dtypes=Formats.NUMERIC_DTYPES.value)
check_valid_array(data=x, source=f'{Statistics.symmetry_index.__name__} y', accepted_ndims=(1,), min_axis_0=1,
accepted_axis_0_shape=[x.shape[0]], accepted_dtypes=Formats.NUMERIC_DTYPES.value)
check_valid_array(data=x, source=f'{Statistics.symmetry_index.__name__} x', accepted_ndims=(1,), min_axis_0=1, accepted_dtypes=Formats.NUMERIC_DTYPES.value)
check_valid_array(data=x, source=f'{Statistics.symmetry_index.__name__} y', accepted_ndims=(1,), min_axis_0=1, accepted_axis_0_shape=[x.shape[0]], accepted_dtypes=Formats.NUMERIC_DTYPES.value)
check_str(name=f'{Statistics.symmetry_index.__name__} agg_type', value=agg_type, options=('mean', 'median'))
si_values = np.abs(x - y) / (0.5 * (x + y)) * 100
if agg_type == 'mean':
Expand Down
Loading

0 comments on commit 0901665

Please sign in to comment.