XNAT Preachive API download session files

35 views
Skip to first unread message

Huangjie Jin

unread,
Dec 21, 2021, 1:13:15 AM12/21/21
to xnat_discussion
Hi all,
I'm writing a script which needs to download session files in Preachive, but when I was looking through the Preachive API documentation, I didn't find the api usage for downloading files. However, I found a API documentation is about how to download XNAT project file, but the response format in the documentation is not as same as the response format of Preachive API, so I was wondering how to download Preachive sessions' files through Preachive API?

Moore, Charlie

unread,
Dec 21, 2021, 11:12:41 AM12/21/21
to xnat_di...@googlegroups.com
Hi Huangjie,

You can download a session from the prearchive using the url property from that first endpoint ("Get A List Of All Sessions In The Prearchive"). For example, on my system right now, the GET to /data/prearchive?format=json returns this

{
  "ResultSet": {
    "Result": [
      {
        "prevent_anon": "false",
        "subject": "Sample_Patient",
        "PROTOCOL": "",
        "project": "SAMPLE",
        "url": "/prearchive/projects/SAMPLE/20211221_160614825/Sample_ID",
        "autoarchive": "",
        "VISIT": "",
        "prevent_auto_commit": "true",
        "uploaded": "2021-12-21 16:06:14.825",
        "name": "Sample ID",
        "SOURCE": "SessionImporter",
        "scan_time": "09:12:06",
        "folderName": "Sample_ID",
        "tag": "1.3.12.2.1107.5.2.32.35177.30000006121218324675000000034",
        "TIMEZONE": "",
        "scan_date": "2006-12-14 00:00:00.0",
        "lastmod": "2021-12-21 16:06:24.069",
        "timestamp": "20211221_160614825",
        "status": "READY"
      }
    ]
  }
}

So, a GET to $SERVER/data/prearchive/projects/SAMPLE/20211221_160614825/Sample_ID?format=zip gives a zip of the whole session. (Note that I did need to add "/data" between the server URL and the url from the prearchive API).

Hopefully that helps.
Thanks,
Charlie

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of Huangjie Jin <huangj...@snac.com.au>
Sent: Tuesday, December 21, 2021 12:12 AM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] XNAT Preachive API download session files
 

* 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/b8256bc2-f655-4fbb-acea-d9f6b48f8154n%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.

Huangjie Jin

unread,
Dec 22, 2021, 5:39:25 PM12/22/21
to xnat_discussion
Hey Charlie

Thank you for your help,  your answer is working and now I can download files by API.

Regards
Huangjie Jin
Reply all
Reply to author
Forward
0 new messages