Example #1
0
    def Process(self, sig):
        #Process is called on every packet
        #Phase transitions occur independently of packets
        #Therefore it is not desirable to use phases for application logic in Process
        if 'MSEnable' in self.params: MagstimApp.process(self, sig)
        if 'DigitimerEnable' in self.params: DigitimerApp.process(self, sig)
        if 'ERPDatabaseEnable' in self.params: ERPApp.process(self, sig)
        if 'ContFeedbackEnable' in self.params: FeedbackApp.process(self, sig)
        if 'GatingEnable' in self.params: GatingApp.process(self, sig)

        #If we are in Task, and we are using GatingApp or MagstimApp or DigitimerApp
        if self.taskMaxNBlocks > 0 and self.in_phase(
                'task', min_packets=self.taskMaxNBlocks):
            self.change_phase('response')
        elif self.in_phase('task', min_packets=self.states['TaskMinNBlocks']):
            criteria_met = not 'GatingEnable' in self.params or not int(
                self.params['GatingEnable']) or self.states['GatingOK']
            magstim_ready = not 'MSEnable' in self.params or not int(
                self.params['MSEnable']) or self.states['MagstimReady']
            digitimer_ready = not 'DigitimerEnable' in self.params or not int(
                self.params['DigitimerEnable']
            ) or self.states['DigitimerReady']
            if criteria_met and magstim_ready and digitimer_ready:
                self.change_phase('response')

        #If we are in Response and we are using ERPApp and the ERP has been collected
        if self.in_phase('response') and \
                'ERPDatabaseEnable' in self.params and int(self.params['ERPDatabaseEnable']) and self.states['ERPCollected']:
            self.change_phase('stopcue')
    def Process(self, sig):
        #Process is called on every packet
        #Phase transitions occur independently of packets
        #Therefore it is not desirable to use phases for application logic in Process
        if 'MSEnable' in self.params:	MagstimApp.process(self, sig)
        if 'DigitimerEnable' in self.params:	DigitimerApp.process(self, sig)
        if 'ERPDatabaseEnable' in self.params:	ERPApp.process(self, sig)
        if 'ContFeedbackEnable' in self.params:	FeedbackApp.process(self, sig)
        if 'GatingEnable' in self.params:	GatingApp.process(self, sig)

        #If we are in Task, and we are using GatingApp or MagstimApp or DigitimerApp
        if self.taskMaxNBlocks>0 and self.in_phase('task', min_packets=self.taskMaxNBlocks):
            self.change_phase('response')
        elif self.in_phase('task', min_packets=self.states['TaskMinNBlocks']):
            criteria_met = not 'GatingEnable' in self.params or not int(self.params['GatingEnable']) or self.states['GatingOK']
            magstim_ready = not 'MSEnable' in self.params or not int(self.params['MSEnable']) or self.states['MagstimReady']
            digitimer_ready = not 'DigitimerEnable' in self.params or not int(self.params['DigitimerEnable']) or self.states['DigitimerReady']
            if criteria_met and magstim_ready and digitimer_ready:
                self.change_phase('response')

        #If we are in Response and we are using ERPApp and the ERP has been collected
        if self.in_phase('response') and \
                'ERPDatabaseEnable' in self.params and int(self.params['ERPDatabaseEnable']) and self.states['ERPCollected']:
            self.change_phase('stopcue')