Including custom variable data in the output of the Subject list API

77 views
Skip to first unread message

james...@gmail.com

unread,
Oct 21, 2021, 6:52:49 AM10/21/21
to xnat_discussion
Hello,

I having trouble understanding how to use XML paths with the XNAT Subject API to include custom demographic data in the output of the XNAT subject list API.

I have a custom variable set up for my subjects, called `keyid`, you can see it's configuration below:

It appears in the output of the Single Subject Record API endpoint, eg:

$ curl -s -u admin:admin http://xnat.snet-apps.local/xnat/data/projects/asclepiostestproject/subjects/demo-subject-000?format=json | jq .
{
  "items": [
    {
      "children": [
        {
          "field": "fields/field",
          "items": [
            {
              "children": [],
              "meta": {
                "create_event_id": 23,
                "xsi:type": "xnat:subjectData_field",
                "isHistory": false,
                "start_date": "Thu Oct 21 09:05:56 UTC 2021"
              },
              "data_fields": {
                "field": "94df7b7e-a106-43cd-bd8d-767973ffc14b",
                "name": "keyid",
                "xnat_subjectData_field_id": 3
              }
            }
          ]
        },
        {
          "field": "experiments/experiment",
          "items": [
            {
              "children": [
                {
                  "field": "scans/scan",
                  "items": [
                    {
                      "children": [],
                      "meta": {
                        "create_event_id": 27,
                        "xsi:type": "snet02:encPsgScanData",
                        "isHistory": false,
                        "start_date": "Thu Oct 21 09:24:57 UTC 2021"
                      },
                      "data_fields": {
                        "xnat_imagescandata_id": 2,
                        "keyid": "94df7b7e-a106-43cd-bd8d-767973ffc14b",
                        "project": "asclepiostestproject",
                        "ID": "514fd482-8fae-4f9d-80a3-1e6aed8cfd86",
                        "image_session_ID": "XNAT3_E00001",
                        "xnat_imageScanData_id": 2
                      }
                    }
                  ]
                }
              ],
              "meta": {
                "create_event_id": 26,
                "xsi:type": "snet02:sleepResearchSessionData",
                "isHistory": false,
                "start_date": "Thu Oct 21 09:24:57 UTC 2021"
              },
              "data_fields": {
                "date": "2022-09-10",
                "subject_ID": "XNAT3_S00001",
                "project": "asclepiostestproject",
                "ID": "XNAT3_E00001",
                "label": "211020211124",
                "id": "XNAT3_E00001"
              }
            }
          ]
        }
      ],
      "meta": {
        "create_event_id": 23,
        "xsi:type": "xnat:subjectData",
        "isHistory": false,
        "start_date": "Thu Oct 21 09:05:56 UTC 2021"
      },
      "data_fields": {
        "project": "asclepiostestproject",
        "ID": "XNAT3_S00001",
        "label": "demo-subject-000"
      }
    }
  ]
}

However I would like to list it in the output of the All Subjects In A Project API endpoint, using the columns parameter. But I can not seem to make it work.

I have tried the following, and other various other similar permutations, the first two just return the default ID and URI columns, the last one throws a 400 due to invalid characters:

http://xnat.snet-apps.local/xnat/data/projects/asclepiostestproject/subjects?format=json&columns=keyid



Is this actually possible with to do with the All Subjects In A Project API endpoint? If so how can I accomplish it?

I would really appreciate some advice.

Regards
,
James

james...@gmail.com

unread,
Oct 21, 2021, 6:55:02 AM10/21/21
to xnat_discussion
Sorry for some reason my screen shot of the variable configuration did not get attached, here it is:
Screenshot from 2021-10-21 12-32-24.png

Moore, Charlie

unread,
Oct 21, 2021, 1:14:43 PM10/21/21
to xnat_di...@googlegroups.com
Hi James,

You were very much on the right track, the syntax is just a bit messy for this. Try this for your columns param:

columns=xnat:subjectData/fields/field%5Bname%3Dkeyid%5D/field

I think that would work (it did for me, locally). Let me know how it goes.

Thanks,
Charlie

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of james...@gmail.com <james...@gmail.com>
Sent: Thursday, October 21, 2021 5:55 AM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] Re: Including custom variable data in the output of the Subject list API
 

* External Email - Caution *

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/ba935279-e170-4dfe-8ed6-ffeee521dbc8n%40googlegroups.com.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

james...@gmail.com

unread,
Oct 22, 2021, 6:26:57 AM10/22/21
to xnat_discussion
Hey Charlie,

That did the trick! Thank you very much for the help.

All the best,
James
Reply all
Reply to author
Forward
0 new messages