How to use the miscnn.data_loading.sample.Sample function in miscnn

To help you get started, we’ve selected a few miscnn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frankkramer-lab / MIScnn / tests / test_subfunctions.py View on Github external
def setUpClass(self):
        np.random.seed(1234)
        # Create imgaging and segmentation data
        img2D = np.random.rand(16, 16) * 255
        img2D = img2D.astype(int)
        img3D = np.random.rand(16, 16, 16) * 255
        img3D = img3D.astype(int)
        seg2D = np.random.rand(16, 16) * 3
        seg2D = seg2D.astype(int)
        seg3D = np.random.rand(16, 16, 16) * 3
        seg3D = seg3D.astype(int)
        # Create testing samples
        self.sample2D = Sample("sample2D", img2D, channels=1, classes=3)
        self.sample2Dseg = Sample("sample2Dseg", img2D, channels=1, classes=3)
        self.sample3D = Sample("sample3D", img3D, channels=1, classes=3)
        self.sample3Dseg = Sample("sample3Dseg", img3D, channels=1, classes=3)
        # Add segmentation to seg samples
        self.sample2Dseg.add_segmentation(seg2D)
        self.sample3Dseg.add_segmentation(seg3D)
github frankkramer-lab / MIScnn / tests / test_subfunctions.py View on Github external
def setUpClass(self):
        np.random.seed(1234)
        # Create imgaging and segmentation data
        img2D = np.random.rand(16, 16) * 255
        img2D = img2D.astype(int)
        img3D = np.random.rand(16, 16, 16) * 255
        img3D = img3D.astype(int)
        seg2D = np.random.rand(16, 16) * 3
        seg2D = seg2D.astype(int)
        seg3D = np.random.rand(16, 16, 16) * 3
        seg3D = seg3D.astype(int)
        # Create testing samples
        self.sample2D = Sample("sample2D", img2D, channels=1, classes=3)
        self.sample2Dseg = Sample("sample2Dseg", img2D, channels=1, classes=3)
        self.sample3D = Sample("sample3D", img3D, channels=1, classes=3)
        self.sample3Dseg = Sample("sample3Dseg", img3D, channels=1, classes=3)
        # Add segmentation to seg samples
        self.sample2Dseg.add_segmentation(seg2D)
        self.sample3Dseg.add_segmentation(seg3D)
github frankkramer-lab / MIScnn / tests / test_subfunctions.py View on Github external
def setUpClass(self):
        np.random.seed(1234)
        # Create imgaging and segmentation data
        img2D = np.random.rand(16, 16) * 255
        img2D = img2D.astype(int)
        img3D = np.random.rand(16, 16, 16) * 255
        img3D = img3D.astype(int)
        seg2D = np.random.rand(16, 16) * 3
        seg2D = seg2D.astype(int)
        seg3D = np.random.rand(16, 16, 16) * 3
        seg3D = seg3D.astype(int)
        # Create testing samples
        self.sample2D = Sample("sample2D", img2D, channels=1, classes=3)
        self.sample2Dseg = Sample("sample2Dseg", img2D, channels=1, classes=3)
        self.sample3D = Sample("sample3D", img3D, channels=1, classes=3)
        self.sample3Dseg = Sample("sample3Dseg", img3D, channels=1, classes=3)
        # Add segmentation to seg samples
        self.sample2Dseg.add_segmentation(seg2D)
        self.sample3Dseg.add_segmentation(seg3D)
github frankkramer-lab / MIScnn / tests / test_subfunctions.py View on Github external
def setUpClass(self):
        np.random.seed(1234)
        # Create imgaging and segmentation data
        img2D = np.random.rand(16, 16) * 255
        img2D = img2D.astype(int)
        img3D = np.random.rand(16, 16, 16) * 255
        img3D = img3D.astype(int)
        seg2D = np.random.rand(16, 16) * 3
        seg2D = seg2D.astype(int)
        seg3D = np.random.rand(16, 16, 16) * 3
        seg3D = seg3D.astype(int)
        # Create testing samples
        self.sample2D = Sample("sample2D", img2D, channels=1, classes=3)
        self.sample2Dseg = Sample("sample2Dseg", img2D, channels=1, classes=3)
        self.sample3D = Sample("sample3D", img3D, channels=1, classes=3)
        self.sample3Dseg = Sample("sample3Dseg", img3D, channels=1, classes=3)
        # Add segmentation to seg samples
        self.sample2Dseg.add_segmentation(seg2D)
        self.sample3Dseg.add_segmentation(seg3D)
github frankkramer-lab / MIScnn / miscnn / data_loading / data_io.py View on Github external
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