Looming pictures

290 views
Skip to first unread message

Craig

unread,
Jun 15, 2010, 1:05:24 PM6/15/10
to E-Prime
Hello,
I am trying to program a task in which there are looming pictures
that change depending on the person's response with the joystick. I
am currently trying to program an experiment in which pictures are
presented on the screen, and participants are required to push or pull
a joystick and squeeze the trigger based on the color of the
background (e.g., a blue background means push the joystick away).
When the joystick is pushed, the image size needs to gradually
decrease (to strengthen the feeling that the picture is pushed
away). When the joystick is pulled, the image size should increase.

I am using E-prime version 2.0. Professional. I found a similar
question on the list, but I didn't see an answer.

I was wondering whether:
1) anyone has programmed a looming task where pictures get bigger or
smaller (I think I need to use the Object Slide, but I am not so sure
how to do it)
and
2) whether anyone has programmed a task where pressing a joystick in a
particular direction and squeezing the trigger causes a picture to
change (i.e., how can I collect joystick-movement-data and how I can
subsequently use this information to present the next picture.).
Thanks so much in advance.
Craig

gilis

unread,
Jun 17, 2010, 6:55:25 AM6/17/10
to E-Prime
Never tried to do something like this, but it seems that if the
picture size is increasing or decreasing in constant rate for each
pull, then you have to build set of stimuli with the different
possible sizes (a lot of work, there is possibly much easier way if
you have the time and knowledge to program it all into inline that
change the size of given pictures in accordance with its present size
and the direction in which the joystick was pulled) for each picture.

Then, you name each stimulus x as x&"y", with y representing number in
a given direction. Say that if subject pull the joystick six times in
one direction then y=6 and the size of the stimulus is corresponding
to that. Y=0 stand for the stimuli initial size and numbers preceded
by "-", for instance, represent the number of pullings in the opposite
dierction.Then, if the subject pulled the joystick in the positive
numbers direction three times (y=3) and then in the following trial
pulled it in the negative numbers direction you set the Y attrbiute to
Y-1, or to Y+1 in the opposite case. You always have to update your
programe after each trial what is the value of Y.

You do that by setting an attribute called y (c.setattrib "Y", 0+z),
with z dimmed as integer. You have to tell your computer that z=1 in
case of pulling in one direction and -1 in the other direction.

It's only on the surface of the things, and it may be that I'm over
simplfying them, but I think this is a start.

Rgds
Gilis

Michiel Spape

unread,
Jun 17, 2010, 1:02:56 PM6/17/10
to e-p...@googlegroups.com

Hiya all,
Not sure whether this has been said already, but one of the questions was regarding polling the direction of joystick presses. I do know someone else asked this question not too long ago, and also went to e-prime support to ask this. The answer, apparently, was this:

-------------
From: e-p...@googlegroups.com [mailto:e-p...@googlegroups.com] On Behalf Of Nick
Sent: 04 February 2010 22:10
To: E-Prime
Subject: Re: Joystick direction as response & RT

Hi All,

Below is the great solution I received from E-Prime support. Does
exactly what I need it to, I hope it helps others as well.

If you do not want subjects to press a button after moving the
joystick to the desired position, you can simply access the cursor
position directly instead of checking for a button press. This means
that you should set the Duration of Stimulus to zero so that the
script can be processed immediately; for an example of this method,
please see SAMPLE:Process Responses Template. By constantly checking
the Y position of the cursor, you can determine whether the subject
has responded. Here is an example of the script to use:

Dim nInitY As Integer
Dim nCurrentY As Integer
Dim nDiff As Integer

nInitY = Joystick.CursorY

Do
nCurrentY = Joystick.CursorY
nDiff = nInitY - nCurrentY

Loop Until Abs(nDiff) > 50

Stimulus.RTTime = Clock.Read
Stimulus.RT = Stimulus.RTTime - Stimulus.OnsetTime

If nDiff > 0 Then
Stimulus.RESP = "Up"
Else
Stimulus.RESP = "Down"
End If
-----------------------

