twocan.IFProcessor

class twocan.IFProcessor(binarize=True, binarization_threshold=0.1, sigma=1)[source]

Bases: object

Preprocessing pipeline for Immunofluorescence (IF) images.

This class provides a standardized preprocessing pipeline for IF images including channel summation, normalization, Gaussian blurring, and optional binarization. The processor can be configured with trial parameters from Optuna optimization.

Parameters:
  • binarize (bool, default=True) – Whether to apply binarization after preprocessing.

  • binarization_threshold (float, default=0.1) – Threshold value for binarization (0-1 range after normalization).

  • sigma (float, default=1) – Standard deviation for Gaussian blur kernel.

binarize

Whether binarization is enabled.

Type:

bool

binarization_threshold

Current binarization threshold.

Type:

float

sigma

Current Gaussian blur sigma value.

Type:

float

configure(trial_params)[source]

Configure processor parameters from Optuna trial parameters.

This method updates the processor parameters based on values suggested by an Optuna trial. It looks for specific parameter names in the trial params dictionary and updates the corresponding attributes.

Parameters:

trial_params (dict) – Dictionary of trial parameters from Optuna optimization. Expected keys: ‘IF_binarization_threshold’, ‘IF_gaussian_sigma’, ‘binarize_images’.

Returns:

self – Returns self for method chaining.

Return type:

IFProcessor