{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# xnatpy: a pythonic feeling interface to XNAT"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "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.\n",
    "\n",
    "To facilitate this xnatpy scans the server xnat.xsd and creates a Python class structure to mimic this is well as possible.\n",
    "\n",
    "Current features:\n",
    "* automatic generate of most data structures from the xnat.xsd\n",
    "* easy exploration of data\n",
    "* easy getting/setting of custom variables\n",
    "* easy downloading/uploading of data\n",
    "* using the prearchive\n",
    "* the import service\n",
    "\n",
    "Missing features (aka my TODO list):\n",
    "* good support for the creation of objects\n",
    "* good support for searches"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "### Some imports and helper code used later on"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import random"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## getting started\n",
    "\n",
    "First we need to set up an xnatpy session. \n",
    "The session scans the xnat.xsd, creates classes,\n",
    "logs in into XNAT, and keeps the connection alive\n",
    "using a hearbeat."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loaded xnatpy version 0.3.2\n"
     ]
    }
   ],
   "source": [
    "import xnat\n",
    "print('Loaded xnatpy version {}'.format(xnat.__version__))\n",
    "session = xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "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.\n",
    "\n",
    "To save your login you set up a .netrc file with the correct information about the target host.\n",
    "A simple example of a .netrc file can be found at  [http://www.mavetju.org/unix/netrc.php](http://www.mavetju.org/unix/netrc.php).\n",
    "\n",
    "It is possible to set the login information on connect without using a netrc file.\n",
    "\n",
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function connect in module xnat:\n",
      "\n",
      "connect(server, user=None, password=None, verify=True, netrc_file=None, debug=False, extension_types=True, loglevel=None, logger=None)\n",
      "    Connect to a server and generate the correct classed based on the servers xnat.xsd\n",
      "    This function returns an object that can be used as a context operator. It will call\n",
      "    disconnect automatically when the context is left. If it is used as a function, then\n",
      "    the user should call ``.disconnect()`` to destroy the session and temporary code file.\n",
      "    \n",
      "    :param str server: uri of the server to connect to (including http:// or https://)\n",
      "    :param str user: username to use, leave empty to use netrc entry or anonymous login.\n",
      "    :param str password: password to use with the username, leave empty when using netrc.\n",
      "                         If a username is given and no password, there will be a prompt\n",
      "                         on the console requesting the password.\n",
      "    :param bool verify: verify the https certificates, if this is false the connection will\n",
      "                        be encrypted with ssl, but the certificates are not checked. This is\n",
      "                        potentially dangerous, but required for self-signed certificates.\n",
      "    :param str netrc_file: alternative location to use for the netrc file (path pointing to\n",
      "                           a file following the netrc syntax)\n",
      "    :param debug bool: Set debug information printing on\n",
      "    :param str loglevel: Set the level of the logger to desired level\n",
      "    :param logging.Logger logger: A logger to reuse instead of creating an own logger\n",
      "    :return: XNAT session object\n",
      "    :rtype: XNATSession\n",
      "    \n",
      "    Preferred use::\n",
      "    \n",
      "        >>> import xnat\n",
      "        >>> with xnat.connect('https://central.xnat.org') as session:\n",
      "        ...    subjects = session.projects['Sample_DICOM'].subjects\n",
      "        ...    print('Subjects in the SampleDICOM project: {}'.format(subjects))\n",
      "        Subjects in the SampleDICOM project: <XNATListing (CENTRAL_S01894, dcmtest1): <SubjectData CENTRAL_S01894>, (CENTRAL_S00461, PACE_HF_SUPINE): <SubjectData CENTRAL_S00461>>\n",
      "    \n",
      "    Alternative use::\n",
      "    \n",
      "        >>> import xnat\n",
      "        >>> session = xnat.connect('https://central.xnat.org')\n",
      "        >>> subjects = session.projects['Sample_DICOM'].subjects\n",
      "        >>> print('Subjects in the SampleDICOM project: {}'.format(subjects))\n",
      "        Subjects in the SampleDICOM project: <XNATListing (CENTRAL_S01894, dcmtest1): <SubjectData CENTRAL_S01894>, (CENTRAL_S00461, PACE_HF_SUPINE): <SubjectData CENTRAL_S00461>>\n",
      "        >>> session.disconnect()\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(xnat.connect)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Session object basic functionality"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method get in module xnat.session:\n",
      "\n",
      "get(self, path, format=None, query=None, accepted_status=None) method of xnat.session.XNATSession instance\n",
      "    Retrieve the content of a given REST directory.\n",
      "    \n",
      "    :param str path: the path of the uri to retrieve (e.g. \"/data/archive/projects\")\n",
      "                     the remained for the uri is constructed automatically\n",
      "    :param str format: the format of the request, this will add the format= to the query string\n",
      "    :param dict query: the values to be added to the query string in the uri\n",
      "    :param list accepted_status: a list of the valid values for the return code, default [200]\n",
      "    :returns: the requests reponse\n",
      "    :rtype: requests.Response\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(session.get)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n",
      "\n",
      "\n",
      "\n",
      "{\"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\"}}\n",
      "\n",
      "\n",
      "\n",
      "{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'}]}}\n"
     ]
    }
   ],
   "source": [
    "response = session.get('/data/projects/xnatpydemo/subjects')\n",
    "print(response)\n",
    "print('\\n\\n')\n",
    "print(response.text)\n",
    "print('\\n\\n')\n",
    "print(session.get_json('/data/projects/xnatpydemo/subjects'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## xnatpy objects\n",
    "\n",
    "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.\n",
    "\n",
    "The entry points for this are the projects, subject and experiments properties in the session object:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ProjectData xnatpydemo>\n"
     ]
    }
   ],
   "source": [
    "sandbox = session.projects['xnatpydemo']\n",
    "print(sandbox)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "u'Random_project_description_4'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sandbox.description"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Changing description to: Random_project_description_76\n"
     ]
    }
   ],
   "source": [
    "new_description = 'Random_project_description_{}'.format(random.randint(0, 100))\n",
    "print('Changing description to: {}'.format(new_description))\n",
    "sandbox.description = new_description"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "u'Random_project_description_76'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sandbox.description"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true,
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<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>}>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Get a list of the subjects\n",
    "sandbox.subjects"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "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:\n",
    "* project: the name\n",
    "* subject: the label\n",
    "* experiment: the label\n",
    "* scan: the scantype\n",
    "* resource: label\n",
    "* file: filename"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "subject = sandbox.subjects['subject001']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Before change:\n",
      "Gender: female\n",
      "Initials: PI\n",
      "After change:\n",
      "Gender: male\n",
      "Initials: JC\n"
     ]
    }
   ],
   "source": [
    "print('Before change:')\n",
    "print('Gender: {}'.format(subject.demographics.gender))\n",
    "print('Initials: {}'.format(subject.initials))\n",
    "\n",
    "# Change gender and initials. Flip them between male and female and JC and PI\n",
    "subject.demographics.gender = 'female' if subject.demographics.gender == 'male' else 'male'\n",
    "subject.initials = 'JC' if subject.initials == 'PI' else 'PI'\n",
    "\n",
    "print('After change:')\n",
    "print('Gender: {}'.format(subject.demographics.gender))\n",
    "print('Initials: {}'.format(subject.initials))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "There is some basic value checking before assignment are carried out. It uses the xsd directives when available. For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true,
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "gender has to be one of: \"male\", \"female\", \"other\", \"unknown\", \"M\", \"F\"",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-13-49f880f144cd>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msubject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdemographics\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgender\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'martian'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m/home/hachterberg/dev/xnat-workshop-2017/venv/local/lib/python2.7/site-packages/xnat/utils.pyc\u001b[0m in \u001b[0;36m__set__\u001b[0;34m(self, obj, value)\u001b[0m\n\u001b[1;32m     56\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfset\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     57\u001b[0m             \u001b[0;32mraise\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"can't set attribute\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 58\u001b[0;31m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     59\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     60\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m__delete__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mobj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/tmp/tmpsv_OoE_generated_xnat.py\u001b[0m in \u001b[0;36mgender\u001b[0;34m(self, value)\u001b[0m\n\u001b[1;32m   1433\u001b[0m         \u001b[0;31m# Restrictions for value\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1434\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m\"male\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"female\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"other\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"unknown\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"M\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"F\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1435\u001b[0;31m             \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'gender has to be one of: \"male\", \"female\", \"other\", \"unknown\", \"M\", \"F\"'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1436\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1437\u001b[0m         \u001b[0;31m# Automatically generated Property, type: xs:string\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mValueError\u001b[0m: gender has to be one of: \"male\", \"female\", \"other\", \"unknown\", \"M\", \"F\""
     ]
    }
   ],
   "source": [
    "subject.demographics.gender = 'martian'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "### Creating an xnatpy object from a REST path\n",
    "\n",
    "If you have a huge database and would like to skip (parts of) the listings, \n",
    "you can create an XNAT object straight from a REST path. It will automatically\n",
    "figure out the correct class from the XNAT response. This object then can be use\n",
    "just as any other xnatpy object:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<SubjectData Case001>\n",
      "<XNATListing {(CENTRAL_E11129, Case001): <MrSessionData Case001>}>\n"
     ]
    }
   ],
   "source": [
    "subject = session.create_object('/data/projects/xnatpydemo/subjects/Case001')\n",
    "print(subject)\n",
    "print(subject.experiments)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "### XNAT to xnatpy class mapping\n",
    "\n",
    "You can see the mapping of classes created by xnatpy using the class lookup:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{u'adrc:ADRCClinicalData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ADRCClinicalData'>,\n",
      " u'arc:fieldSpecification': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldSpecification'>,\n",
      " u'arc:pathInfo': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PathInfo'>,\n",
      " u'arc:pipelineData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PipelineData'>,\n",
      " u'arc:pipelineParameterData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PipelineParameterData'>,\n",
      " u'arc:project': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Project'>,\n",
      " u'arc:property': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Property'>,\n",
      " u'cat:catalog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Catalog'>,\n",
      " u'cat:dcmCatalog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmCatalog'>,\n",
      " u'cat:dcmEntry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmEntry'>,\n",
      " u'cat:entry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Entry'>,\n",
      " u'cnda:adrc_psychometrics': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AdrcPsychometrics'>,\n",
      " u'cnda:atlasScalingFactorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtlasScalingFactorData'>,\n",
      " u'cnda:atrophyNilData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtrophyNilData'>,\n",
      " u'cnda:clinicalAssessmentData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentData'>,\n",
      " u'cnda:cndaSubjectMetadata': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CndaSubjectMetadata'>,\n",
      " u'cnda:csfData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CsfData'>,\n",
      " u'cnda:diagnosesData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesData'>,\n",
      " u'cnda:dtiData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DtiData'>,\n",
      " u'cnda:dtiRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DtiRegion'>,\n",
      " u'cnda:handednessData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessData'>,\n",
      " u'cnda:levelsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LevelsData'>,\n",
      " u'cnda:manualVolumetryData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ManualVolumetryData'>,\n",
      " u'cnda:manualVolumetryRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ManualVolumetryRegion'>,\n",
      " u'cnda:modifiedScheltensData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensData'>,\n",
      " u'cnda:modifiedScheltensPvRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensPvRegion'>,\n",
      " u'cnda:modifiedScheltensRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegion'>,\n",
      " u'cnda:petTimeCourseData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseData'>,\n",
      " u'cnda:psychometricsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsData'>,\n",
      " u'cnda:radiologyReadData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RadiologyReadData'>,\n",
      " u'cnda:segmentationFastData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SegmentationFastData'>,\n",
      " u'cnda:ticVideoCountsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.TicVideoCountsData'>,\n",
      " u'cnda:vitalsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsData'>,\n",
      " u'cnda:volumetryRegionInfo': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfo'>,\n",
      " u'fs:aparcRegionAnalysis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AparcRegionAnalysis'>,\n",
      " u'fs:asegRegionAnalysis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AsegRegionAnalysis'>,\n",
      " u'fs:automaticSegmentationData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AutomaticSegmentationData'>,\n",
      " u'fs:fsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsData'>,\n",
      " u'fs:longFSData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSData'>,\n",
      " u'genetics:geneticTestResults': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GeneticTestResults'>,\n",
      " u'neurocog:symptomsNeurocog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocog'>,\n",
      " u'nunda:nundaDemographicData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NundaDemographicData'>,\n",
      " u'prov:process': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Process'>,\n",
      " u'prov:processStep': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStep'>,\n",
      " u'pup:pupTimeCourseData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PupTimeCourseData'>,\n",
      " u'sapssans:symptomsSAPSSANS': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsSAPSSANS'>,\n",
      " u'scr:screeningAssessment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScreeningAssessment'>,\n",
      " u'scr:screeningScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScreeningScanData'>,\n",
      " u'sf:encounterLog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EncounterLog'>,\n",
      " u'val:additionalVal': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AdditionalVal'>,\n",
      " u'val:protocolData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolData'>,\n",
      " u'wrk:abstractExecutionEnvironment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractExecutionEnvironment'>,\n",
      " u'wrk:workflowData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.WorkflowData'>,\n",
      " u'wrk:xnatExecutionEnvironment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XnatExecutionEnvironment'>,\n",
      " u'xdat:access_log': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AccessLog'>,\n",
      " u'xdat:action_type': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ActionType'>,\n",
      " u'xdat:change_info': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ChangeInfo'>,\n",
      " u'xdat:criteria': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Criteria'>,\n",
      " u'xdat:criteria_set': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CriteriaSet'>,\n",
      " u'xdat:element_action_type': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ElementActionType'>,\n",
      " u'xdat:element_security': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ElementSecurity'>,\n",
      " u'xdat:field_mapping': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldMapping'>,\n",
      " u'xdat:field_mapping_set': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldMappingSet'>,\n",
      " u'xdat:history': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.History'>,\n",
      " u'xdat:infoEntry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.InfoEntry'>,\n",
      " u'xdat:meta_data': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MetaData'>,\n",
      " u'xdat:newsEntry': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NewsEntry'>,\n",
      " u'xdat:primary_security_field': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PrimarySecurityField'>,\n",
      " u'xdat:role_type': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RoleType'>,\n",
      " u'xdat:search_field': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SearchField'>,\n",
      " u'xdat:stored_search': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StoredSearch'>,\n",
      " u'xdat:user': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.User'>,\n",
      " u'xdat:userGroup': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UserGroup'>,\n",
      " u'xdat:user_login': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UserLogin'>,\n",
      " u'xnat:abstractDemographicData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractDemographicData'>,\n",
      " u'xnat:abstractProtocol': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractProtocol'>,\n",
      " u'xnat:abstractResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractResource'>,\n",
      " u'xnat:abstractStatistics': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractStatistics'>,\n",
      " u'xnat:abstractSubjectMetadata': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractSubjectMetadata'>,\n",
      " u'xnat:addField': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AddField'>,\n",
      " u'xnat:computationData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ComputationData'>,\n",
      " u'xnat:contrastBolus': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ContrastBolus'>,\n",
      " u'xnat:crScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CrScanData'>,\n",
      " u'xnat:crSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CrSessionData'>,\n",
      " u'xnat:ctScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanData'>,\n",
      " u'xnat:ctSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtSessionData'>,\n",
      " u'xnat:datatypeProtocol': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DatatypeProtocol'>,\n",
      " u'xnat:demographicData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DemographicData'>,\n",
      " u'xnat:derivedData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DerivedData'>,\n",
      " u'xnat:dicomSeries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeries'>,\n",
      " u'xnat:dx3DCraniofacialScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Dx3DCraniofacialScanData'>,\n",
      " u'xnat:dx3DCraniofacialSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Dx3DCraniofacialSessionData'>,\n",
      " u'xnat:dxScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DxScanData'>,\n",
      " u'xnat:dxSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DxSessionData'>,\n",
      " u'xnat:ecgScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EcgScanData'>,\n",
      " u'xnat:ecgSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EcgSessionData'>,\n",
      " u'xnat:eegScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EegScanData'>,\n",
      " u'xnat:eegSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EegSessionData'>,\n",
      " u'xnat:epsScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EpsScanData'>,\n",
      " u'xnat:epsSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EpsSessionData'>,\n",
      " u'xnat:esScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsScanData'>,\n",
      " u'xnat:esSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsSessionData'>,\n",
      " u'xnat:esvScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsvScanData'>,\n",
      " u'xnat:esvSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EsvSessionData'>,\n",
      " u'xnat:experimentData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentData'>,\n",
      " u'xnat:fieldDefinitionGroup': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldDefinitionGroup'>,\n",
      " u'xnat:fileData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FileData'>,\n",
      " u'xnat:genericData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GenericData'>,\n",
      " u'xnat:gmScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmScanData'>,\n",
      " u'xnat:gmSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmSessionData'>,\n",
      " u'xnat:gmvScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmvScanData'>,\n",
      " u'xnat:gmvSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GmvSessionData'>,\n",
      " u'xnat:hdScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HdScanData'>,\n",
      " u'xnat:hdSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HdSessionData'>,\n",
      " u'xnat:imageAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageAssessorData'>,\n",
      " u'xnat:imageResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResource'>,\n",
      " u'xnat:imageResourceSeries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceSeries'>,\n",
      " u'xnat:imageScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageScanData'>,\n",
      " u'xnat:imageSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageSessionData'>,\n",
      " u'xnat:investigatorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.InvestigatorData'>,\n",
      " u'xnat:ioScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IoScanData'>,\n",
      " u'xnat:ioSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IoSessionData'>,\n",
      " u'xnat:megScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MegScanData'>,\n",
      " u'xnat:megSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MegSessionData'>,\n",
      " u'xnat:mgScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MgScanData'>,\n",
      " u'xnat:mgSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MgSessionData'>,\n",
      " u'xnat:mrAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrAssessorData'>,\n",
      " u'xnat:mrQcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrQcScanData'>,\n",
      " u'xnat:mrScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanData'>,\n",
      " u'xnat:mrSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrSessionData'>,\n",
      " u'xnat:mrsScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrsScanData'>,\n",
      " u'xnat:nmScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NmScanData'>,\n",
      " u'xnat:nmSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NmSessionData'>,\n",
      " u'xnat:opScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OpScanData'>,\n",
      " u'xnat:opSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OpSessionData'>,\n",
      " u'xnat:optScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanData'>,\n",
      " u'xnat:optSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptSessionData'>,\n",
      " u'xnat:otherDicomScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OtherDicomScanData'>,\n",
      " u'xnat:otherDicomSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OtherDicomSessionData'>,\n",
      " u'xnat:otherQcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OtherQcScanData'>,\n",
      " u'xnat:pVisitData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PVisitData'>,\n",
      " u'xnat:petAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetAssessorData'>,\n",
      " u'xnat:petQcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetQcScanData'>,\n",
      " u'xnat:petScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanData'>,\n",
      " u'xnat:petSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionData'>,\n",
      " u'xnat:petmrSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionData'>,\n",
      " u'xnat:projectData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectData'>,\n",
      " u'xnat:projectParticipant': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectParticipant'>,\n",
      " u'xnat:publicationResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PublicationResource'>,\n",
      " u'xnat:qcAssessmentData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcAssessmentData'>,\n",
      " u'xnat:qcManualAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcManualAssessorData'>,\n",
      " u'xnat:qcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcScanData'>,\n",
      " u'xnat:reconstructedImageData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ReconstructedImageData'>,\n",
      " u'xnat:regionResource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RegionResource'>,\n",
      " u'xnat:resource': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Resource'>,\n",
      " u'xnat:resourceCatalog': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ResourceCatalog'>,\n",
      " u'xnat:resourceSeries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ResourceSeries'>,\n",
      " u'xnat:rfScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RfScanData'>,\n",
      " u'xnat:rfSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RfSessionData'>,\n",
      " u'xnat:rtImageScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RtImageScanData'>,\n",
      " u'xnat:rtSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RtSessionData'>,\n",
      " u'xnat:scScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScScanData'>,\n",
      " u'xnat:segScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SegScanData'>,\n",
      " u'xnat:smScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SmScanData'>,\n",
      " u'xnat:smSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SmSessionData'>,\n",
      " u'xnat:srScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SrScanData'>,\n",
      " u'xnat:srSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SrSessionData'>,\n",
      " u'xnat:statisticsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StatisticsData'>,\n",
      " u'xnat:studyProtocol': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocol'>,\n",
      " u'xnat:subjectAssessorData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectAssessorData'>,\n",
      " u'xnat:subjectData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectData'>,\n",
      " u'xnat:subjectMetadata': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectMetadata'>,\n",
      " u'xnat:subjectVariablesData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectVariablesData'>,\n",
      " u'xnat:usScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UsScanData'>,\n",
      " u'xnat:usSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UsSessionData'>,\n",
      " u'xnat:validationData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ValidationData'>,\n",
      " u'xnat:voiceAudioScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VoiceAudioScanData'>,\n",
      " u'xnat:volumetricRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetricRegion'>,\n",
      " u'xnat:xa3DScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Xa3DScanData'>,\n",
      " u'xnat:xa3DSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Xa3DSessionData'>,\n",
      " u'xnat:xaScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanData'>,\n",
      " u'xnat:xaSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaSessionData'>,\n",
      " u'xnat:xcScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcScanData'>,\n",
      " u'xnat:xcSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcSessionData'>,\n",
      " u'xnat:xcvScanData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcvScanData'>,\n",
      " u'xnat:xcvSessionData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XcvSessionData'>,\n",
      " u'xnat_a:scidResearchData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchData'>,\n",
      " u'xnat_a:sideEffectsPittsburghData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SideEffectsPittsburghData'>,\n",
      " u'xnat_a:updrs3Data': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3Data'>,\n",
      " u'xnat_a:ybocsData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YbocsData'>,\n",
      " u'xnat_a:ygtssData': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YgtssData'>,\n",
      " u'xnatpy:DiagnosisString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosisString'>,\n",
      " u'xnatpy:abstractResourceTags': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AbstractResourceTags'>,\n",
      " u'xnatpy:activityFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ActivityFloat'>,\n",
      " u'xnatpy:addFieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AddFieldString'>,\n",
      " u'xnatpy:addIDString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AddIDString'>,\n",
      " u'xnatpy:additionalStatisticsDouble': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AdditionalStatisticsDouble'>,\n",
      " u'xnatpy:aliasString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AliasString'>,\n",
      " u'xnatpy:aparcRegionAnalysisHemisphere': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AparcRegionAnalysisHemisphere'>,\n",
      " u'xnatpy:aparcRegionAnalysisHemisphereRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AparcRegionAnalysisHemisphereRegions'>,\n",
      " u'xnatpy:asegRegionAnalysisRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AsegRegionAnalysisRegions'>,\n",
      " u'xnatpy:atrophyNilDataCsf_ratio': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtrophyNilDataCsfRatio'>,\n",
      " u'xnatpy:atrophyNilDataPeaks': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.AtrophyNilDataPeaks'>,\n",
      " u'xnatpy:bpFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.BpFloat'>,\n",
      " u'xnatpy:catalogMetafields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CatalogMetafields'>,\n",
      " u'xnatpy:clinicalAssessmentDataBloodpressure': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataBloodpressure'>,\n",
      " u'xnatpy:clinicalAssessmentDataDiagnosis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataDiagnosis'>,\n",
      " u'xnatpy:clinicalAssessmentDataMedication': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataMedication'>,\n",
      " u'xnatpy:clinicalAssessmentDataMovement': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataMovement'>,\n",
      " u'xnatpy:clinicalAssessmentDataNeuro': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataNeuro'>,\n",
      " u'xnatpy:clinicalAssessmentDataNeuroCdr': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ClinicalAssessmentDataNeuroCdr'>,\n",
      " u'xnatpy:commentString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CommentString'>,\n",
      " u'xnatpy:compilerString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CompilerString'>,\n",
      " u'xnatpy:csvValuesString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CsvValuesString'>,\n",
      " u'xnatpy:ctScanDataDcmvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataDcmvalidation'>,\n",
      " u'xnatpy:ctScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParameters'>,\n",
      " u'xnatpy:ctScanDataParametersCollimationwidth': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersCollimationwidth'>,\n",
      " u'xnatpy:ctScanDataParametersDerivation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersDerivation'>,\n",
      " u'xnatpy:ctScanDataParametersEstimateddosesaving': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersEstimateddosesaving'>,\n",
      " u'xnatpy:ctScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersFov'>,\n",
      " u'xnatpy:ctScanDataParametersRescale': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersRescale'>,\n",
      " u'xnatpy:ctScanDataParametersVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.CtScanDataParametersVoxelres'>,\n",
      " u'xnatpy:dcmCatalogDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmCatalogDimensions'>,\n",
      " u'xnatpy:dcmCatalogVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmCatalogVoxelres'>,\n",
      " u'xnatpy:dcmValidationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DcmValidationString'>,\n",
      " u'xnatpy:delayInteger': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DelayInteger'>,\n",
      " u'xnatpy:demographicDataHeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DemographicDataHeight'>,\n",
      " u'xnatpy:demographicDataWeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DemographicDataWeight'>,\n",
      " u'xnatpy:derivationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DerivationString'>,\n",
      " u'xnatpy:diagnosesDataMotor': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesDataMotor'>,\n",
      " u'xnatpy:diagnosesDataTicdiagnosis': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesDataTicdiagnosis'>,\n",
      " u'xnatpy:diagnosesDataVocal': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DiagnosesDataVocal'>,\n",
      " u'xnatpy:dicomSeriesDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeriesDimensions'>,\n",
      " u'xnatpy:dicomSeriesImageset': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeriesImageset'>,\n",
      " u'xnatpy:dicomSeriesVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DicomSeriesVoxelres'>,\n",
      " u'xnatpy:doseFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.DoseFloat'>,\n",
      " u'xnatpy:ecatValidationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EcatValidationString'>,\n",
      " u'xnatpy:element_securityListing_actions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ElementSecurityListingActions'>,\n",
      " u'xnatpy:encounterLogEncounters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EncounterLogEncounters'>,\n",
      " u'xnatpy:entryMetafields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EntryMetafields'>,\n",
      " u'xnatpy:estimatedDoseSavingFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.EstimatedDoseSavingFloat'>,\n",
      " u'xnatpy:experimentDataDelay': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentDataDelay'>,\n",
      " u'xnatpy:experimentDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentDataFields'>,\n",
      " u'xnatpy:experimentDataSharing': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ExperimentDataSharing'>,\n",
      " u'xnatpy:fieldDefinitionGroupFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldDefinitionGroupFields'>,\n",
      " u'xnatpy:fieldDefinitionGroupFieldsFieldPossiblevalues': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldDefinitionGroupFieldsFieldPossiblevalues'>,\n",
      " u'xnatpy:fieldSpecificationString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldSpecificationString'>,\n",
      " u'xnatpy:fieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FieldString'>,\n",
      " u'xnatpy:findingString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FindingString'>,\n",
      " u'xnatpy:fsDataMeasures': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasures'>,\n",
      " u'xnatpy:fsDataMeasuresSurface': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresSurface'>,\n",
      " u'xnatpy:fsDataMeasuresSurfaceHemisphereRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresSurfaceHemisphereRegions'>,\n",
      " u'xnatpy:fsDataMeasuresVolumetric': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresVolumetric'>,\n",
      " u'xnatpy:fsDataMeasuresVolumetricRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.FsDataMeasuresVolumetricRegions'>,\n",
      " u'xnatpy:geneticTestResultsGenes': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.GeneticTestResultsGenes'>,\n",
      " u'xnatpy:handednessDataParents_left': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataParentsLeft'>,\n",
      " u'xnatpy:handednessDataSiblings': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataSiblings'>,\n",
      " u'xnatpy:handednessDataSiblingsFemale': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataSiblingsFemale'>,\n",
      " u'xnatpy:handednessDataSiblingsMale': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataSiblingsMale'>,\n",
      " u'xnatpy:handednessDataTask_prefs': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HandednessDataTaskPrefs'>,\n",
      " u'xnatpy:heightFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.HeightFloat'>,\n",
      " u'xnatpy:imageResourceDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceDimensions'>,\n",
      " u'xnatpy:imageResourceSeriesDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceSeriesDimensions'>,\n",
      " u'xnatpy:imageResourceSeriesVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceSeriesVoxelres'>,\n",
      " u'xnatpy:imageResourceVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageResourceVoxelres'>,\n",
      " u'xnatpy:imageScanDataScanner': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageScanDataScanner'>,\n",
      " u'xnatpy:imageScanDataSharing': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageScanDataSharing'>,\n",
      " u'xnatpy:imageSessionDataScanner': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ImageSessionDataScanner'>,\n",
      " u'xnatpy:intermediateFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IntermediateFloat'>,\n",
      " u'xnatpy:isotopeString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.IsotopeString'>,\n",
      " u'xnatpy:labelString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LabelString'>,\n",
      " u'xnatpy:libraryString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LibraryString'>,\n",
      " u'xnatpy:longFSDataMeasures': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasures'>,\n",
      " u'xnatpy:longFSDataMeasuresSurface': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresSurface'>,\n",
      " u'xnatpy:longFSDataMeasuresSurfaceHemisphereRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresSurfaceHemisphereRegions'>,\n",
      " u'xnatpy:longFSDataMeasuresVolumetric': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresVolumetric'>,\n",
      " u'xnatpy:longFSDataMeasuresVolumetricRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataMeasuresVolumetricRegions'>,\n",
      " u'xnatpy:longFSDataTimepoints': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.LongFSDataTimepoints'>,\n",
      " u'xnatpy:manualVolumetryRegionSlice': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ManualVolumetryRegionSlice'>,\n",
      " u'xnatpy:metaFieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MetaFieldString'>,\n",
      " u'xnatpy:modifiedScheltensDataAssessment': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessment'>,\n",
      " u'xnatpy:modifiedScheltensDataAssessmentRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegions'>,\n",
      " u'xnatpy:modifiedScheltensDataAssessmentRegionsBasal_ganglia': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegionsBasalGanglia'>,\n",
      " u'xnatpy:modifiedScheltensDataAssessmentRegionsDeep_white_matter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegionsDeepWhiteMatter'>,\n",
      " u'xnatpy:modifiedScheltensDataAssessmentRegionsPeriventricular': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentRegionsPeriventricular'>,\n",
      " u'xnatpy:modifiedScheltensDataAssessmentVirchow_robin': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensDataAssessmentVirchowRobin'>,\n",
      " u'xnatpy:modifiedScheltensRegionLeft': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionLeft'>,\n",
      " u'xnatpy:modifiedScheltensRegionLeftInfarcts': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionLeftInfarcts'>,\n",
      " u'xnatpy:modifiedScheltensRegionLeftLesions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionLeftLesions'>,\n",
      " u'xnatpy:modifiedScheltensRegionRight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionRight'>,\n",
      " u'xnatpy:modifiedScheltensRegionRightInfarcts': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionRightInfarcts'>,\n",
      " u'xnatpy:modifiedScheltensRegionRightLesions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ModifiedScheltensRegionRightLesions'>,\n",
      " u'xnatpy:mrScanDataDcmvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataDcmvalidation'>,\n",
      " u'xnatpy:mrScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParameters'>,\n",
      " u'xnatpy:mrScanDataParametersDiffusion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersDiffusion'>,\n",
      " u'xnatpy:mrScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersFov'>,\n",
      " u'xnatpy:mrScanDataParametersMatrix': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersMatrix'>,\n",
      " u'xnatpy:mrScanDataParametersVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.MrScanDataParametersVoxelres'>,\n",
      " u'xnatpy:nundaDemographicDataHandednessexam': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NundaDemographicDataHandednessexam'>,\n",
      " u'xnatpy:nundaDemographicDataRelationships': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.NundaDemographicDataRelationships'>,\n",
      " u'xnatpy:optScanDataDcmvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataDcmvalidation'>,\n",
      " u'xnatpy:optScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataParameters'>,\n",
      " u'xnatpy:optScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataParametersFov'>,\n",
      " u'xnatpy:optScanDataParametersVoxelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.OptScanDataParametersVoxelres'>,\n",
      " u'xnatpy:parameterString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ParameterString'>,\n",
      " u'xnatpy:petScanDataEcatvalidation': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataEcatvalidation'>,\n",
      " u'xnatpy:petScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParameters'>,\n",
      " u'xnatpy:petScanDataParametersDimensions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersDimensions'>,\n",
      " u'xnatpy:petScanDataParametersFilter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersFilter'>,\n",
      " u'xnatpy:petScanDataParametersFrames': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersFrames'>,\n",
      " u'xnatpy:petScanDataParametersFramesFrame': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersFramesFrame'>,\n",
      " u'xnatpy:petScanDataParametersOffset': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersOffset'>,\n",
      " u'xnatpy:petScanDataParametersPixelsize': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersPixelsize'>,\n",
      " u'xnatpy:petScanDataParametersResolution': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersResolution'>,\n",
      " u'xnatpy:petScanDataParametersRfilter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersRfilter'>,\n",
      " u'xnatpy:petScanDataParametersZfilter': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetScanDataParametersZfilter'>,\n",
      " u'xnatpy:petSessionDataTracer': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracer'>,\n",
      " u'xnatpy:petSessionDataTracerDose': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerDose'>,\n",
      " u'xnatpy:petSessionDataTracerIntermediate': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerIntermediate'>,\n",
      " u'xnatpy:petSessionDataTracerIsotope': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerIsotope'>,\n",
      " u'xnatpy:petSessionDataTracerTotalmass': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetSessionDataTracerTotalmass'>,\n",
      " u'xnatpy:petTimeCourseDataDurations': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataDurations'>,\n",
      " u'xnatpy:petTimeCourseDataDurationsDurationBp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataDurationsDurationBp'>,\n",
      " u'xnatpy:petTimeCourseDataRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataRegions'>,\n",
      " u'xnatpy:petTimeCourseDataRegionsRegionTimeseries': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetTimeCourseDataRegionsRegionTimeseries'>,\n",
      " u'xnatpy:petmrSessionDataTracer': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracer'>,\n",
      " u'xnatpy:petmrSessionDataTracerDose': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerDose'>,\n",
      " u'xnatpy:petmrSessionDataTracerIntermediate': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerIntermediate'>,\n",
      " u'xnatpy:petmrSessionDataTracerIsotope': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerIsotope'>,\n",
      " u'xnatpy:petmrSessionDataTracerTotalmass': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PetmrSessionDataTracerTotalmass'>,\n",
      " u'xnatpy:pipelineParameterDataCsvvalues': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PipelineParameterDataCsvvalues'>,\n",
      " u'xnatpy:platformString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PlatformString'>,\n",
      " u'xnatpy:possibleValueString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PossibleValueString'>,\n",
      " u'xnatpy:primary_passwordString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PrimaryPasswordString'>,\n",
      " u'xnatpy:primary_security_fieldString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PrimarySecurityFieldString'>,\n",
      " u'xnatpy:processStepCompiler': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepCompiler'>,\n",
      " u'xnatpy:processStepLibrary': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepLibrary'>,\n",
      " u'xnatpy:processStepPlatform': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepPlatform'>,\n",
      " u'xnatpy:processStepProgram': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProcessStepProgram'>,\n",
      " u'xnatpy:programString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProgramString'>,\n",
      " u'xnatpy:projectDataAliases': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectDataAliases'>,\n",
      " u'xnatpy:projectDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectDataFields'>,\n",
      " u'xnatpy:projectPipelines': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelines'>,\n",
      " u'xnatpy:projectPipelinesDescendants': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelinesDescendants'>,\n",
      " u'xnatpy:projectPipelinesDescendantsDescendantPipeline': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelinesDescendantsDescendantPipeline'>,\n",
      " u'xnatpy:projectPipelinesPipeline': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProjectPipelinesPipeline'>,\n",
      " u'xnatpy:propertyString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PropertyString'>,\n",
      " u'xnatpy:protocolDataCheck': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataCheck'>,\n",
      " u'xnatpy:protocolDataCheckComments': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataCheckComments'>,\n",
      " u'xnatpy:protocolDataCheckConditions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataCheckConditions'>,\n",
      " u'xnatpy:protocolDataScans': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataScans'>,\n",
      " u'xnatpy:protocolDataScansScan_checkComments': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataScansScanCheckComments'>,\n",
      " u'xnatpy:protocolDataScansScan_checkConditions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ProtocolDataScansScanCheckConditions'>,\n",
      " u'xnatpy:psychometricsDataKanne': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsDataKanne'>,\n",
      " u'xnatpy:psychometricsDataWais': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsDataWais'>,\n",
      " u'xnatpy:psychometricsDataWms': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PsychometricsDataWms'>,\n",
      " u'xnatpy:pulseInteger': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PulseInteger'>,\n",
      " u'xnatpy:pupTimeCourseDataRois': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.PupTimeCourseDataRois'>,\n",
      " u'xnatpy:qcAssessmentDataScans': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcAssessmentDataScans'>,\n",
      " u'xnatpy:qcAssessmentDataScansScanSliceqc': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcAssessmentDataScansScanSliceqc'>,\n",
      " u'xnatpy:qcScanDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcScanDataFields'>,\n",
      " u'xnatpy:qcScanDataRating': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.QcScanDataRating'>,\n",
      " u'xnatpy:radiologyReadDataFinding': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RadiologyReadDataFinding'>,\n",
      " u'xnatpy:ratingString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RatingString'>,\n",
      " u'xnatpy:regionResourceCreator': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RegionResourceCreator'>,\n",
      " u'xnatpy:regionResourceSubregionlabels': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.RegionResourceSubregionlabels'>,\n",
      " u'xnatpy:scannerString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScannerString'>,\n",
      " u'xnatpy:scidResearchDataAnxietydisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataAnxietydisorders'>,\n",
      " u'xnatpy:scidResearchDataEatingdisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataEatingdisorders'>,\n",
      " u'xnatpy:scidResearchDataMooddisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataMooddisorders'>,\n",
      " u'xnatpy:scidResearchDataMoodepisodes': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataMoodepisodes'>,\n",
      " u'xnatpy:scidResearchDataOptional': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataOptional'>,\n",
      " u'xnatpy:scidResearchDataPsychoticdisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataPsychoticdisorders'>,\n",
      " u'xnatpy:scidResearchDataPsychoticsymptoms': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataPsychoticsymptoms'>,\n",
      " u'xnatpy:scidResearchDataSomatoformdisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataSomatoformdisorders'>,\n",
      " u'xnatpy:scidResearchDataSubstanceusedisorders': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ScidResearchDataSubstanceusedisorders'>,\n",
      " u'xnatpy:shareString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.ShareString'>,\n",
      " u'xnatpy:statisticsDataAddfield': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StatisticsDataAddfield'>,\n",
      " u'xnatpy:statisticsDataAdditionalstatistics': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StatisticsDataAdditionalstatistics'>,\n",
      " u'xnatpy:stored_searchAllowed_user': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StoredSearchAllowedUser'>,\n",
      " u'xnatpy:stored_searchSort_by': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StoredSearchSortBy'>,\n",
      " u'xnatpy:studyProtocolAcqconditions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolAcqconditions'>,\n",
      " u'xnatpy:studyProtocolImagesessiontypes': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolImagesessiontypes'>,\n",
      " u'xnatpy:studyProtocolSubjectgroups': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolSubjectgroups'>,\n",
      " u'xnatpy:studyProtocolSubjectvariables': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.StudyProtocolSubjectvariables'>,\n",
      " u'xnatpy:subjectDataAddid': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectDataAddid'>,\n",
      " u'xnatpy:subjectDataFields': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectDataFields'>,\n",
      " u'xnatpy:subjectVariablesDataVariables': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SubjectVariablesDataVariables'>,\n",
      " u'xnatpy:symptomsNeurocogZ_cog_2grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZCog2grp'>,\n",
      " u'xnatpy:symptomsNeurocogZ_cog_4grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZCog4grp'>,\n",
      " u'xnatpy:symptomsNeurocogZ_psy_2grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZPsy2grp'>,\n",
      " u'xnatpy:symptomsNeurocogZ_psy_4grp': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsNeurocogZPsy4grp'>,\n",
      " u'xnatpy:symptomsSAPSSANSSans': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsSAPSSANSSans'>,\n",
      " u'xnatpy:symptomsSAPSSANSSaps': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.SymptomsSAPSSANSSaps'>,\n",
      " u'xnatpy:tagString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.TagString'>,\n",
      " u'xnatpy:totalMassFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.TotalMassFloat'>,\n",
      " u'xnatpy:updrs3DataActionposturaltremor': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataActionposturaltremor'>,\n",
      " u'xnatpy:updrs3DataClicker': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataClicker'>,\n",
      " u'xnatpy:updrs3DataFingertaps': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataFingertaps'>,\n",
      " u'xnatpy:updrs3DataFoottaps': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataFoottaps'>,\n",
      " u'xnatpy:updrs3DataHandmovementsgrip': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataHandmovementsgrip'>,\n",
      " u'xnatpy:updrs3DataHandsram': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataHandsram'>,\n",
      " u'xnatpy:updrs3DataRigidity': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataRigidity'>,\n",
      " u'xnatpy:updrs3DataTremorrest': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.Updrs3DataTremorrest'>,\n",
      " u'xnatpy:userPrimary_password': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.UserPrimaryPassword'>,\n",
      " u'xnatpy:variableString': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VariableString'>,\n",
      " u'xnatpy:vitalsDataBloodpressure': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataBloodpressure'>,\n",
      " u'xnatpy:vitalsDataHeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataHeight'>,\n",
      " u'xnatpy:vitalsDataPulse': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataPulse'>,\n",
      " u'xnatpy:vitalsDataWeight': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VitalsDataWeight'>,\n",
      " u'xnatpy:volumetricRegionSubregions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetricRegionSubregions'>,\n",
      " u'xnatpy:volumetryRegionInfoRegions': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfoRegions'>,\n",
      " u'xnatpy:volumetryRegionInfoRegionsRegion': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfoRegionsRegion'>,\n",
      " u'xnatpy:volumetryRegionInfoRegionsRegionVoxel_res': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.VolumetryRegionInfoRegionsRegionVoxelRes'>,\n",
      " u'xnatpy:weightFloat': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.WeightFloat'>,\n",
      " u'xnatpy:xaScanDataParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanDataParameters'>,\n",
      " u'xnatpy:xaScanDataParametersFov': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanDataParametersFov'>,\n",
      " u'xnatpy:xaScanDataParametersPixelres': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XaScanDataParametersPixelres'>,\n",
      " u'xnatpy:xnatExecutionEnvironmentParameterfile': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XnatExecutionEnvironmentParameterfile'>,\n",
      " u'xnatpy:xnatExecutionEnvironmentParameters': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.XnatExecutionEnvironmentParameters'>,\n",
      " u'xnatpy:ygtssDataMotor': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YgtssDataMotor'>,\n",
      " u'xnatpy:ygtssDataPhonic': <class 'xnat_gen_973887e06d7184e81993569fbb9198db.YgtssDataPhonic'>}\n"
     ]
    }
   ],
   "source": [
    "import pprint\n",
    "pprint.pprint(session.XNAT_CLASS_LOOKUP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Subject XSI: xnat:subjectData\n",
      "Subject xpath: xnat:subjectData\n",
      "Subject demographics XSI: xnat:demographicData\n",
      "Subject demographics XSI: xnat:subjectData/demographics[@xsi:type=xnat:demographicData]\n"
     ]
    }
   ],
   "source": [
    "print('Subject XSI: {}'.format(subject.__xsi_type__))\n",
    "print('Subject xpath: {}'.format(subject.xpath))\n",
    "print('Subject demographics XSI: {}'.format(subject.demographics.__xsi_type__))\n",
    "print('Subject demographics XSI: {}'.format(subject.demographics.xpath))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Custom Variables\n",
    "\n",
    "In xnatpy custom variables are exposed as a simple mapping type that is very similar to a dictionary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<XNATSimpleListing {}>\n"
     ]
    }
   ],
   "source": [
    "print(subject.fields)\n",
    "subject."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<XNATSimpleListing {u'test_field': u'42'}>\n"
     ]
    }
   ],
   "source": [
    "# Add something\n",
    "subject.fields['test_field'] = 42\n",
    "print(subject.fields)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "u'42'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subject.fields['test_field']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "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.\n",
    "\n",
    "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.\n",
    "\n",
    "To avoid `KeyError`, it would be best to use `subject.fields.get('field_name')` which returns None when not available."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Downloading stuff\n",
    "\n",
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using /home/hachterberg/xnatpy_temp as download directory\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 45.6 MiB |         #                       |   1.1 MiB/s Elapsed Time: 0:00:40\n"
     ]
    }
   ],
   "source": [
    "download_dir = os.path.expanduser('~/xnatpy_temp')\n",
    "print('Using {} as download directory'.format(download_dir))\n",
    "if not os.path.exists(download_dir):\n",
    "    os.makedirs(download_dir)\n",
    "sandbox.subjects['Case001'].download_dir(download_dir)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# import service\n",
    "\n",
    "xnatpy exposes the import service of xnat (documentation at https://xnat.readthedocs.io/en/latest/xnat.html#xnat.services.Services )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "zip_file = os.path.join(download_dir, 'Case001.zip')\n",
    "sandbox.subjects['Case001'].experiments['Case001'].download(zip_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Importing under new subject: import_subject_132\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<PrearchiveSession xnatpydemo/20171016_052006805/Case001>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subject_name = \"import_subject_{}\".format(random.randint(0, 999))\n",
    "print('Importing under new subject: {}'.format(subject_name))\n",
    "session.services.import_(zip_file, destination='/prearchive', project='xnatpydemo', subject=subject_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Prearchive\n",
    "\n",
    "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)\n",
    "\n",
    "More info can be found at https://xnat.readthedocs.io/en/latest/xnat.html#xnat.prearchive.PrearchiveSession"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-- Before archive --\n",
      "prearchive:\n",
      "[<PrearchiveSession xnatpydemo/20171016_052006805/Case001>]\n",
      "project:\n",
      "<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>}>\n",
      "Using name: archive_subject_520 / archive_exp_520\n",
      "-- After archive --\n",
      "prearchive:\n",
      "[]\n",
      "project:\n",
      "None\n",
      "<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>}>\n"
     ]
    }
   ],
   "source": [
    "print(\"-- Before archive --\")\n",
    "print('prearchive:')\n",
    "print session.prearchive.sessions()\n",
    "print('project:')\n",
    "print sandbox.subjects\n",
    "\n",
    "# Create a new name for subject and experiment\n",
    "pas = session.prearchive.sessions()[0]\n",
    "nr = random.randint(0, 999)\n",
    "subject_name = \"archive_subject_{}\".format(nr)\n",
    "experiment_name = \"archive_exp_{}\".format(nr)\n",
    "print('Using name: {} / {}'.format(subject_name, experiment_name))\n",
    "\n",
    "# Archive subject under different name\n",
    "pas.archive(subject=subject_name, experiment=experiment_name)\n",
    "\n",
    "print(\"-- After archive --\")\n",
    "print('prearchive:')\n",
    "print session.prearchive.sessions()\n",
    "print('project:')\n",
    "print sandbox.subjects.clearcache()\n",
    "print sandbox.subjects"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Getting user information\n",
    "\n",
    "You can get some information about the users on the server using the REST API:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<User xnatpydemo [1830]>\n",
      "xnatpy\n",
      "hakim.achterberg@gmail.com\n"
     ]
    }
   ],
   "source": [
    "print(session.users['xnatpydemo'])\n",
    "print(session.users['xnatpydemo'].first_name)\n",
    "print(session.users['xnatpydemo'].email)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Inspect (similar to pyxnat)\n",
    "\n",
    "There is also an inspect module similar to that of pyxnat. It allows you to list datatypes and search fields defined on the server:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "== Datatypes ==\n",
      "[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']\n",
      "== Data fields ==\n",
      "[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']\n"
     ]
    }
   ],
   "source": [
    "print('== Datatypes ==')\n",
    "print(session.inspect.datatypes())\n",
    "print('== Data fields ==')\n",
    "print(session.inspect.datafields('xnat:subjectData'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Close the session!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "# Don't forget to disconnect to close cleanly and clean up temporary things!\n",
    "session.disconnect()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Context operator\n",
    "\n",
    "It is also possible to use xnatpy in a context, which guarantees clean closure of the connections etc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "with xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017') as session:\n",
    "    print('Nosetests project description: {}'.format(session.projects['xnatpydemo'].description))\n",
    "    \n",
    "# Here the session will be closed properly, even if there were exceptions within the `with` context"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Ideas for the future\n",
    "\n",
    "Currently I am thinking on two different additions and how to implement that best.\n",
    "* Creation of new objects\n",
    "* XNAT searches\n",
    "\n",
    "This illustrates my current ideas, but these are not implemented yet. If you have an opinion about this, let me know!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "#### Object creation"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "xnat.SubjectData(parent=projectA, initials='X')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "or alternatively"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "projectA.subjects['subjectX'] = xnat.SubjectData(initials='X')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "#### Searches\n",
    "\n",
    "The idea is to create something similar to SQLAlchemy\n",
    "\n",
    "This sort of works:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'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>'}]\n"
     ]
    }
   ],
   "source": [
    "with xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017') as session:\n",
    "    print session.classes.SubjectData.query().filter(session.classes.SubjectData.initials == 'JC').all()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "But this does not:"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "with xnat.connect('https://central.xnat.org', user='xnatpydemo', password='demo2017') as session:\n",
    "    print session.classes.SubjectData.query().filter(session.classes.SubjectData.demographics.age == 42).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (xnat-workshop)",
   "language": "python",
   "name": "xnatworkshop"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
