def __init__(self, parent=None, paramfile=None, paramdictname=None):
        super(Paradigm, self).__init__(parent)

        # -- Read settings --
        smServerType = rigsettings.STATE_MACHINE_TYPE

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,interval=0.1)
        self.dispatcherView = dispatcher.DispatcherGUI(model=self.dispatcherModel)

        # -- Add parameters --
        self.params = paramgui.Container()
        self.params['periodOn'] = paramgui.NumericParam('Period On',value=0.2,
                                                        group='Timing Parameters')
        self.params['periodOff'] = paramgui.NumericParam('Period Off',value=0.2,
                                                         group='Timing Parameters')
        self.params['trainOn'] = paramgui.NumericParam('Train On',value=2,
                                                         group='Timing Parameters')
        self.params['trainOff'] = paramgui.NumericParam('Train Off',value=1,
                                                         group='Timing Parameters')
        timingParams = self.params.layout_group('Timing Parameters')

        # -- Add graphical widgets to main window --
        centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QHBoxLayout()
        layoutMain.addWidget(self.dispatcherView)
        layoutOneColumn = QtGui.QVBoxLayout()
        layoutOneColumn.addWidget(timingParams)
        layoutOneColumn.addStretch()
        layoutMain.addLayout(layoutOneColumn)
        centralWidget.setLayout(layoutMain)
        self.setCentralWidget(centralWidget)

        # -- Center in screen --
        paramgui.center_in_screen(self)

        # -- Connect signals from dispatcher --
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)
        self.dispatcherModel.timerTic.connect(self.timer_tic)

        self.sm = statematrix.StateMatrix(inputs=rigsettings.INPUTS,
                                          outputs=rigsettings.OUTPUTS,
                                          readystate='ready_next_trial',
                                          extratimers=['trainTimer'])
Beispiel #2
0
    def __init__(self, parent=None, paramfile=None, paramdictname=None):
        super(Paradigm, self).__init__(parent)

        # -- Read settings --
        smServerType = rigsettings.STATE_MACHINE_TYPE

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,interval=0.1)
        self.dispatcherView = dispatcher.DispatcherGUI(model=self.dispatcherModel)

        # -- Add parameters --
        self.params = paramgui.Container()
        self.params['periodOn'] = paramgui.NumericParam('Period On',value=0.5,
                                                        group='Timing Parameters')
        self.params['periodOff'] = paramgui.NumericParam('Period Off',value=1,
                                                         group='Timing Parameters')
        timingParams = self.params.layout_group('Timing Parameters')
        self.params['irrelevant1'] = paramgui.MenuParam('Irrelevant 1',
                                                        ['one_item','another_item'],
                                                        value=0,group='Irrelevant')
        self.params['irrelevant2'] = paramgui.StringParam('Irrelevant 2',value='nothing',
                                                         group='Irrelevant')
        irrelevantParams = self.params.layout_group('Irrelevant')

        # -- Add graphical widgets to main window --
        centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QHBoxLayout()
        layoutMain.addWidget(self.dispatcherView)
        layoutOneColumn = QtGui.QVBoxLayout()
        layoutOneColumn.addWidget(timingParams)
        layoutOneColumn.addWidget(irrelevantParams)
        layoutMain.addLayout(layoutOneColumn)
        centralWidget.setLayout(layoutMain)
        self.setCentralWidget(centralWidget)

        # -- Center in screen --
        paramgui.center_in_screen(self)

        # -- Connect signals from dispatcher --
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)
        self.dispatcherModel.timerTic.connect(self.timer_tic)
