-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_reliability.py
76 lines (66 loc) · 2.53 KB
/
map_reliability.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
69
70
71
72
73
74
75
76
#!/usr/bin/env python
"""
Created on Mon Jan 21 21:52:03 2019
@author: Mary Miedema
"""
import os
import time
import argparse
import yaml
#import mne
import logging.config
#import warnings
#import sys
import map_reliability_support.set_up_replications as setrep
import map_reliability_support.likelihood_calc as likelihood
logger = logging.getLogger(__name__)
#mne.set_log_level("WARNING")
#warnings.simplefilter("ignore", category=DeprecationWarning)
#warnings.simplefilter("ignore", category=RuntimeWarning)
def main(configFile):
"""Top-level run script for mapping the reliability of MEG data."""
try:
logger.info("Opening configuration file ...")
with open(configFile, 'r') as ymlfile:
cfg = yaml.load(ymlfile)
logger.debug("Configuration file successfully loaded.")
except IOError:
logger.error("Configuration file not found.")
logger.info("******Starting reliability mapping******")
logger.info("Creating paths for output data ...")
for section in cfg:
for cat in cfg[section]:
if cat == "dirs":
dir_path = cfg[section][cat].values()[0]
try:
if not os.path.exists(dir_path):
logger.debug("Creating {0}".format(dir_path))
os.makedirs(dir_path)
except OSError as e:
if not os.path.isdir(dir_path):
raise e
else:
pass
start_time = time.time()
logger.info("Setting up replications & calculating nearest neighbours.")
setrep.set_up(cfg)
logger.info("Set-up completed.")
logger.info("Starting maximum likelihood calculations.")
#likelihood.calc(cfg)
#likelihood.initialize()
#likelihood.ICM()
#likelihood.calc_reliability()
#likelihood.map_reliability()
logger.info("Maximum likelihood calculations completed.")
logger.info("Generating reliability maps.")
#rmap.mapdata(cfg)
logger.info("Reliability maps created.")
end_time = time.time()
logger.info("TOTAL TIME = {0:.4f} seconds".format(end_time - start_time))
logger.info("******Reliability mapping completed******")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-cfg",help="Input name of configuration .yml file to use; defaults to config.yml",
default="config.yml")
args = parser.parse_args()
main(args.cfg)