Mouse click to choose four alternative responses, collecting RT and specific response data

97 views
Skip to first unread message

Shanthi Kumarage

unread,
Jan 14, 2018, 6:58:21 PM1/14/18
to E-Prime
I am trying to code a task where participants choose between 4 images on screen by touching the screen (therefore using mouse click input) in E-prime 2.0.10.356. Since it is a forced choice between the 4 images, I do not want the slide to progress unless a response within one of these four images is received. However, as we are collecting RT data, I cannot use a simple goto function to repeat the slide. My current thoughts are that there should be a way to edit the termination response of the input mask but I don't know how to implement this or if that's correct.

Further, whilst one of the alternatives is correct, we are interested in the type of error made so need to collect data on which of the four images is chosen. I have been able to use the HitTest function to get simple ACC output (one image correct, others incorrect) but is there a way to get output that indicates which of the four images was chosen (e.g. 1, 2, 3, 4)?

I found a similar topic on this forum, however the links included in it no longer work and I'm not sure if the solutions proposed will work in this situation as we need accurate RT data: https://groups.google.com/forum/#!topic/e-prime/pVqNqngeB4o

I have searched this forum and checked the E-prime 2.0 samples online to no avail so any help would be much appreciated!

PHILLIP M Mahoney

unread,
Jan 14, 2018, 9:57:24 PM1/14/18
to e-p...@googlegroups.com
Hi Shanthi,

This is certainly doable with a little bit of code.

I am assuming you are using the HitTest code that has been circulating around these parts for years.

In the example below, you will notice a "Do...Loop Until" statement. The purpose of that statement is to disregard a click in any area that does not begin with the string "Text".  So, if your four image boxes are labeled "Text1", "Text2", "Text3", etc., you can accept a mouse click in any of the text boxes, but reject any mouse clicks outside of a text box.

For the next part (logging incorrect responses), you will use some form of strHit [i.e. Left(strHit, 5)] to log the salient integer (1,2,3, etc.). In the example "Left(strHit, 5)", a five character string (i.e. "Text2") is returned. ["Left" means starting from the left and "5" means including 5 characters.] Obviously, the correct answer column in your List will have to use the same format ("Text1", etc.).

Where you decide to put this little bit of code in the HitText example below and how you deal with it in the logical hierarchy, I will--for the time being--leave to you, but don't hesitate to respond with questions after some mindful tinkering.

As David always advises, create a mini-experiment, in which you just test the HitTest function on two images, so that you can use good old trial-and-error problem-solving.

Best of luck,

Phil  

Dim theSlideText As SlideText
Dim currentState As SlideState
Dim cnvs As Canvas
Dim strHit As String
Dim posMouse As Point

Set cnvs = Display.Canvas   
Set  currentState = Response.States("Default")

Do
    Do Until Mouse.Buttons  ' Wait for any mouse click
    Loop
    Mouse.GetCursorPos posMouse
    strHit = currentState.HitTest(posMouse.x, posMouse.y)
Loop Until Left(strHit, 4) = "Text"
Set theMouseResponseData = CMouseResponseData(Response.InputMasks.Responses (1))
Set theSlideText = CSlideText(Response.States.Item("Default").Objects(strHit))
Sleep 200
 
If strHit = c.GetAttrib ("Correct") Then
    Response.ACC = 1
Else
    Response.ACC = 0
End If

Set theMouseResponseData = Nothing

Mouse.ShowCursor False

--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/329ba3c1-2018-48c6-b2c5-b2088b646293%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Phillip Mahoney, Ph.D.
Adjunct Instructor
Department of English
826 Anderson Hall, Temple University
Philadelphia, PA 19122

Shanthi Kumarage

unread,
Jan 15, 2018, 9:53:37 PM1/15/18
to E-Prime
Hi Phil,

Thanks very much for your help! As advised I have tried this in a mini-experiment. I've managed to get the slide to only progress when one of the images is clicked and used the strHit function to log which image this was (after searching your code to work out what each part meant I also found a thread on this google group that I had not uncovered earlier: https://groups.google.com/forum/#!topic/e-prime/q1cuyCCz9KQ). The problem I have now is that I can only get reaction time data for the first click on the slide, not the first click within one of the images. Also, I think I read somewhere that the Sleep 200 is to give the program time to catch up but I'm not sure of the exact purpose and whether I've put it in the right spot. I've included the code in my inline below:

Dim theState As SlideState
Set theState = Slide1.States("Default")
Dim strHit As String
Dim theMouseResponseData As MouseResponseData
Dim posMouse As Point

'Loop until mouseclick in a response area occurs
Do
Do Until Mouse.Buttons
Loop
Mouse.GetCursorPos posMouse
strHit = theState.HitTest(posMouse.x, posMouse.y)
Loop Until Left(strHit, 5) = "Image"

'Handle only this click?
If Left(strHit, 5) = "Image" Then
Set theMouseResponseData = CMouseResponseData(Slide1.InputMasks.Responses(1))
End If
Sleep 200

This is the part I am not sure about. I thought that this would tell E-prime to only analyse a response within an image but E-prime returns RT and RTTime data for the first click not the one specified here.
Also unsure if Sleep 200 is too much/enough or in the right spot.

'Define accuracy
If strHit = c.GetAttrib("CorrectAnswer") Then
Slide1.ACC = 1
Else
Slide1.ACC = 0
End If

'Get Image number
If Left(strHit, 5) = "Image" Then
Dim strImgNr As String
strImgNr = Mid$(strHit,6,7)
c.SetAttrib "AnswerSelected", strImgNr
End If

'Define reaction time
Dim Reaction As Long
Reaction = Slide1.RTTime - Slide1.OnsetTime
c.SetAttrib "Reaction", Reaction
This didn't work to get me the correct RT as hoped.

Thanks again for your help! Do let me know if you know what's going wrong here.

- Shanthi
Reply all
Reply to author
Forward
0 new messages