Beispiel #3
0
    def __init__(self, parent=None, paramfile=None, paramdictname=None):

        '''
        Set up the taskontrol core modules, add parameters to the GUI, and
        initialize the sound server.
        '''

        super(Paradigm, self).__init__(parent)

        self.name = 'am_tuning_curve'

        # -- Read settings --
        smServerType = rigsettings.STATE_MACHINE_TYPE

        # -- Create the speaker calibration object
        self.spkCal = speakercalibration.Calibration(rigsettings.SPEAKER_CALIBRATION_SINE)
        self.noiseCal = speakercalibration.NoiseCalibration(rigsettings.SPEAKER_CALIBRATION_NOISE)

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,
                                                     interval=0.1)

        self.dispatcherView = dispatcher.DispatcherGUI(model=self.dispatcherModel)

        # -- Manual control of outputs --
        self.manualControl = manualcontrol.ManualControl(self.dispatcherModel.statemachine)

        # -- Add parameters --
        self.params = paramgui.Container()
        self.params['experimenter'] = paramgui.StringParam('Experimenter',
                                                            value='santiago',
                                                            group='Parameters')
        self.params['subject'] = paramgui.StringParam('Subject',value='test030',
                                                       group='Parameters')
        self.params['minFreq'] = paramgui.NumericParam('Min Frequency (Hz)',
                                                        value=2000,
                                                        group='Parameters')
        self.params['maxFreq'] = paramgui.NumericParam('Max Frequency (Hz)',
                                                        value=40000,
                                                        group='Parameters')
        self.params['numTones'] = paramgui.NumericParam('Number of Frequencies',
                                                         value=16,
                                                         group='Parameters')
        self.params['minInt'] = paramgui.NumericParam('Min Intensity (dB SPL)',
                                                       value=60,
                                                       group='Parameters')
        self.params['maxInt'] = paramgui.NumericParam('Max Intensity (dB SPL)',
                                                       value=60,
                                                       group='Parameters')
        self.params['numInt'] = paramgui.NumericParam('Number of Intensities',
                                                       value=1,
                                                       group='Parameters')
        self.params['stimDur'] = paramgui.NumericParam('Stimulus Duration (s)',
                                                        value=0.01,
                                                        group='Parameters')
        '''
        self.params['isiMin'] = paramgui.NumericParam('Minimum Interstimulus Interval (s)',
                                                       value=1,
                                                       group='Parameters')
        self.params['isiMax'] = paramgui.NumericParam('Maximum Interstimulus Interval',
                                                      value=3,
                                                      group='Parameters')
        '''
        self.params['isiMean'] = paramgui.NumericParam('Interstimulus interval mean (s)',
                                                       value=2,
                                                       group='Parameters')
        self.params['isiHalfRange'] = paramgui.NumericParam('+/-',
                                                      value=1,
                                                      group='Parameters')
        # self.params['noiseAmp'] = paramgui.NumericParam('Amplitude in Noise-Mode',
        #                                                value=0.3,
        #                                                group='Parameters')
        self.params['randomMode'] = paramgui.MenuParam('Presentation Mode',
                                                         ['Ordered','Random'],
                                                         value=1,group='Parameters')
        self.params['stimType'] = paramgui.MenuParam('Stim Type',
                                                         ['Sine','Chord', 'Noise', 'AM', 'Laser', 'LaserTrain', 'Light', 'SineLaser'],
                                                         value=2,group='Parameters')
        self.params['currentFreq'] = paramgui.NumericParam('Current Frequency (Hz)',
                                                            value=0, units='Hz',
                                                            enabled=False,
                                                            group='Parameters')

        self.params['currentIntensity'] = paramgui.NumericParam('Target Intensity',
                                                                 value=0,
                                                                 enabled=False,
                                                                 group='Parameters')
        self.params['currentAmpL'] = paramgui.NumericParam('Current Amplitude - L',value=0,
                                                           enabled=False,
                                                           group='Parameters',
                                                           decimals=4)
        self.params['currentAmpR'] = paramgui.NumericParam('Current Amplitude - R',value=0,
                                                           enabled=False,
                                                           group='Parameters',
                                                           decimals=4)


        self.params['laserOn'] = paramgui.NumericParam('Laser On', value=0, enabled=False,
                                                            group='Parameters')
        self.params['laserProbability'] = paramgui.NumericParam('Laser Probability (s)', value=0,
                                                            group='Parameters')
        self.params['laserDuration'] = paramgui.NumericParam('Laser Duration (s)', value=0,
                                                            group='Parameters')
        self.params['laserOnset'] = paramgui.NumericParam('Laser Onset (s)', value=0,
                                                            group='Parameters')




        timingParams = self.params.layout_group('Parameters')

        # -- Load parameters from a file --
        self.params.from_file(paramfile,paramdictname)


        # -- Create an empty state matrix --
        self.sm = statematrix.StateMatrix(inputs=rigsettings.INPUTS,
                                          outputs=rigsettings.OUTPUTS,
                                          readystate='readyForNextTrial')

        # -- Module for savng the data --

        self.saveData = savedata.SaveData(rigsettings.DATA_DIR,
                                          remotedir=rigsettings.REMOTE_DIR)
        self.saveData.checkInteractive.setChecked(True)

        # -- Add graphical widgets to main window --
        self.centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QHBoxLayout() #Create a main layout and two columns
        layoutCol1 = QtGui.QVBoxLayout()
        layoutCol2 = QtGui.QVBoxLayout()


        layoutMain.addLayout(layoutCol1) #Add the columns to the main layout
        layoutMain.addLayout(layoutCol2)

        layoutCol1.addWidget(self.dispatcherView) #Add the dispatcher to col1
        layoutCol1.addWidget(self.saveData)
        layoutCol1.addWidget(self.manualControl)

        self.clearButton = QtGui.QPushButton('Clear Stim List', self)
        self.clearButton.clicked.connect(self.clear_tone_list)
        layoutCol1.addWidget(self.clearButton)


        layoutCol2.addWidget(timingParams)  #Add the parameter GUI to column 2

        self.centralWidget.setLayout(layoutMain) #Assign the layouts to the main window
        self.setCentralWidget(self.centralWidget)

        # -- Connect signals from dispatcher --

        #prepare_next_trial is sent whenever the dispatcher reaches the end of
        #the current trial.
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)

        # -- Connect the save data button --
        self.saveData.buttonSaveData.clicked.connect(self.save_to_file)

        print "Connecting to sound server"
        print '***** FIXME: HARDCODED TIME DELAY TO WAIT FOR SERIAL PORT! *****'
        time.sleep(0.2)
        self.soundClient = soundclient.SoundClient()
        self.soundClient.start()
        #soundFreq = self.params['soundFreq'].get_value()

        # -- Initialize the list of trial parameters --
        self.trialParams = []
        self.soundParamList = []
