API reference

Backends and transfers

ParticleHolography.backendFunction
backend()

Return the process-wide default backend. A new Julia process starts with CPU. Call backend(:cpu), backend(:cuda), or backend(:metal) to change it. Explicit backend arguments remain available for side-by-side comparisons.

source
backend(kind; device=nothing)

Select and return the process-wide default execution backend. kind is :cpu, :cuda, :metal, or :auto. Subsequent calls that omit a backend use this selection. :auto prefers CUDA, then Metal, and always falls back to CPU.

Changing the default while concurrent tasks are running is unsupported. Pass an explicit backend object to each call when CPU and GPU work must coexist.

source
ParticleHolography.synchronize_backendFunction
synchronize_backend(backend)

Wait for queued work on an execution backend. Use this before timing GPU work. The longer name avoids collisions with functions exported by CUDA.jl/Metal.jl.

source
ParticleHolography.propagation_gridFunction
propagation_grid([backend], shape, wavelength, pixel_pitch)

Construct the distance-independent spatial-frequency grid used by the angular-spectrum method. shape may be a square side length or (height, width). All length parameters must use the same unit.

source
ParticleHolography.propagation_kernelFunction
propagation_kernel([backend], distance, wavelength, grid)

Construct the angular-spectrum propagation multiplier for distance. The kernel is stored in the order consumed directly by plan_fft.

source
ParticleHolography.pad2dFunction
pad2d(input[, target_shape]; mode=:mean)

Centre input in a larger 2-D array. The default target is twice each input dimension. mode=:mean fills the border with the input mean; mode=:zero uses zero. The result stays on the input backend.

source

Plans and reconstruction

ParticleHolography.phase_retrieval!Function
phase_retrieval!(plan, hologram1, hologram2; iterations=10)

Run Gerchberg-Saxton phase retrieval using buffers owned by plan. The returned Wavefront aliases the plan workspace and is overwritten by the next call. Use phase_retrieval when an owning copy is required.

source
ParticleHolography.ReconstructionRequestType
ReconstructionRequest(slices; volume=Float32, min_projection=nothing)

Describe the outputs to produce during one depth scan. Real-valued volume types store intensity, complex types store the propagated wavefront, and nothing avoids allocating that output. volume accepts N0f8, Float32, ComplexF32, ComplexF64, or nothing; min_projection accepts N0f8, Float32, or nothing.

source
ParticleHolography.MemoryDiagnosticType

Conservative memory estimate for a reconstruction plan and output request. required_bytes is the new allocation covered by scope; safe is missing when the backend cannot report available memory.

source
ParticleHolography.memory_diagnosticFunction
memory_diagnostic(backend, working_shape, request;
                  output_shape=working_shape, include_plan=true,
                  safety_factor=1.2)

Estimate new plan, output, and conversion allocations before reconstruction. The estimate is conservative because FFT libraries do not expose every internal allocation. Metal reports unified host/device memory.

source

Return a conservative memory estimate for an existing phase-retrieval plan.

source
ParticleHolography.reconstructFunction
reconstruct(plan, wavefront, request)

Generate the requested volume and MinIP in one propagation pass. Access the outputs as result.volume and result.min_projection; an unrequested output is nothing. Set check_memory=false only when the conservative preflight should not stop allocation.

source

Allocate and return a reconstructed intensity volume using a reusable plan.

source
ParticleHolography.reconstruct_paddedFunction
reconstruct_padded(plan, wavefront[, request]; mode=:mean)

Pad wavefront to the plan shape and reconstruct only the original central field of view. The propagation uses the padded plane, but no padded 3-D output volume is allocated.

source

Deprecated migration aliases

TransferSqrtPart, Transfer, transfer_sqrt, and transfer are retained as deprecated aliases or wrappers for source migration. New code should use PropagationGrid, PropagationKernel, propagation_grid, and propagation_kernel.

Filters, detection, calibration, and tracking

ParticleHolography.backendMethod
backend(kind; device=nothing)

Select and return the process-wide default execution backend. kind is :cpu, :cuda, :metal, or :auto. Subsequent calls that omit a backend use this selection. :auto prefers CUDA, then Metal, and always falls back to CPU.

Changing the default while concurrent tasks are running is unsupported. Pass an explicit backend object to each call when CPU and GPU work must coexist.

source
ParticleHolography.backendMethod
backend()

Return the process-wide default backend. A new Julia process starts with CPU. Call backend(:cpu), backend(:cuda), or backend(:metal) to change it. Explicit backend arguments remain available for side-by-side comparisons.

source
ParticleHolography.connected_component_labelingMethod
connected_component_labeling(image)

Label non-zero pixels using 8-way connectivity. The reference implementation runs on the host and returns consecutive UInt32 labels with zero reserved for the background. Device inputs are copied one image at a time.

source
ParticleHolography.dictloadMethod
dictload(filename)

Load a particle dictionary from a file in JSON format. The dictionary should have UUID keys and values as Vector{Float32}, which includes the coordinates (and diameters) of the particles.

Arguments

  • filename::String: The path to the file.

Returns

  • Dict: The loaded dictionary.
source
ParticleHolography.dictsaveMethod
dictsave(filename, dict)

