ColonyImages

Documentation for ColonyImages.

ColonyImages.analysis_parametersType
analysis_parameters

A struct for holding parameters related to the analysis.

Fields

  • plot_theme::Attributes: An Attributes object for setting the theme of the plots. Default is a Theme object with a fontsize of 25, a size of (1000,800), a markersize of 15 for Scatter plots, and a linewidth of 4 for Lines plots.

Example

params = analysis_parameters()
source
ColonyImages.parametersType
parameters

A struct that holds various parameters for colony image processing, creation and analysis.

Fields

  • time_points::Vector{Float64}: The time points for the analysis. Default is [0,48,96,144].
  • threshold_conv::Float64: The threshold for the convolution. Default is 0.8.
  • threshold_c::Float64: Another threshold parameter. Default is 0.8.
  • kernel_ratio::Float64: The ratio for the kernel. Default is 0.4.
  • steps_angular::Int: The number of angular steps. Default is 360.
  • samples_pair::Int: The number of sample pairs. Default is 2000000.
  • timesteps::Int64: The number of time steps. Default is 300.
  • im_size::Vector{Int}: The size of the image. Default is [600,600].
  • stacks::Int: The number of stacks, which is the length of time_points.
  • radius_colony::Int: The radius of the colony. Default is round(Int,(im_size[1]*0.05)).
  • Center::Vector{Int}: The center of the image. Default is round.(Int,im_size./2).
  • growth_rate::Float64: The growth rate of the colony. Default is [0.02971700864000873,0.0,.0,.0] The 3 additional terms are only relevant for an addtional sigmodal growth component.
  • colony_size::Function: A function to calculate the size of the colony. Default is t-> (1+growth_rate[1]).^t + growth_rate[2] ./ (1 .+ exp.(-growth_rate[3] .* (t .- growth_rate[4]))).
  • relative_size_filles_holes::Float64: The relative size of filled holes. Default is 0.01.
  • laplac_kernel::Matrix{Int}: The Laplacian kernel. Default is [0 1 0; 1 -4 1; 0 1 0].
  • colony_nr::Int: The number of colonies. Default is 4.
  • colonies::Vector{String}: The names of the colonies. Default is ["Colony x artifical" for x in 1:colony_nr].
  • plot_factor::AbstractFloat: The factor for plotting. Default is 2.0.
  • Points::Vector{Vector{Vector{Int}}}: The lattice points. Default is lattice_points(Int(maximum(im_size)÷2)).
  • col_size_add::Vector{Float64}: The additional size of the colony. Default is colony_size.(time_points).-1.
  • col_size_add_diff::Vector{Float64}: The difference in the additional size of the colony. Default is col_size_add[2:end]-col_size_add[1:end-1].
source
ColonyImages.DataFrame_ColonyMethod
DataFrame_Colony()

This function creates and returns an empty DataFrame with a predefined structure for storing analysis data in the ColonyImages package.

Returns

  • df: A DataFrame with the following columns:
    • data_set::String[]: A column for the dataset names.
    • colony::String[]: A column for the colony names.
    • time::Int[]: A column for the time points.
    • metric_OG::Vector{Vector{Int64}}: A column for the angular metric data calculated using the stacking approach. Each entry is a vector of integers.
    • metric_cov::Vector{Vector{Int64}}: A column for the angular metric data calculated using the convolution approach. Each entry is a vector of integers.
    • pair_OG::Vector{Vector{Int64}}: A column for the pair correlation calculated using the stacking approach. Each entry is a vector of integers.
    • pair_cov::Vector{Vector{Int64}}: A column for the pair correlation calculated using the convolution approach. Each entry is a vector of integers.
    • OG_size::Int[]: A column for the sizes of the colonies in pixels at t = 0, used for later normalizations.
    • border_points::Vector{Vector{CartesianIndex{2}}}: A column for the border points of the colonies. Each entry is a vector of CartesianIndex{2}.
    • Parameters::Vector{parameters}: A column for the parameters used in the simulation or analysis. Each entry is a parameters object.

Example

df = DataFrame_Colony()
source
ColonyImages.angular_metricMethod
angular_metric(img::Union{Matrix{<:Real}, BitMatrix}, center::Vector{Int}; steps::Int = 360)

