-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata_parcer.py
68 lines (58 loc) · 2.5 KB
/
data_parcer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#############################################################################
## data_parcer is a script which reads Embla channel file and prints out
## retrieved information
#############################################################################
## Copyright (c) 2018-2019, University of Liège
## Author: Nikita Beliy
## Owner: Liege University https://www.uliege.be
## Version: 0.74
## Maintainer: Nikita Beliy
## Email: Nikita.Beliy@uliege.be
## Status: developpement
#############################################################################
## This file is part of eegBidsCreator
## eegBidsCreator is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 2 of the License, or
## (at your option) any later version.
## eegBidsCreator is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with eegBidsCreator. If not, see <https://www.gnu.org/licenses/>.
############################################################################
import struct, math
from datetime import datetime, timedelta
import os,sys
from DataStructure.Embla.Channel import EbmChannel
from glob import glob
import argparse
def main(argv):
parser = argparse.ArgumentParser(description='Reads embla channel files (.emb) from given folder and printout the retrieved information')
parser.add_argument('infiles', default="../data_test/EEG/ECG/fd068a73-0527-428f-aeed-9e04fb55ed4b",
metavar='file1',
help='input folder')
args = parser.parse_args(argv[1:])
ch = GetChannels(args.infiles)
for c in ch:
print("####################")
print(c)
print()
return 0
def GetChannels(path):
ch = [EbmChannel(c) for c in glob(path+"/*.ebm")]
ch.sort()
return ch
def GetExtrema(channel, sequence, raw = False):
v_min = sys.maxsize
v_max = -v_min
for j in range(0, channel.getSize(sequence)):
v = channel.getValue(j, sequence, raw = raw)
if v < v_min:
v_min = v
if v > v_max:
v_max = v
return (v_min, v_max)
if __name__ == "__main__":
os.sys.exit(main(os.sys.argv))