Skip to main content

modifiedOtsu

modifiedOtsu implements the local modified Otsu thresholding step used by Park et al. in Segmentation-based tracking of macrophages in 2D+time microscopy movies inside a living animal.

The package default is window_size=(3, 3, 3) for volumetric use. For a 2D+time movie with shape (t, y, x), use window_size=(1, s, s) explicitly for the exact 2D local window used by Park et al. A larger first window dimension, such as (3, 7, 7), is a 3D/temporal extension, not the exact 2D local window from the paper.

The binary decision is:

binary = image > threshold_map

The contrast rejection rule is the relative class-mean rule:

abs(mu_foreground - mu_background) / abs(mu_background) > delta

If mu_background == 0 and the two means differ, the relative separation is considered infinite rather than rejecting the window.

Install

python -m pip install .

For TIFF I/O:

python -m pip install '.[tiff]'

Python API

import tifffile
from modifiedOtsu import getMask

movie = tifffile.imread("movie.tif")  # shape: (t, y, x)
thresholds, mask = getMask(movie, window_size=(1, 7, 7), delta=0.2)

Default volumetric call:

thresholds, mask = getMask(volume, delta=0.2)  # default window_size=(3, 3, 3)

Use delta=0 for ordinary local Otsu without the extra relative-contrast rejection.

For a 3D volume extension:

thresholds, mask = getMask(volume, window_size=(3, 7, 7), delta=0.2)

CLI

One TIFF/NumPy volume:

modified-otsu --input image.tif --window 3 3 3 --delta 0.2

Directory, recursively preserving subdirectories:

modified-otsu \
  --input dataset \
  --output-dir results \
  --recursive \
  --window 3 3 3 \
  --delta 0.2

With threshold maps:

modified-otsu --input image.tif --window 3 3 3 --save-thresholds

Masks are saved as TIFF files with values 0 and 255.

Metadata

Release files for modifiedOtsu 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modifiedOtsu 0.1.2
File Size Uploaded
modifiedotsu-0.1.2.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modifiedOtsu 0.1.2
File Interpreter ABI Platform
modifiedotsu-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / modifiedotsu-0.1.2.tar.gz

Download URL modifiedotsu-0.1.2.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
09e7f4f13628d649665a8a15aecf2a2e1f84267634fcfe2861259c62c9e952a2
BLAKE2b-256 checksum
How to use checksums
081221504fb486d67373bfc068046e52c2bbfcd70ee89e698c31e4dad1b1c686
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / modifiedotsu-0.1.2-py3-none-any.whl

Download URL modifiedotsu-0.1.2-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98a61d7a8c8d991f20b3fde93bee711b3d58d51bbeb997ece208d85b8eedbedd
BLAKE2b-256 checksum
How to use checksums
232478f2f3d1f6e53abd165cbf0fe8a71866b9e3f68ab24985abd27aed0548a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page