Calculates an angular metric for a given image. The metric is a vector where each element represents the number of pixels in a certain angular sector of the image. The sectors are determined by dividing a circle centered at a given point into a certain number of equal parts.

Arguments

  • img::Union{Matrix{<:Real}, BitMatrix}: The input image.
  • center::Vector{Int}: The center of the circle.
  • steps::Int: The number of sectors into which the circle is divided. Default is 360.

Returns

  • A vector where each element represents the number of pixels in a certain angular sector of the image.
source
ColonyImages.anisotropy_indexMethod
anisotropy_index(X::Vector)

Calculates the anisotropy index of a vector X.

Arguments

  • X::Vector: The input vector for which the anisotropy index is to be calculated.

Returns

  • A scalar value representing the anisotropy index of X.

Notes

The anisotropy index is calculated as the difference between the maximum and minimum values of X, divided by the sum of the maximum and minimum values. Before the calculation, a moving average is applied to X using the moving_avg function.

source
ColonyImages.approx_radi_coloMethod
approx_radi_colo(img::Union{Matrix{<:Real}, BitMatrix})

Calculates the approximate diameter of a colony by summing up all the pixel values and taking the square root of the sum.

This function assumes that the pixel values represent the area of the colony. The diameter is then approximated using the formula for the diameter of a circle given its area.

Arguments

  • img::Union{Matrix{<:Real}, BitMatrix}: A 2D array representing the image. The pixel values are assumed to represent the area of the colony.

Returns

  • A float representing the approximate diameter of the colony.
source
ColonyImages.b_wMethod
b_w(img)

Converts a grayscale colony image into a binary image/BitArray. If more than half of the image is black, it inverts the image. This ensures that in the output image, the pixels inside the colony are always set to 1 and the background pixels to 0, regardless of the inversion status of the input image.

Arguments

  • img: The input image.

Returns

  • A binary image where the colony pixels are set to 1 and the background pixels are set to 0.
source
ColonyImages.build_artifical_colony!Method
build_artifical_colony!(center::Vector{Int}, img::AbstractArray}, radius::Int, points::Vector{Vector{Vector{Int}}})

This function constructs an artificial spherical colony within a given image. The colony is represented as a circle with a specified center and radius. The function directly modifies the input image.

Arguments

  • center::Vector{Int}: A vector representing the center coordinates of the colony.
  • img::AbstractArray: The input image where the colony will be built.
  • radius::Int: The radius of the colony.
  • points::Vector{Vector{Vector{Int}}}: A nested vector containing the points used to construct the colony.

Returns

  • The image with the built colony.
source
ColonyImages.build_circleMethod
build_circle(center::Vector{Int}, img::Union{Matrix{<:Real}, BitMatrix}, points::Vector{Vector{Vector{Int}}}; threshold = 0.8::Float64)

Creates a binary image with the same size as the input image. The binary image is a circle with a given center. The circle is built by iterating over a set of points and setting the corresponding pixel in the binary image to 1 if the point is within the circle. The occupation in the outermost circle band is calculated in each iteration and stored in the occupation vector. The function stops building the circle when the mean of the occupation vector is less than a given threshold.

Arguments

  • center::Vector{Int}: The center of the circle.
  • img::Union{Matrix{<:Real}, BitMatrix}: The input image.
  • points::Vector{Vector{Vector{Int}}}: A set of points used to build the circle.
  • threshold::Float64: The threshold for the mean of the occupation vector. Defaults to 0.8.

Returns

  • circle_kernel: A binary image representing the circle.
source
ColonyImages.centroidMethod
centroid(img::Union{Matrix{<:Real}, BitMatrix})

Calculates the centroid of a given image img.

The centroid is calculated as the average of the x and y coordinates of all non-zero pixels in the image, weighted by their intensity. The coordinates are then rounded to the nearest integer.

Arguments

  • img::Union{Matrix{<:Real}, BitMatrix}: A 2D array representing the image. Non-zero values are considered as part of the object to find the centroid of.

Returns

  • centroid_norm::Vector{Int64}: A vector containing the x and y coordinates of the centroid.
