Commit 25a7fed0 authored by Paul Bouchequet's avatar Paul Bouchequet

maj

parent 16917995
......@@ -6,4 +6,6 @@
*.rec
*.rar
*.txt
*.xlsx
\ No newline at end of file
*.xlsx
*.bin
*.json
\ No newline at end of file
bin data dir
\ No newline at end of file
......@@ -21,7 +21,7 @@ for (i in c(1:100)){
recPath <- paste0(target,i,"/",i,".rec")
headers <- edfReader::readEdfHeader(recPath)
if ("C3-M2" %in% headers$sHeaders$label){
dirPath <- paste0(binTarget,i)
dirPath <- paste0(binTarget,"isruc-sleep-",i)
unlink(dirPath, recursive=TRUE)
dir.create(dirPath)
record <- edfReader::readEdfSignals(headers,
......@@ -30,5 +30,9 @@ for (i in c(1:100)){
dir.create(sigPath)
sigFile <- paste0(sigPath,"/data.bin")
writeBin(record$signal, con = sigFile, size = 4)
#Write metadata
srate <- headers$sHeaders[headers$sHeaders$label == "C3-M2",]$sRate[1]
metaPath <- paste0(sigPath,"/meta.json")
writeLines(paste0("{ \"srate\":",srate,"}"), con = metaPath)
}
}
\ No newline at end of file
# python3 data/update.py
import os
import json
import numpy as np
signals = None
scorings = None
for i in range(1,101):
filePath = "data/isruc-sleep/"+str(i)+"/"+str(i)+".rec"
signalPath = "data/bin/isruc-sleep-"+str(i)+"/C3-M2/data.bin"
metaPath = "data/bin/isruc-sleep-"+str(i)+"/C3-M2/meta.json"
if os.path.isfile(signalPath) & os.path.isfile(metaPath):
signal = np.fromfile(signalPath, dtype=np.float32)
with open(metaPath) as f:
srate = json.load(f)["srate"]
epochs = np.split(signal,np.shape(signal)[0]/srate/30)
scoring = np.fromfile("data/isruc-sleep/"+str(i)+"/"+str(i)+"_1.txt",dtype = np.int,sep = "\n")
if scorings is None:
scorings = scoring
else:
scorings = np.concatenate((scorings, scoring), axis=0)
if signals is None:
signals = signal
else:
signals = np.concatenate((signals, signal), axis=0)
np.savetxt("data/bin/signals.bin",signals)
np.savetxt("data/bin/scorings.bin",scorings)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment