xnatpy: a pythonic feeling interface to XNAT

xnatpy attempts to expose objects in XNAT as native feeling Python objects. The objects reflect the state of XNAT and changes to the objects automatically update the server.

To facilitate this xnatpy scans the server xnat.xsd and creates a Python class structure to mimic this is well as possible.

Current features:

  • automatic generate of most data structures from the xnat.xsd
  • easy exploration of data
  • easy getting/setting of custom variables
  • easy downloading/uploading of data
  • using the prearchive
  • the import service

Missing features (aka my TODO list):

  • good support for the creation of objects
  • good support for searches

Some imports and helper code used later on

In [1]:
import os
import random

getting started

First we need to set up an xnatpy session. The session scans the xnat.xsd, creates classes, logs in into XNAT, and keeps the connection alive using a hearbeat.

In [2]:
import xnat
print('Loaded xnatpy version {}'.format(xnat.__version__))
session = xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017')
Loaded xnatpy version 0.3.2

This will create an XNAT session object, which is the base class for all operations with the XNAT server. It also create a keep alive thread that makes sure the session is polled every 14 minutes to keep the connection alive.

To save your login you set up a .netrc file with the correct information about the target host. A simple example of a .netrc file can be found at http://www.mavetju.org/unix/netrc.php.

It is possible to set the login information on connect without using a netrc file.

All the options of the connect function can be found in the docstring. You can turn of certificate verification for self signed certificates, change log options, disbale use of extension type.

In [3]:
help(xnat.connect)
Help on function connect in module xnat:

