From 3f793903373767c0b8b1ad654cf44074376d4f96 Mon Sep 17 00:00:00 2001 From: jmz-b Date: Fri, 3 Apr 2020 12:51:02 +0200 Subject: [PATCH] add upload_to_sse step add a tool to upload edf metadata to the ASCLEPIOS SSE service and execute it after extracting metadata --- README.md | 8 +++++ .../somnonetz-pipeline/bin/upload_to_sse | 34 +++++++++++++++++++ .../resources/upload_to_sse.xml | 25 ++++++++++++++ .../somnonetz-pipeline/somnonetz-pipeline.xml | 16 +++++++++ 4 files changed, 83 insertions(+) create mode 100755 resources/catalog/somnonetz-pipeline/bin/upload_to_sse create mode 100755 resources/catalog/somnonetz-pipeline/resources/upload_to_sse.xml diff --git a/README.md b/README.md index bcfdfc2..c37b066 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,18 @@ xnat pipelines for use with snet-plugin # Prerequisites +### extract_edf_header + * python3 * [edfrd](https://github.com/somnonetz/edfrd) * [pyxnat](https://github.com/pyxnat/pyxnat) +### upload_to_sse + +* nodejs +* [asclepios-sse-client](https://github.com/somnonetz/asclepios-sse-client) +* [argparse](https://github.com/nodeca/argparse) + # Usage see [Installing Pipelines in XNAT](https://wiki.xnat.org/documentation/xnat-administration/configuring-the-pipeline-engine/installing-pipelines-in-xnat) in the official xnat documentation for installation instructions diff --git a/resources/catalog/somnonetz-pipeline/bin/upload_to_sse b/resources/catalog/somnonetz-pipeline/bin/upload_to_sse new file mode 100755 index 0000000..812b14a --- /dev/null +++ b/resources/catalog/somnonetz-pipeline/bin/upload_to_sse @@ -0,0 +1,34 @@ +#!/usr/bin/env node +'use strict' + +const { uploadData } = require('asclepios-sse-client'); +const { ArgumentParser } = require('argparse'); +const { execFile } = require('child_process'); +let parser = new ArgumentParser({}); + +parser.addArgument('-xnatID', { required: true}); +parser.addArgument('-host', { required: true }); +parser.addArgument('-user', { required: true }); +parser.addArgument('-pwd', { required: true }); + +const { xnatID, host, user, pwd } = parser.parseArgs(); +const XnatDataClient = '/data/xnat/pipeline/xnat-tools/XnatDataClient' +const args = ['-u', user, '-p', pwd, '-r', `${host}/REST/experiments/${xnatID}/scans/psg?format=json`]; + +const { SSE_URL, SSE_KEY_G, SSE_KENC, TA_URL, SALT_VALUE, IV_VALUE } = process.env; + +if (!(SSE_URL && SSE_KEY_G && SSE_KENC && TA_URL && SALT_VALUE && IV_VALUE)) { + throw 'One or more of the following environment variables are on set: ' + + 'SSE_URL, SSE_KEY_G, SSE_KENC, TA_URL, SALT_VALUE, IV_VALUE'; +} + +execFile(XnatDataClient, args, function callback(error, stdout, stderr) { + if (error) { + console.error(stderr); + throw error; + } + const session = JSON.parse(stdout); + const data = session.items[0].data_fields; + + uploadData(data, data.image_session_ID, SSE_KEY_G, SSE_KENC); +}); \ No newline at end of file diff --git a/resources/catalog/somnonetz-pipeline/resources/upload_to_sse.xml b/resources/catalog/somnonetz-pipeline/resources/upload_to_sse.xml new file mode 100755 index 0000000..1c4ac7e --- /dev/null +++ b/resources/catalog/somnonetz-pipeline/resources/upload_to_sse.xml @@ -0,0 +1,25 @@ + + + upload_to_sse + somnonetz-pipeline/bin + Executable + Upload EDF metadata to the ASCLEPIOS symmetric searchable encryption service + + + xnatID + XNAT Session ID + + + host + XNAT Host + + + user + XNAT Username + + + pwd + XNAT Password + + + diff --git a/resources/catalog/somnonetz-pipeline/somnonetz-pipeline.xml b/resources/catalog/somnonetz-pipeline/somnonetz-pipeline.xml index cea74cf..408d118 100755 --- a/resources/catalog/somnonetz-pipeline/somnonetz-pipeline.xml +++ b/resources/catalog/somnonetz-pipeline/somnonetz-pipeline.xml @@ -69,5 +69,21 @@ + + + + ^/Pipeline/parameters/parameter[name='xnatID']/values/unique/text()^ + + + ^if (count(/Pipeline/parameters/parameter[name='aliasHost']/values) > 0) then /Pipeline/parameters/parameter[name='aliasHost']/values/unique/text() else /Pipeline/parameters/parameter[name='host']/values/unique/text()^ + + + ^/Pipeline/parameters/parameter[name='user']/values/unique/text()^ + + + ^/Pipeline/parameters/parameter[name='pwd']/values/unique/text()^ + + +