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

Commit

Permalink
add extract_edf_header stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jmz-b committed Mar 13, 2020
1 parent bff551c commit 30d58c1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 32 deletions.
3 changes: 0 additions & 3 deletions resources/catalog/snet-pipeline/bin/snet-pipeline

This file was deleted.

40 changes: 40 additions & 0 deletions resources/catalog/somnonetz-pipeline/bin/extract_edf_header
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

import argparse
from pyxnat import Interface
from edfrd import read_header

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-session', required=True)
parser.add_argument('-subject', required=True)
parser.add_argument('-project', required=True)
parser.add_argument('-xnatID')
parser.add_argument('-host', required=True)
parser.add_argument('-user', required=True)
parser.add_argument('-pwd', required=True)

# args = parser.parse_args()
# xnat = Interface(args.host, user=args.user, password=args.pwd)
# scan = xnat.select(f'/project/{args.project}/subject/{args.subject}/experiment/{args.session}/scan/psg')
# remote_edf = scan.resources().files().first()
# edf_path = remote_edf.get(f'./{remote_edf.label()}')
# header = read_header(edf_path)

# scan.insert(**{
# 'scans': 'snet01:psgScanData',
# 'snet01:psgScanData/edfversion': header.version,
# 'snet01:psgScanData/patientid': header.local_patient_identification,
# 'snet01:psgScanData/localrecordid': header.local_recording_identification,
# 'snet01:psgScanData/recordingstartdate': header.startdate_of_recording,
# 'snet01:psgScanData/recordingstarttime': header.starttime_of_recording,
# 'snet01:psgScanData/numberofheaderbytes': header.number_of_bytes_in_header_record,
# 'snet01:psgScanData/reservedheaderfield': header.reserved,
# 'snet01:psgScanData/numberofdatarecords': header.number_of_data_records,
# # 'snet01:psgScanData/durationofdatarecordseconds': header.duration_of_a_data_record,
# 'snet01:psgScanData/numberofsignalsindatarecord': header.number_of_signals,
# # 'snet01:psgScanData/psgdevice': '?',
# # 'snet01:psgScanData/durationofrecordhours': header.duration_of_a_data_record,
# # 'snet01:psgScanData/continuousdataflag': '0',
# # 'snet01:psgScanData/comment': '',
# })
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<pip:Resource xmlns:pip="http://nrg.wustl.edu/pipeline">
<pip:name>snet-pipeline</pip:name>
<pip:location>snet-pipeline/bin</pip:location>
<pip:name>extract_edf_header</pip:name>
<pip:location>somnonetz-pipeline/bin</pip:location>
<pip:type>Executable</pip:type>
<pip:description>Executes shell script</pip:description>
<pip:description>Extract EDF header data and write back to xnat</pip:description>
<pip:input>
<pip:argument id="session">
<pip:name>session</pip:name>
Expand All @@ -21,10 +21,6 @@
<pip:name>xnatID</pip:name>
<pip:description>XNAT Session ID</pip:description>
</pip:argument>
<pip:argument id="algorithm">
<pip:name>algorithm</pip:name>
<pip:description>algorithm to be applied</pip:description>
</pip:argument>
<pip:argument id="host">
<pip:name>host</pip:name>
<pip:description>XNAT Host</pip:description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Pipeline xmlns="http://nrg.wustl.edu/pipeline" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nrgString="java:org.nrg.pipeline.utils.StringUtils" xsi:schemaLocation="http://nrg.wustl.edu/pipeline ..\schema\pipeline.xsd">
<name>snet-pipeline</name>
<location>snet-pipeline</location>
<description>Execution of polysomnography analysis tools</description>
<name>somnonetz-pipeline</name>
<location>somnonetz-pipeline</location>
<description>Pipeline for use with snet-plugin</description>
<documentation>
<input-parameters>
<parameter>
Expand Down Expand Up @@ -33,20 +33,6 @@
</values>
<description>The XNAT session ID</description>
</parameter>
<parameter>
<name>algorithm</name>
<values>
<csv>sn_getEDFHeaderdata</csv>
</values>
<description>method for </description>
</parameter>
<parameter>
<name>notify</name>
<values>
<csv>0</csv>
</values>
<description>Set the value to 1 if you want the pipeline to notify the user when complete. 0 otherwise</description>
</parameter>
</input-parameters>
</documentation>
<parameters>
Expand All @@ -58,8 +44,8 @@
</parameter>
</parameters>
<steps>
<step id="0" description="Execute shell script" workdirectory="^/Pipeline/parameters/parameter[name='workdir']/values/unique/text()^">
<resource name="snet-resource.xml" location="snet-pipeline/resources">
<step id="0" description="Extract EDF header data and write back to xnat" workdirectory="^/Pipeline/parameters/parameter[name='workdir']/values/unique/text()^">
<resource name="extract_edf_header.xml" location="somnonetz-pipeline/resources">
<argument id="session">
<value>^/Pipeline/parameters/parameter[name='sessionLabel']/values/unique/text()^</value>
</argument>
Expand All @@ -72,9 +58,6 @@
<argument id="xnatID">
<value>^/Pipeline/parameters/parameter[name='xnatID']/values/unique/text()^</value>
</argument>
<argument id="algorithm">
<value>^/Pipeline/parameters/parameter[name='algorithm']/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>
Expand Down

0 comments on commit 30d58c1

Please sign in to comment.