niftynet.contrib.dataset_sampler.sampler_grid_v2 module

Sampling image by a sliding window.

class GridSampler(reader, window_sizes, batch_size=1, spatial_window_size=None, window_border=None, queue_length=10, name='grid_sampler')[source]

Bases: niftynet.contrib.dataset_sampler.image_window_dataset.ImageWindowDataset

This class generators ND image samples with a sliding window.

layer_op()[source]
grid_spatial_coordinates(subject_id, img_sizes, win_sizes, border_size)[source]

This function generates all coordinates of feasible windows, with step sizes specified in grid_size parameter.

The border size changes the sampling locations but not the corresponding window sizes of the coordinates.

Parameters:
  • subject_id – integer value indicates the position of of this image in image_reader.file_list
  • img_sizes – a dictionary of image shapes, {input_name: shape}
  • win_sizes – a dictionary of window shapes, {input_name: shape}
  • border_size – size of padding on both sides of each dim
Returns: