msdnet.data module

Module for image data input.

Below, N_{c} is the number of image channels, and N_{x} \times N_{y} the image dimensions in pixels.

class msdnet.data.DataPoint[source]

Bases: abc.ABC

Base class for a single data point (input image with corresponding target image)

property input

Input image

property target

Target image

property mask

Mask image

abstract getinputarray()[source]

Return input image.

abstract gettargetarray()[source]

Return target image.

getmaskarray()[source]

Return mask image.

getall()[source]

Return input image, target image, and mask image (when given).

class msdnet.data.OnlyAllDataPoint[source]

Bases: msdnet.data.DataPoint

Base class for a single data point (input image with corresponding target image) that can only return all images at once (i.e. getall).

errormsg = 'Only getall supported'
getinputarray()[source]

Return input image.

gettargetarray()[source]

Return target image.

getmaskarray()[source]

Return mask image.

abstract getall()[source]

Return input image, target image, and mask image (when given).

class msdnet.data.BatchProvider(dlist, batchsize, seed=None)[source]

Bases: object

Object that returns small random batches of datapoints.

Parameters
  • dlist – List of DataPoint.

  • batchsize – Number of datapoints per batch.

  • seed – (optional) Random seed.

getbatch()[source]

Return batch of datapoints.

class msdnet.data.ArrayDataPoint(inputarray, targetarray=None, maskarray=None)[source]

Bases: msdnet.data.DataPoint

Datapoint with numpy array image data.

Parameters
  • inputarray – numpy array with input image (size: N_{c} \times N_{x} \times N_{y})

  • targetarray – (optional) numpy array with target image (size: N_{c} \times N_{x} \times N_{y})

  • maskarray – (optional) numpy array with mask image (size: N_{c} \times N_{x} \times N_{y})

getinputarray()[source]

Return input image.

gettargetarray()[source]

Return target image.

getmaskarray()[source]

Return mask image.

class msdnet.data.ImageFileDataPoint(inputfile, targetfile=None, maskfile=None)[source]

Bases: msdnet.data.DataPoint

Datapoint with image files. Supported are: TIFFs and most standard image formats (e.g. PNG and JPEG).

Parameters
  • inputfile – file name of input image

  • targetfile – (optional) file name of target image

  • maskfile – (optional) file name of mask image

getinputarray()[source]

Return input image.

gettargetarray()[source]

Return target image.

getmaskarray()[source]

Return mask image.

class msdnet.data.OneHotDataPoint(datapoint, labels, maskunlabeled=True)[source]

Bases: msdnet.data.DataPoint

Datapoint that converts a data point with a labeled image to one-hot images.

Parameters
  • datapoint – input DataPoint

  • labels – list of numberical labels in label image

  • maskunlabeled – (optional) whether to mask out unlabeled pixels

getinputarray()[source]

Return input image.

getmaskarray()[source]

Return mask image.

gettargetarray()[source]

Return target image.

class msdnet.data.SlabDataPoint(datapoints, flip=False)[source]

Bases: msdnet.data.DataPoint

Datapoint that represents a slab of data points.

Parameters
  • datapoints – list of DataPoint.

  • flip – (optional) whether to augment data by also flipping slab.

getinputarray()[source]

Return input image.

gettargetarray()[source]

Return target image.

getmaskarray()[source]

Return mask image.

msdnet.data.convert_to_slabs(datapoints, n_above_and_below, flip=False, reflective_boundary=True)[source]

Convert a list of datapoints (representing a 3D volume) to a list of datapoints of slabs.

Parameters
  • datapoints – list of DataPoint.

  • n_above_and_below – number of slices to take above and below each slice.

  • flip – (optional) whether to augment data by also flipping slab.

  • reflective_boundary – (optional) whether to use reflective boundary at top and bottom

Returns

list of DataPoint.

class msdnet.data.RotateAndFlipDataPoint(datapoint)[source]

Bases: msdnet.data.OnlyAllDataPoint

Datapoint that augments input datapoint with rotations and flips.

Parameters

datapoint – input DataPoint.

getall()[source]

Return input image, target image, and mask image (when given).