pyMSDtorch.test_data.twoD package¶
Submodules¶
pyMSDtorch.test_data.twoD.build_test_data module¶
- pyMSDtorch.test_data.twoD.build_test_data.build_data_mixed_level_sets_2d(n_imgs=1000, n_peaks=3, n_xy=32, mask_radius=1.0, chunk=10)¶
- pyMSDtorch.test_data.twoD.build_test_data.build_data_standard_sets_2d(n_imgs=1000, n_peaks=3, n_xy=64, snr=1.0, mask_radius=2.0, chunk=10)¶
- pyMSDtorch.test_data.twoD.build_test_data.build_data_standard_sets_2d_time(n_imgs=1000, k_time_points=8, n_peaks=3, sigma=0.02, trend=0.01, dxy=0.01, cc=0.6, n_xy=64, normalize=True)¶
pyMSDtorch.test_data.twoD.diffusion_model module¶
- pyMSDtorch.test_data.twoD.diffusion_model.diffusion_2d(time_steps: int, mean_x: float = 0.0, mean_y: None | float = None, sigma_x: float = 0.01, sigma_y: float = 0.01, cc: float = 0.0) ndarray ¶
Generates a sequence of displacement steps. If mean_y = None, a random vector will be generated with length mean_x
- Parameters:
time_steps – The number of displacements to be generated
mean_x – The mean displacement in x
mean_y – The mean displacement in y. If set to None, a random vector will be generated.
sigma_x – The sigma in x
sigma_y – The sigma in y
cc – The correlation between the two
- Returns:
an array with displacements
- pyMSDtorch.test_data.twoD.diffusion_model.tst(show=False)¶
pyMSDtorch.test_data.twoD.noisy_gauss_2d module¶
- class pyMSDtorch.test_data.twoD.noisy_gauss_2d.DataMaker(n_peaks=1, sigma=1.26, n_xy=128, bump=0.0)¶
Bases:
object
A class that can be used to build training data for 2D peak picking classification. The returned data is a stack of 2D images consisting of noisy data, error free data and a ‘mask’.
- generate_data_with_normal_noise(n_images, snr=0.5, noise_sigma=4.0, noise_base=100.0, mask_radius=1.0, normalize='linear_scale')¶
Build a dataset with uniform noise at a set level
- Parameters:
n_images – The number of
snr – Signal to noise ratio
noise_sigma – standard deviation of the normal noise (the
` Gaussian sigma) :param noise_base: the base noise level (mean of gauss) :param mask_radius: The mask radius for ground_truth mask building :param normalize: scales noisy array
-if linear_scale, linearly scales to interval [-1,1]
- Returns:
ground truth image, mask and noisy images, class images
- generate_ground_truth_image_stack(n_images, mask_radius=1.0)¶
Build a ground truth set of images, and associated binary mask of that image.
- Parameters:
n_images – Number of images to generate.
mask_radius – used to build a binary mask derived from the ground truth image.
- Returns:
ground truth images and associated mask.
- class pyMSDtorch.test_data.twoD.noisy_gauss_2d.MixedNoiseDataMaker(n_peaks=1, sigma=1.26, n_xy=128, bump=0.0)¶
Bases:
object
A class that can be used to build training data for 2D peak picking classification. The returned data is a stack of 2D images consisting of noisy data, error free data and a class labels. The noise levels change for each peak.
- generate_data_with_normal_noise(n_images, snr_brackets=None, noise_sigma=4.0, noise_base=100.0, mask_radius=1.0, normalize='linear_scale')¶
Build a dataset with uniform noise at a set level
- Parameters:
n_images – The number of images to generate
snr_brackets – Signal to noise ratio
noise_sigma – standard deviation of the normal noise (the Gaussian sigma)
noise_base – the base noise level (mean of gauss)
mask_radius – The mask radius for ground_truth mask building
normalize – scales noisy array -if linear_scale, linearly scales to interval [0,1] using range obtained from whole dataset.
- Returns:
ground truth image, mask / class, noisy images, scaled noise images
- generate_ground_truth_image_stack(n_images, mask_radius=1.0)¶
Build a ground truth set of images, and associated binary mask of that image.
- Parameters:
n_images – Number of images to generate.
mask_radius – used to build a binary mask derived from the ground truth image.
- Returns:
ground truth images stacks and associated mask stacks. These stacks need to be further processed down to get actual images.
- set_snr_brackets(snr_brackets=None)¶
Set the brackets of the peak signal to noise levels for each peak.
- Parameters:
snr_brackets – An array of psnr values.
- Returns:
void.
- pyMSDtorch.test_data.twoD.noisy_gauss_2d.run_tst(n_xy=1000, n_imgs=1)¶
- pyMSDtorch.test_data.twoD.noisy_gauss_2d.tst(show=True, n_xy=1000, n_imgs=10)¶
Provides a simple check if the peaks are generated Also serves as an indication how to use the above class.
- Parameters:
show – If True 3 sample images will be shown.
n_xy – Dimensions of the box
n_imgs – Number of images generated
- Returns:
True is test is passed
- pyMSDtorch.test_data.twoD.noisy_gauss_2d.tst_mixed(show=True, n_xy=32, n_imgs=10)¶
Displays data for mixed noise data.
pyMSDtorch.test_data.twoD.noisy_gauss_2d_time module¶
- class pyMSDtorch.test_data.twoD.noisy_gauss_2d_time.DataMaker(n_peaks=1, sigma=0.05, trend=0.0, dxy=0.01, cc=0.5, n_xy=128, bump=4.0)¶
Bases:
object
A class that can be used to build training data for 2D peak picking classification of peaks that diffuse in a 2D plane. The returned data is a stack of 3D images, with two spatial coordinates and one time axis. Returned is noisy data, error free data and a ‘mask’.
- generate_data_with_uniform_noise(m_images, k_time_steps, noise_level=1.0, mask_radius=1.0)¶
Build a dataset with uniform noise at a set level
- Parameters:
m_images – The number of images
k_time_steps – The number of time steps
noise_level – The noise level, data drawn from U(0,noise_level)
mask_radius – The mask radius for ground_truth mask building
- Returns:
ground truth image, mask and noisy images
- generate_ground_truth_image_stack(m_images, k_time_points, mask_radius=1.0)¶
Build a ground truth set of images, and associated binary mask of that image.
- Parameters:
m_images – Number of images to generate.
k_time_points – Number of time points to generate
mask_radius – used to build a binary mask derived from the ground truth image.
- Returns:
ground truth images and associated mask.
- pyMSDtorch.test_data.twoD.noisy_gauss_2d_time.run_tst(n_xy=1000, n_times=10, n_imgs=1)¶
- pyMSDtorch.test_data.twoD.noisy_gauss_2d_time.tst(show=False, n_xy=64, n_times=10, n_img=1)¶
Provides a simple check if the peaks are generated Also serves as an indication how to use the above class.
- Parameters:
show – If True the full time series will be shown.
n_xy – Spatial dimension of box.
n_times – Number of time steps.
n_img – Number of movies made.
- Returns:
True is test is passed.
pyMSDtorch.test_data.twoD.random_shapes module¶
- class pyMSDtorch.test_data.twoD.random_shapes.Rectangle(height=0.2, width=0.05, n_xy=64)¶
Bases:
Shape
- class pyMSDtorch.test_data.twoD.random_shapes.Shape(n_xy=64)¶
Bases:
object
Base class for shapes.
- get_random_rotation()¶
Rotates the canvas in a random fashion
- Returns:
return image in random rotation
- pyMSDtorch.test_data.twoD.random_shapes.build_random_shape_set(n_train, n_test, n_validate, noise_level=0.1, n_xy=64)¶
Build 3 h5 files containing test data with random shapes. Uses standard filenames: train_shapes_2d.hdf5, etc etc
- Parameters:
n_train – number of training images
n_test – number of test images
n_validate – number of validation images
noise_level – noise level
n_xy – canvas size
- Returns:
- pyMSDtorch.test_data.twoD.random_shapes.build_random_shape_set_numpy(n_imgs, noise_level=0.1, n_xy=64)¶
Build a numpy array with random shapes. Returned is a dictionairy with results
- Parameters:
n_imgs (number of images) –
noise_level (noise level) –
n_xy (canvas size) –
- Return type:
GroundTruth, Noisy, ClassImage,Label
- pyMSDtorch.test_data.twoD.random_shapes.get_random_object(noise_level=0.1, n_xy=64)¶
Build a random shape with fixed uniform noise level
- Parameters:
noise_level – uniform noise level
n_xy – canvas size
- Returns:
a random shape
- pyMSDtorch.test_data.twoD.random_shapes.random_circle(radius=(0.1, 0.4), n_xy=64)¶
Build a random circle
- Parameters:
radius – radius range
n_xy – canvas size
- Returns:
a random circle
- pyMSDtorch.test_data.twoD.random_shapes.random_donut(radius=None, width=None, n_xy=64)¶
Build a random donut
- Parameters:
radius – radius range
width – fractional width range, relatrive to radius
n_xy – canvas size
- Returns:
a random donut
- pyMSDtorch.test_data.twoD.random_shapes.random_rectangle(width=(0.1, 0.2), height=(0.3, 0.4), n_xy=64)¶
Build a rectangle of random size
- Parameters:
width – width range
height – height range
n_xy – canvas size
- Returns:
a random rectangle
- pyMSDtorch.test_data.twoD.random_shapes.random_triangle(width=(0.1, 0.35), n_xy=64)¶
Build a random right equilateral triangle
- Parameters:
width – width range
n_xy – canvas size
- Returns:
a random triangle
pyMSDtorch.test_data.twoD.torch_hdf5_loader module¶
- class pyMSDtorch.test_data.twoD.torch_hdf5_loader.Hdf5Dataset2D(filename, x_label, y_label, transform=None, max_size=None)¶
Bases:
Dataset
A pytorch compatible dataset object with input and output based on a single hdf5 file. To be used in tandem with the pyMSDtorch 2d data generators
- class pyMSDtorch.test_data.twoD.torch_hdf5_loader.Hdf5Dataset2DClasses(filename, x_label, y_label, transform=None, max_size=None)¶
Bases:
Dataset
A pytorch compatible dataset object with input and output based on a single hdf5 file. To be used in tandem with the noisy_2d scripts
- class pyMSDtorch.test_data.twoD.torch_hdf5_loader.Hdf5Dataset2Dtime(filename, x_label, y_label, transform=None, max_size=None, time_point=None)¶
Bases:
Dataset
A pytorch compatible dataset object with input and output based on a single hdf5 file. To be used with the 2D + time simulation code.
- pyMSDtorch.test_data.twoD.torch_hdf5_loader.tst()¶
pyMSDtorch.test_data.twoD.tst module¶
- pyMSDtorch.test_data.twoD.tst.hello_world(a, b, cc)¶
- Parameters:
a –
b –
cc –
- Returns: