SMLMVis.MIC
Overview
SMLMVis.MIC — ModuleTools and utilities for the visualization of data collected via the MATLAB Instrument Control Toolbox.
Basic Usage
Process one file using several keyword options
using SMLMVis
dirname = "C:/Data"
filename = "CellMovie"
fn = joinpath(dirname, filename * ".h5")
mic2mp4(fn; fps = 20, percentilerange = 0.99, zoom = 4, frame_range = 1:100)
Process a directory
using SMLMVis
dirname = "C:/Data"
# A little julia ...
files = filter(f -> endswith(f, ".h5"), readdir(dirname))
fullpathfiles = dirname .* "/" .* files
# Use broadcasting over the file names
mic2mp4.(fullpathfiles; fps = 20, percentilerange = 0.99)The first 50 frames in all datasets
using SMLMVis
dirname = "C:/Data"
savedir = "C:/Data/Results"
filename = "CellMovie"
fn = joinpath(dirname, filename * ".h5")
# Use comprehension over datasets and put results a different folder
n = SMLMVis.MIC.count_datasets(fn)
[mic2mp4(fn; savedir=savedir, fps=20, percentilerange=0.99, datasetnum=i, frame_range=1:50) for i in 1:n];API
SMLMVis.MIC.count_datasetsSMLMVis.MIC.isMICSMLMVis.MIC.isTIRFSMLMVis.MIC.mic2mp4SMLMVis.MIC.normalize!SMLMVis.MIC.readMIC
SMLMVis.MIC.count_datasets — Methodcount_datasets(filename::AbstractString; groupname::AbstractString="Channel01/Zposition001")Count the number of datasets in an HDF5 file.
Arguments
filename::AbstractString: The name of the HDF5 file to count datasets in.groupname::AbstractString: The name of the group to count datasets in. Default is "Channel01/Zposition001".
Returns
n_datasets::Int: The number of datasets in the specified group.
SMLMVis.MIC.isMIC — MethodisMIC(filename::AbstractString)Check if an HDF5 file has the expected group structure for a MIC file.
Arguments
filename::AbstractString: The name of the HDF5 file to check.
Returns
out::Bool:trueif the file has the expected group structure,falseotherwise.
SMLMVis.MIC.isTIRF — MethodisTIRF(filename::AbstractString)Check if the given HDF5 file contains TIRF (Total Internal Reflection Fluorescence) data.
Arguments
filename::AbstractString: The path to the HDF5 file to check.
Returns
Bool: Returnstrueif the file contains TIRF data,falseotherwise.
SMLMVis.MIC.mic2mp4 — Methodmic2mp4(filename::AbstractString;
savefilename::Union{Nothing,AbstractString}=nothing,
groupname::AbstractString="Channel01/Zposition001",
datasetnum::Int=1,
framenormalize::Bool=false,
fps::Int=30,
crf::Int=23,
percentilerange::Union{Real,Nothing}=nothing,
zoom::Int=1,
frame_range::Union{AbstractRange, Nothing}=nothing)Convert a MIC HDF5 file to an MP4 video.
This function converts a MIC HDF5 file to an MP4 video using the specified group, dataset number, frames per second, and constant rate factor. The output video is saved to the specified output file, or named after the input file if no output file is specified. If framenormalize is true, each frame of the dataset is normalized individually. The function returns nothing.
Arguments
filename::AbstractString: The name of the HDF5 file to convert.savefilename::Union{Nothing,AbstractString}: The name of the output MP4 file. Ifnothing, the output file is named after the input file. Default isnothing.savedir::Union{Nothing,AbstractString}: The output directory. Ifnothingpath is the same as the input file. Default isnothing.groupname::AbstractString: The name of the group to convert. Default is "Channel01/Zposition001".datasetnum::Int: The number of the dataset to convert. Default is 1.framenormalize::Bool: Whether to normalize each frame of the dataset individually. Default isfalse.fps::Int: The frames per second of the output video. Default is 30.crf::Int: The constant rate factor of the output video. Default is 10.percentilerange::Union{Real,Nothing}=nothing: The percentile range to use for normalization. Ifnothing, the full range ofarris used.zoom::Int: The zoom factor to apply to each frame. Default is 1.frame_range::Union{AbstractRange, Nothing}=nothing: The range of frames to use for the video. Ifnothing, all frames are used.
Returns
nothing
SMLMVis.MIC.normalize! — Methodnormalize!(arr::AbstractArray{<:Real}; minval::Union{Real,Nothing}=nothing, maxval::Union{Real,Nothing}=nothing, percentilerange::Union{Real,Nothing}=nothing)Normalize the input array arr in place. The normalization is done based on the minimum and maximum values of the array, or based on a percentile range if percentilerange is provided.
Arguments
arr::AbstractArray{<:Real}: The array to be normalized.minval::Union{Real,Nothing}=nothing: The minimum value to use for normalization. Ifnothing, the minimum value ofarris used.maxval::Union{Real,Nothing}=nothing: The maximum value to use for normalization. Ifnothing, the maximum value ofarris used.percentilerange::Union{Real,Nothing}=nothing: The percentile range to use for normalization. Ifnothing, the full range ofarris used.
Returns
nothing: The function modifiesarrin place and does not return anything.
SMLMVis.MIC.readMIC — MethodreadMIC(filename::AbstractString;
groupname::AbstractString="Channel01/Zposition001",
datasetnum::Int=1)Read data from a MIC HDF5 file.
Arguments
filename::AbstractString: The name of the HDF5 file to read data from.groupname::AbstractString: The name of the group to read data from. Default is "Channel01/Zposition001".datasetnum::Int: The number of the dataset to read. Default is 1.
Returns
data::Array: The data read from the specified dataset.