Skip to content

Commit

Permalink
Update stack_processing.py
Browse files Browse the repository at this point in the history
- add dask-compatible function for Li thresholding
- change default number of central frames to extract during processing
  • Loading branch information
lanery committed Jul 13, 2024
1 parent a077f21 commit ff4dad8
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/chlamytracker/stack_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@timeit
def get_central_frames(stack, num_central_frames=10):
def get_central_frames(stack, num_central_frames=100):
"""Crops `num_central_frames` from the center of an image stack.
Parameters
Expand Down Expand Up @@ -104,7 +104,7 @@ def rescale_to_float(stack):


@timeit
def otsu_threshold_3d(stack, num_central_frames=10):
def otsu_threshold_3d(stack, num_central_frames=100):
"""Wrapper for `ski.filters.threshold_otsu` better equipped for handling
large image stacks.
Expand All @@ -121,6 +121,24 @@ def otsu_threshold_3d(stack, num_central_frames=10):
return threshold


@timeit
def li_threshold_3d(stack, num_central_frames=100, initial_guess=0.1):
"""Wrapper for `ski.filters.threshold_li` better equipped for handling
large image stacks.
Parameters
----------
stack : (Z, Y, X) array
Input image stack of arbitrary dtype.
num_central_frames : int
Number of central frames to use for determining the threshold. Useful
for speeding up computation time when large stacks when
"""
central_frames = get_central_frames(stack, num_central_frames)
threshold = ski.filters.threshold_li(central_frames, initial_guess=0.1)
return threshold


def otsu_threshold_dask(dask_array):
"""Otsu thresholding function compatible with dask.
Expand Down

0 comments on commit ff4dad8

Please sign in to comment.