niftynet.engine.sampler_uniform module

Generating uniformly distributed image window from input image This can also be considered as a random cropping layer of the input image

class niftynet.engine.sampler_uniform.UniformSampler(reader, data_param, batch_size, windows_per_image, queue_length=10)

Bases: niftynet.layer.base_layer.Layer, niftynet.engine.image_window_buffer.InputBatchQueueRunner

This class generators samples by uniformly sampling each input volume currently the coordinates are randomised for spatial dims only, i.e., the first three dims of image.

This layer can be considered as a random cropping layer of the input image.

layer_op()

This function generates sampling windows to the input buffer image data are from self.reader() it first completes window shapes based on image data, then finds random coordinates based on the window shapes finally extract window with the coordinates and output a dictionary (required by input buffer) :return: output data dictionary {placeholders: data_array}

niftynet.engine.sampler_uniform.rand_spatial_coordinates(subject_id, img_sizes, win_sizes, n_samples=1)

win_sizes could be different, for example in segmentation network input image window size is 32x32x10, training label window is 16x16x10, the network reduces x-y plane spatial resolution. This function handles this situation by first find the largest window across these window definitions, and generate the coordinates. These coordinates are then adjusted for each of the smaller window sizes (the output windows are concentric).