-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcg_get_thresholds.py
45 lines (41 loc) · 1.53 KB
/
cg_get_thresholds.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
# linear fitting between weight(log) and tdmi value(log).
# pairs with sufficient SNR value are counted.
if __name__ == '__main__':
from fcpy.binary_threshold import *
from fcpy.core import EcogTDMI
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import numpy as np
import pickle
arg_default = {
'path': 'tdmi_snr_analysis/',
}
parser = ArgumentParser(
description = "Generate three types of thresholding criteria.",
formatter_class=ArgumentDefaultsHelpFormatter
)
parser.add_argument(
'path', default=arg_default['path'], nargs='?',
type = str,
help = "path of working directory."
)
args = parser.parse_args()
# Load SC and FC data
# ==================================================
data = EcogTDMI('data/')
data.init_data(args.path)
sc, fc = data.get_sc_fc('cg')
data = EcogTDMI('data/')
data.init_data_strict(args.path)
_, fc_fit = data.get_sc_fc('cg')
# ==================================================
w_thresholds = np.logspace(-6, 0, num=7, base=10)
fit_th = get_fit_threshold(sc, fc_fit, w_thresholds)
gap_th = get_gap_threshold(fc)
roc_th = get_roc_threshold(sc, fc, w_thresholds)
suffix = '_tdmi_CG'
with open(args.path + 'th_fit'+suffix+'.pkl', 'wb') as f:
pickle.dump(fit_th, f)
with open(args.path + 'th_roc'+suffix+'.pkl', 'wb') as f:
pickle.dump(roc_th, f)
with open(args.path + 'th_gap'+suffix+'.pkl', 'wb') as f:
pickle.dump(gap_th, f)