niftynet.engine.image_window_buffer module

This module define queues that stores training/evaluation images (and labels)

class InputBatchQueueRunner(capacity, shuffle=True)[source]

Bases: object

This class defines a light wrapper around queue objects for input windows, and the coordinates describes the original location of the window.

After initialisation, run_threads() can be called with tf.session and tf.coordinator to start generating samples with multiple threads.

The sampling threads can be stopped by: close_all() called externally – all threads quit immediately.

pop_batch_op()[source]

This function is used when connecting a sampler output to a network. e.g.:

data_dict = self.get_sampler()[0].pop_batch_op(device_id)
net_output = net_model(data_dict, is_training)

Caution

Note it squeezes the output tensor of 6 dims [batch, x, y, z, time, modality] by removing all dims along which length is one.

Returns:a tensorflow graph op
run_threads(session, coord, num_threads=1)[source]

This function should be called by application.driver, where a session and coordinator is maintained, it starts sampling threads to fill the queue.

Note that the threads will be blocked if there’s no dequeue_op running, or number of samples is less than the dequeue batch size.

Parameters:
  • session – a tensorflow session
  • coord – a tensorflow coordinator
  • num_threads – integer specifies the number of threads
Returns:

close_all()[source]

This function stops all threads immediately and close the queue. Further enqueue/dequeue operation raises errors