Example #1
0
 def makoDoServ(self,btn_value,node):
     murfNode = bt.sib_node(node['id'], self.json, 0)
     servLog = bt.nameLogfile(node, self.subject, murfNode)
     self.run = murfNode['run']  # in case of accidental logout
     self.servProc, self.servOUT, h = lib.doServ(self.subject, self.TabID, self.run, servLog)
     lib.set_here(node,'disabled', True)
     return
Example #2
0
 def makoRealtimeStim(self, btn_value, node):
     murfNode = bt.sib_node(node['id'], self.json, 0)
     stimLog = bt.nameLogfile(node, self.subject, murfNode)
     self.run = murfNode['run']   ## in case of accidental logout
     self.flotJavascript()
     # based on group, use proper stimulus file
     group = lib.get_node(self.json, j.GROUP)
     if group == "high":
         psychofile = j.HIFILE
     elif group == "low":
         psychofile = j.LOFILE
     lib.set_here(node, 'file', psychofile)  # record which stimulus file was used
     # ready to launch!
     self.stimProc, h = lib.doStim(self.subject, self.TabID, self.run, stimLog, psychofile,self.json["study_info"]["group"])
     lib.set_here(node,'disabled', True)  # this button only launches. 'End Murfi' cleans up
     return
Example #3
0
 def makoMurfiHandler(self, btn_value, node):
     ## Handle "Start" & "End" differently
     if ('Start' in btn_value):
         murfLog = bt.nameLogfile(node, self.subject)
         try:
             self.murfProc, self.murfOUT, h = lib.doMurfi(self.subject, self.TabID, self.run, murfLog)
         except:
             self.murfProc.kill()
             self.murfOUT.close()
             raise
         lib.set_here(node,'text','End Murfi')  ## could do this better
         lib.set_here(bt.sib_node(node['id'], self.json, 1), "disabled", False)  ## activate psychopy
         lib.set_here(bt.sib_node(node['id'], self.json, 2), "disabled", False)  ## activate servenii
         lib.writeFlots(self.subject, self.TabID, node['run'])  ## update jquery for murfi plots
         print "attempting to change flotmurfi.js to use " + str(node['run']) +"!\n\n"
     elif "End" in btn_value:
         ## End must also clean up after servenii & rt psychopy, if needed.
         lib.set_here(bt.sib_node(node['id'], self.json, 1), "disabled", True)  ## disable psychopy
         lib.set_here(bt.sib_node(node['id'], self.json, 2), "disabled", True)  ## disable servenii
         ## close errant process handles
         if hasattr(self, 'murfProc'):
             lib.endMurfi(self.murfProc, self.subject, self.TabID, self.run, self.murfOUT)
         if hasattr(self, 'stimProc'):
             self.stimProc.kill()
         if hasattr(self, 'servProc'):
             lib.endServ(self.servProc, self.subject, self.TabID, self.run, self.servOUT)
         lib.set_here(node,'text','Start Murfi')
         ## check if RT run is done yet:
         ## -- 150ish TRs collected in results JSON? ==> done; update progress.
         ## -- otherwise, allow Murfi restart for this run.
         activeFile = os.path.join(self.visitDir,'data','run00%d_active.json'%self.run)
         if os.path.exists(activeFile):
             activeData = lib.load_json(activeFile)
             print "activeData's length is:", len(activeData['data'])
             if len(activeData['data']) > 150:
                 bt.rtDone(self.json, node['id'])  ## bt.updateProgress gets called in here.
             else:
                 lib.set_here(node, "disabled", False) ## ensure murfi can be restarted
     else:
         print "mako_cherry: Can't handle this murfi button value:",btn_value
     return