Beispiel #4
0
    def __init__(self, parent=None, paramfile=None, paramdictname=None):
        '''
        Set up the taskontrol core modules, add parameters to the GUI, and
        initialize the sound server.
        '''

        super(Paradigm, self).__init__(parent)

        self.name = 'bandwidth_am'

        # -- Read settings --
        smServerType = rigsettings.STATE_MACHINE_TYPE

        # -- Create the speaker calibration objects
        self.noiseCal = speakercalibration.NoiseCalibration(
            rigsettings.SPEAKER_CALIBRATION_NOISE)
        self.toneCal = speakercalibration.Calibration(
            rigsettings.SPEAKER_CALIBRATION_SINE)

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,
                                                     interval=0.1)

        self.dispatcherView = dispatcher.DispatcherGUI(
            model=self.dispatcherModel)

        # -- Manual control of outputs --
        self.manualControl = manualcontrol.ManualControl(
            self.dispatcherModel.statemachine)

        # -- Add parameters --
        self.params = paramgui.Container()
        self.params['experimenter'] = paramgui.StringParam('Experimenter',
                                                           value='santiago',
                                                           group='Session')
        self.params['subject'] = paramgui.StringParam('Subject',
                                                      value='test030',
                                                      group='Session')

        self.params['charFreq'] = paramgui.NumericParam(
            'Characteristic Frequency (Hz)', value=8000, group='Session')
        self.params['modRate'] = paramgui.NumericParam('Modulation rate',
                                                       value=2.0,
                                                       group='Session')
        sessionParams = self.params.layout_group('Session')

        self.params['minAmp'] = paramgui.NumericParam(
            'Min noise amplitude (dB)', value=40, group='Sound Parameters')
        self.params['maxAmp'] = paramgui.NumericParam(
            'Max noise amplitude (dB)', value=60, group='Sound Parameters')
        self.params['numAmps'] = paramgui.NumericParam(
            'Number of Amplitudes', value=2, group='Sound Parameters')
        self.params['minBand'] = paramgui.NumericParam(
            'Minimum bandwidth (octaves)',
            value=0.25,
            group='Sound Parameters')
        self.params['maxBand'] = paramgui.NumericParam(
            'Maximum bandwidth (octaves)', value=2.0, group='Sound Parameters')
        self.params['numBands'] = paramgui.NumericParam(
            'Number of bandwidths', value=4, group='Sound Parameters')
        # -- Added extremes as separate option in case we want to add other stim types (unmodulated white noise) --
        self.params['whiteNoise'] = paramgui.MenuParam(
            'Add white noise to bandwidths?', ['yes', 'no'],
            value=0,
            group='Sound Parameters')
        self.params['pureTone'] = paramgui.MenuParam(
            'Add pure tone to bandwidths?', ['yes', 'no'],
            value=1,
            group='Sound Parameters')
        self.params['soundType'] = paramgui.MenuParam(
            'Sound type', ['full_spectrum', 'harmonics', 'both'],
            value=0,
            group='Sound Parameters')
        self.params['stimDur'] = paramgui.NumericParam(
            'Stimulus Duration (s)', value=1.0, group='Sound Parameters')
        self.params['isiMean'] = paramgui.NumericParam(
            'Interstimulus interval mean (s)',
            value=2,
            group='Sound Parameters')
        self.params['isiHalfRange'] = paramgui.NumericParam(
            '+/-', value=1, group='Sound Parameters')
        self.params['randomMode'] = paramgui.MenuParam(
            'Presentation Mode', ['Ordered', 'Random'],
            value=1,
            group='Sound Parameters')
        soundParams = self.params.layout_group('Sound Parameters')

        self.params['signalType'] = paramgui.MenuParam(
            'Include pure tone signal?', ['yes', 'no'],
            value=1,
            group='Signal Parameters')
        self.params['minSNR'] = paramgui.NumericParam(
            'Minimum signal to noise',
            value=10,
            decimals=0,
            units='dB',
            group='Signal Parameters')
        self.params['maxSNR'] = paramgui.NumericParam(
            'Maximum signal to noise',
            value=20,
            decimals=0,
            units='dB',
            group='Signal Parameters')
        self.params['numSNRs'] = paramgui.NumericParam(
            'Number of SNRs',
            value=3,
            decimals=0,
            units='dB',
            group='Signal Parameters')
        signalParams = self.params.layout_group('Signal Parameters')

        self.params['laserPercent'] = paramgui.MenuParam(
            'Percentage of trials with laser', ['0%', '50%', '100%'],
            value=1,
            group='Laser Parameters')
        self.params['laserType'] = paramgui.MenuParam('Laser colour',
                                                      ['blue', 'green'],
                                                      value=1,
                                                      group='Laser Parameters')
        self.params['laserFrontOverhang'] = paramgui.NumericParam(
            'Laser Front Overhang',
            value=0,
            group='Laser Parameters',
            decimals=1)
        self.params['laserBackOverhang'] = paramgui.NumericParam(
            'Laser Back Overhang',
            value=0,
            group='Laser Parameters',
            decimals=1)
        laserParams = self.params.layout_group('Laser Parameters')

        self.params['currentAmp'] = paramgui.NumericParam(
            'Current Amplitude',
            value=0,
            enabled=False,
            group='Current Trial',
            decimals=1)
        self.params['currentBand'] = paramgui.NumericParam(
            'Current Bandwidth',
            value=0,
            enabled=False,
            group='Current Trial',
            decimals=2)
        self.params['currentSNR'] = paramgui.NumericParam(
            'Current SNR',
            value=0.0,
            decimals=1,
            units='dB',
            enabled=False,
            group='Current Trial')
        self.params['laserTrial'] = paramgui.NumericParam(
            'Laser Trial?',
            value=0,
            enabled=False,
            group='Current Trial',
            decimals=0)
        self.params['harmTrialType'] = paramgui.NumericParam(
            'Harmonics Trial?',
            value=0,
            enabled=False,
            group='Current Trial',
            decimals=0)
        trialParams = self.params.layout_group('Current Trial')

        # -- Load parameters from a file --
        self.params.from_file(paramfile, paramdictname)

        # -- Create an empty state matrix --
        self.sm = statematrix.StateMatrix(inputs=rigsettings.INPUTS,
                                          outputs=rigsettings.OUTPUTS,
                                          readystate='readyForNextTrial')

        # -- Module for saving the data --
        self.saveData = savedata.SaveData(rigsettings.DATA_DIR,
                                          remotedir=rigsettings.REMOTE_DIR)
        self.saveData.checkInteractive.setChecked(True)

        # -- Add graphical widgets to main window --
        self.centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QHBoxLayout()  #Create a main layout and two columns
        layoutCol1 = QtGui.QVBoxLayout()
        layoutCol2 = QtGui.QVBoxLayout()

        layoutMain.addLayout(layoutCol1)  #Add the columns to the main layout
        layoutMain.addLayout(layoutCol2)

        layoutCol1.addWidget(self.dispatcherView)  #Add the dispatcher to col1
        layoutCol1.addWidget(self.saveData)
        layoutCol1.addWidget(self.manualControl)
        layoutCol1.addWidget(trialParams)

        self.clearButton = QtGui.QPushButton('Clear Stim List', self)
        self.clearButton.clicked.connect(self.clear_tone_list)
        layoutCol1.addWidget(self.clearButton)

        layoutCol2.addWidget(sessionParams)  #Add the parameter GUI to column 2
        layoutCol2.addWidget(soundParams)
        layoutCol2.addWidget(signalParams)
        layoutCol2.addWidget(laserParams)

        self.centralWidget.setLayout(
            layoutMain)  #Assign the layouts to the main window
        self.setCentralWidget(self.centralWidget)

        # -- Connect signals from dispatcher --

        #prepare_next_trial is sent whenever the dispatcher reaches the end of
        #the current trial.
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)

        # -- Connect the save data button --
        self.saveData.buttonSaveData.clicked.connect(self.save_to_file)

        print "Connecting to sound server"
        print '***** FIXME: HARDCODED TIME DELAY TO WAIT FOR SERIAL PORT! *****'
        time.sleep(0.2)
        self.soundClient = soundclient.SoundClient()
        self.soundClient.start()
        #soundFreq = self.params['soundFreq'].get_value()

        # -- Initialize the list of trial parameters --
        self.trialParams = []
        self.soundParamList = []
    def __init__(self, parent=None, paramfile=None, paramdictname=None):
        super(Paradigm, self).__init__(parent)

        #self.setStyleSheet(stylesheets.styleCompact)

        # -- Read settings --
        smServerType = rigsettings.STATE_MACHINE_TYPE
        #smServerType = 'dummy'

        # -- Module for saving data --
        self.saveData = savedata.SaveData(rigsettings.DATA_DIR)

        # -- Sides plot --
        sidesplot.set_pg_colors(self)
        self.mySidesPlot = sidesplot.SidesPlot(nTrials=80)

        # -- Create an empty state matrix --
        self.sm = statematrix.StateMatrix(inputs=rigsettings.INPUTS,
                                          outputs=rigsettings.OUTPUTS,
                                          readystate='ready_next_trial')

        # -- Add parameters --
        self.params = paramgui.Container()
        self.params['experimenter'] = paramgui.StringParam(
            'Experimenter', value='santiago', group='Session info')
        self.params['subject'] = paramgui.StringParam('Subject',
                                                      value='saja000',
                                                      group='Session info')
        sessionInfo = self.params.layout_group('Session info')

        self.params['stimulusDuration'] = paramgui.NumericParam(
            'Stim duration', value=0.2, group='Timing parameters')
        self.params['rewardDuration'] = paramgui.NumericParam(
            'Reward duration', value=0.05, group='Timing parameters')
        timingParams = self.params.layout_group('Timing parameters')

        # -- Load parameters from a file --
        #self.params.from_file('params_008.py','saja002') ### DEBUG
        self.params.from_file(paramfile, paramdictname)

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,
                                                     interval=0.3)
        self.dispatcherView = dispatcher.DispatcherGUI(
            model=self.dispatcherModel)

        # -- Manual control of outputs --
        self.manualControl = manualcontrol.ManualControl(
            self.dispatcherModel.statemachine)

        # -- Add graphical widgets to main window --
        centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QVBoxLayout()
        layoutTop = QtGui.QVBoxLayout()
        layoutBottom = QtGui.QHBoxLayout()
        layoutCol1 = QtGui.QVBoxLayout()
        layoutCol2 = QtGui.QVBoxLayout()

        layoutMain.addLayout(layoutTop)
        #layoutMain.addStretch()
        layoutMain.addSpacing(0)
        layoutMain.addLayout(layoutBottom)

        layoutTop.addWidget(self.mySidesPlot)

        layoutBottom.addLayout(layoutCol1)
        layoutBottom.addLayout(layoutCol2)

        layoutCol1.addWidget(self.saveData)
        layoutCol1.addWidget(sessionInfo)
        layoutCol1.addWidget(self.dispatcherView)

        layoutCol2.addWidget(timingParams)
        layoutCol2.addWidget(self.manualControl)

        centralWidget.setLayout(layoutMain)
        self.setCentralWidget(centralWidget)

        # -- Center in screen --
        self.center_in_screen()

        # -- Add variables for storing results --
        maxNtrials = 4000
        self.results = arraycontainer.Container()
        self.results.labels['rewardSide'] = {'left': 0, 'right': 1}
        self.results['rewardSide'] = np.random.randint(2, size=maxNtrials)
        self.results.labels['choice'] = {'left': 0, 'right': 1, 'none': 2}
        self.results['choice'] = np.empty(maxNtrials, dtype=int)
        self.results.labels['outcome'] = {
            'correct': 1,
            'error': 0,
            'invalid': 2
        }
        self.results['outcome'] = np.empty(maxNtrials, dtype=int)
        self.results['timeTrialStart'] = np.empty(maxNtrials, dtype=float)
        self.results['timeCenterIn'] = np.empty(maxNtrials, dtype=float)
        self.results['timeCenterOut'] = np.empty(maxNtrials, dtype=float)
        self.results['timeSideIn'] = np.empty(maxNtrials, dtype=float)

        # --- Create state matrix ---
        #self.set_state_matrix() ################# ?????????????

        # -- Connect signals from dispatcher --
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)
        ###self.dispatcherModel.startNewTrial.connect(self.start_new_trial)
        self.dispatcherModel.timerTic.connect(self.timer_tic)

        # -- Connect messenger --
        self.messagebar = messenger.Messenger()
        self.messagebar.timedMessage.connect(self.show_message)
        #self.messagebar.timedMessage.emit('Created window')
        self.messagebar.collect('Created window')

        # -- Connect signals to messenger
        self.saveData.logMessage.connect(self.messagebar.collect)
        self.dispatcherModel.logMessage.connect(self.messagebar.collect)

        # -- Connect other signals --
        self.saveData.buttonSaveData.clicked.connect(self.save_to_file)

        # -- Prepare first trial --
        self.prepare_next_trial(0)
