diff --git a/resources/catalog/somnonetz-pipeline/bin/extract_edf_header b/resources/catalog/somnonetz-pipeline/bin/extract_edf_header index a370314..1e7a23e 100755 --- a/resources/catalog/somnonetz-pipeline/bin/extract_edf_header +++ b/resources/catalog/somnonetz-pipeline/bin/extract_edf_header @@ -13,7 +13,7 @@ if __name__ == "__main__": parser.add_argument('-host', required=True) parser.add_argument('-user', required=True) parser.add_argument('-pwd', required=True) - + args = parser.parse_args() args.host = args.host.strip('/') # remove trailing slash from host as pyxnat fails to connect if it's present @@ -21,22 +21,42 @@ if __name__ == "__main__": 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) + edf_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/edfversion': edf_header.version, + 'snet01:psgScanData/patientid': edf_header.local_patient_identification, + 'snet01:psgScanData/localrecordid': edf_header.local_recording_identification, + 'snet01:psgScanData/recordingstartdate': edf_header.startdate_of_recording, + 'snet01:psgScanData/recordingstarttime': edf_header.starttime_of_recording, + 'snet01:psgScanData/numberofheaderbytes': edf_header.number_of_bytes_in_header_record, + 'snet01:psgScanData/reservedheaderfield': edf_header.reserved, + 'snet01:psgScanData/numberofdatarecords': edf_header.number_of_data_records, + 'snet01:psgScanData/durationofdatarecordseconds': edf_header.duration_of_a_data_record, + 'snet01:psgScanData/numberofsignalsindatarecord': edf_header.number_of_signals, # 'snet01:psgScanData/psgdevice': '?', - # 'snet01:psgScanData/durationofrecordhours': header.duration_of_a_data_record, + 'snet01:psgScanData/durationofrecordhours': edf_header.duration_of_a_data_record / 3600, # 'snet01:psgScanData/continuousdataflag': '0', # 'snet01:psgScanData/comment': '', }) + + for i, signal_header in enumerate(edf_header.signals): + scan.insert(**{ + 'scans': 'snet01:psgScanData', + 'snet01:psgScanData/records/record/labeldevice': signal_header.label, + 'snet01:psgScanData/records/record/labelstandard': signal_header.label, + 'snet01:psgScanData/records/record/channelnumberdevice': i, + 'snet01:psgScanData/records/record/channelnumberstandard': i, + # 'snet01:psgScanData/records/record/numberofchunks': , + 'snet01:psgScanData/records/record/samplingrate': signal_header.nr_of_samples_in_each_data_record / edf_header.duration_of_a_data_record, + 'snet01:psgScanData/records/record/transducertype': signal_header.transducer_type, + 'snet01:psgScanData/records/record/physicaldimension': signal_header.physical_dimension, + 'snet01:psgScanData/records/record/physicalminimum': signal_header.physical_minimum, + 'snet01:psgScanData/records/record/physicalmaximum': signal_header.physical_maximum, + 'snet01:psgScanData/records/record/digitalminimum': signal_header.digital_minimum, + 'snet01:psgScanData/records/record/digitalmaximum': signal_header.digital_maximum, + # 'snet01:psgScanData/records/record/prefiltering': , + 'snet01:psgScanData/records/record/samplesinrecord': signal_header.nr_of_samples_in_each_data_record, + 'snet01:psgScanData/records/record/reserved': signal_header.reserved, + }) \ No newline at end of file