trigger TMS + collect responses during stimulus presentation

B de Haan bianca.de-haan at klinikum.uni-tuebingen.de
Fri Jun 15 14:22:19 UTC 2007


Dear E-prime list,

I've been racking my brain over this problem longer than I care to think
about, so I hope someone can help me figure this out.

I want to present a targetstimulus (mainstimulus) followed by a maskstimulus
(mainmask2). Depending on the targetstimulus duration (titrated in a
previous block) an x amount of TMS pulses occur during presentation of the
targetstimulus (first pulse synchronized with stimulus onset) and the
remaining TMS pulses occur during presentation of the maskstimulus.
Furthermore, during presentation of the maskstimulus, I would also like to
be able to collect 2 button presses.

Mostly, I've managed to get it all to work (see code at the end of this
email). I have put the ImageDisplays of both the targetstimulus and the
mainstimulus under unreferenced objects with a duration of 0, time limit
infinite and end action none. The stimuli are presented correctly and the
tms pulses are fired during stimulus presentation) However, there are 2
problems I can't seem to solve.

Firstly, the timing seems to be way off. The most critical timing is the
timing of the targetstimulus and the TMS pulses. I have applied all the
tricks in the Timing-chapter of the E-Prime manual. Furthermore, I have run
the RefreshClockTest which shows that my computer is theoretically capable
of achieving millisecond precision. Finally, I calculate the exact Refresh
duration at the start of the experiment (using part of the code of the
RefreshClockTest experiment) and specify all my timings in multiples of the
calculated refresh duration (8.333ms at 120Hz monitor) with half a refresh
duration subtracted to make sure events happen on the exact vertical
refresh. Still, I don't achieve anything near good timing, especially for
the TMS pulses. 

Secondly, during presentation of the maskstimulus it does not register all
button presses. Sometimes a button press is detected, sometimes it's not.
I've had a look at monitoring responses using Inputmasks, but have not been
able to get this to work at all (mainmask2.Inputmasks.(Responses?).RT <> 0
cannot be compiled).

If anyone can provide me with any tips or tricks as to how to solve these 2
problems, they will earn my eternal gratitude.

Many thanks,

Bianca de Haan

Excerpt of code follows:
################################################################

	'create pulsecount to make sure each pulse is only fired once
	PulseCount = 1

	do 'start loop that will display mainstimulus till
stimdisplayduration has elapsed
		
		dim i1 as integer 'start loop counter
			
		'draw mainstimulus for infinite duration, terminated by
StimDisplayDuration
		mainstimulus.Filename = c.GetAttrib("mainstimulus")
		mainstimulus.Load
		mainstimulus.Run
		c.SetAttrib "mainstimulus.OnsetDelay",
mainstimulus.OnsetDelay
		c.SetAttrib "mainstimulus.OnsetTime", mainstimulus.OnsetTime
		c.SetAttrib "mainstimulus.PreRelease",
mainstimulus.PreRelease
		c.SetAttrib "mainstimulus.StartTime", mainstimulus.StartTime
		c.SetAttrib "mainstimulus.TimingMode",
mainstimulus.TimingMode
		c.SetAttrib "mainstimulus.CustomOnsetTime",
mainstimulus.CustomOnsetTime
		c.SetAttrib "mainstimulus.TargetOnsetTime",
mainstimulus.TargetOnsetTime

		'onsettime will only be collected in first loop and first
tms pulse synched with stimulus onset
		if i1 = 0 then 
			MainStimOnset = mainstimulus.OnsetTime 
			mainstimulus.OnsetSignalEnabled = True
			'send pulse at stimulus onset
			mainstimulus.OnsetSignalPort = &H378
			mainstimulus.OnsetSignalData = &HFF
			'write time that the pulse was really sent
			PulseTime = clock.read()
			c.SetAttrib "PulseTime1", PulseTime
			'switch port off again to enable second pulse
			writeport &H378, 0
			PulseCount = PulseCount + 1
		end if

		i1 = i1 + 1

	'end loop when stimulus duration has elapsed
	loop until clock.read() > MainStimOnset + StimDisplayDuration


	'create respcount to count the responses
	RespCount = 0
	'create place to log the 2 responses
	dim resp1 as Integer
	dim resp2 as Integer

	do 'start loop that runs mainmask2 until 2 responses are collected
while firing remaining tms pulses

		mainmask2.InputMasks.Reset
		mainmask2EchoClients.RemoveAll
		mainmask2.InputMasks.Add Keyboard.CreateInputMask("{ANY}",
"", CLng("-1"), CLng("2"), ebEndResponseActionNone, CLogical("Yes"), "", "",
"ResponseMode:All ProcessBackspace:Yes")
		mainmask2.Run
		c.SetAttrib "mainmask2.OnsetDelay", mainmask2.OnsetDelay
		c.SetAttrib "mainmask2.OnsetTime", mainmask2.OnsetTime
		c.SetAttrib "mainmask2.RTTime", mainmask2.RTTime
		c.SetAttrib "mainmask2.ACC", mainmask2.ACC
		c.SetAttrib "mainmask2.RT", mainmask2.RT
		c.SetAttrib "mainmask2.RESP", mainmask2.RESP
		c.SetAttrib "mainmask2.CRESP", mainmask2.CRESP

		'fire pulse 2
		if clock.read() >= MainStimOnset + (4.5 * RefreshDuration)
and PulseCount = 2 then
			WritePort &H378,255
			WritePort &H378,255
			WritePort &H378,255
			PulseTime = clock.read()
			c.SetAttrib "PulseTime2", PulseTime
			WritePort &H378,0
			PulseCount = PulseCount + 1
		end if	
		
		'fire pulse 3
		if clock.read() >= MainStimOnset + (9.5 * RefreshDuration)
and PulseCount = 3 then
			WritePort &H378,255
			WritePort &H378,255
			WritePort &H378,255
			PulseTime = clock.read()
			c.SetAttrib "PulseTime3", PulseTime
			WritePort &H378,0
			PulseCount = PulseCount + 1
		end if	
		
		'fire pulse 4
		if clock.read() >= MainStimOnset + (14.5 * RefreshDuration)
and PulseCount = 4 then
			WritePort &H378,255
			WritePort &H378,255
			WritePort &H378,255
			PulseTime = clock.read()
			c.SetAttrib "PulseTime4", PulseTime
			WritePort &H378,0
			PulseCount = PulseCount + 1
		end if	
		
		'fire pulse 5
		if clock.read() >= MainStimOnset + (19.5 * RefreshDuration)
and PulseCount = 5 then
			WritePort &H378,255
			WritePort &H378,255
			WritePort &H378,255
			PulseTime = clock.read()
			c.SetAttrib "PulseTime5", PulseTime
			WritePort &H378,0
			PulseCount = PulseCount + 1
		end if	

		'continuously check whether a response has been made and
then log which
		'response has been made
		if mainmask2.RT <> 0 then
			RespCount = RespCount + 1
			
			if RespCount = 1 then
			resp1 = mainmask2.RESP
			c.SetAttrib "resp1", resp1
			elseif RespCount = 2 then
			resp2 = mainmask2.RESP
			c.SetAttrib "resp2", resp2
			'collate the 2 responses in 1 column so I don't have
to change a previous response assignment
			c.SetAttrib "BothResps", resp1 & resp2
			end if
		
		end if

	'loop until 2 responses are collected
	loop until RespCount = 2

############################################################################
#



More information about the Eprime mailing list