-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_generation.py
57 lines (51 loc) · 2.6 KB
/
plot_generation.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
import cPickle
from config_manager import Parameters
from argparse import ArgumentParser
from plot_functions import brms_asd_plot, brms_time_plots, auxiliary_plots
class Data:
def __init__(self, filename):
with open(filename) as f:
savingdict = cPickle.load(f)
self.ccfs = savingdict['ccfs']
self.mean_cohs = savingdict['mean_cohs']
self.group_dict = savingdict['group_dict']
self.times = savingdict['times']
self.freqs = savingdict['freqs']
self.aux_dict = savingdict['aux_dict']
self.brms_psd = savingdict['brms_psd']
self.cohs = savingdict['cohs']
self.aux_results = savingdict['aux_results']
# Plot generating function
def main(initialization, ccf_thresh=0.5, mn_coh_thresh=0.05):
par = Parameters(initialization)
gpsb = par.res_param['gpsb']
gpse = par.res_param['gpse']
pdir = par.res_param['pdir']
hdir = par.res_param['hdir']
data = Data(hdir + 'post_proc_data.dat')
for group, g_dict in data.group_dict.iteritems():
# Plot time series of the brms
brms_time_plots(data.times, g_dict, hdir + pdir + group + '_time.png')
# Plot ASDs of the brms
brms_asd_plot(data.brms_psd[group], data.freqs, g_dict,
hdir + pdir + group + '_psd.png', gpsb, gpse)
# Plot the auxilliary channels coherences and histograms if their
# mean coherence or correlation cohefficient surpasses a threshold
auxiliary_plots(group, data.aux_dict, g_dict, data.freqs, data.ccfs,
data.cohs, data.mean_cohs, data.aux_results, gpsb,
gpse, hdir + pdir, ccf_thresh=ccf_thresh, mn_coh_thresh=mn_coh_thresh)
if __name__ == "__main__":
# read configuration options and dataess
parser = ArgumentParser()
parser.add_argument("-i", "--init", dest="initialization",
default='NonStatMoni.ini',
help="set initialization FILE", metavar="cfgFILE")
parser.add_argument("-ccf", "--ccf_threshold", dest="ccf_thresh",
help="set minimum correlation cohefficient condition for the correlation plots",
metavar="CCF_THRESHOLD", type=float, default= 0.5)
parser.add_argument("-coh", "--mean_coh_threshold", dest="mn_coh_thresh",
help="set minimum mean coherence condition for the coherence plots",
metavar="COH_THRESHOLD", type=float, default= 0.05)
args = vars(parser.parse_args())
# launch main function
main(args['initialization'], args['ccf_thresh'], args['mn_coh_thresh'])