コード例 #1
0
 def sample_loader(self,
                   index,
                   load_seg=True,
                   load_pred=False,
                   backup=False):
     # If sample is a backup -> load it from pickle
     if backup: return self.load_sample_pickle(index)
     # Load the image with the I/O interface
     image = self.interface.load_image(index)
     # Create a Sample object
     sample = MIScnn_sample.Sample(index, image, self.interface.channels,
                                   self.interface.classes)
     # IF needed read the provided segmentation for current sample
     if load_seg:
         segmentation = self.interface.load_segmentation(index)
         sample.add_segmentation(segmentation)
     # IF needed read the provided prediction for current sample
     if load_pred:
         prediction = self.interface.load_prediction(
             index, self.output_path)
         sample.add_prediction(prediction)
     # Add optional details to the sample object
     sample.add_details(self.interface.load_details(index))
     # Return sample object
     return sample
コード例 #2
0
 def test_IOI_IMAGE_predictionhandling(self):
     interface = Image_interface(pattern="image")
     sample = MIScnn_sample.Sample("pred.image", self.img[:, :, 0], 1, 2)
     sample.add_prediction(self.seg[:, :, 0])
     interface.save_prediction(sample, self.tmp_data.name)
     pred = interface.load_prediction("pred.image", self.tmp_data.name)
     self.assertTrue(np.array_equal(pred, self.seg[:, :, 0]))
コード例 #3
0
ファイル: test_iointerfaces.py プロジェクト: sosaz009/MIScnn
 def test_IOI_NIFTI_predictionhandling(self):
     interface = NIFTI_interface(pattern="nifti")
     sample_list = interface.initialize(self.tmp_data.name)
     sample = MIScnn_sample.Sample("pred.nifti", np.asarray([0]), interface.channels, interface.classes)
     sample.add_prediction(self.seg);
     interface.save_prediction(sample, self.tmp_data.name)
     pred = interface.load_prediction("pred.nifti", self.tmp_data.name)
     self.assertTrue(np.array_equal(pred.reshape(self.seg.shape), self.seg))
コード例 #4
0
ファイル: test_iointerfaces.py プロジェクト: sosaz009/MIScnn
 def test_IOI_DICTIONARY_predictionhandling(self):
     my_dict = dict()
     my_dict["dict_sample"] = (self.img, self.seg)
     interface = Dictionary_interface(my_dict)
     sample_list = interface.initialize("")
     sample = MIScnn_sample.Sample("dict_sample", np.asarray([0]), 1, 2)
     sample.add_prediction(self.seg);
     interface.save_prediction(sample, "")
     pred = interface.load_prediction("dict_sample", "")
     self.assertTrue(np.array_equal(pred.reshape(self.seg.shape), self.seg))
コード例 #5
0
ファイル: test_iointerfaces.py プロジェクト: sosaz009/MIScnn
 def test_IOI_NIFTI_loading(self):
     interface = NIFTI_interface(pattern="nifti")
     sample_list = interface.initialize(self.tmp_data.name)
     img, extended = interface.load_image(sample_list[0])
     # Create a Sample object
     sample = MIScnn_sample.Sample(sample_list[0], img, interface.channels, interface.classes, extended)
     seg = interface.load_segmentation(sample_list[0])
     
     self.assertTrue(np.array_equal(img, self.img))
     self.assertTrue(np.array_equal(seg, self.seg))