entry_exit_mouse_box.utils module

entry_exit_mouse_box.utils.apply_lut(tags, to_pass, classes)[source]

tags: Layer that will receive the LUT. to_pass: List of gray levels to which we will have to bind a color. classes: Dictionary of colors to bind to the gray levels.

entry_exit_mouse_box.utils.cast_to_pixels(unit_str_src, length_float_src, unit_str_tgt, scale_tgt)[source]

Converts a length from its unit to the viewer’s unit and then to pixels.

Args: - unit_str_src: str The unit of the length to convert (ex: the pillar’s unit). - length_float_src: float The length to convert (ex: the diameter of the pillar). - unit_str_tgt: str The unit of the viewer (ex: the calibration unit). - scale_tgt: float The scale factor to convert the length to pixels (the calibration of the scalebar).

Returns: - int The length in pixels.

entry_exit_mouse_box.utils.merge_close_points(path, min_distance, dot_threshold=-0.7)[source]

Merge points in a 2D path that are closer than a specified minimum distance. Points are merged into their average position. The operation preserves the path order and does not merge non-consecutive points if the path crosses over itself.

Parameters: - path: A list or numpy array of 2D points (e.g., [[x1, y1], [x2, y2], …]). - min_distance: The minimum allowed distance between consecutive points.

Returns: - A new list of points with no consecutive points closer than the minimum distance.

entry_exit_mouse_box.utils.setup_logger(file_path)[source]
entry_exit_mouse_box.utils.smooth_path_2d(points, window_size=3)[source]

Smooth a path of 2D points using a simple moving average with a sliding window.

Parameters: - points: A NumPy array of 2D points, shape (n_points, 2). - window_size: The size of the sliding window for the moving average.

Returns: - A NumPy array of the smoothed 2D points.