Class that holds the properties to access a XNAT server.
>>> interface = Interface( server='http://central.xnat.org:8080',
user='login',
password='pwd',
datastore='/tmp'
)
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
All REST resources objects are derived from ResourceObject which contains the common mechanisms to read and write on the server.
All REST resources objects are derived from ResourceObject which contains the common mechanisms to read and write on the server.
Creates the corresponding element on the XNAT server.
Note
The xsi_type is defined in the XNAT XML Schema. It allows a generic type such as xnat:experimentData to be derived in xnat:mrSessionData and xnat:petSessionData to be given some specific attributes.
Parameters: | xsi_type: string or None :
|
---|
See also
Deletes the corresponding resource on the XNAT server.
Parameters: | delete_files: True or False :
|
---|
Test whether this object actually exists.
Returns: | True or False : |
---|
Returns the xnat_type or xsi_type``which is defined in the XNAT schema of this ``ResourceObject.
ResourceObject | possible xsi types |
---|---|
Project | xnat:projectData |
Subject | xnat:subjectData |
Experiment | xnat:mrSessionData xnat:petSessionData |
Collection of ResourceObjects.
A CollectionObject provides a collection of ResourceObject.
It is mainly useful because it is iterable and enables the following behaviour:
>>> for p in interface.projects():
>>> print p.subjects()
Specific elements in the collection can be accessed either by their ID or by their index in the corresponding list:
>>> projects = interface.projects()
>>> print projects
['A', 'B', 'C']
>>> projects[1] == projects['B']
True
Specialized ResourceObject class for subjects.
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Specialized ResourceObject class for experiments.
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Specialized ResourceObject class for scans.
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Parameters: | ID: string :
|
---|
Parameters: | id_filter: string :
|
---|
Specialized ResourceObject class for files.
Returns: | The specified content for this file. : e.g. T1, DTI, sequence preview, table : |
---|
Returns: | The specified format for this file. : e.g. NIFTI, DICOM, jpeg, txt, csv : |
---|
Downloads the file if it is not in the local cache.
Note
The data in the cache is kept up to date using the cache HTTP headers. If an external program were to modify the data without updating the headers, the data would no longer be synchronized correctly. This is why the returned file descriptor is read-only. Use get_copy() if you wish to modify the data.
Returns: | A read-only file descriptor. : |
---|
See also
Downloads the file if it is not in the local cache and creates a copy.
Parameters: | dest: string | None :
|
---|---|
Returns: | The file path as a string. : |
See also
Uploads a local file on the server.
Returns: | True if successful, False otherwise. : |
---|
Returns: | The size of the file in bytes as a string. : |
---|
Returns: | The specified tags for this file. : |
---|
Manual manager for the cached data.
The cache management is mainly transparent but it is useful sometimes to do theses actions manually.
A cache manager is linked to a ResourceObject and only works upon the cached data related to this object.
The cache manager should be accessed through the cache attribute of its corresponding resource.
>>> subject.cache(pattern='*', files=True, recursive=True)
>>> subject.cache.clear()
Parameters: | robj: ResourceObject :
|
---|
Put all the resources related to this object in the local datastore.
Parameters: | attrib: True or False :
files: True or False :
recursive: True or False :
|
---|
Clears the cached data for this object.
Parameters: | data: ‘all’ | ‘resources’ | ‘files’ :
|
---|
Define constraints to make a complex search on the database.
A search manager is available as an Interface attribute. Its main usage is simply to be called to create a Search object which will be responsible for specifying the returned data and for submitting the actual query.
Some additional methods are provided to list, retrieve and delete saved search.
>>> query = [ ('xnat:subjectData/SUBJECT_ID', 'LIKE', '%'),
('xnat:projectData/ID', '=', 'my_project'),
[ ('xnat:subjectData/AGE', '>', '14'),
'AND'
],
'OR'
]
>>> search = interface.search('my_search', query)
>>>
>>> # no search is saved because it was not submitted
>>> interface.search.names()
[]
>>> # submit and get results
>>> search.get_subjects()
[...]
>>> # now the search is saved
>>> interface.search.names()
['my_search']
>>>
>>> same_search = interface.search.get('my_search')
Setups and returns a Search object.
Warning
The search itself is not submitted here. The search is executed when a Search method like get_subjects(), which defines what kind of data is to be returned is called.
Parameters: | name: string :
query: list :
|
---|
See also
Search.get_table, Search.get_subjects, Search.get_experiments
Submits the defined search and returns a table.
Parameters: | row_type: string :
columns: list of strings :
|
---|---|
Returns: | A JsonTable object containing the results. : |