def ClickOnApply(self):
        """
          get selected pdfs structure
          make commands with argparser parameter
          apply cmds to subprocess

          """

        self.PDFBox.verbose = self.verbose
        pdfs = self.PDFBox.GetSelectedPDFs()
        if not pdfs:
            wx.CallAfter(pub.sendMessage,
                         "MAIN_FRAME.MSG.ERROR",
                         data="\nPlease select PDFs first\n in: " +
                         self.GetName())
            return

        #cmd_parameter       = self.AP.GetParameter()
        cmd_command = self.AP.get_fullfile_command(ShowFileIO=True)
        joblist = []

        #--- del  "stage"
        cmd_list = cmd_command.split()
        for k in [
                "--meg_stage", "--eeg_stage", "-smeg", "-seeg", "--list_path"
        ]:
            for idx in range(len(cmd_list)):
                if cmd_list[idx].startswith(k):
                    del cmd_list[idx]
                    break

        cmd_command = " ".join(cmd_list)
        # print(cmd_command)

        for subject_id in pdfs.get('mne'):
            for idx in range(len(pdfs['mne'][subject_id])):
                if not pdfs['mne'][subject_id][idx]["selected"]: continue
                cmd = cmd_command
                eeg_idx = pdfs["eeg_index"][subject_id][idx]
                cmd += " --meg_stage=" + pdfs["stage"]
                cmd += " -fmeg " + pdfs["mne"][subject_id][idx]["pdf"]
                cmd += " --eeg_stage=" + pdfs["stage"]
                cmd += " -feeg " + pdfs["eeg"][subject_id][eeg_idx]["pdf"]
                #cmd += " "+ cmd_parameter
                joblist.append(cmd)

        if self.verbose:
            wx.LogMessage(
                jb.pp_list2str(joblist, head="MEEG Merger Job list: "))
            wx.LogMessage(
                jb.pp_list2str(self.HostCtrl.HOST.GetParameter(),
                               head="HOST Parameter"))
        if joblist:
            # wx.CallAfter(pub.sendMessage,"SUBPROCESS.RUN.START",jobs=joblist,host_parameter=self.HostCtrl.HOST.GetParameter(),verbose=self.verbose)
            wx.CallAfter(self.SubProcess.run,
                         jobs=joblist,
                         host_parameter=self.HostCtrl.HOST.GetParameter(),
                         verbose=self.verbose)
Exemplo n.º 2
0
    def ClickOnApply(self):
        """
          apply to subprocess
          """
        self.PDFBox.verbose = self.verbose
        pdfs = self.PDFBox.GetSelectedPDFs(
        )  # returns list of list [[pdf,extention] ..]
        if not pdfs:
            wx.CallAfter(pub.sendMessage,
                         "MAIN_FRAME.MSG.ERROR",
                         data="\nPlease select PDFs first\n in: " +
                         self.GetName())
            return

        cmd_command = self.AP.get_fullfile_command(ShowFileIO=False)
        joblist = []

        #--- del  "--fif_extention="
        cmd_list = []
        for s in cmd_command.split():
            if s.startswith("--fif"):
                continue  #del cmd_list[idx]
            cmd_list.append(s)

        cmd_command = " ".join(cmd_list)
        fif_stage = self.GetFIFStage()
        logger.info("FIF stage 2: {}".format(fif_stage))

        for pdf in pdfs:
            cmd = cmd_command
            #cmd += " --pdf_stage=" + os.path.expandvars( os.path.expanduser(os.path.dirname( self.PDFBox.GetStage() +"/"+ pdf )))
            cmd += " --pdf_stage=" + self.PDFBox.GetStage(
            ) + "/" + os.path.dirname(pdf[0])
            cmd += " --fif_stage=" + fif_stage
            cmd += " --fif_extention=" + pdf[1]
            joblist.append(cmd)

    # logger.info(joblist)

        if self.verbose:
            wx.LogMessage(
                jb.pp_list2str(joblist, head="MEEG Merger Job list: "))
            wx.LogMessage(
                jb.pp_list2str(self.HostCtrl.HOST.GetParameter(),
                               head="HOST Parameter"))
        if joblist:
            # wx.CallAfter(pub.sendMessage,"SUBPROCESS.RUN.START",jobs=joblist,host_parameter=self.HostCtrl.HOST.GetParameter(),verbose=self.verbose)
            wx.CallAfter(self.SubProcess.run,
                         jobs=joblist,
                         host_parameter=self.HostCtrl.HOST.GetParameter(),
                         verbose=self.verbose)
