<html>
<body>
<br><br>
Hi - a previous suggestion was to do away with the image display
object and use canvas to remove your reported display delay and also
ensure ttl pulse accurately marks stimulus onset.<br><br>
If it is of any use, here is some example code that preloads the image
info into video memory - offScreenCanvas - prior to the time critical
parts of the trial .. fixation, and then image display, where the
offScreenCanvas is drawn to screen (copied to the display canvas [cnvs]),
and a ttl pulse is sent to some NeuroScan equipment. The copy operation
takes <1ms (t6-t5), so the image becomes available to subject over the
~11.7 ms @ 85Hz (i.e., half drawn by ~6 ms) as the screen is drawn, and
ttl pulse is reliably sent on same screen refresh.<br><br>
Sequence is: 1) InLine - StimPrep; 2) Fixation (a text object); 3) InLine
- DisplayStim<br><br>
- Key variables are declared in User Script<br>
- TrialList needs attributes 1) Pic = image name; 2) PicType =
condition<br>
- 9 conditions in this example, with event codes 1 to 9<br>
- Image display duration is set at the beginning of the experiment with
an integer value (intDur) collected by an AskBox. This could be hard
coded if you wanted.<br>
- There is a delay (blank screen) of 3 screen refreshes (~35 ms) between
Fixation offset and stimulus onset<br>
- Stimulus displayed centred on gray background<br>
- The Attributes t1, t2, ... t9, start, are all timing information used
for diagnostics. Fixation onset and offset are grabbed as well ..
intervals between these are easily computed later (e.g., in SPSS) and for
each trial you can see how long various bits of code execution take
(e.g., preload image, t2-t1); stimulus duration (t9-start); whether your
machine accurately tracks retraces (t3-fixation.OffsetTime; t4-t3;
t5-t4); and the accuracy of your ttl communication.. that is, that the
pulse is sent on the screen refresh where the stimulus is drawn to screen
(t7-t6), and the duration of the pulse (t8-t7). 7 ms has been OK for us
(no missed event markers), recording EEG @ 500Hz.<br><br>
Some of this code might be a bit rough. If anyone notices any errors in
this approach, please post.<br><br>
'--------------------------------------------------------------------------<br>
' User Script<br>
'--------------------------------------------------------------------------<br>
Public dstim As String<br>
Public hh, gg As Long<br>
Dim cnvs As Canvas<br>
Dim offScreenCnvs As Canvas<br>
Dim intDur As Integer<br><br>
<br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab>' InLine -
StimPrep BEGIN<br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab><br>
dstim = c.GetAttrib ("Pic")<br>
hh = Clock.Read<br>
c.SetAttrib "t1", hh <br><br>
'Define the display canvas for later <br>
Set cnvs = Display.Canvas<br><br>
cnvs.BackStyle = "transparent"<br><br>
cnvs.FillColor = CColor("Gray")<br><br>
'use the CreateCanvas to create an off-screen canvas<br>
Set offScreenCnvs =
Display.CreateCanvas<x-tab>
</x-tab><x-tab>
</x-tab><br>
offScreenCnvs.Clear<br><br>
offScreencnvs.BackStyle = "transparent" <br><br>
offScreenCnvs.FillColor = CColor("Gray")<br><br>
offscreenCnvs.LoadImage dstim<br><br>
hh = Clock.Read<br>
c.SetAttrib "t2", hh <br><br>
' Image loads in top left corner - all images 512*384<br>
' ..so define region - rectangle - of offScreenCnvs to copy<br>
Dim srcRect As Rect<br>
srcRect.Left = 0<br>
srcRect.Right = 512<br>
srcRect.Top = 0<br>
srcRect.Bottom = 384<br><br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab>' InLine -
StimPrep END<br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab><br>
<x-tab> </x-tab>' Fxation
set to terminate synched with vertical retrace<br><br>
<x-tab> </x-tab>
Fixation.Run<br>
<x-tab> </x-tab>
c.SetAttrib "Fixation.OnsetTime", Fixation.OnsetTime<br>
<x-tab> </x-tab>
c.SetAttrib "Fixation.OffsetTime", Fixation.OffsetTime<br>
<x-tab> </x-tab><br><br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab>' InLine -
DisplayStim BEGIN<br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab><br><br>
' include a delay of 3 vertical retraces...1st is between Fixation Offset
and this one<br>
Display.WaitForVerticalBlank<br><br>
' grab timing info: start 1st of vertical retrace<br>
hh = Clock.Read<br>
c.SetAttrib "t3", hh <br><br>
' 2nd vertical retrace delay is between 1st WaitForVerticalBlank command
and this one<br>
Display.WaitForVerticalBlank<br><br>
' grab timing info: start of 2nd vertical retrace<br>
hh = Clock.Read<br>
c.SetAttrib "t4", hh <br><br>
' 3rd delay between 2nd WaitForVerticalBlank command and this one, <br>
' after which stimuli is drawn to screen<br>
Display.WaitForVerticalBlank<br><br>
' grab timing info: start of 3rd vertical retrace<br>
hh = Clock.Read<br>
c.SetAttrib "t5", hh <br><br>
' Define destination rectangle for centred display<br>
Dim desRect As Rect<br>
desRect.Left = 256<br>
desRect.Right = 768<br>
desRect.Top = 192<br>
desRect.Bottom = 576<br><br>
' Copy source rectangle to destination rectangle<br>
cnvs.Copy offScreenCnvs, srcRect, desRect<br><br>
Dim start As Long<br>
start = Clock.Read<br>
c.SetAttrib "t6", start <br><br>
Dim dHex As Double<br><br>
' parse condition and send appropriate trigger code to NuAmps<br>
If c.GetAttrib ("PicType") = 1 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H1)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 2 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H2)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 3 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H3)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 4 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H4)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 5 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H5)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 6 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H6)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 7 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H7)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 8 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H8)<br><br>
<x-tab> </x-tab>elseif
c.GetAttrib ("PicType") = 9 then<br>
<x-tab> </x-tab><x-tab>
</x-tab>dHex =
Val(&H9)<br><br>
<br>
End If<br><br>
' set time trigger code begins execution<br>
gg = Clock.Read<br>
c.SetAttrib "t7", gg <br><br>
' send pulse for 7ms<x-tab> </x-tab><br>
Do<br>
WritePort &H378, dHex<br>
hh = Clock.Read<br>
Loop While hh - gg < 7<br><br>
'toggle all bits low (turn off TTL pulse)<br>
WritePort &H378, &H0<br><br>
c.SetAttrib "dTrig", dHex<br><br>
gg = Clock.Read<br>
c.SetAttrib "t8", gg <br><br>
' Display the stimuli for appropriate duration (set at start of
experiment)<br>
Do<br>
gg = Clock.Read<br>
Loop While gg - start < intDur<br><br>
hh = Clock.Read<br>
c.SetAttrib "t9", gg <br><br>
<br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab>' InLine -
DisplayStim END<br>
<x-tab> </x-tab>
'''''''''''''''''''''''''''''''''''''''''''''<br>
<x-tab> </x-tab><br><br>
At 12:30 PM 15/04/2009, you wrote:<br><br>
<blockquote type=cite class=cite cite="">get rid of image display object.
use canvas to display image. Use inline to preload image to video memory
at start of each trial. In inline that draws canvas, have ttl pulse code
immediately after write to screen code. Hold high for maybe 7ms, then
pull all pins low. Pulse should occur on screen refresh where image is
drawn.<br><br>
At 12:22 PM 15/04/2009, you wrote:<br>
<blockquote type=cite class=cite cite="">Dear David<br>
I have read Chapter 3 of
Userguide thoroughly, but still feel a little confusion. In each block of
my programme, there was a TextDisplay, a Inline Scripe and a
ImageDisplay(stimulous).To synchronize the signal of NeroScan and the
stimuli of e-Prime, I have inverted a in-line WritePort command before
"ImageDisplay" and set the PreRelease time (100ms) in the
TextDisplay. However, the unwanted delay or unsynchronization still
existed between the e-Prime and EEG recording system result in anormal
delay of N170 component. Thus, I want to ask whether the WritePort
command was sent to the recording system at the beginning of Prelease
time or at the point when stimulous presents on the screen. In other
word, I want to know whether the WritePort command and image were sent at
the same time from E-Prime.<br>
Thank you for your concerning.<br>
<br>
> Date: Wed, 8 Apr 2009 11:26:12 -0400<br>
> To: e-prime@googlegroups.com<br>
> From: mcfarla9@msu.edu<br>
> Subject: Re: Image display delay<br>
> <br>
> <br>
> At 4/5/2009 09:35 PM Sunday, maocong wrote:<br>
> >I am a greenhand in programming on e-prime, and I need some help
on<br>
> >the fellowing issue:<br>
> ><br>
> >I designed an ERP visual stimulous experiment by using the
control of<br>
> >ImageDisplay on e-Prime 2.0v and the EEG recording system is
NeroScan<br>
> >4.3v. And I found a 8~14ms delay on image display(shown by
the<br>
> >programme running result file), and the help file showed this
delay is<br>
> >the difference between orignial onset time and actual display
time.<br>
> >This random image display delay greatly effect the accuracy of
N170<br>
> >latency recorded, which lead to the unreliablity of the
experiment<br>
> >result. Therefore I hope you can give me some advices about how
to<br>
> >eliminate/compensate this display delay or how to uniform this
display<br>
> >delay<br>
> <br>
> Please read thoroughly chapter 3 ("Critical timing...") of
the User's <br>
> Guide that came with E-Prime.<br>
> <br>
> -- David McFarlane, Professional Faultfinder<br>
> <br>
> <br>
> More than mail–Windows Live™ goes way beyond your inbox.ox.
<a href="http://www.microsoft.com/windows/windowslive/">More than
messages</a></blockquote><br>
</blockquote><br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups "E-Prime" group. <br> To post to this group, send email to e-prime@googlegroups.com <br> To unsubscribe from this group, send email to e-prime+unsubscribe@googlegroups.com <br> For more options, visit this group at http://groups.google.com/group/e-prime?hl=en<br>
-~----------~----~----~----~------~----~------~--~---<br>
</body>
</html>
<br>