From e49177bf651203bd712fe5470d9a3964a9ad633d Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 4 Apr 2023 10:19:24 +0100 Subject: [PATCH 1/2] Type BallFilter --- .../detect/filters/volume/ball_filter.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cellfinder_core/detect/filters/volume/ball_filter.py b/src/cellfinder_core/detect/filters/volume/ball_filter.py index 421c2b9a..9e36101c 100644 --- a/src/cellfinder_core/detect/filters/volume/ball_filter.py +++ b/src/cellfinder_core/detect/filters/volume/ball_filter.py @@ -26,10 +26,10 @@ def __init__( ball_xy_size: int, ball_z_size: int, overlap_fraction: float = 0.8, - tile_step_width=None, - tile_step_height=None, + tile_step_width: Optional[int] = None, + tile_step_height: Optional[int] = None, threshold_value: Optional[int] = None, - soma_centre_value=None, + soma_centre_value: Optional[int] = None, ): """ Parameters @@ -125,13 +125,13 @@ def __init__( self.__current_z = -1 @property - def ready(self): + def ready(self) -> bool: """ Return `True` if enough layers have been appended to run the filter. """ return self.__current_z == self.ball_z_size - 1 - def append(self, layer, mask): + def append(self, layer: np.ndarray, mask: np.ndarray) -> None: """ Add a new 2D layer to the filter. """ @@ -162,14 +162,14 @@ def append(self, layer, mask): self.volume[:, :, self.__current_z] = layer[:, :] self.inside_brain_tiles[:, :, self.__current_z] = mask[:, :] - def get_middle_plane(self): + def get_middle_plane(self) -> np.ndarray: """ Get the plane in the middle of self.volume. """ z = self.middle_z_idx return np.array(self.volume[:, :, z], dtype=np.uint16) - def walk(self): # Highly optimised because most time critical + def walk(self) -> None: # Highly optimised because most time critical ball_radius = self.ball_xy_size // 2 # Get extents of image that are covered by tiles tile_mask_covered_img_width = ( From 843316e3fba8a311e1f911c743681352c0362b07 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 4 Apr 2023 10:20:32 +0100 Subject: [PATCH 2/2] Make all arguments to BallFilter non-optional --- .../detect/filters/volume/ball_filter.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cellfinder_core/detect/filters/volume/ball_filter.py b/src/cellfinder_core/detect/filters/volume/ball_filter.py index 9e36101c..d53a0937 100644 --- a/src/cellfinder_core/detect/filters/volume/ball_filter.py +++ b/src/cellfinder_core/detect/filters/volume/ball_filter.py @@ -1,5 +1,3 @@ -from typing import Optional - import numpy as np from numba import jit @@ -25,11 +23,11 @@ def __init__( layer_height: int, ball_xy_size: int, ball_z_size: int, - overlap_fraction: float = 0.8, - tile_step_width: Optional[int] = None, - tile_step_height: Optional[int] = None, - threshold_value: Optional[int] = None, - soma_centre_value: Optional[int] = None, + overlap_fraction: float, + tile_step_width: int, + tile_step_height: int, + threshold_value: int, + soma_centre_value: int, ): """ Parameters