Commit bb225b1f authored by Boers, Frank's avatar Boers, Frank
Browse files

work on reports

parent ca033279
...@@ -514,7 +514,11 @@ class DCNN_PATH(_SLOTS): ...@@ -514,7 +514,11 @@ class DCNN_PATH(_SLOTS):
if self.add_basedir and self.basedir: if self.add_basedir and self.basedir:
if not path.startswith(self.basedir): if not path.startswith(self.basedir):
path = op.join(self.basedir,path) if path.startswith("/"):
path = self.basedir
else:
path = op.join(self.basedir,path)
logger.warning(" ADD basedir: {} => {}".format(self.basedir,path)) logger.warning(" ADD basedir: {} => {}".format(self.basedir,path))
is_path = isPath(path,head="{} check path: {}".format(self._cls_name,label), is_path = isPath(path,head="{} check path: {}".format(self._cls_name,label),
......
...@@ -716,23 +716,23 @@ class DCNN(object): ...@@ -716,23 +716,23 @@ class DCNN(object):
npz = np.load(fname, allow_pickle=True) npz = np.load(fname, allow_pickle=True)
logger.info('Done loading gDCNN results from disk\n') logger.info('Done loading gDCNN results from disk\n')
if self.verbose: # if self.verbose:
for k, v in npz.items(): # for k, v in npz.items():
logger.info("gDCNN data: {}\n{}".format(k, v)) # logger.info("gDCNN data: {}\n{}".format(k, v))
# get details # get details
self.path.init(**npz.get('path').item()) # load dict self.path.init(**npz.get('path').item()) # load dict
logger.info("path:\n -> {}".format(self.path)) logger.info("path:\n -> {}".format(self.path))
self.model = npz.get('model').item() # load dict self.model = npz.get('model').item() # load dict
logger.info("model:\n -> {}".format(self.model)) #logger.info("model:\n -> {}".format(self.model))
# data objects # data objects
self.meg.init(**npz['meg'].item()) # get dict from np.array self.meg.init(**npz['meg'].item()) # get dict from np.array
self.ica.init(**npz['ica'].item()) # get dict from np.array self.ica.init(**npz['ica'].item()) # get dict from np.array
self.sources.init(**npz['sources'].item()) # get dict from np.array self.sources.init(**npz['sources'].item()) # get dict from np.array
logger.info("sources:\n -> {}".format(self.sources)) #logger.info("sources:\n -> {}".format(self.sources))
return npz return npz
......
...@@ -635,7 +635,7 @@ def run1(fname=None,verbose=False): ...@@ -635,7 +635,7 @@ def run1(fname=None,verbose=False):
if __name__ == "__main__": if __name__ == "__main__":
# Test setup # Test setup
fnz = "$JUMEG_LOCAL_DATA"+"/dcnn/ica_labeled/Juelich/4D_test_c,rfDC_bcc,nr-raw-gdcnn.npz" fnz = "$JUMEG_PATH_LOCAL_DATA"+"/dcnn/ica_labeled/Juelich/4D_test_c,rfDC_bcc,nr-raw-gdcnn.npz"
verbose = True verbose = True
logger = setup_script_logging() logger = setup_script_logging()
......
...@@ -73,15 +73,21 @@ def run(fnconfig=None,basedir=None,data_meg=None,data_train=None,pattern='-raw.f ...@@ -73,15 +73,21 @@ def run(fnconfig=None,basedir=None,data_meg=None,data_train=None,pattern='-raw.f
# ========================================================== # ==========================================================
# check ICA auto labelling # check ICA auto labelling
# ========================================================== # ==========================================================
npz_pattern = pattern.split(".",-1)[0] +"-gdcnn.npz"
if do_label_check: if do_label_check:
path_in = dcnn.path.data_train path_in = dcnn.path.data_train
for fname in file_looper(rootdir=path_in, pattern='*.npz',version=__version__,verbose=verbose,log2file=log2file,logoverwrite=False): from mne.report import Report
report = Report(title='Check IC labels')
for fname in file_looper(rootdir=path_in, pattern=npz_pattern,version=__version__,verbose=verbose,log2file=log2file,logoverwrite=False):
dcnn.load_gdcnn(fname) dcnn.load_gdcnn(fname)
# check IC labels (and apply corrections) # check IC labels (and apply corrections)
#dcnn.check_labels(save=True) #dcnn.check_labels(save=True)
fnreport ="test_report"
# check IC labels (and apply corrections) # check IC labels (and apply corrections)
name = os.path.basename(fname[:-4]) name = os.path.basename(fname[:-4])
...@@ -91,6 +97,9 @@ def run(fnconfig=None,basedir=None,data_meg=None,data_train=None,pattern='-raw.f ...@@ -91,6 +97,9 @@ def run(fnconfig=None,basedir=None,data_meg=None,data_train=None,pattern='-raw.f
report.save(fnreport + '.h5', overwrite=True) report.save(fnreport + '.h5', overwrite=True)
report.save(fnreport + '.html', overwrite=True, open_browser=True) report.save(fnreport + '.html', overwrite=True, open_browser=True)
#dcnn.check_labels(save=True, path_out=cfg.config['path']['data_train']) #dcnn.check_labels(save=True, path_out=cfg.config['path']['data_train'])
...@@ -107,7 +116,7 @@ def run(fnconfig=None,basedir=None,data_meg=None,data_train=None,pattern='-raw.f ...@@ -107,7 +116,7 @@ def run(fnconfig=None,basedir=None,data_meg=None,data_train=None,pattern='-raw.f
if do_performance_check: if do_performance_check:
path_in = cfg.config['path']['data_train'] path_in = cfg.config['path']['data_train']
for fname in file_looper(rootdir=path_in, pattern='*.npz',version=__version__,verbose=verbose,log2file=log2file,logoverwrite=False): for fname in file_looper(rootdir=path_in, pattern=npz_pattern,version=__version__,verbose=verbose,log2file=log2file,logoverwrite=False):
dcnn.load_gdcnn(fname) dcnn.load_gdcnn(fname)
# ToDo plot performance, save to report # ToDo plot performance, save to report
...@@ -137,8 +146,11 @@ if __name__ == "__main__": ...@@ -137,8 +146,11 @@ if __name__ == "__main__":
#opt.data_meg = "data_examples" #opt.data_meg = "data_examples"
#opt.data_train = "$JUMEG_PATH_LOCAL_DATA"+"/exp/dcnn/ica_labeled/Juelich" #opt.data_train = "$JUMEG_PATH_LOCAL_DATA"+"/exp/dcnn/ica_labeled/Juelich"
#-- 4D #-- 4D
opt.pattern = "*-raw.fif" #"*.c,rfDC_bcc,nr-raw.fif" opt.pattern = "*int-raw.fif" #"*.c,rfDC_bcc,nr-raw.fif"
opt.config = "config_4D_Juelich.yaml" opt.config = "config_4D_Juelich.yaml"
# ToDo trouble with
# 205399_MEG94T_121220_1322_2_c,rfDC_EC_bcc-raw-gdcnn.npz
# eog / ICs found ???
opt.ica = do_label_ica opt.ica = do_label_ica
opt.check = do_label_check opt.check = do_label_check
......
...@@ -25,7 +25,6 @@ __version__= "2020.07.06.001" ...@@ -25,7 +25,6 @@ __version__= "2020.07.06.001"
def setup_logfile(fname,version=__version__,verbose=False,overwrite=True,level=None): def setup_logfile(fname,version=__version__,verbose=False,overwrite=True,level=None):
Hlog = init_logfile(logger=logger,fname=fname,overwrite=overwrite,level=level) Hlog = init_logfile(logger=logger,fname=fname,overwrite=overwrite,level=level)
msg = ["DCNN : {}".format(version), msg = ["DCNN : {}".format(version),
" -> raw file : {}".format(fname),
" -> logfile : {}".format(Hlog.filename), " -> logfile : {}".format(Hlog.filename),
" -> overwrite: {}".format(overwrite)] " -> overwrite: {}".format(overwrite)]
logger.info("\n".join(msg)) logger.info("\n".join(msg))
...@@ -252,7 +251,7 @@ def file_looper(rootdir='.',pattern='*',recursive=False,version=None,verbose=Fal ...@@ -252,7 +251,7 @@ def file_looper(rootdir='.',pattern='*',recursive=False,version=None,verbose=Fal
msg.extend(msg_info) msg.extend(msg_info)
raise Exception("\n".join(msg)) raise Exception("\n".join(msg))
msg = ["DCNN files to process: {}\n{}".format(len(fnames),"\n -> ".join(fnames))] msg = ["DCNN files to process: {}\n -> {}".format(len(fnames),"\n -> ".join(fnames))]
for fnraw in fnames: for fnraw in fnames:
Hlog = None Hlog = None
...@@ -1011,6 +1010,8 @@ def get_ic_info(ics, labels, score_ecg_ctps, score_ecg_corr, score_eog_ver, scor ...@@ -1011,6 +1010,8 @@ def get_ic_info(ics, labels, score_ecg_ctps, score_ecg_corr, score_eog_ver, scor
for ic in ics: for ic in ics:
sc_ecg1 = np.abs(score_ecg_ctps[ic]) sc_ecg1 = np.abs(score_ecg_ctps[ic])
sc_ecg2 = np.abs(score_ecg_corr[ic]) sc_ecg2 = np.abs(score_ecg_corr[ic])
#logger.info("eog1: {}".format( score_eog_ver[ic]))
sc_eog1 = np.abs(score_eog_ver[ic]) sc_eog1 = np.abs(score_eog_ver[ic])
sc_eog2 = np.abs(score_eog_hor[ic]) sc_eog2 = np.abs(score_eog_hor[ic])
info = 'IC#%2d: %s: scores (%.3f, %.3f); (%.3f, %.3f)' % \ info = 'IC#%2d: %s: scores (%.3f, %.3f); (%.3f, %.3f)' % \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment