def test_inverse_mapping(self): reader = get_label_reader() sampler = ResizeSampler(reader=reader, data_param=MOD_LABEL_DATA, batch_size=1, shuffle_buffer=False, queue_length=50) aggregator = ResizeSamplesAggregator(image_reader=reader, name='label', output_path=os.path.join( 'testing_data', 'aggregated'), interp_order=0) more_batch = True with self.test_session() as sess: coordinator = tf.train.Coordinator() sampler.run_threads(sess, coordinator, num_threads=2) while more_batch: out = sess.run(sampler.pop_batch_op()) more_batch = aggregator.decode_batch(out['label'], out['label_location']) output_filename = '{}_niftynet_out.nii.gz'.format( sampler.reader.get_subject_id(0)) output_file = os.path.join('testing_data', 'aggregated', output_filename) self.assertAllClose(nib.load(output_file).shape, [256, 168, 256, 1, 1]) sampler.close_all()
def test_inverse_mapping(self): reader = get_label_reader() sampler = ResizeSampler(reader=reader, data_param=MOD_LABEL_DATA, batch_size=1, shuffle_buffer=False, queue_length=50) aggregator = ResizeSamplesAggregator( image_reader=reader, name='label', output_path=os.path.join('testing_data', 'aggregated'), interp_order=0) more_batch = True with self.test_session() as sess: coordinator = tf.train.Coordinator() sampler.run_threads(sess, coordinator, num_threads=2) while more_batch: out = sess.run(sampler.pop_batch_op()) more_batch = aggregator.decode_batch( out['label'], out['label_location']) output_filename = '{}_niftynet_out.nii.gz'.format( sampler.reader.get_subject_id(0)) output_file = os.path.join( 'testing_data', 'aggregated', output_filename) self.assertAllClose( nib.load(output_file).shape, [256, 168, 256, 1, 1]) sampler.close_all()
def test_3d_init(self): sampler = ResizeSampler(reader=get_3d_reader(), data_param=MULTI_MOD_DATA, batch_size=1, shuffle_buffer=False, queue_length=1) with self.test_session() as sess: coordinator = tf.train.Coordinator() sampler.run_threads(sess, coordinator, num_threads=2) out = sess.run(sampler.pop_batch_op()) self.assertAllClose(out['image'].shape, [1, 7, 10, 2, 2]) sampler.close_all()
def test_3d_init(self): sampler = ResizeSampler( reader=get_3d_reader(), data_param=MULTI_MOD_DATA, batch_size=1, shuffle_buffer=False, queue_length=1) with self.test_session() as sess: coordinator = tf.train.Coordinator() sampler.run_threads(sess, coordinator, num_threads=2) out = sess.run(sampler.pop_batch_op()) self.assertAllClose(out['image'].shape, [1, 7, 10, 2, 2]) sampler.close_all()