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'¶
- 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
- abstract metadata_missing()[source]¶
Return True if this item or any parent requires metadata which could be found from the child Files
- 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'¶
- 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
- 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
- interface_method = 'files'¶
- 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
- 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
- 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_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
- 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
- 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'¶
- 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
- does_request_succeed(uri, method='GET')[source]¶
Execute a REST call on the server and return True if it succeeds
- 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
- metadata_missing()[source]¶
Return True if this item or any parent requires metadata which could be found from the child Files
- 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'¶