copyxnat.xnat.xnat_interface module

Abstraction for communicating with an XNAT server

class copyxnat.xnat.xnat_interface.XnatAssessor(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatParentItem

Wrapper for access to an XNAT assessor

interface_method = 'assessors'
rebuild_catalog()[source]

Send a catalog refresh request

visible_name = 'Assessor'
xnat_type = 'assessor'
class copyxnat.xnat.xnat_interface.XnatBase(parent_cache, interface, label, read_only, app_settings, reporter, parent)[source]

Bases: object

Base class for an item in the XNAT data hierarchy

full_label()[source]

The full data hierarchy and label of this item

full_name_label()[source]

Full data hierarchy of this item plus type

get_children(ignore_filter)[source]

Return XNAT child objects of this XNAT object

abstract get_server()[source]

Return the parent server object

abstract metadata_missing()[source]

Return True if this item or any parent requires metadata which could be found from the child Files

name_label()[source]

Name and type of this object formatted for display to user

abstract provide_metadata(metadata)[source]

Supply missing metadata to parent items

user_visible_info()[source]

String representation of this object that can be shown to user

abstract property visible_name

Return the XnatType of this class

abstract property xnat_type

Return the XnatType of this class

class copyxnat.xnat.xnat_interface.XnatExperiment(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatParentItem

Wrapper for access to an XNAT experiment

interface_method = 'experiments'
ohif_generate_session()[source]

Trigger regeneration of OHIF session data

post_create()[source]

Post-processing after item creation

progress_update(reporter)[source]

Update the user about current progress

rebuild_catalog()[source]

Send a catalog refresh request

visible_name = 'Experiment'
xnat_type = 'experiment'
class copyxnat.xnat.xnat_interface.XnatFile(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatItem

Base wrapper for file items

add_missing_metadata(local_file=None)[source]

Update parent items using metadata from this file

create_from_source(src_item, xml_cleaner)[source]

Create this item on this server by fetching the item from the source and applying XML cleaning where required

Src_item

the item from which to cope the file or XML

Xml_cleaner

XmlCleaner to modify the XML as required

export(app_settings)[source]

Save this item to the cache

interface_method = 'files'
user_visible_info()[source]

String representation of this object that can be shown to user

visible_name = 'File'
xnat_type = 'file'
class copyxnat.xnat.xnat_interface.XnatFileContainerItem(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatItem

Base wrapper for resource items

create_from_source(src_item, xml_cleaner)[source]

Create this item on this server by fetching the item from the source and applying XML cleaning where required

Src_item

the item from which to cope the file or XML

Xml_cleaner

XmlCleaner to modify the XML as required

export(app_settings)[source]

Save this item to the cache

user_visible_info()[source]

String representation of this object that can be shown to user

class copyxnat.xnat.xnat_interface.XnatInResource(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatFileContainerItem

Wrapper for access to an XNAT resource

get_or_create_child(parent, label)[source]

Create an XNAT item under the specified parent if it does not already exist, and return an XnatItem wrapper that can be used to access this item.

Parent

The XnatItem under which the child will be created if it does not already exist

Label

The identifier used to find or create the child item

Returns

new XnatItem wrapping the item fetched or created

interface_method = 'in_resources'
visible_name = 'In_Resource'
xnat_type = 'in_resource'
class copyxnat.xnat.xnat_interface.XnatItem(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatBase

Base class for data-level item in the XNAT data hierarchy. Used for all non-root items (ie all items other than XnatServer)

abstract create_from_source(src_item, xml_cleaner)[source]

Create this item on this server by fetching the item from the source and applying XML cleaning where required

Src_item

the item from which to cope the file or XML

Xml_cleaner

XmlCleaner to modify the XML as required

create_on_server(create_params, local_file)[source]

Create this item on the XNAT server

datatype()[source]

Return datatype name of the underlying XNAT item

exists_on_server()[source]

Return True if item already exists on the XNAT server

abstract export(app_settings)[source]

Save this item to the cache

get_attribute(name)[source]

Return the specified XNAT attribute from this item

classmethod get_existing(interface, parent)[source]

Return XnatItem for the provided interface which must represent an item that already exists on the server. Error if it does not exist. :return: a new XnatItem corresponding to the interface

get_id()[source]

Return XNAT ID of the underlying XNAT item

get_or_create_child(parent, label)[source]

Create an XNAT item under the specified parent if it does not already exist, and return an XnatItem wrapper that can be used to access this item.

Parent

The XnatItem under which the child will be created if it does not already exist

Label

The identifier used to find or create the child item

Returns

new XnatItem wrapping the item fetched or created

get_server()[source]

Return the parent XnatServer object

metadata_missing()[source]

Return True if this item or any parent requires metadata which could be found from the child Files

post_create()[source]

Post-processing after item creation

progress_update(reporter)[source]

Update the user about current progress

project_server_path()[source]

Return XNAT server archive path

provide_metadata(metadata)[source]

Supply missing metadata to parent items

rebuild_catalog()[source]

Send a catalog refresh request

set_attribute(name, value)[source]

Set the specified XNAT attribute of this item

class copyxnat.xnat.xnat_interface.XnatOutResource(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatFileContainerItem

Wrapper for access to an XNAT resource

interface_method = 'out_resources'
visible_name = 'Out_Resource'
xnat_type = 'out_resource'
class copyxnat.xnat.xnat_interface.XnatParentItem(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatItem

Base class for item in the XNAT data hierarchy which can contain resources and child items

create_from_source(src_item, xml_cleaner)[source]

Create this item on this server by fetching the item from the source and applying XML cleaning where required

Src_item

the item from which to cope the file or XML

Xml_cleaner

XmlCleaner to modify the XML as required

export(app_settings)[source]

Save this item to the cache

get_xml()[source]

Get an XML representation of this item

get_xml_string()[source]

Get an XML string representation of this item

class copyxnat.xnat.xnat_interface.XnatProject(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatParentItem

Wrapper for access to an XNAT project

experiment_in_cache(label)[source]

Return True if this experiment label is in the cached list of existing experiment labels for this project. The list will be created on first access. True indicates an experiment already exists (assuming no experiment deletion), but False does not necessarily indicate a experiment does not exist (as it may have been created since the list was populated)

interface_method = 'projects'
progress_update(reporter)[source]

Update the user about current progress

project_server_path()[source]

Return XNAT server archive path

visible_name = 'Project'
xnat_type = 'project'
class copyxnat.xnat.xnat_interface.XnatReconstruction(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatParentItem

Wrapper for access to an XNAT assessor

get_or_create_child(parent, label)[source]

Create an XNAT item under the specified parent if it does not already exist, and return an XnatItem wrapper that can be used to access this item.

Parent

The XnatItem under which the child will be created if it does not already exist

Label

The identifier used to find or create the child item

Returns

new XnatItem wrapping the item fetched or created

interface_method = 'reconstructions'
visible_name = 'Reconstruction'
xnat_type = 'reconstruction'
class copyxnat.xnat.xnat_interface.XnatResource(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatFileContainerItem

Wrapper for access to an XNAT resource

interface_method = 'resources'
visible_name = 'Resource'
xnat_type = 'resource'
class copyxnat.xnat.xnat_interface.XnatScan(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatParentItem

Wrapper for access to an XNAT scan

interface_method = 'scans'
visible_name = 'Scan'
xnat_type = 'scan'
class copyxnat.xnat.xnat_interface.XnatServer(factory, params, app_settings, base_cache, reporter, read_only)[source]

Bases: copyxnat.xnat.xnat_interface.XnatBase

Access an XNAT server

clear_data_caches()[source]

Sends request to monitoring service to clear the nrg data caches

datatypes()[source]

Return all the session datatypes in use on this server

does_request_succeed(uri, method='GET')[source]

Execute a REST call on the server and return True if it succeeds

get_archive_path()[source]

Return the XNAT server’s local data archive path

get_disallowed_project_ids(label)[source]

Return list of project names and secondary IDs that cannot be used for the destination project because they are already in use by other projects on this server. If the project already exists (which imples the project is being udated) then its IDs are permitted (ie they will not be included in the disallowed lists).

Parameters

label – the label of the current project

Returns

list of IDs (names and secondary_IDs) used by other projects

get_server()[source]

Return the parent server object

logout()[source]

Disconnect from this server

metadata_missing()[source]

Return True if this item or any parent requires metadata which could be found from the child Files

num_experiments(project)[source]

Return number of experiments in this project

ohif_present()[source]

Return True if the OHIF viewer plugin is installed on server

project(label)[source]

Return XnatProject for this project id

project_list()[source]

Return array of project ids

project_name_metadata()[source]

Return list of dictionaries containing project name metadata

provide_metadata(metadata)[source]

Supply missing metadata to parent items

request_json_property(uri)[source]

Execute a REST call on the server and return string

request_string(uri, error_on_failure=True)[source]

Execute a REST call on the server and return string

visible_name = 'Server'
xnat_type = 'server'
class copyxnat.xnat.xnat_interface.XnatSubject(interface, label, parent, exists=None)[source]

Bases: copyxnat.xnat.xnat_interface.XnatParentItem

Wrapper for access to an XNAT subject

interface_method = 'subjects'
visible_name = 'Subject'
xnat_type = 'subject'
class copyxnat.xnat.xnat_interface.XnatType(value)[source]

Bases: enum.Enum

Describe the type of XNAT item so cleaning can be performed

ASSESSOR = 'assessor'
EXPERIMENT = 'experiment'
FILE = 'file'
IN_RESOURCE = 'in_resource'
OUT_RESOURCE = 'out_resource'
PROJECT = 'project'
RECONSTRUCTION = 'reconstruction'
RESOURCE = 'resource'
SCAN = 'scan'
SERVER = 'server'
SUBJECT = 'subject'