示例#1
0
class ExamineDataModel(object):

    ''' the model for the data to be presented '''

    def __init__(self, files, mainwin):
        ''' the eyedata takes a number of files '''
        self.files      = files
        self.MAINWIN    = mainwin
        self.fileindex  = 0
        self.trialindex = 0
        self.eyedata    = None
        if not self.loadEyeFile():
            return
        self._loadEyeData()

    def loadEyeFile(self):
        ''' load the eyefile '''
        fid = self.files[self.fileindex]
        pr = parseEyeFile(fid)
        entries = pr.getEntries()
        if not entries:
            errors = pr.getErrors()
            for i in errors:
                self.MAINWIN.reportStatus(i[2], i[0] + ':' + str(i[1]))
            return False

        MODEL = self.MAINWIN.getModel()[0] # ignore the controller in the tuple

        # Optionally filter right or left gaze from the experiment
        if  (MODEL[MODEL.EXTRACT_RIGHT] and MODEL[MODEL.EXTRACT_LEFT]) or\
            (not MODEL[MODEL.EXTRACT_LEFT] and not MODEL[MODEL.EXTRACT_RIGHT]):
            pass # If both are specified or if none are specified extract both eyes
        elif MODEL[MODEL.EXTRACT_LEFT]:
            entries = LogEntry.removeRightGaze(entries)
        elif MODEL[MODEL.EXTRACT_RIGHT]:
            entries = LogEntry.removeLeftGaze(entries)
        else:
            raise RuntimeError("The control flow shouldn't get here.")

        if not entries:
            return

        self.experiment = EyeExperiment(entries)
        self.trials     = self.experiment.trials

        return True

    def _loadEyeData(self):
        ''' Load eyedata '''
        trial = self.trials[self.trialindex]
        # We only want to read the model thus no need to get the controller
        MM = self.MAINWIN.getModel()[0]
        thres   = MM[MM.THRESHOLD]
        nthres  = MM[MM.NTHRESHOLD]
        smooth  = MM[MM.SMOOTH]
        win     = MM[MM.SMOOTHWIN]
        order   = MM[MM.SMOOTHORDER]

        self.eyedata = EyeData(thres, nthres, smooth, win, order)
        self.eyedata.processTrial(self.trials[self.trialindex])
示例#2
0
    def _loadEyeData(self):
        ''' Load eyedata '''
        trial = self.trials[self.trialindex]
        # We only want to read the model thus no need to get the controller
        MM = self.MAINWIN.getModel()[0]
        thres   = MM[MM.THRESHOLD]
        nthres  = MM[MM.NTHRESHOLD]
        smooth  = MM[MM.SMOOTH]
        win     = MM[MM.SMOOTHWIN]
        order   = MM[MM.SMOOTHORDER]

        self.eyedata = EyeData(thres, nthres, smooth, win, order)
        self.eyedata.processTrial(self.trials[self.trialindex])