API Reference

quanfima.morphology module

quanfima.simulation module

quanfima.simulation.additive_noise(params, noise_lvl, smooth_lvl, use_median=True, median_rad=3)[source]

Contaminates datasets with a speficied additive Gaussian noise and smoothing level.

Contaminates the datasets (generated with generate_datasets function) with the specified level of additive Gaussian noise and smoothing, uneven illumination can be added by extracting blobs from params tuple with some other arguments.

params : tuple
Contains name, dataset_path, blobs, output_dir arguments passed from generate_noised_data.
noise_level : float
Indicates the standard deviations of noise.
smooth_level : float
Indicates the sigma value of Gaussian filter.
use_median : boolean
Specifies if the median filter should be applied after addition of noise.
median_rad : integer
Indicates the size of median filter.
datasets_props : dict
The dictionary containing the path to the reference dataset, the path to the contaminated dataset, the generated name, the SNR level, the precision, the recall and f1-score, and the level of noise and smoothing.
quanfima.simulation.generate_blobs(volume_size, blob_size_fraction=0.1, transparency_ratio=0.5, sigma=90.0)[source]

Generates random blobs smoothed with Gaussian filter in a volume.

Generates several blobs of random size in a volume using function from scikit-image, which are subsequently smoothed with a Gaussian filter of a large sigma to imitate 3D uneven illumination of the volume.

volume_size : tuple
Indicates the size of the volume.
blob_size_fraction : float
Indicates the fraction of volume occupied by blobs.
transparency_ratio : float
Indicates the transparency of blobs in a range [0, 1].
sigma : float
Indicates the sigma of Gaussian filter.
blobs_smeared : ndarray
The volume with smoothed blobs of a specified transparency.
quanfima.simulation.generate_datasets(volume_size=(512, 512, 512), n_fibers=50, radius_lim=(4, 10), length_lim=(0.2, 0.8), gap_lim=(3, 10), max_fails=100, median_rad=3, intersect=False, output_dir=None, params=None)[source]

Simulates speficied configurations of fibers and stores in a npy file.

Simulates a number of fiber configurations speficied in params with n_fibers of the radii and lengths in ranges radius_lim and length_lim, separated with gaps in a range of gap_lim. The simulation process stops if the number of attempts to generate a fiber exceeds max_fails.

volume_size : tuple
Indicates the size of the volume.
n_fibers : integer
Indicates the number of fibers to be generated.
radius_lim : tuple
Indicates the range of radii for fibers to be generated.
length_lim : tuple
Indicates the range of lengths for fibers to be generated.
gap_lim : tuple
Indicates the range of gaps separating the fibers from each other.
max_fails : integer
Indicates the maximum number of failures during the simulation process.
median_rad : integer
Indicates the radius of median filter to fill holes occured due to rounding of coordinates of the generated fibers.
intersect : boolean
Specifies if generated fibers can intersect.
output_dir : str
Indicates the path to the output folder where the data will be stored.
params : dict
Indicates the configurations of orientation of fibers to be generated.
out : dict
The dictionary of generated datasets of specified configurations.
quanfima.simulation.generate_noised_data(datasets_path, noise_levels=[0.0, 0.15, 0.3], smooth_levels=[0.0, 1.0, 2.0], blobs=None, use_median=True, median_rad=3, output_dir=None, n_processes=9)[source]

Contaminates datasets with a speficied additive Gaussian noise and smoothing level.

Contaminates the datasets (generated with generate_datasets function) with the specified level of additive Gaussian noise and smoothing, uneven illumination can be added if blobs is provided. The contaminating process can be performed in a parallel n_processes processes.

datasets_path : str
Indicates the path to dataset.
noise_levels : array
Indicates the array of standard deviations of noise.
smooth_levels : array
Indicates the array of sigma values of Gaussian filter.
blobs : ndarray
Indicates the volume of uneven illumination generated by generate_blobs.
use_median : boolean
Specifies if the median filter should be applied after addition of noise.
median_rad : integer
Indicates the size of median filter.
output_dir : str
Indicates the path to the output folder where the data will be stored.
n_processes : integer
Indicates the number of parallel processes.
results : array of dicts
The array of dictionaries containing paths to contaminated datasets, and other properties.
quanfima.simulation.generate_particle_dataset(volume_size=(512, 512, 512), n_particles=500, radius_lim=(4, 10), max_fails=100, output_dir=None)[source]

