forked from jchromik/qrs-certainty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·49 lines (37 loc) · 1.43 KB
/
run.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
#!/usr/bin/env python3
from argparse import ArgumentParser
from os.path import dirname, isabs, join, realpath
import json
import os
import sys
import warnings
# Parse CLI command
parser = ArgumentParser(description=(
"Evaluate different methods for finding QRS complexes "
"in single channel ECG signals."))
parser.add_argument(
"configuration_file", metavar="CONFIGURATION_FILE", type=str,
help="Configuration file specifying the evaluation.")
args = parser.parse_args()
def absify(path, dir):
return path if isabs(path) else realpath(join(dir, path))
# Read configuration file
with open(args.configuration_file, "r") as f:
conf = json.load(f)
conf["input_dir"] = absify(conf["input_dir"], dirname(f.name))
conf["output_dir"] = absify(conf["output_dir"], dirname(f.name))
if not conf["verbose"]:
# disable Tensorflow logging
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
# disable Python warnings
if not sys.warnoptions: warnings.simplefilter("ignore")
# Build Evaluator
sys.path.append(join(dirname(__file__), "./raccoon"))
from utils.builders import evaluator_from_dict
evaluator = evaluator_from_dict(conf)
cv_method = conf["cv_method"]
test_records = conf["test_records"] if "test_records" in conf else None
if cv_method == "loocv": evaluator.loocv()
elif cv_method == "k2": evaluator.kfold(k=2)
elif cv_method == "k10": evaluator.kfold(k=10)
elif cv_method == 'defined': evaluator.defined(test_records)