SMLMVis.MIC

Overview

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_datasetsMethod
count_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.
source
SMLMVis.MIC.isMICMethod
isMIC(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: true if the file has the expected group structure, false otherwise.
source
SMLMVis.MIC.isTIRFMethod
isTIRF(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: Returns true if the file contains TIRF data, false otherwise.
source
SMLMVis.MIC.mic2mp4Method
mic2mp4(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. If nothing, the output file is named after the input file. Default is nothing.
  • savedir::Union{Nothing,AbstractString}: The output directory. If nothing path is the same as the input file. Default is nothing.
  • 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 is false.
  • 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. If nothing, the full range of arr is 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. If nothing, all frames are used.

Returns

  • nothing
source
SMLMVis.MIC.normalize!Method
normalize!(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. If nothing, the minimum value of arr is used.
  • maxval::Union{Real,Nothing}=nothing: The maximum value to use for normalization. If nothing, the maximum value of arr is used.
  • percentilerange::Union{Real,Nothing}=nothing: The percentile range to use for normalization. If nothing, the full range of arr is used.

Returns

  • nothing: The function modifies arr in place and does not return anything.
source
SMLMVis.MIC.readMICMethod
readMIC(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.
source