niftynet.engine.image_window module¶
This module provides an interface for data elements passed from sampler to network.
-
class
niftynet.engine.image_window.
ImageWindow
(names, shapes, dtypes)¶ Bases:
object
Each window is associated with a tuple of coordinates. These data properties are used to create TF placeholders when constructing a TF graph. Samplers read the data specifications and fill the placeholder with data.
-
coordinates_placeholder
(name)¶ get coordinates placeholder, location name is formed using LOCATION_FORMAT
Parameters: name – input name string Returns: coordinates placeholder
-
classmethod
from_data_reader_properties
(source_names, image_shapes, image_dtypes, data_param)¶ Create a window instance with input data properties each property is grouped into dict, with pairs of image_name: data_value. Some input images is a concatenated data array from multiple data sources. example of input: source_names={
‘image’: (u’modality1’, u’modality2’), ‘label’: (u’modality3’,)},- image_shapes={
- ‘image’: (192, 160, 192, 1, 2), ‘label’: (192, 160, 192, 1, 1)},
- image_dtypes={
- ‘image’: tf.float32, ‘label’: tf.float32},
- data_param={
- ‘modality1’: ParserNamespace(spatial_window_size=(10, 10, 2)), ‘modality2’: ParserNamespace(spatial_window_size=(10, 10, 2)), ‘modality3’: ParserNamespace(spatial_window_size=(5, 5, 1))}
see niftynet.io.ImageReader for more details.
Parameters: - source_names – input image names
- image_shapes – tuple of image window shapes
- image_dtypes – tuple of image window data types
- data_param – dict of each input source specifications
Returns: an ImageWindow instance
-
image_data_placeholder
(name)¶ get the image data placeholder by name
Parameters: name – input name string Returns: image placeholder
-
match_image_shapes
(image_shapes)¶ if the window has dynamic shapes, this function infers the fully specified shape from the image_shapes
Parameters: image_shapes – Returns: dict of fully specified window shapes
-
placeholders_dict
(n_samples=1)¶ This function create a dictionary with items of {name: placeholders} name should match the queue input names placeholders corresponds to the image window data for each of these items an additional {location_name: placeholders} is created to hold the spatial location of the image window
Parameters: n_samples – specifies the number of image windows Returns: a dictionary with window data and locations placeholders
-
set_spatial_shape
(spatial_window)¶ overrides all spatial window defined in input modalities sections this is useful when do inference with a spatial window which is different from the training specifications
Parameters: spatial_window – tuple of integers specifying new shape Returns:
-