Exemplo n.º 3
0
    def UpdatePropertyGrid(self, name=None, TMP=None):
        """
        update Template Parameter within a wx.PropertyGrid

        Parameter
        ---------
         name: name of experiment
         TMP : the template structure as dict
       """
        # print(self.Template.TMP._template_data)

        if name:
            self.Template.update_template(name=name)
        if TMP:
            data = TMP.template_data
        else:
            data = self.Template.TMP.template_data

        if self.verbose:
            wx.LogMessage("Update " + self.title + " : " +
                          self.Template.GetExperiment()
                          )  #data["experiment"].get("name"))
            wx.LogMessage(jb.pp_list2str(data))

        self.PropertyGridNoteBoook.update(data=data)
Exemplo n.º 4
0
    def ClickOnSave(self):
        """
       show File Save DLG
       save template data in json format

       """
        data = self.PropertyGridNoteBoook.GetData()
        #--- make file name
        self.Template.TMP.template_name = self.GetDataName(data)
        #fjson  = self.Template.TMP.template_full_filename
        SaveDLG = wx.FileDialog(
            self,
            message='Save Template data.',
            wildcard='template (*.' + self.Template.TMP.template_extention +
            ')|*.json|All Files|*',
            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT | wx.FD_PREVIEW)

        SaveDLG.SetDirectory(self.Template.TMP.template_path)
        SaveDLG.SetFilename(self.Template.TMP.template_filename)

        if SaveDLG.ShowModal() == wx.ID_OK:
            #--- update templatev info
            data["info"] = self.Template.TMP.update_template_info(
                gui_version=__version__)

            fout = os.path.join(SaveDLG.GetDirectory(), SaveDLG.GetFilename())
            if self.verbose:
                wx.LogMessage(" ---> experiment template             : " +
                              data["experiment"]["name"])
                wx.LogMessage("  --> saving experiment template file : " +
                              fout)
                if self.debug:
                    wx.LogDebug("   -> experiment template data: \n" +
                                json.dumps(data, indent=4))
            try:
                with open(fout, "w") as f:
                    f.write(json.dumps(data, indent=4))
                    os.fsync(f.fileno())  # make to disk
                f.close()
                if self.verbose:
                    wx.LogMessage(
                        " ---> done saving experiment template file: " + fout)
            #--- update Experiment Template lists and update ExpTmp ComboBox with new template name
            #---  TEST_jumeg_experiment_template.json  => TEST
                name = SaveDLG.GetFilename().split(
                    "_" + self.Template.TMP.template_postfix)[0]
                self.Template.update_template(name=name)

            except Exception as e:
                wx.LogError("Save failed!\n" + jb.pp_list2str(
                    e, head="Error writing experiment template file: " + fout))
                pub.sendMessage("MAIN_FRAME.MSG.ERROR",
                                data="Error writing template file: " + fout)
                raise
            finally:
                SaveDLG.Destroy()
Exemplo n.º 5
0
 def info(self):
     logger.info("  -> PDFs:\n  -> " + "\n".join(self.pdfs))
     if self.debug:
         logger.debug(jb.pp_list2str(self.__dict__))
Exemplo n.º 6
0
 def log_info_process(self):
     wx.LogMessage(jb.pp_list2str(self.cmd,head=" -->SubProcess cmd:"))
Exemplo n.º 7
0
 def msg(self,msg,head=""):
     if isinstance(msg,(list,dict)):
        wx.LogMessage(jb.pp_list2str(msg,head=self.msg_prefix +" "+head +"\n"))
     else:
        wx.LogMessage(self.msg_prefix +" "+head +"\n"+msg)
Exemplo n.º 8
0
 def msg_cmd(self,cmd):
     wx.LogMessage(jb.pp_list2str(cmd,head=self.msg_prefix + " cmd:"))