
Bleedthrough Module¶
flyqma.bleedthrough
provides methods for correcting for spectral bleedthrough between fluorescent reporter channels.
Background Extraction¶
Tools for extracting the background pixels from a segmented image.
-
class
flyqma.bleedthrough.background.
BackgroundExtraction
(layer, niters=10)[source]¶ Object for extracting image background pixels.
Attributes:
layer (Layer) - layer RGB image
bg_mask (np.ndarray[bool]) - background mask, True where background
-
build_background_mask
(niters=0)[source]¶ Construct background mask by dilating foregound.
Args:
niters (int) - number of binary dilations
Returns:
bg_mask (np.ndarray[bool]) - background mask, True where background
-
extract_pixels
(channel)[source]¶ Extract pixels from image background.
Args:
channel (int) - color channel to be extracted
Returns:
px (np.ndarray[float]) - 1D array of background pixel intensities
-
Resampling¶
Tools for resampling a set of pixel intensities.
-
flyqma.bleedthrough.resampling.
resample_uniformly
(x, y, size=None, cutoff=None)[source]¶ Resample X and Y uniformly in X.
Args:
x, y (np.ndarray[float]) - original samples
size (int) - number of uniform samples
cutoff (int) - upper bound for samples (quantile, 0 to 100)
Returns:
x, y (np.ndarray[float]) - resampled s.t. x is uniformly distributed
Bleedthrough Coefficient Characterization¶
Tools for characterizing bleedthrough coefficients.
-
class
flyqma.bleedthrough.models.
GLM
(x, y, **fit_kw)[source]¶ Generalized linear model with gamma distributed residuals and an identity link function fit to X and Y data.
Attributes:
model (sm.genmod.GLM) - generalized linear model
domain (np.ndarray[float]) - regularly spaced x-domain
Inherited attributes:
x, y (array like) - data
Bleedthrough Correction¶
Tools for correcting measurements subject to bleedthrough.
-
class
flyqma.bleedthrough.correction.
Correction
(xt, yt, bg_x, bg_y, remove_zeros=False, resample=True, resample_size=None, resample_cutoff=None, store_pixels=True, **fit_kw)[source]¶ Linear correction for background correlation between fluorescence channels within an individual layer.
Attributes:
xt, yt (np.ndarray[float]) - foreground measurements
xraw, yraw (np.ndarray[float]) - raw background pixel intensities
x, y (np.ndarray[float]) - resampled background pixel intensities
-
class
flyqma.bleedthrough.correction.
LayerCorrection
(layer, xvar, yvar, niters=50, remove_zeros=False, resample=True, resample_size=None, resample_cutoff=None, store_pixels=False, **fit_kw)[source]¶ Linear correction for background correlation between fluorescence channels within an individual layer.
Attributes:
layer (Layer) - layer RGB image
Inherited attributes:
xt, yt (np.ndarray[float]) - foreground measurements
xraw, yraw (np.ndarray[float]) - raw background pixel intensities
x, y (np.ndarray[float]) - resampled background pixel intensities
Parameters:
xvar (str) - name of independent variable attribute in measurement data
yvar (str) - name of dependent variable attribute in measurement data
niters (int) - number of binary dilations applied to foreground mask
remove_zeros (bool) - if True, remove all zero-valued pixels.
resample (bool) - if True, uniformly resample pixels in X
resample_size (int) - number of uniform samples
resample_cutoff (int) - upper bound for samples (quantile, 0 to 100)
-
classmethod
load
(layer)[source]¶ Load linear model from file.
Args:
path (str) - path to correction directory
Returns:
correction (LayerCorrection)
-
save
(images=True)[source]¶ Save linear model and corrected levels.
Args:
images (bool) - if True, save model fit and corrected measurement figs
-
save_figs
(dpi=100, fmt='png')[source]¶ Save all figures.
Args:
dpi (int) - resolution
fmt (str) - image format
-
property
xkey
¶ DataFrame key for independent channel.
-
property
ykey
¶ DataFrame key for dependent channel.
-
classmethod
Visualization¶
Tools for visualizing the bleedthrough correction procedure.
-
class
flyqma.bleedthrough.visualization.
CorrectionVisualization
[source]¶ Methods for visualizing correction procedure.
-
show_correction
(figsize=(6, 2), selected_only=False)[source]¶ Show cell measurements before and after correction.
Args:
figsize (tuple) - figure size
selected_only (bool) - if True, exclude cells outside selection bounds
-