Michiel Spapé
Research Fellow
Perception & Action group
University of Nottingham
School of Psychology

Rgds
Gilis

--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-p...@googlegroups.com.
To unsubscribe from this group, send email to e-prime+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

David McFarlane

unread,
Jun 17, 2010, 3:15:44 PM6/17/10
to e-p...@googlegroups.com
Craig,

When I want to manipulate the size of images
(either an ImageDisplay or a SlideImage on a Slide), I do the following:

- Open the property pages for the image. On the
General tab, set Stretch to Yes. On the Frame
tab, enter attribute references for Width and
Height (e.g., [StimWidth], [StimHeight]).

- On the User tab of the Script window, add a
global variable to hold the latest value of width
& height (see Chapter 4 of the User Guide that
came with E-Prime). E.g. (note that variables
and attributes may use the same name with no
conflict, as long as you can keep track of which is which),

Dim StimHeight as Single, StimWidth as Single

- In inline code before the image object, update
the width & height as needed and use c.SetAttrib
to set the attribute values for use. You may use
units of either % or pixels, as you like. E.g.,

' Magnify geometrically (i.e., constant factor)...
Const ImageFactor as Single = 1.5 ' might instead make this global
StimHeight = StimHeight * ImageFactor
StimWidth = StimWidth * ImageFactor
c.SetAttrib "StimHeight", StimHeight
c.SetAttrib "StimWidth", StimWidth

or

' Increment arithmetically...
Const ImageIncrement as Integer = 50 ' might instead make this global
StimHeight = StimHeight + ImageIncrement
StimWidth = StimWidth + ImageIncrement
c.SetAttrib "StimHeight", StimHeight
c.SetAttrib "StimWidth", StimWidth

You would still have to wrap these in the
appropriate If...Then...Else clauses, etc.


I think this makes the code more manageable,
although there are probably methods with better
performance if you don't mind more code.

-- David McFarlane, Professional Faultfinder

fehe...@newschool.edu

unread,
Feb 15, 2018, 3:42:06 PM2/15/18
to E-Prime
I have been attempting to make this code work for my own Push/Pull task,
but without success. If anyone could take a look at my inline and let me
know where I'm going wrong, it would be much appreciated:

----------------------------

Dim nInitY As Integer
Dim nCurrentY As Integer
Dim nDiff As Integer

nInitY = Mouse.CursorY

Do
    nCurrentY = Mouse.CursorY

    nDiff = nInitY - nCurrentY

Loop Until Abs(nDiff) > 50

If nDiff > 0 Then
     StimHeight = StimHeight*ImageFactor2
StimWidth = StimWidth*ImageFactor2

c.SetAttrib "StimHeight", StimHeight
c.SetAttrib "StimWidth", StimWidth
Else
     StimHeight = StimHeight*ImageFactor1
StimWidth = StimWidth*ImageFactor1

c.SetAttrib "StimHeight", StimHeight
c.SetAttrib "StimWidth", StimWidth
End If
----------------------------

ImageFactor 1 and 2 are global variables in order to multiply the
dimensions of the stimulus slide image (50x50%) by either 1.75 or 0.5 in
order to grow or shrink the images. When I run through however, the
pictures don't move. I suspect that I am not placing the c.SetAttrib
statements properly. I guess I'm wondering where those *should* be, and
also what the corresponding list/attributes would look like. I just want
each picture to start at 50% and go up to 75% or down to 25%. In the
sub-object property for the stimulus, I have the width set to
[StimWidth]:50% and the length to [StimLength]:50%. Does this mean the
attribute list should have the actual dimensions of the image, and this
would be setting them to 50% of that? Because I was under the assumption
that the 50% related to the amount of the background slide the sub-object
takes up.

Cheers,
Nick

David McFarlane

unread,
Feb 15, 2018, 3:59:07 PM2/15/18
to e-p...@googlegroups.com
Nick,

