Random error using load image, canvas copy

181 views
Skip to first unread message

Camila Gomes Victorino

unread,
Feb 9, 2016, 6:32:59 AM2/9/16
to E-Prime
Hi,
I am trying to do an EEG decision making experiment with two options. When the participant press left, one picture is loaded showing one green arrow on the left and a red arrow on the right and if the participant press right, it is the opposite, so I ask E-prime to load other picture, where the right arrow is green and the left arrow is red.
As the picture depends on the participant response, I am not using lists or c.getattrib so I tried to use a conditional load image. (if left, load and copy left stim, if right, load and copy right stim).
I am able to compile the experiment and also run it but after some successful trials (sometimes 40 trials, sometimes, 60, sometimes, 20) it crashes and error 91 appears.

It says: value of the object variable has not been set or is invalid.

I don't know what to do as I set the values and I guess the object is valid (specially because I declared it before and it is compiling and running, at least for a while).

This is the code:
'Declare variables

Dim Playcard As SlideState
Dim cnvs As Canvas
Dim lngth As Integer
Dim x, y, i As Integer
Dim source As Rect
Dim Destine As rect
Dim ArrowLeft As Canvas
Dim ArrowRight As Canvas

'Create variables
Set cnvs = Display.Canvas
Set ArrowLeft = Display.CreateCanvas
Set ArrowRight = Display.CreateCanvas

cnvs.FillColor = CColor("silver")
cnvs.clear


x=905'469 increase x value=more right
y=485'336 'increase the y value=nearer to the bottom

'Define the source rectangle

source.Left = 0
source.Right = 57 'decrease value=decrease offscreen
source.Top = 0
source.Bottom = 180 ' 155 increased values mean decrease picture in y

'Define the destine rectangle

destine.Left = x
destine.Right = 903+56
destine.Top = y
destine.Bottom = 485+162 'decreased values means decreased pictures in y
cnvs.FillColor = CColor("silver")

'Load the image to offscreen canvas

If RESPONSE.RESP = "a" Then
'Triggers (response choice left = trigger 1)
Writeport &HD050, 1

ArrowLeft.LoadImage "leftsmaller.gif"
cnvs.Copy ArrowLeft, source, destine
Set Playcard = RESPONSE.States (RESPONSE.ActiveState)

Sleep (962)

ElseIf RESPONSE.RESP = "l" Then

'Triggers (response choice right = trigger 2)
Writeport &HD050, 2

ArrowRight.LoadImage "rightsmaller.gif"
cnvs.Copy ArrowRight, source, destine
Set Playcard = RESPONSE.States (RESPONSE.ActiveState)

Sleep (962)

End If

sleep 5
writeport &HD050, 0
sleep 5

I've already tried to change the picture to bmp, tried to put load image before if/else, tried to redo the experiment in a different folder, tried to use others pictures but I still don't figure it out why it is crashing.

Also, I tried to give up the canvas copy and draw the two arrows (green for left and red for right or the opposite) and the experiment stopped crashing. However, one of the arrows is being drawn before the other (some ms before) and as I need it synchronized for the EEG, I gave up this solution too. 

Any ideas about what is happening?
Thank you.
Best regards, 

pten...@gmail.com

unread,
Feb 9, 2016, 11:18:13 AM2/9/16
to E-Prime
Could it be that LoadImage is not sufficient, you must also Draw before copying? The E Basic Help documentation on Canvas.Copy has an example that may be of help

Alison H

unread,
Feb 15, 2016, 5:25:06 PM2/15/16
to E-Prime
I am not familiar with Canvas or how this potential solution would work with the feedback slide/EEG, but I have a similar set up using E-Prime Extensions for Tobii (EET) in that the location of the images changes based on the response during the previous trial. I ended up cloning slide states for both my test trials and reinforcer trials because I needed it to work with the eye-tracking contingency command, but hopefully you could easily do something similar using key presses if you haven't found a different solution yet! 

I have a slide called "Fixation," which has 2 active state options. I renamed the default slide state "Fixation" in the slide properties. The "Fixation" slide state has two subobjects which are image files (the images of Shapes A and B), with Shape A on the left and Shape B on the right. I cloned that slide state and named it Fixation2. It's identical to the Fixation slide state except the position of the shapes has flipped. I created an attribute in my trial list called "PositionAOI" with two levels (Fixation and Fixation2). I did the exact same thing with my "feedback" slide (note: I did not use the "feedback" object in E-Prime-just a regular "slide" object), which had a reinforcer video and a placeholder "blank" video in the same locations as the objects from my fixation slide, with the slide states called ReinforcerLeft and ReinforcerRight, respectively, and the attribute called "PositionReinforcer."

You can specify in the properties tab of your red/green arrow slide that you want the ActiveState to be selected from an attribute from your list (e.g., "PositionAOI"), which corresponds to the slide states in your list (e.g., Fixation and Fixation2). You would just need to change the setting from "Default" to [PositionAOI] in your properties. 

I was able to run this with only two levels in my trial list and no in-line scripts, so it is very efficient! I really didn't even need attributes in my list for the objects or reinforcer videos to run it, but I needed it for data analyses later. If you need clarification on anything, please let me know! 

Good luck!



On Tuesday, February 9, 2016 at 6:32:59 AM UTC-5, Camila Gomes Victorino wrote:
Reply all
Reply to author
Forward
0 new messages