Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #133 from dstansby/type-ball-filter
Browse files Browse the repository at this point in the history
Type ball filter
  • Loading branch information
alessandrofelder authored Apr 4, 2023
2 parents 8a1e9c2 + 843316e commit 5e353bd
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/cellfinder_core/detect/filters/volume/ball_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np
from numba import jit

Expand All @@ -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=None,
tile_step_height=None,
threshold_value: Optional[int] = None,
soma_centre_value=None,
overlap_fraction: float,
tile_step_width: int,
tile_step_height: int,
threshold_value: int,
soma_centre_value: int,
):
"""
Parameters
Expand Down Expand Up @@ -125,13 +123,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.
"""
Expand Down Expand Up @@ -162,14 +160,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 = (
Expand Down

0 comments on commit 5e353bd

Please sign in to comment.