src.imagedata.transports package

Submodules

src.imagedata.transports.abstracttransport module

Abstract class for image transports.

Defines generic functions.

class src.imagedata.transports.abstracttransport.AbstractTransport(name, description, authors, version, url, schemes)[source]

Bases: object

Abstract base class definition for imagedata transport plugins. Plugins must be a subclass of AbstractPlugin and must define the attributes set in __init__() and the following methods:

open() method isfile() method walk() method

property authors

Plugin authors

Multi-line string naming the author(s) of the plugin.

abstract close()[source]

Close the transport

property description

Plugin description

Single line string describing the transport method.

abstract info(path) str[source]

Return info describing the object

Parameters:

path (str) – object path

Returns:

Preferably a one-line string describing the object

Return type:

description (str)

abstract isfile(path)[source]

Return True if path is an existing regular file.

property name

Plugin name

Single word string describing the image format. Typical names: file, dicom, xnat

abstract open(path, mode='r')[source]

Extract a member from the archive as a file-like object.

plugin_type = 'transport'
property schemes

List of transport schemes supported by this plugin.

List of strings.

property url

Plugin URL

URL string to the site of the plugin or the author(s).

property version

Plugin version

String giving the plugin version. Version scheme: 1.0.0

abstract walk(top)[source]

Generate the file names in a directory tree by walking the tree. Input: - top: starting point for walk (str) Return: - tuples of (root, dirs, files)

exception src.imagedata.transports.abstracttransport.NoOtherInstance[source]

Bases: Exception

src.imagedata.transports.dicomtransport module

Transfer DICOM images to and from DICOM Storage SCP

exception src.imagedata.transports.dicomtransport.AssociationFailed[source]

Bases: Exception

exception src.imagedata.transports.dicomtransport.AssociationNotEstablished[source]

Bases: Exception

class src.imagedata.transports.dicomtransport.DicomTransport(netloc=None, root=None, mode='r', read_directory_only=False, opts=None)[source]

Bases: AbstractTransport

Send DICOM images to DICOM Storage SCP

authors = 'Erling Andersen'
close()[source]

Close the DICOM association transport

description = 'Receive/Send DICOM images to DICOM Storage SCP.'
info(path) str[source]

Return info describing the object

Parameters:

path (str) – object path

Returns:

Preferably a one-line string describing the object

Return type:

description (str)

isfile(path)[source]

Return True if path is an existing regular file.

name = 'dicom'
open(path, mode='r')[source]

Extract a member from the archive as a file-like object.

schemes = ['dicom']
store(ds)[source]

Store DICOM dataset using DICOM Storage SCU protocol.

url = 'www.helse-bergen.no'
version = '2.0.0'
walk(top)[source]

Generate the file names in a directory tree by walking the tree. Input: - top: starting point for walk (str) Return: - tuples of (root, dirs, files)

src.imagedata.transports.filetransport module

Read/Write local files

class src.imagedata.transports.filetransport.FileTransport(netloc=None, root=None, mode='r', read_directory_only=False, opts=None)[source]

Bases: AbstractTransport

Read/write local files.

Parameters:
  • netloc (str) – Not used.

  • root (str) – Root path.

  • mode (str) – Filesystem access mode.

  • read_directory_only (bool) – Whether root should refer to a directory.

  • opts (dict) – Options

Returns:

FileTransport instance

Raises:
  • RootIsNotDirectory – when the root is not a directory when read_directory_only is True.

  • RootDoesNotExist – Specified root does not exist.

  • AssertionError – When root is None.

authors = 'Erling Andersen'
close()[source]

Close the transport

description = 'Read and write local files.'
info(path) str[source]

Return info describing the object

Parameters:

path (str) – object path

Returns:

Preferably a one-line string describing the object

Return type:

description (str)

isfile(path)[source]

Check whether path refers to an existing regular file.

Parameters:

path – Path to file.

Returns:

Existense of regular file (bool)

name = 'file'
open(path, mode='r')[source]

Extract a member from the archive as a file-like object.

Parameters:
  • path (str) – Path to file.

  • mode (str) – Open mode, can be ‘r’, ‘w’, ‘x’ or ‘a’

schemes = ['file']
url = 'www.helse-bergen.no'
version = '1.1.0'
walk(top)[source]

Generate the file names in a directory tree by walking the tree.

Parameters:

top – starting point for walk (str)

Returns:

tuples of (root, dirs, files)

src.imagedata.transports.xnattransport module

Read/write files in xnat database

class src.imagedata.transports.xnattransport.XnatTransport(netloc=None, root=None, mode='r', read_directory_only=False, opts=None)[source]

Bases: AbstractTransport

Read/write files in xnat database.

authors = 'Erling Andersen'
close()[source]

Close the transport

description = 'Read and write files in xnat database.'
info(path) str[source]

Return info describing the object

Parameters:

path (str) – object path

Returns:

Preferably a one-line string describing the object

Return type:

description (str)

isfile(path)[source]

Return True if path is an existing regular file.

name = 'xnat'
open(path, mode='r')[source]

Extract a member from the archive as a file-like object.

schemes = ['xnat']
url = 'www.helse-bergen.no'
version = '2.0.0'
walk(top)[source]

Generate the file names in a directory tree by walking the tree. Input: - top: starting point for walk (str) Return: - tuples of (root, dirs, files)

Module contents

This module provides plugins for various image transports.

Standard plugins provides support for file, http/https and xnat transports.

exception src.imagedata.transports.FunctionNotSupported[source]

Bases: Exception

exception src.imagedata.transports.RootDoesNotExist[source]

Bases: Exception

exception src.imagedata.transports.RootIsNotDirectory[source]

Bases: Exception

src.imagedata.transports.Transport(scheme, netloc=None, root=None, mode='r', read_directory_only=False, opts=None)[source]

Return plugin for given transport scheme.

exception src.imagedata.transports.TransportPluginNotFound[source]

Bases: Exception