Exemple #1
0
    def ClickOnShowDLG(self, evt):
        """
       shows File, DirDialog depending on file extention
       :param evt:
       :return:
       """
        try:
            obj = evt.GetEventObject()
        except:
            obj = evt

    # txt ctrl
        p = jb.expandvars(obj.GetValue())
        if os.path.isdir(p):
            with wx.DirDialog(self,
                              message=obj.GetName(),
                              defaultPath=p,
                              style=wx.DD_DEFAULT_STYLE,
                              name=obj.GetName() + "_DLG") as DLG:
                DLG.SetPath(p)
                if DLG.ShowModal() == wx.ID_CANCEL:
                    return  # the user changed their mind
                obj.SetValue(DLG.GetPath())
        else:
            fext = p.rsplit(".", 1)[-1]
            wc = "files (*." + fext + ",*.*)|*." + fext + ";*.all"
            with wx.FileDialog(self,
                               "{} => Select File Name".format(obj.GetName()),
                               wildcard=wc,
                               style=wx.DD_DEFAULT_STYLE,
                               name=obj.GetName() + "_DLG") as DLG:
                DLG.SetPath(p)
                if DLG.ShowModal() == wx.ID_CANCEL:
                    return  # the user changed their mind
                obj.SetValue(DLG.GetPath())
 def save_cfg(self, fname=None, data=None):
     """
      """
     if data:
         self._cfg = data
     if fname:
         self._fname = jb.expandvars(fname)
     with open(self._fname, "w") as f:
         self._yaml.dump(self._cfg, f)
    def load_cfg(self, fname=None, key=None):
        if fname:
            self._fname = jb.expandvars(fname)
        with open(self._fname) as f:
            self._cfg = self._yaml.load(f)
            if key:
                self._cfg = self._cfg.get(key)
            self._data = Struct(self._cfg)

        return self._data
Exemple #4
0
def main(argv):

    opt, parser = get_args(argv, version=__version__)
    if len(argv) < 2:
        parser.print_help()
        sys.exit(-1)

    if opt.test:
        os.environ["JUMEG_PATH_BTI_EXPORT"] = jb.expandvars(
            "$JUMEG_PATH_LOCAL_DATA") + "/megdaw_data21"

    #if opt.archive:
    #   opt.run = True

    if opt.run: apply(name=argv[0], opt=opt)
Exemple #5
0
 def fname(self, v):
     self._fname = jb.expandvars(v)
Exemple #6
0
from jumeg.filter.jumeg_mne_filter import JuMEG_MNE_FILTER
from jumeg.base import jumeg_logger

logger = logging.getLogger("jumeg")
logger = jumeg_logger.setup_script_logging(logger=logger,
                                           fname="quaters_epocher.log",
                                           level="INFO",
                                           logfile=True)  #,mode="w" )

#---
DO_EVENTS = True
DO_FILTER = True
DO_EPOCHS = True
verbose = True
debug = False
stage = jb.expandvars("$JUMEG_PATH_LOCAL_DATA/exp/QUATERS/mne")

epocher_path = None
hdf_path = None
raw = None

jumeg_epocher.use_yaml = True

template_name = "QUATERS"
template_path = os.path.dirname(__file__)
condition_list = ["RCC_ST", "RCC_FB"
                  ]  #,"RCI_ST","RCI_FB","RII_ST","RII_FB","RIC_ST","RIC_FB",
# "PCC_ST","PCC_FB","PCI_ST","PCI_FB","PII_ST","PII_FB","PIC_ST","PIC_FB"]

fraws = [
    #"207048/QUATERS01/191218_1447/2/207049_QUATERS01_191218_1447_2_c,rfDC,meeg-raw.fif",
 def path(self,v):
     if v:
        self._path = jb.expandvars(v)
        mkpath(self._path,mode=0o770)
     else:
         self._path=v
 def run(self,**kwargs):
     """
     :param kwargs:
     :return:
     stage=jpl.stage,subject_id=subject_id,fname=raw_fname,config=jpl.config.get("report")
     jReport.run(path=report_path,report_config_file=report_config_file,
                 experiment="QUARTERS",subject_id=210857,config=config)
         
     open/read cfg /reprt/fname-report.yaml
     MNEreport.open
      update NR
      update ICa
      save HDf5
      save htlm
      
     report config as dict
     report_path=report_path,path=path,fname=raw_fname,subject_id=210857,config=config
    
     report:
      run: True
      save: True
      overwrite: False
      noise_reducer:
       run: True
      ica:
       run: True
     """
     # logger.info(kwargs)
     self._update_from_kwargs(**kwargs)
     self.Report._update_from_kwargs(**kwargs)
     
    #--- try from jumeg config <report>  config=config.get("report")
     if "config" in kwargs:
        self._jumeg_cfg = kwargs.get("config")
     
     #logger.info("jumeg config report: {}".format( self.jumeg_cfg))
     
    #--- update from kwargs
     self.stage = jb.expandvars(self.stage)
     self.path  = kwargs.get("path",self.path) #--- report image path / image yaml file
     
     if self.stage.endswith("mne"):
        rp = self.stage.replace("mne","report")
     else:
        rp = self.stage
    #--- setup & open MNE report
     if not self.Report.open(path=rp):  return False
   
    #--- report image config
     self.update_report_cfg()
     
    #--- noise reducer
     if self.jumeg_cfg.get("noise_reducer",False):
        cfg = self.report_cfg.GetDataDict("noise_reducer")
        if cfg:
           self.Report.update_report(data=cfg.get("files"), path=self.path,section="Noise Reducer",prefix="NR")
    #--- ica
     if self.jumeg_cfg.get("ica",False):
        cfg = self.report_cfg.GetDataDict("ica")
        if cfg:
           self.Report.update_report(data=cfg,path=self.path,section="ICA",prefix="ICA")
    #--- save
     if self.jumeg_cfg.get("save",False):
        self.Report.save(overwrite=True)
 def path(self,v):
     pext = self._jumeg_cfg.get("path","report")
     if not v.endswith(pext):
        self._path = jb.expandvars( os.path.join(v,pext) )
     else:
        self._path = jb.expandvars(v)
 def fhdf(self,v):
     self._fhdf = jb.expandvars(v)
     mkpath(os.path.dirname(self._fhdf),mode=0o770)