Offhand, your code looks good enough. So then I wonder if you might be
running into the recurring gotcha described at
groups.google.com/d/topic/e-prime/Liej8Ik83sU , so please look there
first. The "Looming pictures" thread here goes back to 2010, possibly
before we had the gotchas introduced with EP2.0.10 and described in the
linked thread, so it's just as well that you brought this up so we could
update the thread.

---------------
David McFarlane
E-Prime® 2.0 training online:
psychology.msu.edu/workshop-and-additional-course/e-prime-introduction-to-programming-computerized-behavioral-tasks
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)

fehe...@newschool.edu

unread,
Feb 15, 2018, 4:53:50 PM2/15/18
to E-Prime
If I'm understanding the "Gotcha" issue correctly, it could presumably be worked around by a) not having a pre-release prior to the Inline object (which I don't) and b) setting the script generation for the stimulus ImageDisplay object to TopOfProcedure (which I just did). Unfortunately, the image still will not expand or shrink according to my mouse movements (practicing w/ a mouse before I switch to joystick). I am able to log the movements as a PUSH or a PULL, but the script I posted above just isn't making the images move at all. 

Otherwise, everything runs fine, aside from the issue of advancing to the next trial that ben outlined in the following thread: https://groups.google.com/forum/#!searchin/e-prime/joystick|sort:date/e-prime/cu8Fm6lbE_I/JcZaf_ORhk8J. His fix did not work for me either (i.e. moving the mouse doesn't seem to register as input, aside from collecting RT and the PUSH/PULL distinction, and so I still need to click the mouse button to advance).

At this point however, I'd settle for just getting the images moving.

David McFarlane

unread,
Feb 15, 2018, 5:12:58 PM2/15/18
to e-p...@googlegroups.com
Nick,,

OK, just wanted to take care of the easy things first because that
gotcha keeps coming up when people use inline code ever since EP2.0.10.
Next, could you please post a sketch of the structure of your
Procedure where you do all this? And to clarify, your .edat2 file
correctly shows the changing values for StimHeight and StimWidth, it's
just that you see no change on the display, right?

-- David McFarlane


