Skip to content
This repository has been archived by the owner on Apr 21, 2020. It is now read-only.

Commit

Permalink
add upload_to_sse step
Browse files Browse the repository at this point in the history
add a tool to upload edf metadata to the ASCLEPIOS SSE service and
execute it after extracting metadata
  • Loading branch information
jmz-b committed Apr 3, 2020
1 parent 5d03d01 commit 3f79390
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 34 additions & 0 deletions resources/catalog/somnonetz-pipeline/bin/upload_to_sse
Original file line number Diff line number Diff line change
@@ -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);
});
25 changes: 25 additions & 0 deletions resources/catalog/somnonetz-pipeline/resources/upload_to_sse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<pip:Resource xmlns:pip="http://nrg.wustl.edu/pipeline">
<pip:name>upload_to_sse</pip:name>
<pip:location>somnonetz-pipeline/bin</pip:location>
<pip:type>Executable</pip:type>
<pip:description>Upload EDF metadata to the ASCLEPIOS symmetric searchable encryption service</pip:description>
<pip:input>
<pip:argument id="xnatID">
<pip:name>xnatID</pip:name>
<pip:description>XNAT Session ID</pip:description>
</pip:argument>
<pip:argument id="host">
<pip:name>host</pip:name>
<pip:description>XNAT Host</pip:description>
</pip:argument>
<pip:argument id="user">
<pip:name>user</pip:name>
<pip:description>XNAT Username</pip:description>
</pip:argument>
<pip:argument id="pwd" isSensitive="true">
<pip:name>pwd</pip:name>
<pip:description>XNAT Password</pip:description>
</pip:argument>
</pip:input>
</pip:Resource>
16 changes: 16 additions & 0 deletions resources/catalog/somnonetz-pipeline/somnonetz-pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,21 @@
</argument>
</resource>
</step>
<step id="1" description="Upload EDF metadata to the ASCLEPIOS symmetric searchable encryption service" workdirectory="^/Pipeline/parameters/parameter[name='workdir']/values/unique/text()^">
<resource name="upload_to_sse.xml" location="somnonetz-pipeline/resources">
<argument id="xnatID">
<value>^/Pipeline/parameters/parameter[name='xnatID']/values/unique/text()^</value>
</argument>
<argument id="host">
<value>^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()^</value>
</argument>
<argument id="user">
<value>^/Pipeline/parameters/parameter[name='user']/values/unique/text()^</value>
</argument>
<argument id="pwd">
<value>^/Pipeline/parameters/parameter[name='pwd']/values/unique/text()^</value>
</argument>
</resource>
</step>
</steps>
</Pipeline>

0 comments on commit 3f79390

Please sign in to comment.