Multi-Target & I/O
Multi-Target
Multi-channel (multi-color) analysis types. The orchestrator config MultiTargetConfig is documented on the Multi-Channel Analysis page; its result, info, and step types are below. See Composite Render / Cross-Alignment / Cross-Correlation for the individual steps.
SMLMAnalysis.MultiTargetResult — Type
MultiTargetResultResult of a multi-target analysis. Holds per-channel AnalysisResult objects and the final SMLD vectors for composite rendering.
Fields
labels::Vector{Symbol}: Channel labels in ordersmlds::Vector{SMLMData.BasicSMLD}: Per-channel SMLD results (may be aligned)channels::Dict{Symbol, AnalysisResult}: Per-channel resultsstep_infos::Vector{StepInfo}: Multi-target step historyoutdir::String: Output directory
Indexing
result[:IgG] # Access per-channel AnalysisResult
keys(result) # Channel labels
result.smlds # Vector of all SMLDsSMLMAnalysis.MultiTargetInfo — Type
MultiTargetInfo <: AbstractSMLMInfoAggregated metadata from a multi-target analysis.
Fields
elapsed_s::Float64: Total elapsed time in secondschannels::Dict{Symbol, AnalysisInfo}: Per-channel analysis infostep_infos::Vector{StepInfo}: Multi-target step history (composite renders, alignment, etc.)steps::Dict{Symbol, Any}: Step name → info mapping for convenience
SMLMAnalysis.AbstractMultiTargetStep — Type
AbstractMultiTargetStep <: AbstractSMLMConfigAbstract supertype for steps that operate on Vector{BasicSMLD} in the multi-target pipeline (composite rendering, cross-channel alignment, etc.).
SMLMAnalysis.CompositeRenderConfig — Type
CompositeRenderConfig <: AbstractMultiTargetStepConfiguration for a composite multi-channel render in the multi-target pipeline.
Fields
strategy: Rendering strategy (default: GaussianRender())zoom: Zoom factor (default: 20.0)colors: Per-channel colors (nothing = inherit from MultiTargetConfig)clip_percentile: Intensity clipping.:auto(default) picks per strategy — saturate (no clip) for histogram, 0.99 for others. AFloat64clips at that percentile;nothingforces saturate mode.normalize_each: Per-channel normalization (nothing = auto: false for histogram, true for others)scalebar: Enable scale bar (default: true)scalebar_length: Scale bar length in μm (nothing = auto)scalebar_position: Scale bar corner (default: :br)scalebar_color: Scale bar color (default: :white)
SMLMAnalysis.CrossAlignConfig — Type
CrossAlignConfig <: AbstractMultiTargetStepConfiguration for cross-channel alignment in the multi-target pipeline.
Wraps SMLMDriftCorrection.align_smld which uses entropy-based or FFT cross-correlation alignment.
Fields
method: Alignment method —:entropy(CC + entropy refinement) or:fft(CC only)maxn: Maximum neighbors for entropy calculation (default: 100)histbinsize: Histogram bin size in μm for cross-correlation (default: 0.05)
SMLMAnalysis.CrossCorrConfig — Type
CrossCorrConfig <: AbstractMultiTargetStepConfiguration for pair cross-correlation g(r) between two channels.
Fields
r_max: Maximum correlation distance in μm (default: 1.0)dr: Radial bin width in μm (default: 0.01)edge_correction: Apply Ripley's isotropic edge correction (default: true)channels: Which channels to correlate, as 1-based indices (default: (1, 2))
SMLMAnalysis.CompositeRenderInfo — Type
CompositeRenderInfo <: AbstractSMLMInfoInfo from a multi-channel composite render step.
SMLMAnalysis.CrossAlignInfo — Type
CrossAlignInfo <: AbstractSMLMInfoInfo from cross-channel alignment step.
SMLMAnalysis.CrossCorrInfo — Type
CrossCorrInfo <: AbstractSMLMInfoInfo from pair cross-correlation g(r) step.
Fields
r::Vector{Float64}: Bin centers (μm)g::Vector{Float64}: g(r) valuesn_a::Int: Emitter count in channel An_b::Int: Emitter count in channel Barea::Float64: FOV area (μm²)r_max::Float64: Maximum correlation distance (μm)dr::Float64: Bin width (μm)channel_a::Symbol: Label for channel Achannel_b::Symbol: Label for channel Belapsed_s::Float64: Elapsed time (s)
I/O
Save and load localization results and pipeline state, and import microscope .h5 data. See I/O & Resume for the workflow.
SMLMAnalysis.save_smld — Function
save_smld(filepath::String, smld::BasicSMLD;
source_file::Union{String,Nothing}=nothing,
drift_model=nothing,
compression::Int=3)Save BasicSMLD to HDF5 file with full metadata for reproducibility.
Supports all emitter types including GaussMLE types with fitted PSF widths:
- Emitter2DFitSigma: saves fitted σ (isotropic PSF width)
- Emitter2DFitSigmaXY: saves fitted σx, σy (anisotropic PSF widths)
Arguments
filepath: Output .h5 file pathsmld: BasicSMLD object to savesource_file: Original data file path (for provenance tracking)drift_model: Optional drift correction model (LegendrePolynomial, etc.)compression: HDF5 compression level 0-9 (default: 3)
File Structure
/metadata - Format version, package info, timestamps
/emitters - Columnar emitter data (x, y, z, photons, psf_sigma_x, etc.)
/camera - Camera type and calibration
/drift_correction - Drift model coefficients (if provided)
/provenance - Source file infoExample
save_smld("results.h5", smld; source_file="/data/experiment.h5", drift_model=dm)SMLMAnalysis.load_smld — Function
load_smld(filepath::String) -> BasicSMLDLoad BasicSMLD from HDF5 file.
Returns a BasicSMLD with the saved emitters, camera, and metadata. Automatically reconstructs the correct emitter type (including GaussMLE types with PSF width fields).
Drift correction info is stored in metadata["drift_correction"] if present.
Example
smld = load_smld("results.h5")SMLMAnalysis.smld_info — Function
smld_info(filepath::String)Print summary info about an SMLD HDF5 file without loading all data.
SMLMAnalysis.save_pipeline_state — Function
save_pipeline_state(path::String, result::AnalysisResult;
smld_raw=nothing, step_infos=StepInfo[], camera=nothing)Save pipeline state to JLD2 for cross-session resume.
Example
(result, info) = analyze(image_stacks, config)
save_pipeline_state("output/checkpoint.jld2", result;
step_infos=info.step_infos, camera=config.camera)SMLMAnalysis.load_pipeline_state — Function
load_pipeline_state(path::String) -> NamedTupleLoad pipeline state from JLD2.
Returns a NamedTuple with fields: smld, smldraw, smldconnected, driftmodel, stepinfos, camera.
Example
state = load_pipeline_state("output/checkpoint.jld2")
smld = state.smld
# Continue pipeline from here
(smld, info) = analyze(smld, FilterConfig(photons=(500.0, Inf)))SMLMAnalysis.load_smart_h5 — Function
load_smart_h5(filepath::String; frame_range=nothing)Load image data from a SMART microscope HDF5 file.
Arguments
filepath::String: Path to the HDF5 fileframe_range: Optional range of frames to load (e.g., 1:1000). If nothing, loads all frames.
Returns
data::Array{UInt16, 3}: Image data (width, height, frames)
Example
# Load all frames
data = load_smart_h5("data/experiment.h5")
# Load first 1000 frames
data = load_smart_h5("data/experiment.h5", frame_range=1:1000)SMLMAnalysis.load_smart_h5_info — Function
load_smart_h5_info(filepath::String)Load metadata about a SMART microscope HDF5 file without reading the full dataset.
Returns a NamedTuple with:
- filepath: Full path to the file
- width, height, nframes: Image dimensions
- dtype: Data type of the images
- filesizegb: Approximate file size in GB
Example
info = load_smart_h5_info("path/to/smart_data.h5")
println("File contains ", info.nframes, " frames of size ", info.width, "x", info.height)SMLMAnalysis.load_smart_h5_frame — Function
load_smart_h5_frame(filepath::String, frame::Int)Load a single frame from a SMART microscope HDF5 file.
Arguments
filepath::String: Path to the HDF5 fileframe::Int: Frame number to load (1-indexed)
Returns
frame_data::Matrix{UInt16}: Single frame image
Example
frame1 = load_smart_h5_frame("data/experiment.h5", 1)SMLMAnalysis.smart_h5_to_array — Function
smart_h5_to_array(filepath::String; max_frames=nothing)Load SMART microscope data as a properly formatted array for SMLM processing.
This function transposes the data from (width, height, frames) to (height, width, frames) to match standard image conventions where the first dimension is rows (y) and second is columns (x).
Arguments
filepath::String: Path to the HDF5 filemax_frames: Optional maximum number of frames to load
Returns
data::Array{UInt16, 3}: Image data in (rows, cols, frames) formatinfo::NamedTuple: File metadata
Example
data, info = smart_h5_to_array("data/experiment.h5", max_frames=1000)
println("Loaded ", size(data, 3), " frames of size ", size(data, 1), "x", size(data, 2))SMLMAnalysis.load_mic_h5 — Function
load_mic_h5(filepath; max_frames=nothing, max_blocks=nothing) -> images, dataset_indicesLoad MIC dSTORM H5 file. Each block becomes a "dataset".
Returns:
- images: 3D array (height × width × n_frames)
- dataset_indices: Vector{Int} mapping each frame to its block (1-indexed)
SMLMAnalysis.load_mic_h5_info — Function
load_mic_h5_info(filepath) -> NamedTupleGet info about MIC H5 file without loading all data.
Returns NamedTuple with fields:
- height, width: image dimensions
- n_frames: total frames across all blocks
- n_blocks: number of data blocks (datasets)
- framesperblock: Vector of frame counts per block
- has_calibration: whether calibration data exists
SMLMAnalysis.load_mic_h5_block — Function
load_mic_h5_block(filepath, block_num::Int) -> Array{Float32,3}Load a single data block from MIC H5 file. block_num is 1-indexed.
SMLMAnalysis.load_mic_h5_calibration — Function
load_mic_h5_calibration(filepath) -> NamedTupleLoad calibration data from MIC H5 file.
Returns NamedTuple with (offset, variance, gain) as 2D arrays.
NOTE: The gain in MIC H5 files is INVERTED compared to our convention. Our convention: ADU = photons * gain, so gain ≈ 0.24 e-/ADU MIC H5: gain stored as ~4, which is 1/gain in our convention Use loadmich5calibrationfor_scmos() to get corrected values.
SMLMAnalysis.load_mic_h5_calibration_for_scmos — Function
load_mic_h5_calibration_for_scmos(filepath) -> NamedTupleLoad calibration data and convert to SCMOSCamera convention.
Returns NamedTuple with:
- offset: per-pixel offset (unchanged)
- readnoise: per-pixel readnoise (sqrt of variance)
- gain: per-pixel gain (INVERTED from stored value)
SMLMAnalysis.build_camera_from_mic_h5 — Function
build_camera_from_mic_h5(filepath; pixel_size, qe=1.0) -> SCMOSCameraBuild an SCMOSCamera from MIC H5 per-pixel calibration data (offset, readnoise, gain).
Pixel size and QE are not stored in MIC H5 files and must be provided.
Arguments
filepath: Path to MIC H5 file with Calibration/ grouppixel_size: Pixel size in μm (required)qe: Quantum efficiency 0-1 (default: 1.0)
Utilities
SMLMAnalysis.crop_camera — Function
crop_camera(camera::AbstractCamera, roi_x::UnitRange, roi_y::UnitRange)Crop camera to specified pixel ROI while preserving physical coordinates.
Returns a new camera with:
- pixeledgesx/y sliced to cover ROI (preserves original μm positions)
- For SCMOSCamera: offset/gain/readnoise/qe matrices cropped accordingly
Arguments
camera: Original cameraroi_x: Pixel range in x (columns), e.g., 100:300roi_y: Pixel range in y (rows), e.g., 50:200
Example
cam = IdealCamera(512, 512, 0.1)
cam_cropped = crop_camera(cam, 100:300, 50:200)
# cam_cropped.pixel_edges_x[1] = 10.0 μm (not 0!)SMLMAnalysis.crop_images — Function
crop_images(images::AbstractArray{T,3}, roi_x::UnitRange, roi_y::UnitRange) where TCrop image stack to specified pixel ROI.
Arguments
images: 3D array (y, x, frames) - Julia convention: [row, col]roi_x: Pixel range in x (columns)roi_y: Pixel range in y (rows)
SMLMAnalysis.step_name — Function
step_name(cfg::AbstractSMLMConfig) -> StringDerive step name from config type (e.g., FilterConfig → "filter", DriftConfig → "drift").
SMLMAnalysis.step_outdir — Function
step_outdir(outdir, step_number, cfg) -> Union{String, Nothing}Compute output directory for a step: outdir/02_filter/. Returns nothing if outdir is nothing.
SMLMAnalysis.n_datasets — Function
n_datasets(ds::DataSource) -> IntNumber of datasets in this data source.
SMLMAnalysis.n_frames_per_dataset — Function
n_frames_per_dataset(ds::DataSource) -> IntFrames per dataset. For Vector{Array}, uses first element.