Imagedata packages

Module Axis

Axis defines a dimension of an images Series.

class imagedata.axis.UniformAxis(name, start, stop, step=1)[source]

Define axis by giving start, stop and step (optional). Start, stop and step are given in actual values


>>> ax = UniformAxis('row', 0, 128)
class imagedata.axis.UniformLengthAxis(name, start, n, step=1)[source]

Define axis by giving start, length and step (optional). Start and step are given in actual values.


>>> ax = UniformLengthAxis('row', 0, 128)
class imagedata.axis.VariableAxis(name, values)[source]

Define axis by giving an array of values. values are actual values.


>>> ax = VariableAxis('time', [0, 1, 4, 9, 11, 13])

Module cmdline

Add standard command line options.

class imagedata.cmdline.CommaSepAction(option_strings, dest, nargs=None, **kwargs)[source]
class imagedata.cmdline.DictAction(option_strings, dest, nargs=None, **kwargs)[source]
class imagedata.cmdline.DtypeAction(option_strings, dest, nargs=None, **kwargs)[source]
class imagedata.cmdline.InputOrderAction(option_strings, dest, nargs=None, **kwargs)[source]
class imagedata.cmdline.OutputFormatAction(option_strings, dest, nargs=None, **kwargs)[source]
class imagedata.cmdline.SortOnAction(option_strings, dest, nargs=None, **kwargs)[source]

Module imagedata.header

Image series header

class imagedata.header.Header[source]

Image header object.

  • ~Header.input_order

  • ~Header.sort_on

  • ~Header.input_format

  • ~Header.DicomHeaderDict

  • ~Header.seriesNumber

  • ~Header.seriesDescription

  • ~Header.imageType

  • ~Header.frameOfReferenceUID

  • ~Header.studyInstanceUID

  • ~Header.studyID

  • ~Header.seriesInstanceUID

  • ~Header.SOPClassUID

  • ~Header.accessionNumber

  • ~Header.patientName

  • ~Header.patientID

  • ~Header.patientBirthDate

  • ~Header.input_sort

  • ~Header.sliceLocations

  • ~Header.tags

  • ~Header.spacing

  • ~Header.imagePositions

  • ~Header.orientation

  • ~Header.transformationMatrix

  • ~Header.color

  • ~Header.photometricInterpretation

  • ~Header.axes

  • ~Header.__uid_generator

  • ~Header.studyInstanceUID

  • ~Header.seriesInstanceUID

  • ~Header.frameOfReferenceUID

  • ~Header.DicomHeaderDict

  • ~Header.tags

  • ~Header.axes

add_geometry(template, geometry)[source]

Add geometry data to obj header.

  • self – header or dict

  • template – template header or dict. Can be None.

  • geometry – geometry template header or dict. Can be None.


Add template data to this header. Does not add geometry data.


template – template header. Can be None.

new_uid() str[source]

Return the next available UID from the UID generator.


Set default values.

imagedata.header.deepcopy_DicomHeaderDict(source, filename=None)[source]

Deepcopy contents of DicomHeaderDict.

Module imagedata.readdata

Read/Write image files, calling appropriate transport, archive and format plugins

exception imagedata.readdata.NoArchiveError[source]
exception imagedata.readdata.NoTransportError[source]
exception imagedata.readdata.UnknownOptionType[source], order=None, opts=None)[source]

Read image data, calling appropriate transport, archive and format plugins

  • urls – list of urls or url to read (list of str, or str)

  • order – determine how to sort the images (default: auto-detect)

  • opts – input options (argparse.Namespace or dict)


tuple of
  • hdr: header instance

  • si[tag,slice,rows,columns]: numpy array

  • ValueError – When no sources are given.

  • UnknownOptionType – When opts cannot be made into a dict.

  • FileNotFoundError – When specified URL cannot be opened.

  • imagedata.formats.UnknownInputError – When the input format could not be determined.

  • imagedata.formats.CannotSort – When input data cannot be sorted.


Sort plugins such that any Nifti plugin is used early.


Convert dtype string to numpy dtype.

imagedata.readdata.write(si, url, opts=None, formats=None)[source]

Write image data, calling appropriate format plugins

  • si[tag – Series array

  • slice – Series array

  • rows – Series array

  • columns] – Series array

  • url – output destination url

  • opts – Output options (argparse.Namespace or dict)

  • formats – list of output formats, overriding opts.output_format (list or str)

  • UnknownOptionType – When opts cannot be made into a dict.

  • TypeError – List of output format is not list().

  • ValueError – Wrong number of destinations given, or no way to write multidimensional image.

  • imagedata.formats.WriteNotImplemented – Cannot write this image format.