Imagedata packages
Module Axis
Axis defines a dimension of an images Series.
- class imagedata.axis.UniformAxis(name: str, start: type[SupportsFloat], stop: type[SupportsFloat], step: type[SupportsFloat] = 1)[source]
Define axis by giving start, stop and step (optional). Start, stop and step are given in actual values
Examples
>>> ax = UniformAxis('row', 0, 128)
- copy(name: str = None, start: type[SupportsFloat] = None, stop: type[SupportsFloat] = None, step: type[SupportsFloat] = None, n: int = None) UniformAxis[source]
Return a copy of the axis, where the length n can be different.
- class imagedata.axis.UniformLengthAxis(name: str, start: type[SupportsFloat], n: int, step: type[SupportsFloat] = 1)[source]
Define axis by giving start, length and step (optional). Start and step are given in actual values.
Examples
>>> ax = UniformLengthAxis('row', 0, 128)
- copy(name: str = None, start: type[SupportsFloat] = None, n: type[SupportsFloat] = None, step: type[SupportsFloat] = None) UniformLengthAxis[source]
Return a copy of the axis, where the length n can be different.
- class imagedata.axis.VariableAxis(name: str, values: Sequence)[source]
Define axis by giving an array of values. values are actual values.
Examples
>>> ax = VariableAxis('time', [0, 1, 4, 9, 11, 13])
- copy(name: str = None, n: type[SupportsFloat] = None) VariableAxis[source]
Return a copy of the axis, where the length n can be different.
Module cmdline
Add standard command line options.
Module imagedata.header
Image series header
- class imagedata.header.Header[source]
Image header object.
- Variables:
input_order
sort_on
input_format
dicomTemplate
seriesNumber
seriesDescription
imageType
frameOfReferenceUID
studyInstanceUID
studyID
seriesInstanceUID
SOPClassUID
accessionNumber
patientName
patientID
patientBirthDate
input_sort
sliceLocations (#)
tags
spacing
imagePositions
orientation
transformationMatrix
photometricInterpretation
axes (collections.namedtuple)
__uid_generator
- add_geometry(geometry)[source]
Add geometry data to obj header.
- Parameters:
self – header or dict
geometry – geometry template header or dict. Can be None.
- add_template(template) None[source]
Add template data to this header. Does not add geometry data.
- Parameters:
template – template header. Can be None.
- property shape: tuple
Return matrix shape as given by axes properties.
Module imagedata.readdata
Read/Write image files, calling appropriate transport, archive and format plugins
- imagedata.readdata.read(urls, order=None, opts=None, input_format=None)[source]
Read image data, calling appropriate transport, archive and format plugins
- Parameters:
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)
input_format – specify a particular input format (default: auto-detect)
- Returns:
- tuple of
hdr: header instance
si[tag,slice,rows,columns]: numpy array
- Raises:
ValueError – When no sources are given.
UnknownOptionType – When opts cannot be made into a dict.
FileNotFoundError – When specified URL cannot be opened.
UnknownInputError – When the input format could not be determined.
CannotSort – When input data cannot be sorted.
- imagedata.readdata.sorted_plugins_dicom_first(plugins, input_format)[source]
Sort plugins such that any Nifti plugin is used early.
- imagedata.readdata.write(si, url, opts=None, formats=None)[source]
Write image data, calling appropriate format plugins
- Parameters:
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)
- Raises:
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.