pyfli.simulator.calibration.multicluster#
Multi-cluster priors and images, following the pyfli multi-ROI example.
Functions
|
|
|
Depth of the density valley between two components: the pixels assigned to either are projected onto the line joining the means, a Gaussian KDE (Scott bandwidth) of the projection is evaluated between the two projected means, and the minimum is divided by the smaller of the densities at the means. |
|
|
|
Top-left corner of a tile fully inside the sample mask that contains as many clusters as possible, with the most balanced composition (largest minority share). |
|
Inputs for calibrating one cluster: the experiment's inputs restricted to the cluster mask, with the IRF of the whole-experiment calibration (the IRF belongs to the detector, not to a cell population). |
|
Find well-separated pixel populations inside |
|
Per-pixel IRF cube |
|
A calibrated config as a pyfli |
|
pyfli |
Classes
|
- class ClusterResult(labels: numpy.ndarray, n_clusters: int, fractions: list[float], report: dict = <factory>)[source]#
Bases:
object
- detect_clusters(decay, mask, max_components=4, separation=2.0, min_fraction=0.05, use_intensity=False, n_fit=20000, smooth=True, seed=0, max_dip_ratio=0.5)[source]#
Find well-separated pixel populations inside
mask; see the module docstring.Two mixture components stay separate only if Ashman’s D is at least separation and the pixel density projected onto the line joining their means has a real dip between them (
_dip_ratio()below max_dip_ratio). A mixture fitted to a few hundred pixels of one skewed population can reach D > 2 by chance, but its projected density has no dip (ratio ~0.7-1), while separate populations give ~0.
- cluster_inputs(base, cluster_mask_path, whole_irf_path, output_dir)[source]#
Inputs for calibrating one cluster: the experiment’s inputs restricted to the cluster mask, with the IRF of the whole-experiment calibration (the IRF belongs to the detector, not to a cell population).
- Parameters:
base (CalibrationInputs)
cluster_mask_path (str)
whole_irf_path (str)
output_dir (str)
- Return type:
- roi_config(json_path, seed=None)[source]#
A calibrated config as a pyfli
roi_paramsentry (tuples restored; optional fixed seed).
- irf_tile(json_path, shape, seed=0, peak=1e4)[source]#
Per-pixel IRF cube
(H, W, T)with the calibratedOffsetGenbehaviour: each pixel getsroll(template, round(a)) + b, a ~ U(a_range), b ~ U(b_range). It is scaled topeakbecause pyfli’sirf_pickeronly accepts 3D IRFs whose peak exceeds 500 (each pixel is sum-normalised by the generator anyway).
- choose_tile(labels, shape=(8, 8), seed=0)[source]#
Top-left corner of a tile fully inside the sample mask that contains as many clusters as possible, with the most balanced composition (largest minority share).
- simulate_multicluster_tile(labels_tile, cluster_configs, irf_json, detector_type='discrete', sample_mask_tile=None, seed=0)[source]#
pyfli
FLIModelImageGeneratorimage for a cluster label tile, as in the pyfli multi-ROI example:roi_paramsfollowsnp.unique(roi_mask). Label 0 (outside the sample) is background with an empty config and is zeroed by the intensity / bool mask.