Exemplo n.º 1
0
 def processLogin(self):
     subject = self.subject
     print 'SUBJECT['+ subject+']'
     self.mySubjectDir = j.checkSubjDir(subject)
     j.dirStructure(subject)  # verify/create subject's directory structure (visits, etc.)
     self.jsonpath = os.path.join(self.mySubjectDir,
                                  "%s_experiment_info.json" % subject)
     if os.path.exists(self.jsonpath):
         self.json = lib.load_json(self.jsonpath)
         self.json['flotscript'] = ''
         if 'flotscript_header' in self.json:
             del self.json['flotscript_header']
     else:
         lib.set_node(self.json, subject, j.SUBJID) ## get a fresh json_template
     ## find the next incomplete visit (if study complete, display final visit)
     for v in range(j.NUM_VISITS):
         self.setTab(v)
         if not lib.get_node(self.json, self.vNodePath + j.VCOMPLETE):
             break
     visit = v
     # handle subject's group assignment and create visit/session dir based on group, if needed.
     group = lib.get_node(self.json, j.GROUP)
     if not group == "":
         ### create & populate session dir
         self.visitDir, correctVisit = j.checkVisitDir(subject, visit, group, self.json)
         if not correctVisit == visit:
             self.subjectMoved("<b>Cannot move on to next visit without ROI masks!</b>", "false")
         self.setTab(correctVisit)
         return self.renderAndSave()   # saves the json, and renders the page
     else:
         return self.modalthing()  # render modal to assign group -> call setgroup() -> save json & render normally
Exemplo n.º 2
0
 def setgroup(self, group=None):
     ## Responds to result of modalthing's form submission. 
     ## Uses group value to create session dir.
     ## Note: group might not be assigned if "Cancel" is pressed
     if group:
         lib.set_node(self.json, group, j.GROUP)
         self.visitDir = j.checkVisitDir(self.subject, self.TabID, group, self.json) ### create & populate session dir
     return self.renderAndSave()
Exemplo n.º 3
0
 def doMakoLogin(self,subject=None,visit=None):
     self.subject = subject    ## keep this accessible to other methods
     self.mySubjectDir = j.checkSubjDir(subject)
     self.jsonpath = os.path.join(self.mySubjectDir, "%s_experiment_info.json"%subject)
     if os.path.exists(self.jsonpath):
         self.json = lib.load_json(self.jsonpath)  
     else:
         lib.set_node(self.json,subject,j.SUBJID) ## get a fresh json_template
     visit = lib.get_node(self.json,j.TAB)
     self.setTab(visit)          # activates the tab
     # handle subject's group assignment and create visit/session dir based on group, if needed.
     group = lib.get_node(self.json, j.GROUP)
     if not group == "":
         self.visitDir = j.checkVisitDir(subject,visit,group, self.json) ### create & populate session dir        
         return self.renderAndSave()   # saves the json, and renders the page
     else:
         return self.modalthing()  # render modal to assign group -> call setgroup() -> save json & render normally