Legacy Module
legacy.py
Deprecated functions retained for backward compatibility only.
Do not use these in new code; they may be removed in a future version. Use the corresponding functions from the main exo2micro modules instead.
- exo2micro.legacy.compile_ims_old(target_ch, ref_ch, dirname='./', name_str='')[source]
Deprecated since version Use: load_image_pair() from exo2micro.utils instead.
Given a directory of .tif image files, read them into arrays. Assumes a target channel and variable reference channels.
- Parameters:
target_ch (str) – Single 2-digit string for the target channel, e.g. ‘00’.
ref_ch (list of str) – List of 2-digit strings for reference channels, e.g. [‘01’, ‘02’].
dirname (str) – Directory containing the images (default ‘./’).
name_str (str) – Partial filename string to select a specific set (default ‘’).
- Return type:
target_fname, ref_fnames, target_im, ref_ims
- exo2micro.legacy.mask_em(red)[source]
Deprecated since version Use: exo2micro.utils.build_tissue_mask() instead.
Create a binary mask: 1.0 where red > 0, NaN elsewhere.
- Parameters:
red (ndarray)
- Return type:
ndarray
- exo2micro.legacy.maskandsave(blue_img, red_img, green_img, sub00, sub02)[source]
Deprecated since version Use: the SampleDye pipeline for output management instead.
Apply mask and save processed images to Analyzed_Images/.
- exo2micro.legacy.optimize_subtraction(post_im, pre_im, method='least_squares', percentile=None, n_hist_bins=100, noise_floor_percentile=5, boundary_erosion=50, mask=None, signal_percentile=50, plot_ratio_hist=False, sample='', dye='', save_prefix=None)[source]
Deprecated since version 2.3: Moved from
exo2micro.scalingintoexo2micro.legacyand no longer used by the main pipeline. UseSampleDye(scale_percentile=...)for the equivalent percentile-based workflow in the current pipeline.Compute a pre-stain scale factor for subtraction.
- Parameters:
post_im (ndarray) – Post-stain and registered pre-stain images (2-D).
pre_im (ndarray) – Post-stain and registered pre-stain images (2-D).
method (str) –
'least_squares'or'robust_percentile'(default'least_squares').percentile (int or None) – For
robust_percentile:None= histogram mode, int = use that percentile of the log-ratio distribution.n_hist_bins (int) – Histogram bins for the log-ratio distribution (default 100).
noise_floor_percentile (float) – Pixels below this percentile of post_im are excluded (default 5).
boundary_erosion (int) – Erode the signal mask by this many pixels (default 50).
mask (ndarray or None) – Optional boolean base mask.
signal_percentile (float) – Bright-in-both percentile (default 50).
plot_ratio_hist (bool) – If True, also return a data dict for plotting (default False).
sample (str) – Labels for plots.
dye (str) – Labels for plots.
save_prefix (str or None) – If set, save diagnostic figures to disk.
- Returns:
opt_scale (float)
scale_sig (float or None)
tissue_mask_out (ndarray of bool)
plot_data (dict or None)
- exo2micro.legacy.plot_diff_comparison(post_im, pre_im, scale_ls, scale_robust, title='', sig_mask=None, sample='', dye='')[source]
Two-panel comparison of LS and robust difference images.
- exo2micro.legacy.plot_im_sub(post_im, pre_im, scale, comp=None, scale_robust=None, sample='', dye='')[source]
Subtract a scaled pre-stain image and display panels.
- Parameters:
post_im (ndarray) – Post-stain and aligned pre-stain images.
pre_im (ndarray) – Post-stain and aligned pre-stain images.
scale (float) – Least-squares scale factor.
comp (ndarray or None) – Comparison image.
scale_robust (float or None) – If set, add robust subtraction panels.
sample (str) – For title.
dye (str) – For title.
- Returns:
fig (matplotlib.Figure)
diff_im (ndarray) – LS difference image.
- exo2micro.legacy.plot_ratio_histogram(plot_data, save_path=None)[source]
Diagnostic histogram of post/pre ratio distribution.
- exo2micro.legacy.plot_residual_histogram(plot_data, save_path=None)[source]
Post-subtraction residual histogram comparing LS and robust methods.
- exo2micro.legacy.plot_signal_scatter(post_im, pre_im, scale_ls, scale_sig, scale_robust, tissue_mask, signal_percentile=50, n_points=100000, sample='', dye='', save_path=None)[source]
Diagnostic scatter plot of post vs pre brightness.
Shows scale lines for LS, signal-only LS, and robust methods on a log-log density plot.
- Parameters:
post_im (ndarray) – Post-stain and aligned pre-stain images.
pre_im (ndarray) – Post-stain and aligned pre-stain images.
scale_ls (float) – LS scale over all tissue pixels.
scale_sig (float or None) – LS scale over signal-only pixels.
scale_robust (float) – Robust scale.
tissue_mask (ndarray of bool) – Tissue mask.
signal_percentile (float) – Percentile threshold shown as dashed lines (default 50).
n_points (int) – Number of points to display (default 100000).
sample (str) – For title.
dye (str) – For title.
save_path (str or None) – If set, save to this path.
- Returns:
fig
- Return type:
matplotlib.Figure or None
- exo2micro.legacy.plot_stretch_comparison(post_im, pre_im, scale_ls, scale_robust, title='', sample='', dye='')[source]
4-row x 2-column grid comparing stretch methods on LS and robust diffs.
Rows: asinh, signed log, global z-score, local z-score. Columns: LS (diverging cmap), Robust (inferno cmap).
- exo2micro.legacy.plot_zoom_region(post_im, pre_im, scale_ls, scale_robust, sig_mask=None, box_size=300, title='', sample='', dye='')[source]
Zoom into the densest signal region and compare LS vs robust subtraction.
- exo2micro.legacy.register_loworder(post_im, pre_im, stopit=500, stopdelta=1e-06, down_scale=0.5, save_prefix=None)[source]
Deprecated since version Use: register_highorder() from exo2micro.alignment instead, which handles both low-order and high-order registration.
Register using Euclidean (rotation + translation) motion model via ECC.
- exo2micro.legacy.residuals_collapsed(scale, post_im, pre_im)[source]
Deprecated since version Use: optimize_subtraction() from exo2micro.scaling instead.
Subtract a scaled pre-stain image and return residuals as 1D array.
- Parameters:
scale (float)
post_im (ndarray)
pre_im (ndarray)
- Return type:
ndarray