connect(server, user=None, password=None, verify=True, netrc_file=None, debug=False, extension_types=True, loglevel=None, logger=None)
    Connect to a server and generate the correct classed based on the servers xnat.xsd
    This function returns an object that can be used as a context operator. It will call
    disconnect automatically when the context is left. If it is used as a function, then
    the user should call ``.disconnect()`` to destroy the session and temporary code file.
    
    :param str server: uri of the server to connect to (including http:// or https://)
    :param str user: username to use, leave empty to use netrc entry or anonymous login.
    :param str password: password to use with the username, leave empty when using netrc.
                         If a username is given and no password, there will be a prompt
                         on the console requesting the password.
    :param bool verify: verify the https certificates, if this is false the connection will
                        be encrypted with ssl, but the certificates are not checked. This is
                        potentially dangerous, but required for self-signed certificates.
    :param str netrc_file: alternative location to use for the netrc file (path pointing to
                           a file following the netrc syntax)
    :param debug bool: Set debug information printing on
    :param str loglevel: Set the level of the logger to desired level
    :param logging.Logger logger: A logger to reuse instead of creating an own logger
    :return: XNAT session object
    :rtype: XNATSession
    
    Preferred use::
    
        >>> import xnat
        >>> with xnat.connect('https://central.xnat.org') as session:
        ...    subjects = session.projects['Sample_DICOM'].subjects
        ...    print('Subjects in the SampleDICOM project: {}'.format(subjects))
        Subjects in the SampleDICOM project: <XNATListing (CENTRAL_S01894, dcmtest1): <SubjectData CENTRAL_S01894>, (CENTRAL_S00461, PACE_HF_SUPINE): <SubjectData CENTRAL_S00461>>
    
    Alternative use::
    
        >>> import xnat
        >>> session = xnat.connect('https://central.xnat.org')
        >>> subjects = session.projects['Sample_DICOM'].subjects
        >>> print('Subjects in the SampleDICOM project: {}'.format(subjects))
        Subjects in the SampleDICOM project: <XNATListing (CENTRAL_S01894, dcmtest1): <SubjectData CENTRAL_S01894>, (CENTRAL_S00461, PACE_HF_SUPINE): <SubjectData CENTRAL_S00461>>
        >>> session.disconnect()

Session object basic functionality

The session is the main entry point for the module. It has some basic REST functions on which the rest of the package is built, these are the get, put, post, delete, head, download and upload methods. They are very similar to the requests package but contain helpers that build the total URL from a REST path and check the resulting HTML code and content somewhat.

In [4]:
help(session.get)
Help on method get in module xnat.session:

get(self, path, format=None, query=None, accepted_status=None) method of xnat.session.XNATSession instance
    Retrieve the content of a given REST directory.
    
    :param str path: the path of the uri to retrieve (e.g. "/data/archive/projects")
                     the remained for the uri is constructed automatically
    :param str format: the format of the request, this will add the format= to the query string
    :param dict query: the values to be added to the query string in the uri
    :param list accepted_status: a list of the valid values for the return code, default [200]
    :returns: the requests reponse
    :rtype: requests.Response

In [5]:
response = session.get('/data/projects/xnatpydemo/subjects')
print(response)
print('\n\n')
print(response.text)
print('\n\n')
print(session.get_json('/data/projects/xnatpydemo/subjects'))
<Response [200]>



{"ResultSet":{"Result":[{"project":"xnatpydemo","insert_user":"xnatpydemo","ID":"CENTRAL_S06138","insert_date":"2017-10-15 09:05:36.025","label":"Case001","URI":"/data/subjects/CENTRAL_S06138"},{"project":"xnatpydemo","insert_user":"xnatpydemo","ID":"CENTRAL_S06139","insert_date":"2017-10-15 10:22:35.673","label":"archive_subject_489","URI":"/data/subjects/CENTRAL_S06139"},{"project":"xnatpydemo","insert_user":"xnatpydemo","ID":"CENTRAL_S06140","insert_date":"2017-10-15 10:23:40.707","label":"archive_subject_981","URI":"/data/subjects/CENTRAL_S06140"},{"project":"xnatpydemo","insert_user":"xnatpydemo","ID":"CENTRAL_S06137","insert_date":"2017-10-15 08:56:12.551","label":"subject001","URI":"/data/subjects/CENTRAL_S06137"},{"project":"xnatpydemo","insert_user":"xnatpydemo","ID":"CENTRAL_S06141","insert_date":"2017-10-15 10:25:19.826","label":"archive_subject_158","URI":"/data/subjects/CENTRAL_S06141"}], "totalRecords": "5"}}



{u'ResultSet': {u'totalRecords': u'5', u'Result': [{u'insert_user': u'xnatpydemo', u'insert_date': u'2017-10-15 09:05:36.025', u'URI': u'/data/subjects/CENTRAL_S06138', u'label': u'Case001', u'project': u'xnatpydemo', u'ID': u'CENTRAL_S06138'}, {u'insert_user': u'xnatpydemo', u'insert_date': u'2017-10-15 10:22:35.673', u'URI': u'/data/subjects/CENTRAL_S06139', u'label': u'archive_subject_489', u'project': u'xnatpydemo', u'ID': u'CENTRAL_S06139'}, {u'insert_user': u'xnatpydemo', u'insert_date': u'2017-10-15 10:23:40.707', u'URI': u'/data/subjects/CENTRAL_S06140', u'label': u'archive_subject_981', u'project': u'xnatpydemo', u'ID': u'CENTRAL_S06140'}, {u'insert_user': u'xnatpydemo', u'insert_date': u'2017-10-15 08:56:12.551', u'URI': u'/data/subjects/CENTRAL_S06137', u'label': u'subject001', u'project': u'xnatpydemo', u'ID': u'CENTRAL_S06137'}, {u'insert_user': u'xnatpydemo', u'insert_date': u'2017-10-15 10:25:19.826', u'URI': u'/data/subjects/CENTRAL_S06141', u'label': u'archive_subject_158', u'project': u'xnatpydemo', u'ID': u'CENTRAL_S06141'}]}}

xnatpy objects

xnatpy creates a class hierarchy based on the xnat.xsd and other schemas it can find on the XNAT server (including extension types). These classes mirror the behaviour described in the xsd as best as possible in Python. The idea is that it feels like you are manipulating python objects, while in fact you are working on the XNAT server. It completely abstract the REST interface away.

The entry points for this are the projects, subject and experiments properties in the session object:

In [6]:
sandbox = session.projects['xnatpydemo']
print(sandbox)
<ProjectData xnatpydemo>
In [7]:
sandbox.description
Out[7]:
u'Random_project_description_4'
In [8]:
new_description = 'Random_project_description_{}'.format(random.randint(0, 100))
print('Changing description to: {}'.format(new_description))
sandbox.description = new_description
Changing description to: Random_project_description_76
In [9]:
sandbox.description
Out[9]:
u'Random_project_description_76'
In [10]:
# Get a list of the subjects
sandbox.subjects
Out[10]:
<XNATListing {(CENTRAL_S06138, Case001): <SubjectData Case001>, (CENTRAL_S06139, archive_subject_489): <SubjectData archive_subject_489>, (CENTRAL_S06140, archive_subject_981): <SubjectData archive_subject_981>, (CENTRAL_S06137, subject001): <SubjectData subject001>, (CENTRAL_S06141, archive_subject_158): <SubjectData archive_subject_158>}>

Note that the entries are in the form (CENTRAL_S01824, custom_label): <SubjectData CENTRAL_S01824>. This does not mean that the key is (CENTRAL_S01824, custom_label), but that both the keys CENTRAL_S01824 and custom_label can be used for lookup. The first key is always the XNAT internal id, the second key is defined as:

  • project: the name
  • subject: the label
  • experiment: the label
  • scan: the scantype
  • resource: label
  • file: filename
In [11]:
subject = sandbox.subjects['subject001']
In [12]:
print('Before change:')
print('Gender: {}'.format(subject.demographics.gender))
print('Initials: {}'.format(subject.initials))

# Change gender and initials. Flip them between male and female and JC and PI
subject.demographics.gender = 'female' if subject.demographics.gender == 'male' else 'male'
subject.initials = 'JC' if subject.initials == 'PI' else 'PI'

print('After change:')
print('Gender: {}'.format(subject.demographics.gender))
print('Initials: {}'.format(subject.initials))
Before change:
Gender: female
Initials: PI
After change:
Gender: male
Initials: JC

There is some basic value checking before assignment are carried out. It uses the xsd directives when available. For example:

In [13]:
subject.demographics.gender = 'martian'
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-49f880f144cd> in <module>()
----> 1 subject.demographics.gender = 'martian'

/home/hachterberg/dev/xnat-workshop-2017/venv/local/lib/python2.7/site-packages/xnat/utils.pyc in __set__(self, obj, value)
     56         if self.fset is None:
     57             raise AttributeError("can't set attribute")
---> 58         self.fset(obj, value)
     59 
     60     def __delete__(self, obj):

/tmp/tmpsv_OoE_generated_xnat.py in gender(self, value)
   1433         # Restrictions for value
   1434         if value not in ["male", "female", "other", "unknown", "M", "F"]:
-> 1435             raise ValueError('gender has to be one of: "male", "female", "other", "unknown", "M", "F"')
   1436 
   1437         # Automatically generated Property, type: xs:string

ValueError: gender has to be one of: "male", "female", "other", "unknown", "M", "F"

Creating an xnatpy object from a REST path

If you have a huge database and would like to skip (parts of) the listings, you can create an XNAT object straight from a REST path. It will automatically figure out the correct class from the XNAT response. This object then can be use just as any other xnatpy object:

In [14]:
subject = session.create_object('/data/projects/xnatpydemo/subjects/Case001')
print subject
print subject.experiments
<SubjectData Case001>
<XNATListing {(CENTRAL_E11129, Case001): <MrSessionData Case001>}>

XNAT to xnatpy class mapping

You can see the mapping of classes created by xnatpy using the class lookup:

In [15]:
import pprint
pprint.pprint(session.XNAT_CLASS_LOOKUP)
{u'adrc:ADRCClinicalData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ADRCClinicalData'>,
 u'arc:fieldSpecification': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldSpecification'>,
 u'arc:pathInfo': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PathInfo'>,
 u'arc:pipelineData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PipelineData'>,
 u'arc:pipelineParameterData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PipelineParameterData'>,
 u'arc:project': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Project'>,
 u'arc:property': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Property'>,
 u'cat:catalog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Catalog'>,
 u'cat:dcmCatalog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmCatalog'>,
 u'cat:dcmEntry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmEntry'>,
 u'cat:entry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Entry'>,
 u'cnda:adrc_psychometrics': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AdrcPsychometrics'>,
 u'cnda:atlasScalingFactorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtlasScalingFactorData'>,
 u'cnda:atrophyNilData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtrophyNilData'>,
 u'cnda:clinicalAssessmentData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentData'>,
 u'cnda:cndaSubjectMetadata': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CndaSubjectMetadata'>,
 u'cnda:csfData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CsfData'>,
 u'cnda:diagnosesData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesData'>,
 u'cnda:dtiData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DtiData'>,
 u'cnda:dtiRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DtiRegion'>,
 u'cnda:handednessData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessData'>,
 u'cnda:levelsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LevelsData'>,
 u'cnda:manualVolumetryData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ManualVolumetryData'>,
 u'cnda:manualVolumetryRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ManualVolumetryRegion'>,
 u'cnda:modifiedScheltensData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensData'>,
 u'cnda:modifiedScheltensPvRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensPvRegion'>,
 u'cnda:modifiedScheltensRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegion'>,
 u'cnda:petTimeCourseData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseData'>,
 u'cnda:psychometricsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsData'>,
 u'cnda:radiologyReadData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RadiologyReadData'>,
 u'cnda:segmentationFastData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SegmentationFastData'>,
 u'cnda:ticVideoCountsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.TicVideoCountsData'>,
 u'cnda:vitalsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsData'>,
 u'cnda:volumetryRegionInfo': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfo'>,
 u'fs:aparcRegionAnalysis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AparcRegionAnalysis'>,
 u'fs:asegRegionAnalysis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AsegRegionAnalysis'>,
 u'fs:automaticSegmentationData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AutomaticSegmentationData'>,
 u'fs:fsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsData'>,
 u'fs:longFSData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSData'>,
 u'genetics:geneticTestResults': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GeneticTestResults'>,
 u'neurocog:symptomsNeurocog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocog'>,
 u'nunda:nundaDemographicData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NundaDemographicData'>,
 u'prov:process': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Process'>,
 u'prov:processStep': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStep'>,
 u'pup:pupTimeCourseData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PupTimeCourseData'>,
 u'sapssans:symptomsSAPSSANS': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsSAPSSANS'>,
 u'scr:screeningAssessment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScreeningAssessment'>,
 u'scr:screeningScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScreeningScanData'>,
 u'sf:encounterLog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EncounterLog'>,
 u'val:additionalVal': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AdditionalVal'>,
 u'val:protocolData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolData'>,
 u'wrk:abstractExecutionEnvironment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractExecutionEnvironment'>,
 u'wrk:workflowData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.WorkflowData'>,
 u'wrk:xnatExecutionEnvironment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XnatExecutionEnvironment'>,
 u'xdat:access_log': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AccessLog'>,
 u'xdat:action_type': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ActionType'>,
 u'xdat:change_info': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ChangeInfo'>,
 u'xdat:criteria': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Criteria'>,
 u'xdat:criteria_set': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CriteriaSet'>,
 u'xdat:element_action_type': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ElementActionType'>,
 u'xdat:element_security': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ElementSecurity'>,
 u'xdat:field_mapping': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldMapping'>,
 u'xdat:field_mapping_set': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldMappingSet'>,
 u'xdat:history': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.History'>,
 u'xdat:infoEntry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.InfoEntry'>,
 u'xdat:meta_data': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MetaData'>,
 u'xdat:newsEntry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NewsEntry'>,
 u'xdat:primary_security_field': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PrimarySecurityField'>,
 u'xdat:role_type': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RoleType'>,
 u'xdat:search_field': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SearchField'>,
 u'xdat:stored_search': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StoredSearch'>,
 u'xdat:user': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.User'>,
 u'xdat:userGroup': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UserGroup'>,
 u'xdat:user_login': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UserLogin'>,
 u'xnat:abstractDemographicData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractDemographicData'>,
 u'xnat:abstractProtocol': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractProtocol'>,
 u'xnat:abstractResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractResource'>,
 u'xnat:abstractStatistics': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractStatistics'>,
 u'xnat:abstractSubjectMetadata': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractSubjectMetadata'>,
 u'xnat:addField': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AddField'>,
 u'xnat:computationData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ComputationData'>,
 u'xnat:contrastBolus': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ContrastBolus'>,
 u'xnat:crScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CrScanData'>,
 u'xnat:crSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CrSessionData'>,
 u'xnat:ctScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanData'>,
 u'xnat:ctSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtSessionData'>,
 u'xnat:datatypeProtocol': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DatatypeProtocol'>,
 u'xnat:demographicData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DemographicData'>,
 u'xnat:derivedData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DerivedData'>,
 u'xnat:dicomSeries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeries'>,
 u'xnat:dx3DCraniofacialScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Dx3DCraniofacialScanData'>,
 u'xnat:dx3DCraniofacialSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Dx3DCraniofacialSessionData'>,
 u'xnat:dxScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DxScanData'>,
 u'xnat:dxSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DxSessionData'>,
 u'xnat:ecgScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EcgScanData'>,
 u'xnat:ecgSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EcgSessionData'>,
 u'xnat:eegScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EegScanData'>,
 u'xnat:eegSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EegSessionData'>,
 u'xnat:epsScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EpsScanData'>,
 u'xnat:epsSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EpsSessionData'>,
 u'xnat:esScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsScanData'>,
 u'xnat:esSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsSessionData'>,
 u'xnat:esvScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsvScanData'>,
 u'xnat:esvSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsvSessionData'>,
 u'xnat:experimentData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentData'>,
 u'xnat:fieldDefinitionGroup': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldDefinitionGroup'>,
 u'xnat:fileData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FileData'>,
 u'xnat:genericData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GenericData'>,
 u'xnat:gmScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmScanData'>,
 u'xnat:gmSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmSessionData'>,
 u'xnat:gmvScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmvScanData'>,
 u'xnat:gmvSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmvSessionData'>,
 u'xnat:hdScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HdScanData'>,
 u'xnat:hdSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HdSessionData'>,
 u'xnat:imageAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageAssessorData'>,
 u'xnat:imageResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResource'>,
 u'xnat:imageResourceSeries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceSeries'>,
 u'xnat:imageScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageScanData'>,
 u'xnat:imageSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageSessionData'>,
 u'xnat:investigatorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.InvestigatorData'>,
 u'xnat:ioScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IoScanData'>,
 u'xnat:ioSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IoSessionData'>,
 u'xnat:megScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MegScanData'>,
 u'xnat:megSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MegSessionData'>,
 u'xnat:mgScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MgScanData'>,
 u'xnat:mgSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MgSessionData'>,
 u'xnat:mrAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrAssessorData'>,
 u'xnat:mrQcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrQcScanData'>,
 u'xnat:mrScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanData'>,
 u'xnat:mrSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrSessionData'>,
 u'xnat:mrsScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrsScanData'>,
 u'xnat:nmScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NmScanData'>,
 u'xnat:nmSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NmSessionData'>,
 u'xnat:opScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OpScanData'>,
 u'xnat:opSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OpSessionData'>,
 u'xnat:optScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanData'>,
 u'xnat:optSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptSessionData'>,
 u'xnat:otherDicomScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OtherDicomScanData'>,
 u'xnat:otherDicomSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OtherDicomSessionData'>,
 u'xnat:otherQcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OtherQcScanData'>,
 u'xnat:pVisitData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PVisitData'>,
 u'xnat:petAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetAssessorData'>,
 u'xnat:petQcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetQcScanData'>,
 u'xnat:petScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanData'>,
 u'xnat:petSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionData'>,
 u'xnat:petmrSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionData'>,
 u'xnat:projectData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectData'>,
 u'xnat:projectParticipant': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectParticipant'>,
 u'xnat:publicationResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PublicationResource'>,
 u'xnat:qcAssessmentData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcAssessmentData'>,
 u'xnat:qcManualAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcManualAssessorData'>,
 u'xnat:qcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcScanData'>,
 u'xnat:reconstructedImageData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ReconstructedImageData'>,
 u'xnat:regionResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RegionResource'>,
 u'xnat:resource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Resource'>,
 u'xnat:resourceCatalog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ResourceCatalog'>,
 u'xnat:resourceSeries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ResourceSeries'>,
 u'xnat:rfScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RfScanData'>,
 u'xnat:rfSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RfSessionData'>,
 u'xnat:rtImageScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RtImageScanData'>,
 u'xnat:rtSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RtSessionData'>,
 u'xnat:scScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScScanData'>,
 u'xnat:segScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SegScanData'>,
 u'xnat:smScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SmScanData'>,
 u'xnat:smSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SmSessionData'>,
 u'xnat:srScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SrScanData'>,
 u'xnat:srSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SrSessionData'>,
 u'xnat:statisticsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StatisticsData'>,
 u'xnat:studyProtocol': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocol'>,
 u'xnat:subjectAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectAssessorData'>,
 u'xnat:subjectData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectData'>,
 u'xnat:subjectMetadata': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectMetadata'>,
 u'xnat:subjectVariablesData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectVariablesData'>,
 u'xnat:usScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UsScanData'>,
 u'xnat:usSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UsSessionData'>,
 u'xnat:validationData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ValidationData'>,
 u'xnat:voiceAudioScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VoiceAudioScanData'>,
 u'xnat:volumetricRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetricRegion'>,
 u'xnat:xa3DScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Xa3DScanData'>,
 u'xnat:xa3DSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Xa3DSessionData'>,
 u'xnat:xaScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanData'>,
 u'xnat:xaSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaSessionData'>,
 u'xnat:xcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcScanData'>,
 u'xnat:xcSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcSessionData'>,
 u'xnat:xcvScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcvScanData'>,
 u'xnat:xcvSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcvSessionData'>,
 u'xnat_a:scidResearchData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchData'>,
 u'xnat_a:sideEffectsPittsburghData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SideEffectsPittsburghData'>,
 u'xnat_a:updrs3Data': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3Data'>,
 u'xnat_a:ybocsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YbocsData'>,
 u'xnat_a:ygtssData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YgtssData'>,
 u'xnatpy:DiagnosisString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosisString'>,
 u'xnatpy:abstractResourceTags': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractResourceTags'>,
 u'xnatpy:activityFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ActivityFloat'>,
 u'xnatpy:addFieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AddFieldString'>,
 u'xnatpy:addIDString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AddIDString'>,
 u'xnatpy:additionalStatisticsDouble': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AdditionalStatisticsDouble'>,
 u'xnatpy:aliasString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AliasString'>,
 u'xnatpy:aparcRegionAnalysisHemisphere': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AparcRegionAnalysisHemisphere'>,
 u'xnatpy:aparcRegionAnalysisHemisphereRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AparcRegionAnalysisHemisphereRegions'>,
 u'xnatpy:asegRegionAnalysisRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AsegRegionAnalysisRegions'>,
 u'xnatpy:atrophyNilDataCsf_ratio': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtrophyNilDataCsfRatio'>,
 u'xnatpy:atrophyNilDataPeaks': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtrophyNilDataPeaks'>,
 u'xnatpy:bpFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.BpFloat'>,
 u'xnatpy:catalogMetafields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CatalogMetafields'>,
 u'xnatpy:clinicalAssessmentDataBloodpressure': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataBloodpressure'>,
 u'xnatpy:clinicalAssessmentDataDiagnosis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataDiagnosis'>,
 u'xnatpy:clinicalAssessmentDataMedication': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataMedication'>,
 u'xnatpy:clinicalAssessmentDataMovement': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataMovement'>,
 u'xnatpy:clinicalAssessmentDataNeuro': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataNeuro'>,
 u'xnatpy:clinicalAssessmentDataNeuroCdr': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataNeuroCdr'>,
 u'xnatpy:commentString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CommentString'>,
 u'xnatpy:compilerString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CompilerString'>,
 u'xnatpy:csvValuesString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CsvValuesString'>,
 u'xnatpy:ctScanDataDcmvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataDcmvalidation'>,
 u'xnatpy:ctScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParameters'>,
 u'xnatpy:ctScanDataParametersCollimationwidth': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersCollimationwidth'>,
 u'xnatpy:ctScanDataParametersDerivation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersDerivation'>,
 u'xnatpy:ctScanDataParametersEstimateddosesaving': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersEstimateddosesaving'>,
 u'xnatpy:ctScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersFov'>,
 u'xnatpy:ctScanDataParametersRescale': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersRescale'>,
 u'xnatpy:ctScanDataParametersVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersVoxelres'>,
 u'xnatpy:dcmCatalogDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmCatalogDimensions'>,
 u'xnatpy:dcmCatalogVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmCatalogVoxelres'>,
 u'xnatpy:dcmValidationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmValidationString'>,
 u'xnatpy:delayInteger': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DelayInteger'>,
 u'xnatpy:demographicDataHeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DemographicDataHeight'>,
 u'xnatpy:demographicDataWeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DemographicDataWeight'>,
 u'xnatpy:derivationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DerivationString'>,
 u'xnatpy:diagnosesDataMotor': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesDataMotor'>,
 u'xnatpy:diagnosesDataTicdiagnosis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesDataTicdiagnosis'>,
 u'xnatpy:diagnosesDataVocal': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesDataVocal'>,
 u'xnatpy:dicomSeriesDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeriesDimensions'>,
 u'xnatpy:dicomSeriesImageset': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeriesImageset'>,
 u'xnatpy:dicomSeriesVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeriesVoxelres'>,
 u'xnatpy:doseFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DoseFloat'>,
 u'xnatpy:ecatValidationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EcatValidationString'>,
 u'xnatpy:element_securityListing_actions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ElementSecurityListingActions'>,
 u'xnatpy:encounterLogEncounters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EncounterLogEncounters'>,
 u'xnatpy:entryMetafields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EntryMetafields'>,
 u'xnatpy:estimatedDoseSavingFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EstimatedDoseSavingFloat'>,
 u'xnatpy:experimentDataDelay': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentDataDelay'>,
 u'xnatpy:experimentDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentDataFields'>,
 u'xnatpy:experimentDataSharing': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentDataSharing'>,
 u'xnatpy:fieldDefinitionGroupFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldDefinitionGroupFields'>,
 u'xnatpy:fieldDefinitionGroupFieldsFieldPossiblevalues': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldDefinitionGroupFieldsFieldPossiblevalues'>,
 u'xnatpy:fieldSpecificationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldSpecificationString'>,
 u'xnatpy:fieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldString'>,
 u'xnatpy:findingString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FindingString'>,
 u'xnatpy:fsDataMeasures': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasures'>,
 u'xnatpy:fsDataMeasuresSurface': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresSurface'>,
 u'xnatpy:fsDataMeasuresSurfaceHemisphereRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresSurfaceHemisphereRegions'>,
 u'xnatpy:fsDataMeasuresVolumetric': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresVolumetric'>,
 u'xnatpy:fsDataMeasuresVolumetricRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresVolumetricRegions'>,
 u'xnatpy:geneticTestResultsGenes': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GeneticTestResultsGenes'>,
 u'xnatpy:handednessDataParents_left': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataParentsLeft'>,
 u'xnatpy:handednessDataSiblings': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataSiblings'>,
 u'xnatpy:handednessDataSiblingsFemale': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataSiblingsFemale'>,
 u'xnatpy:handednessDataSiblingsMale': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataSiblingsMale'>,
 u'xnatpy:handednessDataTask_prefs': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataTaskPrefs'>,
 u'xnatpy:heightFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HeightFloat'>,
 u'xnatpy:imageResourceDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceDimensions'>,
 u'xnatpy:imageResourceSeriesDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceSeriesDimensions'>,
 u'xnatpy:imageResourceSeriesVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceSeriesVoxelres'>,
 u'xnatpy:imageResourceVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceVoxelres'>,
 u'xnatpy:imageScanDataScanner': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageScanDataScanner'>,
 u'xnatpy:imageScanDataSharing': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageScanDataSharing'>,
 u'xnatpy:imageSessionDataScanner': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageSessionDataScanner'>,
 u'xnatpy:intermediateFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IntermediateFloat'>,
 u'xnatpy:isotopeString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IsotopeString'>,
 u'xnatpy:labelString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LabelString'>,
 u'xnatpy:libraryString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LibraryString'>,
 u'xnatpy:longFSDataMeasures': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasures'>,
 u'xnatpy:longFSDataMeasuresSurface': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresSurface'>,
 u'xnatpy:longFSDataMeasuresSurfaceHemisphereRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresSurfaceHemisphereRegions'>,
 u'xnatpy:longFSDataMeasuresVolumetric': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresVolumetric'>,
 u'xnatpy:longFSDataMeasuresVolumetricRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresVolumetricRegions'>,
 u'xnatpy:longFSDataTimepoints': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataTimepoints'>,
 u'xnatpy:manualVolumetryRegionSlice': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ManualVolumetryRegionSlice'>,
 u'xnatpy:metaFieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MetaFieldString'>,
 u'xnatpy:modifiedScheltensDataAssessment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessment'>,
 u'xnatpy:modifiedScheltensDataAssessmentRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegions'>,
 u'xnatpy:modifiedScheltensDataAssessmentRegionsBasal_ganglia': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegionsBasalGanglia'>,
 u'xnatpy:modifiedScheltensDataAssessmentRegionsDeep_white_matter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegionsDeepWhiteMatter'>,
 u'xnatpy:modifiedScheltensDataAssessmentRegionsPeriventricular': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegionsPeriventricular'>,
 u'xnatpy:modifiedScheltensDataAssessmentVirchow_robin': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentVirchowRobin'>,
 u'xnatpy:modifiedScheltensRegionLeft': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionLeft'>,
 u'xnatpy:modifiedScheltensRegionLeftInfarcts': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionLeftInfarcts'>,
 u'xnatpy:modifiedScheltensRegionLeftLesions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionLeftLesions'>,
 u'xnatpy:modifiedScheltensRegionRight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionRight'>,
 u'xnatpy:modifiedScheltensRegionRightInfarcts': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionRightInfarcts'>,
 u'xnatpy:modifiedScheltensRegionRightLesions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionRightLesions'>,
 u'xnatpy:mrScanDataDcmvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataDcmvalidation'>,
 u'xnatpy:mrScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParameters'>,
 u'xnatpy:mrScanDataParametersDiffusion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersDiffusion'>,
 u'xnatpy:mrScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersFov'>,
 u'xnatpy:mrScanDataParametersMatrix': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersMatrix'>,
 u'xnatpy:mrScanDataParametersVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersVoxelres'>,
 u'xnatpy:nundaDemographicDataHandednessexam': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NundaDemographicDataHandednessexam'>,
 u'xnatpy:nundaDemographicDataRelationships': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NundaDemographicDataRelationships'>,
 u'xnatpy:optScanDataDcmvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataDcmvalidation'>,
 u'xnatpy:optScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataParameters'>,
 u'xnatpy:optScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataParametersFov'>,
 u'xnatpy:optScanDataParametersVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataParametersVoxelres'>,
 u'xnatpy:parameterString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ParameterString'>,
 u'xnatpy:petScanDataEcatvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataEcatvalidation'>,
 u'xnatpy:petScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParameters'>,
 u'xnatpy:petScanDataParametersDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersDimensions'>,
 u'xnatpy:petScanDataParametersFilter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersFilter'>,
 u'xnatpy:petScanDataParametersFrames': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersFrames'>,
 u'xnatpy:petScanDataParametersFramesFrame': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersFramesFrame'>,
 u'xnatpy:petScanDataParametersOffset': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersOffset'>,
 u'xnatpy:petScanDataParametersPixelsize': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersPixelsize'>,
 u'xnatpy:petScanDataParametersResolution': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersResolution'>,
 u'xnatpy:petScanDataParametersRfilter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersRfilter'>,
 u'xnatpy:petScanDataParametersZfilter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersZfilter'>,
 u'xnatpy:petSessionDataTracer': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracer'>,
 u'xnatpy:petSessionDataTracerDose': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerDose'>,
 u'xnatpy:petSessionDataTracerIntermediate': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerIntermediate'>,
 u'xnatpy:petSessionDataTracerIsotope': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerIsotope'>,
 u'xnatpy:petSessionDataTracerTotalmass': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerTotalmass'>,
 u'xnatpy:petTimeCourseDataDurations': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataDurations'>,
 u'xnatpy:petTimeCourseDataDurationsDurationBp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataDurationsDurationBp'>,
 u'xnatpy:petTimeCourseDataRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataRegions'>,
 u'xnatpy:petTimeCourseDataRegionsRegionTimeseries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataRegionsRegionTimeseries'>,
 u'xnatpy:petmrSessionDataTracer': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracer'>,
 u'xnatpy:petmrSessionDataTracerDose': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerDose'>,
 u'xnatpy:petmrSessionDataTracerIntermediate': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerIntermediate'>,
 u'xnatpy:petmrSessionDataTracerIsotope': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerIsotope'>,
 u'xnatpy:petmrSessionDataTracerTotalmass': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerTotalmass'>,
 u'xnatpy:pipelineParameterDataCsvvalues': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PipelineParameterDataCsvvalues'>,
 u'xnatpy:platformString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PlatformString'>,
 u'xnatpy:possibleValueString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PossibleValueString'>,
 u'xnatpy:primary_passwordString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PrimaryPasswordString'>,
 u'xnatpy:primary_security_fieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PrimarySecurityFieldString'>,
 u'xnatpy:processStepCompiler': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepCompiler'>,
 u'xnatpy:processStepLibrary': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepLibrary'>,
 u'xnatpy:processStepPlatform': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepPlatform'>,
 u'xnatpy:processStepProgram': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepProgram'>,
 u'xnatpy:programString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProgramString'>,
 u'xnatpy:projectDataAliases': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectDataAliases'>,
 u'xnatpy:projectDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectDataFields'>,
 u'xnatpy:projectPipelines': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelines'>,
 u'xnatpy:projectPipelinesDescendants': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelinesDescendants'>,
 u'xnatpy:projectPipelinesDescendantsDescendantPipeline': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelinesDescendantsDescendantPipeline'>,
 u'xnatpy:projectPipelinesPipeline': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelinesPipeline'>,
 u'xnatpy:propertyString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PropertyString'>,
 u'xnatpy:protocolDataCheck': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataCheck'>,
 u'xnatpy:protocolDataCheckComments': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataCheckComments'>,
 u'xnatpy:protocolDataCheckConditions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataCheckConditions'>,
 u'xnatpy:protocolDataScans': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataScans'>,
 u'xnatpy:protocolDataScansScan_checkComments': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataScansScanCheckComments'>,
 u'xnatpy:protocolDataScansScan_checkConditions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataScansScanCheckConditions'>,
 u'xnatpy:psychometricsDataKanne': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsDataKanne'>,
 u'xnatpy:psychometricsDataWais': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsDataWais'>,
 u'xnatpy:psychometricsDataWms': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsDataWms'>,
 u'xnatpy:pulseInteger': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PulseInteger'>,
 u'xnatpy:pupTimeCourseDataRois': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PupTimeCourseDataRois'>,
 u'xnatpy:qcAssessmentDataScans': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcAssessmentDataScans'>,
 u'xnatpy:qcAssessmentDataScansScanSliceqc': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcAssessmentDataScansScanSliceqc'>,
 u'xnatpy:qcScanDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcScanDataFields'>,
 u'xnatpy:qcScanDataRating': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcScanDataRating'>,
 u'xnatpy:radiologyReadDataFinding': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RadiologyReadDataFinding'>,
 u'xnatpy:ratingString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RatingString'>,
 u'xnatpy:regionResourceCreator': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RegionResourceCreator'>,
 u'xnatpy:regionResourceSubregionlabels': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RegionResourceSubregionlabels'>,
 u'xnatpy:scannerString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScannerString'>,
 u'xnatpy:scidResearchDataAnxietydisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataAnxietydisorders'>,
 u'xnatpy:scidResearchDataEatingdisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataEatingdisorders'>,
 u'xnatpy:scidResearchDataMooddisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataMooddisorders'>,
 u'xnatpy:scidResearchDataMoodepisodes': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataMoodepisodes'>,
 u'xnatpy:scidResearchDataOptional': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataOptional'>,
 u'xnatpy:scidResearchDataPsychoticdisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataPsychoticdisorders'>,
 u'xnatpy:scidResearchDataPsychoticsymptoms': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataPsychoticsymptoms'>,
 u'xnatpy:scidResearchDataSomatoformdisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataSomatoformdisorders'>,
 u'xnatpy:scidResearchDataSubstanceusedisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataSubstanceusedisorders'>,
 u'xnatpy:shareString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ShareString'>,
 u'xnatpy:statisticsDataAddfield': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StatisticsDataAddfield'>,
 u'xnatpy:statisticsDataAdditionalstatistics': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StatisticsDataAdditionalstatistics'>,
 u'xnatpy:stored_searchAllowed_user': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StoredSearchAllowedUser'>,
 u'xnatpy:stored_searchSort_by': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StoredSearchSortBy'>,
 u'xnatpy:studyProtocolAcqconditions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolAcqconditions'>,
 u'xnatpy:studyProtocolImagesessiontypes': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolImagesessiontypes'>,
 u'xnatpy:studyProtocolSubjectgroups': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolSubjectgroups'>,
 u'xnatpy:studyProtocolSubjectvariables': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolSubjectvariables'>,
 u'xnatpy:subjectDataAddid': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectDataAddid'>,
 u'xnatpy:subjectDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectDataFields'>,
 u'xnatpy:subjectVariablesDataVariables': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectVariablesDataVariables'>,
 u'xnatpy:symptomsNeurocogZ_cog_2grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZCog2grp'>,
 u'xnatpy:symptomsNeurocogZ_cog_4grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZCog4grp'>,
 u'xnatpy:symptomsNeurocogZ_psy_2grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZPsy2grp'>,
 u'xnatpy:symptomsNeurocogZ_psy_4grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZPsy4grp'>,
 u'xnatpy:symptomsSAPSSANSSans': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsSAPSSANSSans'>,
 u'xnatpy:symptomsSAPSSANSSaps': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsSAPSSANSSaps'>,
 u'xnatpy:tagString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.TagString'>,
 u'xnatpy:totalMassFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.TotalMassFloat'>,
 u'xnatpy:updrs3DataActionposturaltremor': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataActionposturaltremor'>,
 u'xnatpy:updrs3DataClicker': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataClicker'>,
 u'xnatpy:updrs3DataFingertaps': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataFingertaps'>,
 u'xnatpy:updrs3DataFoottaps': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataFoottaps'>,
 u'xnatpy:updrs3DataHandmovementsgrip': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataHandmovementsgrip'>,
 u'xnatpy:updrs3DataHandsram': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataHandsram'>,
 u'xnatpy:updrs3DataRigidity': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataRigidity'>,
 u'xnatpy:updrs3DataTremorrest': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataTremorrest'>,
 u'xnatpy:userPrimary_password': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UserPrimaryPassword'>,
 u'xnatpy:variableString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VariableString'>,
 u'xnatpy:vitalsDataBloodpressure': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataBloodpressure'>,
 u'xnatpy:vitalsDataHeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataHeight'>,
 u'xnatpy:vitalsDataPulse': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataPulse'>,
 u'xnatpy:vitalsDataWeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataWeight'>,
 u'xnatpy:volumetricRegionSubregions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetricRegionSubregions'>,
 u'xnatpy:volumetryRegionInfoRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfoRegions'>,
 u'xnatpy:volumetryRegionInfoRegionsRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfoRegionsRegion'>,
 u'xnatpy:volumetryRegionInfoRegionsRegionVoxel_res': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfoRegionsRegionVoxelRes'>,
 u'xnatpy:weightFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.WeightFloat'>,
 u'xnatpy:xaScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanDataParameters'>,
 u'xnatpy:xaScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanDataParametersFov'>,
 u'xnatpy:xaScanDataParametersPixelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanDataParametersPixelres'>,
 u'xnatpy:xnatExecutionEnvironmentParameterfile': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XnatExecutionEnvironmentParameterfile'>,
 u'xnatpy:xnatExecutionEnvironmentParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XnatExecutionEnvironmentParameters'>,
 u'xnatpy:ygtssDataMotor': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YgtssDataMotor'>,
 u'xnatpy:ygtssDataPhonic': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YgtssDataPhonic'>}
In [16]:
print('Subject XSI: {}'.format(subject.__xsi_type__))
print('Subject xpath: {}'.format(subject.xpath))
print('Subject demographics XSI: {}'.format(subject.demographics.__xsi_type__))
print('Subject demographics XSI: {}'.format(subject.demographics.xpath))
Subject XSI: xnat:subjectData
Subject xpath: xnat:subjectData
Subject demographics XSI: xnat:demographicData
Subject demographics XSI: xnat:subjectData/demographics[@xsi:type=xnat:demographicData]

Custom Variables

In xnatpy custom variables are exposed as a simple mapping type that is very similar to a dictionary.

In [17]:
print(subject.fields)
subject.
<XNATSimpleListing {}>
In [18]:
# Add something
subject.fields['test_field'] = 42
print(subject.fields)
<XNATSimpleListing {u'test_field': u'42'}>
In [19]:
subject.fields['test_field']
Out[19]:
u'42'

Note that custom variables are always stored as string in the database. So the value is always casted to a string. Also the length of a value is limited because they are passed on the requested url.

The custom variables are by default not visible in the UI, there are special settings in the UI to make them appear. Defined variables in the UI that are not set, are just not appearing in the fields dictionary.

To avoid KeyError, it would be best to use subject.fields.get('field_name') which returns None when not available.

Downloading stuff

Downloading with xnatpy is fairly simple. Most objects that are downloadable have a .download method. There is also a download_dir method that downloads the zip and unpacks it to the target directory.

In [20]:
download_dir = os.path.expanduser('~/xnatpy_temp')
print('Using {} as download directory'.format(download_dir))
if not os.path.exists(download_dir):
    os.makedirs(download_dir)
sandbox.subjects['Case001'].download_dir(download_dir)
Using /home/hachterberg/xnatpy_temp as download directory
 45.6 MiB |         #                       |   1.1 MiB/s Elapsed Time: 0:00:40

import service

xnatpy exposes the import service of xnat (documentation at https://xnat.readthedocs.io/en/latest/xnat.html#xnat.services.Services )

In [21]:
zip_file = os.path.join(download_dir, 'Case001.zip')
#sandbox.subjects['Case001'].experiments['Case001'].download(zip_file)
In [22]:
subject_name = "import_subject_{}".format(random.randint(0, 999))
print('Importing under new subject: {}'.format(subject_name))
session.services.import_(zip_file, destination='/prearchive', project='xnatpydemo', subject=subject_name)
Importing under new subject: import_subject_132
Out[22]:
<PrearchiveSession xnatpydemo/20171016_052006805/Case001>

Prearchive

xnatpy also offers an interface to the prearchive using the session.prearchive.session method, which list the PrearchiveSessions. These object can be used to inspect a session in the prearchive and to manipulate it (e.g. delete, move, archive)

More info can be found at https://xnat.readthedocs.io/en/latest/xnat.html#xnat.prearchive.PrearchiveSession

In [23]:
print("-- Before archive --")
print('prearchive:')
print session.prearchive.sessions()
print('project:')
print sandbox.subjects

# Create a new name for subject and experiment
pas = session.prearchive.sessions()[0]
nr = random.randint(0, 999)
subject_name = "archive_subject_{}".format(nr)
experiment_name = "archive_exp_{}".format(nr)
print('Using name: {} / {}'.format(subject_name, experiment_name))

# Archive subject under different name
pas.archive(subject=subject_name, experiment=experiment_name)

print("-- After archive --")
print('prearchive:')
print session.prearchive.sessions()
print('project:')
print sandbox.subjects.clearcache()
print sandbox.subjects
-- Before archive --
prearchive:
[<PrearchiveSession xnatpydemo/20171016_052006805/Case001>]
project:
<XNATListing {(CENTRAL_S06138, Case001): <SubjectData Case001>, (CENTRAL_S06139, archive_subject_489): <SubjectData archive_subject_489>, (CENTRAL_S06140, archive_subject_981): <SubjectData archive_subject_981>, (CENTRAL_S06137, subject001): <SubjectData subject001>, (CENTRAL_S06141, archive_subject_158): <SubjectData archive_subject_158>}>
Using name: archive_subject_520 / archive_exp_520
-- After archive --
prearchive:
[]
project:
None
<XNATListing {(CENTRAL_S06138, Case001): <SubjectData Case001>, (CENTRAL_S06139, archive_subject_489): <SubjectData archive_subject_489>, (CENTRAL_S06140, archive_subject_981): <SubjectData archive_subject_981>, (CENTRAL_S06137, subject001): <SubjectData subject001>, (CENTRAL_S06141, archive_subject_158): <SubjectData archive_subject_158>, (CENTRAL_S06142, archive_subject_520): <SubjectData archive_subject_520>}>

Getting user information

You can get some information about the users on the server using the REST API:

In [24]:
print(session.users['xnatpydemo'])
print(session.users['xnatpydemo'].first_name)
print(session.users['xnatpydemo'].email)
<User xnatpydemo [1830]>
xnatpy
hakim.achterberg@gmail.com

Inspect (similar to pyxnat)

There is also an inspect module similar to that of pyxnat. It allows you to list datatypes and search fields defined on the server:

In [25]:
print('== Datatypes ==')
print(session.inspect.datatypes())
print('== Data fields ==')
print(session.inspect.datafields('xnat:subjectData'))
== Datatypes ==
[u'xnat:qcAssessmentData', u'fs:aparcRegionAnalysis', u'wrk:workflowData', u'xnat:investigatorData', u'fs:automaticSegmentationData', u'fs:asegRegionAnalysis', u'cnda:manualVolumetryData', u'genetics:geneticTestResults', u'cnda:clinicalAssessmentData', u'fs:fsData', u'cnda:psychometricsData', u'xnat:subjectData', u'cnda:dtiData', u'cnda:atlasScalingFactorData', u'xnat:rtSessionData', u'sf:encounterLog', u'xnat:petSessionData', u'neurocog:symptomsNeurocog', u'xnat:mrSessionData', u'cnda:segmentationFastData', u'sapssans:symptomsSAPSSANS', u'adrc:ADRCClinicalData', u'xnat:ctSessionData', u'xnat:usSessionData', u'pup:pupTimeCourseData', u'xnat:projectData', u'cnda:radiologyReadData', u'cnda:modifiedScheltensData']
== Data fields ==
[u'xnat:subjectData/INSERT_DATE', u'xnat:subjectData/INSERT_USER', u'xnat:subjectData/GENDER_TEXT', u'xnat:subjectData/HANDEDNESS_TEXT', u'xnat:subjectData/DOB', u'xnat:subjectData/EDUC', u'xnat:subjectData/SES', u'xnat:subjectData/INVEST_CSV', u'xnat:subjectData/PROJECTS', u'xnat:subjectData/PROJECT', u'xnat:subjectData/SUB_GROUP', u'xnat:subjectData/ADD_IDS', u'xnat:subjectData/RACE', u'xnat:subjectData/ETHNICITY', u'xnat:subjectData/XNAT_COL_SUBJECTDATALABEL', u'xnat:subjectData/XNAT_COL_DEMOGRAPHICDATAAGE']

Close the session!

In [ ]:
# Don't forget to disconnect to close cleanly and clean up temporary things!
session.disconnect()

Context operator

It is also possible to use xnatpy in a context, which guarantees clean closure of the connections etc.

In [ ]:
with xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017') as session:
    print('Nosetests project description: {}'.format(session.projects['xnatpydemo'].description))
    
# Here the session will be closed properly, even if there were exceptions within the `with` context

Ideas for the future

Currently I am thinking on two different additions and how to implement that best.

  • Creation of new objects
  • XNAT searches

This illustrates my current ideas, but these are not implemented yet. If you have an opinion about this, let me know!

Object creation

xnat.SubjectData(parent=projectA, initials='X')

or alternatively

projectA.subjects['subjectX'] = xnat.SubjectData(initials='X')

Searches

The idea is to create something similar to SQLAlchemy

This sort of works:

In [26]:
with xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017') as session:
    print session.classes.SubjectData.query().filter(session.classes.SubjectData.initials == 'JC').all()
[{'insert_user': 'xnatpydemo', 'subject_label': 'subject001', 'ses': '', 'insert_date': '2017-10-15 08:56:12.551', 'dob': '', 'gender': 'male', 'handedness': 'left', 'quarantine_status': 'active', 'subjectid': 'CENTRAL_S06137', 'project': 'xnatpydemo', 'educ': '', 'projects': ',<xnatpydemo>'}]

But this does not:

with xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017') as session: print session.classes.SubjectData.query().filter(session.classes.SubjectData.demographics.age == 42).all()
In [ ]: