# -*- coding: utf-8 -*- """ Measure click thresholds, left, right or both ears, CI or not. @author: wschnupp """ import numpy as np ears='right' # make this "left", "right" or "both" simulate=True # set this to "true" if running a simulation on any computer. Set to false to do real recording on the TDT rig. CIstimulus=False # True for CI stimuli, false for acoustic stimuli myRate = 1 # click Rate in Hz myStimDur = 0.1 # click train duration in s myLevels=np.array([-5,0,5,10,15,20])+20 # levels in dB. These are dB SPL if this is acoustc, dB re 100 uA if this is CI. #myLevels=[20,30,40,50,60] # levels in dB. These are dB SPL if this is acoustc, dB re 100 uA if this is CI. # Caution! Levels for CI should be about 40-50 dB lower! myRepeats=20 # number of repeat presentations per stimulus import psyPhysConfig as config #config.location="Freiburg" config.location="HongKong" # load recorder object import RZ2ephys if simulate: config.ephysRecorder=RZ2ephys.Virtual_Cont_Recorder() else: config.ephysRecorder=RZ2ephys.TDT_RZ2_Cont_Recorder() config.ephysRecorder.sweepLen=0.5 #%% load stimulus object module import ClickTrainLibrary as stimulatorModule # select output hardware # select output hardware if simulate: stimulatorModule.soundPlayer=stimulatorModule.pygameSoundHardware() else: if CIstimulus: stimulatorModule.soundPlayer=stimulatorModule.TDT_CI_Hardware() else: stimulatorModule.soundPlayer=stimulatorModule.TDT_RZ6() soundPlayer=stimulatorModule.soundPlayer # set up stimulus module stim=stimulatorModule.clickTrainObject() stim.stimParams['duration (s)']=myStimDur stim.stimParams['clickRate (Hz)']=myRate stim.stimParams['ABL (dB)']=myLevels[-1] stim.ears=ears if CIstimulus: if simulate: stim.reference=0.100 # set reference to "0.100 mA" - this produces sounds that are within pygame dyn range stim.clickShape=np.array([1,1,0,0]) # in pygame simulation, short biphasics are inaudible. Use a short square wave instead else: stim.reference=100 # set reference to 100 uA stim.clickShape=np.array([1,0,-1,0]) # biphasic stimulus stim.levelRePeak=True else: stim.clickShape=np.array([0.7111 , -0.0476, -0.4480, 0.1398, -0.3584, 0.0183, -0.0152]) # a short white noise burst # work out stim duration and make sure sweep len is long enough stim.ready() #stim.play() #%% stimDur=stim.sounds.shape[0]/stimulatorModule.soundPlayer.sampleRate if stimDur+0.2 > config.ephysRecorder.sweepLen: config.ephysRecorder.sweepLen=stimDur+0.2 # load response module. # THis is an ephys anaesthetised experiment. No behaviour to detect detectors=None # load data saving module import dataHandlingEphys dataHandler=dataHandlingEphys.dataHandler() # we don't want to save data, only display it #%% # load scheduling module import listScheduler import numpy as np # define which stimulus paramaters you want to systematically vary in the experiment # and over which set of paramater values: mySchedule=listScheduler.schedule(["ABL (dB)"]) mySchedule.permute([myLevels],myRepeats) scheduler=listScheduler.scheduler(detectors,stim,dataHandler,mySchedule) #%% the main program try: scheduler.start() except: config.ephysRecorder.stop() raise finally: print() print('Tidying up') dataHandler.done() if not detectors is None: detectors.done() scheduler.done() #%% tidy up modules #dataHandler.done() #if not detectors is None: # detectors.done() #scheduler.done() #stim.done()