Save a particle dictionary to a file in JSON format. The dictionary should have UUID keys and values as Vector{Float32}, which includes the coordinates (and diameters) of the particles.

Arguments

  • filename::String: The path to the file.
  • dict::Dict: The dictionary to save.

Returns

  • nothing
source
ParticleHolography.dilateMethod
dilate(volume)

Dilate each XY slice with a 3×3 neighbourhood. The operation stays on the input array's backend and preserves the v0.2 convention that boundary pixels remain false.

source
ParticleHolography.find_external_contoursMethod
find_external_contours(image)

Finds non-hole contours in binary images. This function is excuted on the CPU. Equivalent to CVRETREXTERNAL and CVCHAINAPPROX_NONE modes of the findContours() function provided in OpenCV.

Arguments

  • image: The binary image. the image should be a 2D array of 0 and 1.

Returns

  • Vector{Vector{CartesianIndex}}: A vector of contours. Each contour is a vector of CartesianIndex.
source
ParticleHolography.labonteMethod
labonte(frame1, frame2; kwargs...)

Apply the improved Labonté particle-correspondence algorithm to two frames. Input dictionaries are never mutated.

source
ParticleHolography.load_gray2floatMethod
load_gray2float(path)

Load a grayscale image from a file and return it as a Array{Float32, 2} array.

Arguments

  • path::String: The path to the image file.

Returns

  • Array{Float32, 2}: The image as a Float32 array.
source
ParticleHolography.load_grayimgMethod
load_grayimg(path)

Load a grayscale image from a file and return it as a Array{Gray{N0f8}, 2} array.

Arguments

  • path::String: The path to the image file.

Returns

  • Array{Gray{N0f8}, 2}: The image as a Gray{N0f8} array.
source
ParticleHolography.make_backgroundMethod
make_background(pathlist; mode=:mode)

Make a background image from a list of image paths. The background image is calculated by taking the mean or mode of the images in the list. The default mode is :mode.

Arguments

  • pathlist::Vector{String}: A list of image paths. glob() can be used to generate this list.
  • mode::Symbol: The mode to use for calculating the background. Options are :mean or :mode. Default is :mode.

Returns

  • Array{Float64, 2}: The background image.
source
ParticleHolography.make_background_modeMethod
make_background_mode(images; backend=backend())

Compute the per-pixel 8-bit mode without allocating the former 256 × height × width vote volume. GPU inputs are staged to the host once; this preprocessing step deliberately favours bounded memory over acceleration.

source
ParticleHolography.memory_diagnosticFunction
memory_diagnostic(backend, working_shape, request;
                  output_shape=working_shape, include_plan=true,
                  safety_factor=1.2)

Estimate new plan, output, and conversion allocations before reconstruction. The estimate is conservative because FFT libraries do not expose every internal allocation. Metal reports unified host/device memory.

source
ParticleHolography.pad2dFunction
pad2d(input[, target_shape]; mode=:mean)

Centre input in a larger 2-D array. The default target is twice each input dimension. mode=:mean fills the border with the input mean; mode=:zero uses zero. The result stays on the input backend.

source
ParticleHolography.particle_bounding_boxesMethod
particle_bounding_boxes(binary_volume)

Connect slice components whenever their inclusive XY bounding boxes overlap. This keeps the original non-adjacent-z behaviour used to join fragmented holographic particle signatures.

source
ParticleHolography.phase_retrieval!Method
phase_retrieval!(plan, hologram1, hologram2; iterations=10)

Run Gerchberg-Saxton phase retrieval using buffers owned by plan. The returned Wavefront aliases the plan workspace and is overwritten by the next call. Use phase_retrieval when an owning copy is required.

source
ParticleHolography.piv_mapMethod
piv_map(backend, image1, image2; grid_size=128, interrogation_size=128, search_size=256)

Compute the same brute-force normalized-cross-correlation PIV map used in v0.2. CPU is the portable reference; CUDA.jl supplies the accelerated method. Metal currently uses the documented CPU fallback for this calibration step.

source
ParticleHolography.propagation_gridMethod
propagation_grid([backend], shape, wavelength, pixel_pitch)

Construct the distance-independent spatial-frequency grid used by the angular-spectrum method. shape may be a square side length or (height, width). All length parameters must use the same unit.

source
ParticleHolography.propagation_kernelMethod
propagation_kernel([backend], distance, wavelength, grid)

Construct the angular-spectrum propagation multiplier for distance. The kernel is stored in the order consumed directly by plan_fft.

source
ParticleHolography.reconstructMethod
reconstruct(plan, wavefront, request)

Generate the requested volume and MinIP in one propagation pass. Access the outputs as result.volume and result.min_projection; an unrequested output is nothing. Set check_memory=false only when the conservative preflight should not stop allocation.

source
ParticleHolography.reconstruct_paddedFunction
reconstruct_padded(plan, wavefront[, request]; mode=:mean)

Pad wavefront to the plan shape and reconstruct only the original central field of view. The propagation uses the padded plane, but no padded 3-D output volume is allocated.

source
ParticleHolography.synchronize_backendMethod
synchronize_backend(backend)

Wait for queued work on an execution backend. Use this before timing GPU work. The longer name avoids collisions with functions exported by CUDA.jl/Metal.jl.

source

Index