On 2018-02-15 4:53 PM, fehe...@newschool.edu wrote:
> If I'm understanding the "Gotcha" issue correctly, it could presumably be
> worked around by a) not having a pre-release prior to the Inline object
> (which I don't) and b) setting the script generation for the stimulus
> ImageDisplay object to TopOfProcedure (which I just did). Unfortunately,
> the image still will not expand or shrink according to my mouse movements
> (practicing w/ a mouse before I switch to joystick). I am able to log the
> movements as a PUSH or a PULL, but the script I posted above just isn't
> making the images move at all.
>
> Otherwise, everything runs fine, aside from the issue of advancing to the
> next trial that ben outlined in the following
> thread: https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_forum_-23-21searchin_e-2Dprime_joystick-257Csort-3Adate_e-2Dprime_cu8Fm6lbE-5FI_JcZaf-5FORhk8J&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=_sJwBQMyWWf0pcG_mDwr6daD_mj-rDW2QJEBoVzAoFc&s=sFB10UOCsqknFAenIRK__-fP6GjLSP-BVMDcXTgdbFg&e=.

David McFarlane

unread,
Feb 16, 2018, 10:35:01 AM2/16/18
to e-p...@googlegroups.com
Nick,

Oh, I just read your earlier post a little more carefully. You said
that you set script generation for the stimulus ImageDisplay object to
TopOfProcedure. That is the opposite of the advice at the thread that I
linked earlier. You need to set Generate PreRun to "BeforeObjectRun",
you may do that either for the specific object or for the Procedure
itself. Again, please look at that thread again and follow the other
links there, you will find this more fully discussed.

-- David McFarlane

fehe...@newschool.edu

unread,
Feb 23, 2018, 3:33:05 PM2/23/18
to E-Prime
David,

So I finally heard back from PST support and they were able to give me some very helpful scripts and examples. The following is what finally worked for making the pictures move consistently with the joystick:

Mouse.ShowCursor False [at the beginning of the experiment]

Joystick.AttachToMouseCursor = True [at the beginning of the procedure]

[after the stimuli:]
Dim y_old As Integer
Dim upper_limit As Integer
Dim midlower_limit As Integer
Dim midupper_limit As Integer
Dim lower_limit As Integer
Dim EndMovementTime As Long
Dim StartMovementTime As Long
Dim MidMovementTime As Long


StartMovementTime = Clock.Read - Stimuli.OnsetTime
 
c.SetAttrib "StartTime", StartMovementTime

upper_limit = 0
lower_limit = 479
midupper_limit = 100
midlower_limit = 250


Do
Dim ptCursor As Point
Mouse.GetCursorPos ptCursor.x, ptCursor.y

If ptCursor.y > y_old - 10 Or ptCursor.y < y_old + 10 Then 
Stimuli.Height = ptCursor.y
Stimuli.Draw
y_old = ptCursor.y

If ptCursor.y = midupper_limit Or ptCursor.y = midlower_limit Then
MidMovementTime = Clock.Read = Stimuli.OnsetTime
c.SetAttrib "MidPointTime", MidMovementTime
End If
End If



Loop Until ptCursor.y = upper_limit Or ptCursor.y = lower_limit

' RT = upper and lower limit
Stimuli.RT = Clock.Read()-Stimuli.OnsetTime

If ptCursor.y = upper_limit Then 
EndMovementTime = Clock.Read - Stimuli.OnsetTime
c.SetAttrib "FinishTime", EndMovementTime
' push (upward movement of cursor)
c.SetAttrib "up_down", 1 
'or?   Stimulus.RESP = "PUSH"
Else
EndMovementTime = Clock.Read - Stimuli.OnsetTime
c.SetAttrib "FinishTime", EndMovementTime
' pull(enlarge, downward movement of cursor)
c.SetAttrib "up_down", 0
'or?   Stimulus.RESP = "PULL"
End If

Then, for the inconsistent joystick movements, the same but with the following added (replacing the first IF/THEN statements):
Dim nAdjusted As Long

If ptCursor.y > y_old - 10 Or ptCursor.y < y_old + 10 Then
 If ptCursor.y >= Display.YRes/2 Then
  y_old = ptCursor.y
  nAdjusted = Display.YRes/2 - (ptCursor.y - Display.YRes/2)
  Image.Height = nAdjusted
  Image.Draw
 Else
  y_old = ptCursor.y
  nAdjusted = Display.YRes/2 + (Display.YRes/2 - ptCursor.y)
  Image.Height = nAdjusted
  Image.Draw   
 End If
End If
So the movement works, despite some choppiness of the pictures as they're moving away (shrinking) into the distance. If anyone has suggestions about a smoother shrink, that would be helpful.

However, my next big challenge is including variable delays (100ms, 400ms, or 700ms) that occur when the joystick is moved but PRIOR to the images themselves moving. The person I'm in contact with at PST had the following to say:

"For the Delay that you want, you could put a Sleep statement with a c.GetAttrib call to the Delay Attribute and place it just before the draw. However, this is likely to affect the appearance of the image changing (not so smooth). Then we would be getting into the problem of the cursor changing during the delay as participants are likely to keep pushing or pulling to illicit a visual change. The most obvious solution to this problem, if the paradigm allows, is let the participants know and expect a deliberate delay. One alternative that you may want to look into is slowing down the cursor speed to achieve the delay. Please see speed.es2 attached to this response for how to go about this."

Any suggestions re: the delay that might be smoother than what was suggested here? I have not yet had a chance to try the sleep option, but I kind of need something more fluid/seamless as participants need to be able to a) determine if there was a delay and how long was it?, and b) they need to make a judgment about whether or not they feel they made the pictures move. The stop/start nature implied by the possible solution would likely disrupt the task.
Reply all
Reply to author
Forward
0 new messages