source
ColonyImages.convMethod
conv(img::Union{Matrix{<:Real}, BitMatrix}, kernel::Union{Matrix{<:Real}, BitMatrix})

Performs a convolution operation on an image using a given kernel. The input image and kernel are 2D arrays of Int or Float or Bool. The function returns a 2D Float64 array of the same size as the input image.

Arguments

  • img::Union{Matrix{<:Real}, BitMatrix}: The input image, a 2D array of Int, Float or Bool.
  • kernel::Union{Matrix{<:Real}, BitMatrix}: The kernel used for the convolution, a smaller 2D array of Int,Float or Bool.

Returns

  • A 2D Float64 array representing the convolved image.
source
ColonyImages.create_kernelMethod
create_kernel(rad::Int;  geometry::String = "circle")

Creates a binary image kernel with a given radius. The kernel can be either a circle or a square.

Arguments

  • rad::Int: The radius of the kernel.
  • geometry::String: The shape of the kernel. Can be either "circle" or "square". Defaults to "circle".

Returns

  • kernel: A 2D array representing the kernel.
source
ColonyImages.expand_colony_circular!Method
expand_colony_circular!(img::AbstractArray, points::Vector{Vector{Vector{Int}}}, center::Vector{Int}, pixels_to_add::Int)

This function expands an artifical colony in a circular pattern within an image. The expansion starts from the center of the colony and proceeds outward. The function directly modifies the input image.

Arguments

  • img::AbstractArray: The input image where the colony will be expanded.
  • points::Vector{Vector{Vector{Int}}}: A nested vector containing the points used to expand the colony.
  • center::Vector{Int}: A vector representing the center coordinates of the colony.
  • pixels_to_add::Int: The number of pixels to add to the colony.
source
ColonyImages.expand_colony_finger_radom_cov!Method
expand_colony_finger_radom_cov!(img::AbstractArray, pixels_to_add::Int, dir::Vector{Int}; dir_match_rate::AbstractFloat = 0.999, still_spawn_rate::AbstractFloat = 0.99, min_neigbour::Int = 2)

Expand the colony in the image img by adding pixels_to_add pixels. The expansion is done randomly at the border of the colony, but it is more likely to expand in the direction specified by dir. The border is determined by convolving the image with a Laplacian kernel and finding points where the convolution is greater than 0.1. The function modifies the input image in-place.

Arguments

  • img::AbstractArray: A 2D array representing the image of the colony. The colony is represented by 1s and the background by 0s.
  • pixels_to_add::Int: The number of pixels to add to the colony.
  • dir::Vector{Int}: A vector representing the preferred direction of expansion.
  • dir_match_rate::AbstractFloat: A float representing the threshold for the dot product between the preferred direction and the point. Default is 0.999.
  • still_spawn_rate::AbstractFloat: A float representing the probability of expanding in a direction opposite to dir. Default is 0.99.
  • min_neigbour::Int: The minimum number of neighboring points that must be occupied for a point to be added to the colony. Default is 2.

Example

img = zeros(100, 100)
img[50:55, 50:55] .= 1
expand_colony_finger_radom_cov!(img, 100, [1, 0])
source
ColonyImages.expand_colony_point!Method
expand_colony_point!(img::AbstractArray, cov_img::AbstractArray, point::Vector{Int})

Expands a colony at a given point in an image. The function uses a Laplacian kernel to convolve the image and find border points. If the given point is in the border points and is in the background of the image, it is added to the colony and the convolution image is updated.

Arguments

  • img::AbstractArray: The input image.
  • cov_img::AbstractArray: The convolution image.
  • point::Vector{Int}: The point at which to expand the colony.

Returns

  • The updated convolution image.
source
ColonyImages.expand_colony_radom_cov!Method
expand_colony_radom_cov!(img::AbstractArray, pixels_to_add::Int)

Expand the colony in the image img by adding pixels_to_add pixels. The expansion is done randomly at the border of the colony. The border is determined by convolving the image with a Laplacian kernel and finding points where the convolution is greater than 0.1. The function modifies the input image in-place.

