How to use the miscnn.data_loading.interfaces.NIFTIslicer_interface 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_iointerfaces.py View on Github external
def test_IOI_NIFTIslicer_initialize(self):
        interface = NIFTIslicer_interface(pattern="nifti")
        sample_list = interface.initialize(self.tmp_data.name)
        self.assertEqual(len(sample_list), self.img.shape[2])
        self.assertEqual(sample_list[0], "nifti:#:0")
    # Loading Images and Segmentations
github frankkramer-lab / MIScnn / tests / test_iointerfaces.py View on Github external
def test_IOI_NIFTIslicer_loading(self):
        interface = NIFTIslicer_interface(pattern="nifti")
        sample_list = interface.initialize(self.tmp_data.name)
        img = interface.load_image(sample_list[-1])
        seg = interface.load_segmentation(sample_list[-1])
        self.assertTrue(np.array_equal(img, self.img[-1]))
        self.assertTrue(np.array_equal(seg, self.seg[-1]))
    # NIFTI_interface - Loading and Storage of Predictions
github frankkramer-lab / MIScnn / tests / test_iointerfaces.py View on Github external
def test_IOI_NIFTIslicer_predictionhandling(self):
        interface = NIFTIslicer_interface(pattern="nifti")
        sample_list = interface.initialize(self.tmp_data.name)
        seg = interface.load_segmentation(sample_list[-1])
        interface.save_prediction(seg, "pred.NIIslice", self.tmp_data.name)
        pred = interface.load_prediction("pred.NIIslice", self.tmp_data.name)
        self.assertTrue(np.array_equal(pred, seg))
github frankkramer-lab / MIScnn / tests / test_iointerfaces.py View on Github external
def test_IOI_NIFTIslicer_creation(self):
        interface = NIFTIslicer_interface()
    # Initialization
github frankkramer-lab / MIScnn / tutorials / NIfTIslicer_interface.py View on Github external
## IO interface.
##
## This interface automatically slices a data set of NIfTI 3D volumes into 2D
## images for using specific 2D models
##
## Based on the KITS 19 data set (Kidney Tumor Segmentation Challenge 2019)
## Data Set: https://github.com/neheller/kits19

# Import all libraries we need
from miscnn import Data_IO, Preprocessor, Neural_Network
from miscnn.data_loading.interfaces import NIFTIslicer_interface
from miscnn.processing.subfunctions import Resize
import numpy as np

# Initialize the NIfTI interface IO slicer variant
interface = NIFTIslicer_interface(pattern="case_0000[0-3]", channels=1, classes=3)

# Initialize the Data IO class
data_path = "/home/mudomini/projects/KITS_challenge2019/kits19/data.interpolated/"
data_io = Data_IO(interface, data_path, delete_batchDir=False)

# Obtain the list of samples from our data set
## A sample is defined as a single slice (2D image)
samples_list = data_io.get_indiceslist()
samples_list.sort()

# Let's test out, if the the NIfTI slicer interface works like we want
# and output the image and segmentation shape of a random slice
sample = data_io.sample_loader("case_00002:#:42", load_seg=True)
print(sample.img_data.shape, sample.seg_data.shape)

## As you hopefully noted, the index of a slice is defined