How to use the miscnn.data_loading.interfaces.abstract_io.Abstract_IO 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 / miscnn / data_loading / interfaces / dicom_io.py View on Github external
from skimage import draw

# Internal libraries/scripts
from miscnn.data_loading.interfaces.abstract_io import Abstract_IO

#-----------------------------------------------------#
#                 DICOM I/O Interface                 #
#-----------------------------------------------------#
""" This class provides a Data I/O Interface that can be used to load images and structure sets
    that are provided in the Digital Imaging and Communications in Medicine (DICOM) format

    The DICOM Viewer was designed for the Lung CT Segmentation Challenge 2017.
    https://wiki.cancerimagingarchive.net/display/Public/Lung+CT+Segmentation+Challenge+2017#cb38430390714dbbad13f267f39a33eb
"""

class DICOM_interface(Abstract_IO):
    # Class variable initialization
    def __init__(self, channels=1, classes=2, three_dim=True, mask_background=0,
                 structure_dict={}, annotation_tag=None):

        """
        Args:
            channels (int): Number of channels of the input images.
            classes (int): Number of segmentation classes.
            three_dim (bool): 3D volume if True.
            mask_background (int): Determines the value of the background pixels.
            structure_dict (dict): Dictionary containg ROI names.
            annotation_tag (string): String to identify annotation series.
        Returns:
            None
        """
github frankkramer-lab / MIScnn / miscnn / data_loading / interfaces / nifti_io.py View on Github external
import numpy as np
import warnings
# Internal libraries/scripts
from miscnn.data_loading.interfaces.abstract_io import Abstract_IO

#-----------------------------------------------------#
#                 NIfTI I/O Interface                 #
#-----------------------------------------------------#
""" Data I/O Interface for NIfTI files. The Neuroimaging Informatics Technology Initiative file format
    is designed to contain brain images from e.g. magnetic resonance tomography. Nevertheless, it is
    currently broadly used for any 3D medical image data.

Code source heavily modified from the Kidney Tumor Segmentation Challenge 2019 git repository:
https://github.com/neheller/kits19
"""
class NIFTI_interface(Abstract_IO):
    # Class variable initialization
    def __init__(self, channels=1, classes=2, three_dim=True, pattern=None):
        self.data_directory = None
        self.channels = channels
        self.classes = classes
        self.three_dim = three_dim
        self.pattern = pattern
        self.cache = dict()

    #---------------------------------------------#
    #                  initialize                 #
    #---------------------------------------------#
    # Initialize the interface and return number of samples
    def initialize(self, input_path):
        # Resolve location where imaging data should be living
        if not os.path.exists(input_path):
github frankkramer-lab / MIScnn / miscnn / data_loading / interfaces / nifti_slicer_io.py View on Github external
from miscnn.data_loading.interfaces.abstract_io import Abstract_IO

#-----------------------------------------------------#
#                 NIfTI I/O Interface                 #
#-----------------------------------------------------#
""" Data I/O Interface for NIfTI files. The Neuroimaging Informatics Technology Initiative file format
    is designed to contain brain images from e.g. magnetic resonance tomography. Nevertheless, it is
    currently broadly used for any 3D medical image data.

    In contrast to the normal NIfTI IO interface, the NIfTI slicer IO interface splits the 3D volumes
    into separate 2D images (slices).
    This can be useful if it is desired to apply specific 2D architectures.

    Be aware that this interface defines slices on the first axis.
"""
class NIFTIslicer_interface(Abstract_IO):
    # Class variable initialization
    def __init__(self, channels=1, classes=2, pattern=None):
        self.data_directory = None
        self.channels = channels
        self.classes = classes
        self.three_dim = False
        self.pattern = pattern

    #---------------------------------------------#
    #                  initialize                 #
    #---------------------------------------------#
    # Initialize the interface and return number of samples
    def initialize(self, input_path):
        # Resolve location where imaging data should be living
        if not os.path.exists(input_path):
            raise IOError(
github frankkramer-lab / MIScnn / miscnn / data_loading / interfaces / image_io.py View on Github external
Methods:
    __init__                Object creation function
    initialize:             Prepare the data set and create indices list
    load_image:             Load an image
    load_segmentation:      Load a segmentation
    load_prediction:        Load a prediction
    load_details:           Load optional information
    save_prediction:        Save a prediction to disk

Args:
    classes (int):          Number of classes of the segmentation
    img_type (string):      Type of imaging. Options: "grayscale", "rgb"
    img_format (string):    Imaging format: Popular formats: "png", "tif", "jpg"
    pattern (regex):        Pattern to filter samples
"""
class Image_interface(Abstract_IO):
    #---------------------------------------------#
    #                   __init__                  #
    #---------------------------------------------#
    def __init__(self, classes=2, img_type="grayscale", img_format="png",
                 pattern=None):
        self.classes = classes
        self.img_type = img_type
        self.img_format = img_format
        self.three_dim = False
        self.pattern = pattern
        if img_type == "grayscale" : self.channels = 1
        elif img_type == "rgb" : self.channels = 3

    #---------------------------------------------#
    #                  initialize                 #
    #---------------------------------------------#
github frankkramer-lab / MIScnn / miscnn / data_loading / interfaces / dictionary_io.py View on Github external
#-----------------------------------------------------#
""" Data I/O Interface for python dictionaries. This interface uses the basic-python
    dictionary to load and save data. Therefore the complete data management happens
    in the memory. Therefore, for common data set sizes this is NOT recommended!

    It is advised to use already provided I/O interfaces of this package or to implement
    a custom I/O interface for perfect usability.

    Dictionary structure:
        Key: sample_index
        Value: Tuple containing:    (0) image as numpy array
                                    (1) optional segmentation as numpy array
                                    (2) optional prediction as numpy array
                                    (3) optional details
"""
class Dictionary_interface(Abstract_IO):
    # Class variable initialization
    def __init__(self, dictionary, channels=1, classes=2, three_dim=True):
        self.dictionary = dictionary
        self.channels = channels
        self.classes = classes
        self.three_dim = three_dim

    #---------------------------------------------#
    #                  initialize                 #
    #---------------------------------------------#
    # Initialize the interface and return number of samples
    def initialize(self, input_path):
        # Return sample list
        return list(self.dictionary.keys())

    #---------------------------------------------#