Beispiel #6
0
    def __init__(self, parent=None):
        super(Protocol, self).__init__(parent)

        # -- Read settings --
        smhost = rigsettings.STATE_MACHINE_SERVER

        # -- Add widgets --
        centralWidget = QtGui.QWidget()
        self.dispatcher = dispatcher.Dispatcher(host=smhost,
                                                interval=0.3,
                                                connectnow=True,
                                                dummy=True)
        self.saveData = savedata.SaveData()
        self.evplot = eventsplot.EventsPlot(xlim=[0, 4])
        self.manualControl = manualcontrol.ManualControl(self.dispatcher)

        # -- Parameters --
        self.params = paramgui.Container()

        self.params['experimenter'] = paramgui.StringParam(
            'Experimenter',
            value='santiago',
            group='Session info',
            history=False)
        self.params['animal'] = paramgui.StringParam('Animal',
                                                     value='saja000',
                                                     group='Session info',
                                                     history=False)

        self.params['soundDuration'] = paramgui.NumericParam('Sound Duration',
                                                             value=0.1,
                                                             group='Sound')
        self.params['irrelevantParam1'] = paramgui.NumericParam('Irrelevant 1',
                                                                value=0,
                                                                group='Sound')
        self.params['irrelevantParam2'] = paramgui.NumericParam('Irrelevant 2',
                                                                value=0,
                                                                group='Sound')
        self.params['chooseNumber'] = paramgui.MenuParam(
            'MenuParam', ('One', 'Two', 'Three'), group='Sound')
        self.params['anotherNumber'] = paramgui.MenuParam(
            'AnotherParam', ('VerLongOne', 'VerLongTwo', 'VerLongThree'),
            group='Sound')
        for ind in range(6):
            self.params['par%d' % ind] = paramgui.NumericParam(
                'Param%d' % ind, value=1.0 * (ind + 1), group='OtherParams')

        groupSessionInfo = self.params.layoutGroup('Session info')
        groupSound = self.params.layoutGroup('Sound')
        groupOther = self.params.layoutGroup('OtherParams')

        layoutMain = QtGui.QVBoxLayout()
        layoutTop = QtGui.QVBoxLayout()
        layoutBottom = QtGui.QHBoxLayout()
        layoutCol0 = QtGui.QVBoxLayout()
        layoutCol1 = QtGui.QVBoxLayout()
        layoutCol2 = QtGui.QVBoxLayout()

        layoutMain.addLayout(layoutTop)
        layoutMain.addStretch()
        layoutMain.addLayout(layoutBottom)

        layoutTop.addWidget(self.evplot)
        layoutBottom.addLayout(layoutCol0)
        layoutBottom.addLayout(layoutCol1)
        layoutBottom.addLayout(layoutCol2)

        layoutCol0.addWidget(self.saveData)
        layoutCol0.addWidget(groupSessionInfo)
        layoutCol0.addWidget(self.dispatcher)
        layoutCol1.addWidget(self.manualControl)
        layoutCol1.addWidget(groupSound)
        layoutCol2.addWidget(groupOther)

        centralWidget.setLayout(layoutMain)
        self.setCentralWidget(centralWidget)

        # --- Create state matrix ---
        self.sm = statematrix.StateMatrix(readystate=('ready_next_trial', 1))
        self.setStateMatrix()

        # -- Setup events plot --
        #self.evplot.setStatesColor(np.random.rand(6))
        '''
        statesColor = [ [255,0,0],[0,255,0],[0,0,255],\
                        [255,255,0],[255,0,255],[0,255,255] ]  
        self.evplot.setStatesColor(statesColor)
        '''
        statesColorDict = {
            'wait_for_cpoke': [127, 127, 255],
            'play_target': [255, 255, 0],
            'wait_for_apoke': [191, 191, 255],
            'reward': [0, 255, 0],
            'punish': [255, 0, 0],
            'ready_next_trial': [0, 0, 0]
        }
        self.evplot.setStatesColor(statesColorDict, self.sm.getStatesDict())

        # -- Connect signals from dispatcher --
        self.connect(self.dispatcher, QtCore.SIGNAL('PrepareNextTrial'),
                     self.prepareNextTrial)
        self.connect(self.dispatcher, QtCore.SIGNAL('StartNewTrial'),
                     self.startNewTrial)
        self.connect(self.dispatcher, QtCore.SIGNAL('TimerTic'), self.timerTic)

        self.connect(self.saveData.buttonSaveData, QtCore.SIGNAL('clicked()'),
                     self.fileSave)

        # -- Connect messenger --
        self.mymess = messenger.Messenger()
        self.connect(self.mymess.emitter, QtCore.SIGNAL('NewMessage'),
                     self.showMessage)
        self.mymess.send('Created window')
    def __init__(self, parent=None, paramfile=None, paramdictname=None):
        super(Paradigm2AFC, self).__init__(parent)

        self.name = '2afc'
        smServerType = rigsettings.STATE_MACHINE_TYPE

        # -- Sides plot --
        sidesplot.set_pg_colors(self)
        self.mySidesPlot = sidesplot.SidesPlot(nTrials=120)

        # -- Module for saving data --
        self.saveData = savedata.SaveData(rigsettings.DATA_DIR, remotedir=rigsettings.REMOTE_DIR)

        # -- Create an empty state matrix --
        self.sm = statematrix.StateMatrix(inputs=rigsettings.INPUTS,
                                          outputs=rigsettings.OUTPUTS,
                                          readystate='readyForNextTrial')

        # -- Add parameters --
        self.params = paramgui.Container()
        self.params['trainer'] = paramgui.StringParam('Trainer (initials)',
                                                      value='',
                                                      group='Session info')
        self.params['experimenter'] = paramgui.StringParam('Experimenter',
                                                           value='experimenter',
                                                           group='Session info')
        self.params['subject'] = paramgui.StringParam('Subject',value='subject',
                                                      group='Session info')
        self.sessionInfo = self.params.layout_group('Session info')

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,interval=0.1)
        self.dispatcherView = dispatcher.DispatcherGUI(model=self.dispatcherModel)
 
        # -- Connect to sound server and define sounds --
        # FINISH

        # -- Manual control of outputs --
        self.manualControl = manualcontrol.ManualControl(self.dispatcherModel.statemachine)

        # -- Add graphical widgets to main window --
        self.centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QVBoxLayout()
        layoutTop = QtGui.QVBoxLayout()
        layoutBottom = QtGui.QHBoxLayout()
        layoutCol1 = QtGui.QVBoxLayout()
        layoutCol2 = QtGui.QVBoxLayout()

        
        layoutMain.addLayout(layoutTop)
        #layoutMain.addStretch()
        layoutMain.addSpacing(0)
        layoutMain.addLayout(layoutBottom)

        layoutTop.addWidget(self.mySidesPlot)

        layoutBottom.addLayout(layoutCol1)
        layoutBottom.addLayout(layoutCol2)

        layoutCol1.addWidget(self.saveData)
        layoutCol1.addWidget(self.sessionInfo)
        layoutCol1.addWidget(self.dispatcherView)
        
        layoutCol2.addWidget(self.manualControl)
        layoutCol2.addStretch()

        self.centralWidget.setLayout(layoutMain)
        self.setCentralWidget(self.centralWidget)

        # -- Center in screen --
        self._center_in_screen()

        # -- Add variables storing results --
        self.results = arraycontainer.Container()

        # -- Connect signals from dispatcher --
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)
        self.dispatcherModel.timerTic.connect(self._timer_tic)

        # -- Connect messenger --
        self.messagebar = messenger.Messenger()
        self.messagebar.timedMessage.connect(self._show_message)
        self.messagebar.collect('Created window')

        # -- Connect signals to messenger
        self.saveData.logMessage.connect(self.messagebar.collect)
        self.dispatcherModel.logMessage.connect(self.messagebar.collect)

        # -- Connect other signals --
        self.saveData.buttonSaveData.clicked.connect(self.save_to_file)
    def __init__(self,
                 parent=None,
                 paramfile=None,
                 paramdictname=None,
                 dummy=False):
        super(WaterCalibration, self).__init__(parent)

        self.name = '2afc'

        # -- Read settings --
        if dummy:
            smServerType = 'dummy'
        else:
            smServerType = rigsettings.STATE_MACHINE_TYPE

        # -- Module for saving data --
        self.saveData = savedata.SaveData(rigsettings.DATA_DIR)

        # -- Create an empty state matrix --
        self.sm = statematrix.StateMatrix(inputs=rigsettings.INPUTS,
                                          outputs=rigsettings.OUTPUTS,
                                          readystate='readyForNextTrial')

        # -- Add parameters --
        self.params = paramgui.Container()
        '''
        self.params['experimenter'] = paramgui.StringParam('Experimenter',
                                                           value='experimenter',
                                                           group='Session info')
        self.params['subject'] = paramgui.StringParam('Subject',value='subject',
                                                      group='Session info')
        self.sessionInfo = self.params.layout_group('Session info')
        '''

        self.params['timeWaterValveL'] = paramgui.NumericParam(
            'Time valve left', value=0.04, units='s', group='Valves times')
        #self.params['timeWaterValveC'] = paramgui.NumericParam('Time valve center',value=0.04,
        #                                                       units='s',group='Valves times')
        self.params['timeWaterValveR'] = paramgui.NumericParam(
            'Time valve right', value=0.04, units='s', group='Valves times')
        valvesTimes = self.params.layout_group('Valves times')

        self.params['waterVolumeL'] = paramgui.NumericParam(
            'Water volume left', value=0, units='ml', group='Water volume')
        #self.params['waterVolumeC'] = paramgui.NumericParam('Water volume center',value=0,
        #                                                       units='ml',group='Water volume')
        self.params['waterVolumeR'] = paramgui.NumericParam(
            'Water volume right', value=0, units='ml', group='Water volume')
        waterVolume = self.params.layout_group('Water volume')

        self.params['offTime'] = paramgui.NumericParam('Time between',
                                                       value=0.5,
                                                       units='s',
                                                       group='Schedule')
        self.params['nDeliveries'] = paramgui.NumericParam('N deliveries',
                                                           value=2,
                                                           units='',
                                                           group='Schedule')
        self.params['nDelivered'] = paramgui.NumericParam('N delivered',
                                                          value=0,
                                                          units='',
                                                          group='Schedule')
        self.params['nDelivered'].set_enabled(False)
        schedule = self.params.layout_group('Schedule')

        # -- Create dispatcher --
        self.dispatcherModel = dispatcher.Dispatcher(serverType=smServerType,
                                                     interval=0.1)
        self.dispatcherView = dispatcher.DispatcherGUI(
            model=self.dispatcherModel)

        # -- Manual control of outputs --
        self.manualControl = manualcontrol.ManualControl(
            self.dispatcherModel.statemachine)

        # -- Add graphical widgets to main window --
        self.centralWidget = QtGui.QWidget()
        layoutMain = QtGui.QHBoxLayout()
        layoutCol1 = QtGui.QVBoxLayout()
        layoutCol2 = QtGui.QVBoxLayout()
        layoutCol3 = QtGui.QVBoxLayout()

        layoutCol1.addWidget(self.saveData)
        #layoutCol1.addWidget(self.sessionInfo)
        layoutCol1.addWidget(self.dispatcherView)

        layoutCol2.addWidget(valvesTimes)
        layoutCol2.addStretch()
        layoutCol2.addWidget(self.manualControl)

        layoutCol3.addWidget(waterVolume)
        layoutCol3.addStretch()
        layoutCol3.addWidget(schedule)

        layoutMain.addLayout(layoutCol1)
        layoutMain.addLayout(layoutCol2)
        layoutMain.addLayout(layoutCol3)

        self.centralWidget.setLayout(layoutMain)
        self.setCentralWidget(self.centralWidget)

        # -- Add variables storing results --
        self.results = arraycontainer.Container()

        # -- Connect signals from dispatcher --
        self.dispatcherModel.prepareNextTrial.connect(self.prepare_next_trial)
        self.dispatcherModel.timerTic.connect(self._timer_tic)

        # -- Connect messenger --
        self.messagebar = messenger.Messenger()
        self.messagebar.timedMessage.connect(self._show_message)
        self.messagebar.collect('Created window')

        # -- Connect signals to messenger
        self.saveData.logMessage.connect(self.messagebar.collect)
        self.dispatcherModel.logMessage.connect(self.messagebar.collect)

        # -- Connect other signals --
        self.saveData.buttonSaveData.clicked.connect(self.save_to_file)

        # -- Center in screen --
        paramgui.center_in_screen(self)