Simulates a speficied number of particles and stores complete dataset in a npy file.

volume_size : tuple
Indicates the size of the volume.
n_particles : integer
Indicates the number of particles to be generated.
radius_lim : tuple
Indicates the range of radii for particles to be generated.
max_fails : integer
Indicates the maximum number of failures during the simulation process.
output_dir : str
Indicates the path to the output folder where the data will be stored.
out : dict
The dictionary of generated dataset.
quanfima.simulation.mkfiber(dims_size, length, radius, azth, lat, offset_xyz)[source]

Computes fiber coordinates and its length.

Computes a fiber of speficied length, radius, oriented under azimuth azth and latitude / elevation lat angles shifted to offset_xyz from the center of a volume of size dims_size.

dims_size : tuple
Indicates the size of the volume.
length : integer
Indicates the length of the simulated fiber.
radius : integer
Indicates the radius of the simulated fiber.
azth : float
Indicates the azimuth component of the orientation angles of the fiber in radians.
lat : float
Indicates the latitude / elevation component of the orientation angles of the fiber in radians.
offset_xyz : tuple
Indicates the offset from the center of the volume where the fiber will be generated.
fiber_pts, fiber_len : tuple of array and number
The array of fiber coordinates and the length.
quanfima.simulation.random_in(rng, number=1)[source]

Returns a random value within a given range.

quanfima.simulation.simulate_fibers(volume_shape, n_fibers=1, radius_lim=(4, 10), length_lim=(0.2, 0.8), lat_lim=(0, 3.141592653589793), azth_lim=(0, 3.141592653589793), gap_lim=(3, 10), max_fails=10, max_len_loss=0.5, intersect=False)[source]

Simulates fibers in a volume.

Simulates n_fibers of the radii and lengths in ranges radius_lim and length_lim, oriented in a range of azimuth azth_lim and latitude elevation ‘lat_lim’ angles, separated with a gap in a range of gap_lim. The simulation process stops if the number of attempts to generate a fiber exceeds max_fails.

volume_shape : tuple
Indicates the size of the volume.
n_fibers : integer
Indicates the number of fibers to be generated.
radius_lim : tuple
Indicates the range of radii for fibers to be generated.
length_lim : tuple
Indicates the range of lengths for fibers to be generated.
lat_lim : tuple
Indicates the range of latitude / elevation component of the orientation angles of the fibers to be generated.
azth_lim : tuple
Indicates the range of azimuth component of the orientation angles of the fibers to be generated.
gap_lim : tuple
Indicates the range of gaps separating the fibers from each other.
max_fails : integer
Indicates the maximum number of failures during the simulation process.
max_len_loss : float
Indicates the maximum fraction of the generated fiber placed out of volume, exceeding which the fiber is counted as failed.
intersect : boolean
Specifies if generated fibers can intersect.
(volume, lat_ref, azth_ref, diameter, n_generated, elapsed_time) : tuple of arrays and numbers
The binary volume of generated fibers, the volumes of latitude / elevation and azimuth angles at every fiber point, the volume of diameters at every fibers point, the number of generated fibers and the simulation time.
quanfima.simulation.simulate_particles(volume_shape, n_particles=1, radius_lim=(3, 30), max_fails=10)[source]

Simulates particles in a volume.

Simulates n_particles of the radii in a range radius_lim. The simulation process stops if the number of attempts to generate a particle exceeds max_fails.

volume_shape : tuple
Indicates the size of the volume.
n_particles : integer
Indicates the number of particles to be generated.
radius_lim : tuple
Indicates the range of radii for particles to be generated.
max_fails : integer
Indicates the maximum number of failures during the simulation process.
(volume, diameter, n_generated, elapsed_time) : tuple of arrays and numbers
The binary volume of generated particles, the volume of diameters at every point of particles, the number of generated particles and the simulation time.
quanfima.simulation.unpack_additive_noise(args)[source]

Unpack arguments and return result of additive_noise function.

quanfima.utils module

quanfima.visualization module