Fix for non-scalar output and csv output
@@ -28,6 +28,9 @@ class ClassifierSamplesAggregator(ImageWindowsAggregator):
self.name = name
self.output_path = os.path.abspath(output_path)
self.output_interp_order = 0
+ self.csv_path = os.path.join(self.output_path, 'niftynet_out.csv')
+ if os.path.exist(self.csv_path):
+ os.remove(self.csv_path)
def decode_batch(self, window, location):
"""
@@ -48,7 +51,7 @@ class ClassifierSamplesAggregator(ImageWindowsAggregator):
def _save_current_image(self, image_out):
if self.input_image is None:
return
- window_shape = [1, 1, 1, 1, 1]
+ window_shape = [1, 1, 1, 1, image_out.shape[-1]]
image_out = np.reshape(image_out, window_shape)
for layer in reversed(self.reader.preprocessors):
if isinstance(layer, DiscreteLabelNormalisationLayer):
@@ -61,4 +64,8 @@ class ClassifierSamplesAggregator(ImageWindowsAggregator):
image_out,
source_image_obj,
self.output_interp_order)
+
+ with open(self.csv_path,'ab') as f:
+ np.savetxt(f, image_out[0,0,0,0,:], delimiter=",")
+
return
