niftynet.contrib.segmentation_selective_sampler.sampler_selective module¶
Generating sample arrays from random distributions
-
class
SelectiveSampler
(reader, data_param, batch_size, windows_per_image, constraint, random_windows_per_image=0, queue_length=10)[source]¶ Bases:
niftynet.engine.sampler_uniform_v2.UniformSampler
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.
-
create_label_size_map
(data)[source]¶ This function creates the maps of label size. For each connected component of a label with value :value:, the binary segmentation is replaced by the size of the considered element :param data: segmentation :param value: value of the label to consider :return: count_data
-
candidate_indices
(win_sizes, data, constraint)[source]¶ This functions creates a binary map of potential candidate indices given the specified constraints and the recalculated probability to select each of
these candidates so as to uniformise the sampling according to the size of connected elementsParameters: - win_sizes –
- data – segmentation
- constraint – sampling constraint
Returns: candidates: binary map of potential indices, proba_fin:
corresponding maps of associated sampling probability
-
create_probability_weights
(candidates, mean_counts_size)[source]¶ This functions creates the probability weighting given the valid candidates and the size of connected components associated to this candidate :param candidates: binary map of the valid candidates :param mean_counts_size: counts attributed to each candidate :return: probability map for the selection of any voxel as candidate
-
rand_choice_coordinates
(subject_id, img_sizes, win_sizes, candidates, mean_counts_size=None, n_samples=1, n_samples_rand=0)[source]¶ 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).