Compared to expand_colony_radom!, this function is faster for large images and many pixels to add, but slower for small images and fewer pixels to add. This is due to the fact that the computationally heavy convolution only needs to be calculated once for the whole image, whereas the distance transform in expand_colony_radom needs to be calculated for each iteration of the loop.

Arguments

  • img::AbstractArray: A 2D array representing the image of the colony. The colony is represented by 1s and the background by 0s.
  • pixels_to_add::Int: The number of pixels to add to the colony.

Example

img = zeros(100, 100)
img[50:55, 50:55] .= 1
expand_colony_radom_cov!(img, 100)

Compared to expand_colony_radom!, this function is faster for large images and many pixels to add, but slower for small images and fewer pixels to add. This is due to the fact that the computational heavy convolution only needs to be calculated once for the whole image, whereas the distance transform in expand_colony_radom needs to be calculated for each iteration of the loop.

source
ColonyImages.expand_colony_radom_cov_show!Method
expand_colony_radom_cov!(img::AbstractArray, pixels_to_add::Int)

Expand the colony in the image img by adding pixels_to_add pixels. The expansion is done randomly at the border of the colony. The border is determined by convolving the image with a Laplacian kernel and finding points where the convolution is greater than 0.1. The function modifies the input image in-place.

Compared to expand_colony_radom!, this function is faster for large images and many pixels to add, but slower for small images and fewer pixels to add. This is due to the fact that the computationally heavy convolution only needs to be calculated once for the whole image, whereas the distance transform in expand_colony_radom needs to be calculated for each iteration of the loop.

Arguments

  • img::AbstractArray: A 2D array representing the image of the colony. The colony is represented by 1s and the background by 0s.
  • pixels_to_add::Int: The number of pixels to add to the colony.

Example

img = zeros(100, 100)
img[50:55, 50:55] .= 1
expand_colony_radom_cov!(img, 100)

Compared to expand_colony_radom!, this function is faster for large images and many pixels to add, but slower for small images and fewer pixels to add. This is due to the fact that the computational heavy convolution only needs to be calculated once for the whole image, whereas the distance transform in expand_colony_radom needs to be calculated for each iteration of the loop.

source
ColonyImages.expand_colony_un_random_cov!Method
expand_colony_un_radom_cov!(img::AbstractArray, pixels_to_add::Int, dir::Vector{Int}; still_spawn_rate::AbstractFloat = 0.5)

This function expands a colony in a given direction by adding pixels to the image.

Arguments

  • img::AbstractArray: A 2D array representing the image of the colony.
  • pixels_to_add::Int: The number of pixels to add to the colony.
  • dir::Vector{Int}: A vector representing the direction in which to expand the colony.
  • still_spawn_rate::AbstractFloat: The probability of adding a pixel even if it is not in the desired direction. Default is 0.5.

Example

img = zeros(100, 100)
img[50:55, 50:55] .= 1
expand_colony_un_radom_cov!(img, 100, [1, 0])
source
ColonyImages.expand_matrixMethod

expand_matrix(mat::Union{Matrix{<:Real}, BitMatrix}; annuli::Int = 2 )

Expands a matrix by adding zero-filled columns to its outermost right column and rotating it 90 degrees counterclockwise. This process is repeated 4 times per annulus. The number of additional bands (annuli) added to the matrix is determined by the annuli parameter.

Arguments mat::Union{Matrix{<:Real}, BitMatrix}: The input matrix. annuli::Int: The number of additional bands to be added to the matrix. Default is 2. Returns The expanded matrix. Examples

mat = [1 2; 3 4]
expand_matrix(mat, annuli = 1)
4×4 Matrix{Int64}:
 0  0  0  0
 0  1  2  0
 0  3  4  0
 0  0  0  0
source
ColonyImages.fill_holesMethod
fill_holes(img, size_holes::Real)

Fills holes in a binary image. The size of the holes to be filled is determined by the size_holes parameter.

Arguments

  • `img: The input binary image.
  • size_holes::Real: The relative size of the holes to be filled. This is a fraction of the total number of pixels in the image.

Returns

  • A binary image with the holes filled.
source
ColonyImages.filter_fourier_alphaMethod
filter_fourier_alpha(vec; a = 5)

Filters a vector by setting all elements after the a-th element to zero. This function is useful for filtering the results of a Fourier transform, where the elements of the vector represent the amplitudes of the frequencies, and the index of the element represents the frequency. By setting all elements after the a-th element to zero, we effectively remove all frequencies higher than a.

Arguments

  • vec::Vector{<:Real}: The input vector.
  • a::Int: The cutoff frequency. All frequencies higher than a are removed. Default is 5.

Returns

  • A new vector where all elements after the a-th element are zero.
source
ColonyImages.filter_fourier_betaMethod
filter_fourier_beta(vec::Vector{<:Real}; b::AbstractFloat = 0.5)

Filters a vector by setting all elements whose absolute value is less than or equal to b times the maximum absolute value of the elements to zero. This function is useful for filtering the results of a Fourier transform, where the elements of the vector represent the amplitudes of the frequencies. By setting all elements whose amplitude is less than or equal to b times the maximum amplitude to zero, we effectively remove all frequencies with low amplitudes.

Arguments

  • vec::Vector{<:Real}: The input vector.
  • b::AbstractFloat: The threshold for the amplitude. All frequencies with amplitudes less than or equal to b times the maximum amplitude are removed. Default is 0.5.

Returns

  • A new vector where all elements whose absolute value is less than or equal to b times the maximum absolute value are zero.
source
ColonyImages.find_freqMethod
find_freq(vec::Vector{<:Real}; ignore_latter_half = true )

Finds the frequencies in a vector that have non-zero amplitudes. This function is useful for analyzing the results of a Fourier transform, where the elements of the vector represent the amplitudes of the frequencies, and the index of the element represents the frequency.

Arguments

  • vec::Vector{<:Real}: The input vector.
  • ignore_latter_half::Bool: If true, the function only considers the first half of the vector. This is useful when the input vector is the result of a Fourier transform, where the second half of the vector contains the same information as the first half but in reverse order. Default is true.

Returns

  • A vector of the frequencies that have non-zero amplitudes.
source
ColonyImages.find_peaksMethod
find_peaks(signal::Vector{<:Real}; threshold::AbstractFloat = 1.0)

Finds the local maxima inside a 1D signal, in areas where the signal exceeds its mean value by a given factor.

Arguments

  • signal::Vector{<:Real}: The input 1D signal.
  • threshold::AbstractFloat: The factor by which the signal needs to exceed its mean value to be considered a peak. Default is 1.0.

Returns

  • position_peaks: A vector of the positions of the peaks in the signal.
  • nr_peaks: The number of peaks found in the signal.
source
ColonyImages.generate_dir_vecMethod
generate_dir_vec(para::parameters)

Generates vectors of x and y coordinates that span vectors ranging from 0 to 2π. This function is used to generate the vectors used in expand_colony_finger_radom_cov!.

Arguments

  • para::parameters: A parameters object containing various parameters for the analysis.
    • number_finger: The number of vectors to generate.
    • finger_dist: The random distance to add to the vectors.

Returns

  • dir::Array{Array{Float64,1},1}: A vector of vectors, each containing the y and x coordinates of a vector.

Example

using CairoMakie
para = parameters(number_finger = 20, finger_dist = 0.1)
dir = generate_dir_vec(para)
yy = zeros(para.number_finger)
arrows(yy,yy, [d[1] for d in dir], [d[2] for d in dir])
source
ColonyImages.growth_colonies!Method
growth_colonies(vec_of_sims::Vector{Vector{BitArray{3}}}, para::parameters, Points::Vector{Vector{Vector{Int}}})

Simulates the growth of colonies based on the provided parameters and initial conditions.

Arguments

  • vec_of_sims: A vector of 3D bit arrays representing the initial state of each colony.
  • para: An instance of the parameters struct containing the simulation parameters.
  • Points: A vector of vectors of vectors of integers representing the points in the colony.

Details

The function first creates an artificial colony using the build_artifical_colony! function. It then iterates over the simulations and colonies specified in para, expanding each colony at each time point based on the specified simulation type ("Random", "Fingerweak", or "Fingerstrong").

Example

growth_colonies(vec_of_sims, para, Points)
source
ColonyImages.initialize_coloniesMethod
initialize_colonies(para::parameters)

Initialize colonies for simulations.

Arguments

  • para::parameters: A parameters object containing simulation parameters.

Returns

  • vec_of_sims: A vector of vectors of BitArray{3} representing the initialized empty arrays which will later became colonies.
source
ColonyImages.lattice_pointsMethod
lattice_points(r::Int)

Generates asceding discrete lattice points within a circle of radius r.

The function returns a nested vector of points, each represented by its x and y coordinates. The points are sorted by their distance from the origin and grouped into bands with width 1, each band containing all points with the same first decicmal and an asceding distance to the origin.

Arguments

  • r::Int: The radius of the circle within which the lattice points are generated.

Returns

  • points3::Vector{Vector{Vector{Int}}}: A nested vector of points.

points3 is a vector of vectors of Lattice vectors in ascending order by their length . Whereas the first entry of Points contains a vector of all lattice vectors which lengths are lower than 2:

Points[1] = [[0, 1], [0, 1], [0, -1], [0, -1], [1, 0], [-1, 0], [1, 0], [-1, 0], [1, 1], [-1, 1], [1, -1], [-1, -1]]

Points[2] does the same for length lower than 3:

Points[2] = [[0, 2], [0, 2], [0, -2], [0, -2], [2, 0], [-2, 0], [2, 0], [-2, 0], [1, 2], [-1, 2], [1, -2], [-1, -2], [2, 1], [-2, 1], [2, -1], [-2, -1], [2, 2], [-2, 2], [2, -2], [-2, -2]]

and so on...

source
ColonyImages.moving_avgFunction
moving_avg(X::Vector, numofele::Int = length(X) ÷ 2)

Calculates the moving average of a vector X using a window of size numofele.

Arguments

  • X::Vector: The input vector for which the moving average is to be calculated.
  • numofele::Int: The number of elements to consider for the moving average (i.e., the window size). Defaults to half the length of X.

Returns

  • A vector of the same length as X where each element is the moving average of numofele elements centered around the corresponding element in X.

Notes

The function handles the edges by shrinking the window size so that it fits within the input vector.

source
ColonyImages.occupied_pointsMethod
occupied_points(img::Union{Matrix{<:Real}, BitMatrix})

Calculates the proportion of occupied points in a given binary image img.

The function sums up all the pixel values in the image and divides by the total number of pixels. This gives the proportion of occupied points, assuming that non-zero pixel values represent occupied points.

Arguments

  • img::Union{Matrix{<:Real}, BitMatrix}: A 2D array representing the image. Non-zero values are considered as occupied points.

Returns

  • A float representing the proportion of occupied points in the image.
source
ColonyImages.pair_cor_metric3Method
pair_cor_metric3(img::Union{Matrix{<:Real}, BitMatrix}, center::Vector{Int}; samples::Int = 10000, steps::Int = 360)

Calculates a pair correlation metric for a given image. The metric is a vector where each element represents the number of pairs of pixels that have a certain relative angle. The angles are determined by dividing a half-circle into a certain number of equal parts.

Arguments

  • img::Union{Matrix{<:Real}, BitMatrix}: The input image.
  • center::Vector{Int}: The reference point for calculating the relative angles.
  • samples::Int: The number of pairs of pixels to sample. Default is 10000.
  • steps::Int: The number of sectors into which the half-circle is divided. Default is 360.

Returns

  • A vector where each element represents the number of pairs of pixels that have a certain relative angle.
source
ColonyImages.plot_convolution_schematic2Method
plot_convolution_schematic2(colony::AbstractArray, colony_cov::AbstractArray, para::parameters; name = "cov_fig1")

This function creates a plot of a colony image and its convolution.

Arguments

  • colony::AbstractArray: A 3D array representing the colony image stack or a 2D array representing a single colony image.
  • colony_cov::AbstractArray: A 3D array representing the convoluted colony image stack or a 2D array representing a single convoluted colony image.
  • para::parameters: A parameters object containing various parameters for the analysis.
  • name::String: An optional name for the output plot. Default is "cov_fig1".

Returns

  • cov_fig::Figure: A Figure object containing the plots.

Details

The function first determines the type of the colony and colony_cov inputs and extracts the data for the last time point if they are 3D arrays.

It then creates a Figure object and two Axis objects for the original colony and the convoluted colony. It adds heatmaps to each of these axes using the respective data.

The function then iterates over each point in the images and adds a text object to each point in the heatmaps, displaying the value at that point.

Finally, the function saves the figure as a PNG image and returns the Figure object.

source
ColonyImages.plot_convolution_schematic3Method
plot_convolution_schematic3(colony, colony_cov, para; name = "cov_fig_kernel")

This function creates a schematic plot of a convolution operation on a colony image.

Arguments

  • colony::Array: A 3D array representing the colony image stack.
  • colony_cov::Array: A 3D array representing the convoluted colony image stack.
  • para::parameters: A parameters object containing various parameters for the analysis.
  • name::String: An optional name for the output plot. Default is "covfigkernel".

Returns

  • cov_fig_k::Figure: A Figure object containing the plots.

Details

The function first sets up a theme for the plot with a specific font size. It then extracts the data for the last time point from the colony and convoluted images. It creates a kernel and places it in a larger matrix of zeros.

The function then creates a Figure object and three Axis objects for the original colony, the kernel, and the convoluted colony. It adds heatmaps to each of these axes using the respective data.

The function then iterates over each point in the images and adds a text object to each point in the heatmaps, displaying the value at that point.

Finally, the function saves the figure as a PNG image and returns the Figure object.

source
ColonyImages.plot_metric_schematicMethod
plot_metric_schematic(colony::AbstractArray, para::parameters, colormap ; name = "metric_fig1")

This function creates a schematic plot of a colony image and how it is cut into angle section to be analysed later.

Arguments

  • colony::AbstractArray: A 3D array representing the colony image stack.
  • para::parameters: A parameters object containing various parameters for the analysis.
  • colormap: A colormap to use for the heatmap.
  • name::String: An optional name for the output plot. Default is "metric_fig1".

Returns

  • fig::Figure: A Figure object containing the plots.

Details

The function first creates a Figure object and extracts the first and last images from the colony stack. It creates a kernel based on the approximate radius of the colony and the kernel ratio parameter.

The function then cuts a portion of the last image and rotates it 90 degrees. It creates two Axis objects on the Figure and hides their decorations.

The function then cuts a portion of the first image and rotates it 90 degrees. It adds a heatmap to the first Axis, showing the difference between the last and first images.

The function then creates a pie chart on the second Axis, with each slice having an equal value, representing the angle sections of the colony.

Finally, the function returns the Figure object.

source
ColonyImages.plot_time_series_cov_centroidMethod
plot_time_series_cov_centroid(img_vec::AbstractArray, para::parameters)

Generates a time series plot of the centroids of the images in img_vec. The centroids are calculated in three ways:

  1. The original centroid of the first timestep of the timeseries.
  2. The centroid after applying a convolution operation.
  3. The current centroid of the image.

Arguments

  • img_vec::AbstractArray: A vector of 3D image stacks.
  • para::parameters: A parameters object containing various parameters for the analysis.
    • kernel_ratio::Float64: The ratio for the kernel operation. Default is 0.4.
    • plot_factor: The scaling factor for the plot size.
    • threshold_conv: The threshold for the convolution operation.
    • colonies: The names of the colonies.

Returns

  • fig_big::Figure: A Figure object with the time series plot of the centroids.

Example

img_vec = [rand(100, 100, 10) for _ in 1:5]
para = parameters(kernel_ratio = 0.4, plot_factor = 1, threshold_conv = 0.5, colonies = ["Colony i" for i in 1:5])
fig = plot_time_series_cov_centroid(img_vec, para)
source
ColonyImages.plot_time_series_metricsMethod
plot_time_series_metrics(img_vec, para)

This function creates a series of plots for each image in a stack, showing the original image, the angular metric, and the pair correlation metric.

Arguments

  • img_vec::Array: A 4D array where the first two dimensions are the image dimensions, the third dimension is the time point, and the fourth dimension is the image stack.
  • para::parameters: A parameters object containing various parameters for the analysis.

Returns

  • fig_big::Figure: A Figure object containing the plots.

Details

The function first creates a Figure object with a size determined by the res_scaling function. It then loops over each image stack in img_vec. For each stack, it calculates the centroid of the first image and creates a kernel based on the approximate radius of the colony in the image.

The function then loops over each time point in the image stack. For each time point, it calculates the centroid of the convoluted image and calculates the angular metric and pair correlation metric for the original image and the image minus the first image in the stack.

The function then fits a circle to the image and calculates the angular metric and pair correlation metric for the image minus the fitted circle.

The function then creates three Axis objects for the original image, the angular metric, and the pair correlation metric, and adds plots to each axis. If the time point is not the first, it also plots the angular metric and pair correlation metric for the image minus the fitted circle.

Finally, the function increments a counter and returns the Figure object after looping over all image stacks and time points.

source
ColonyImages.plot_timeseries_heatmapMethod
plot_timeseries_heatmap(colony::AbstractArray, para::parameters; name = "Eden Growth Model", colormap  = reverse(co.Blues))

This function creates a heatmap plot of a colony image stack over time.

Arguments

  • colony::AbstractArray: A 3D array representing the colony image stack.
  • para::parameters: A parameters object containing various parameters for the analysis.
  • name::String: An optional name for the output plot. Default is "Eden Growth Model".
  • colormap: An optional colormap to use for the heatmap. Default is the reverse of Blues.

Returns

  • fig_eden::Figure: A Figure object containing the heatmap plot.

Details

The function first creates a Figure object and an Axis object with the title set to the provided name. It then initializes an intensity image with zeros.

The function then iterates over the z-dimension of the colony stack, adding each image to the intensity image.

It then creates a heatmap on the Axis, showing the intensity image with the maximum intensity subtracted and the sign reversed.

The function then hides the decorations of the Axis and adds a colorbar to the Figure, with the ticks set to the time points and the label set to "time [h]".

Finally, the function saves the Figure as a PDF in the plots folder and returns the Figure object.

source
ColonyImages.rad2deg_discreteMethod
rad2deg_discrete(ϕ::AbstractFloat; steps::Int =360)

Converts an angle in radians to a discrete angle in degrees. The output is the number of a circular sector on a unit circle divided into a given number of sectors. For example, if the angle is 0.0 and the number of steps is 360, the output is 1, which corresponds to the first circular sector on the unit circle. If the angle is (2pi - 0.01) and the number of steps is 360, the output is 360, which corresponds to the last circular sector on the unit circle.

Arguments

  • ϕ::AbstractFloat: The input angle in radians.
  • steps::Int: The number of circular sectors into which the unit circle is divided. Default is 360.

Returns

  • The number of the circular sector to which the angle corresponds.
source
ColonyImages.res_scalingMethod
res_scaling(img_int_vec; factor = 3, plots = 1)

Scales the resolution of a plot based on a given factor. The function counts the number of images in the given image_vec and and scales the resolution of plot containg all these images accordingly.

Arguments

  • img_int_vec: A vector of images.
  • factor: The scaling factor. Defaults to 3.
  • plots: The number of plots per images. Defaults to 1.

Returns

  • A tuple containing the scaled width and height of the image.
source
ColonyImages.save_time_series_metrics!Method
save_time_series_metrics!(img_vec::AbstractArray, para::parameters, df::DataFrame; name_data="random_growth")

This function calculates and saves time series metrics for a given set of images.

Arguments

  • img_vec::AbstractArray: An array of image stacks.
  • para::parameters: An object containing various parameters for the analysis.
  • df::DataFrame: The DataFrame to which the calculated metrics will be appended.
  • name_data::String: (optional) A string representing the name of the data set. Default is "random_growth".

Returns

  • data_set::String: The name of the data set.
source
ColonyImages.@hMacro

@h methodname

Outputs documentations in jupyternotenbooks in VScode as markdown without bugs.

Example of how to use the @h macro:

@h res_scaling(img_int_vec; factor = 3, plots = 1)

Outputs documentations in jupyternotenbooks in VScode as markdown without bugs.

source