multiple mouse click recording on a single picture (not slide)

Paul Groot pfc.groot at gmail.com
Fri Nov 16 00:43:06 UTC 2012


Hi again Eszter,

There are several way's to do this, but assuming your bitmap pictures are
drawn unstretched in the middle of the screen (and have fixed dimensions),
then you could try something like this (be warned, this will be uggly):

        Const N_x As Integer = 4 ' number of images hor.
        Const N_y As Integer = 4 ' number of images vert.
        Const size_x As Long = 1000 ' width of bitmap in pixels
        Const size_y As Long = 776  ' height of bitmap in pixels
        Dim offset_x As Long
        Dim offset_y As Long
        Dim index_x As Integer
        Dim index_y As Integer
        Dim delta_x As Long
        Dim delta_y As Long
        offset_x = (size_x - Display.XRes)/2
        delta_x = size_x / N_x
        index_x = (theMouseResponseData.CursorX-offset_x)/delta_x
        offset_y = (size_y - Display.YRes) / 2
        delta_y = size_y / N_y
        index_y = (theMouseResponseData.CursorY-offset_y)/delta_y

        Dim index As Integer
        index = (index_y-1)*N_x+index_x
        debug.print "I=" & index & "  (" & index_x & "," & index_y & ")"

You could put this inside the if-then-endif part to get the subimage
indices of the selected images (ranging from 1 to 16; counting row-by-row)
The next thing to do would be a simple test if the indices match the
correct answer. Normally you would but the correct answer as attributes in
the trial list. However, because all 8 clicks are handled within a single
trial, you would have to specify the correct indices for all 8 clicks as 8
separate attributes (i.e. 'CorrectCLick.1', 'CorrectCLick.2' etc.).

        Dim correct_index As Integer
        correct_index = CInt(c.GetAttrib("CorrectClick." & CStr(iResponse)))
        c.SetAttrib "ClickACC." & CStr(iResponse), IIf(index =
correct_index, 1, 0)

I'm sure there are dozens of bugs in this code, but this is the general
idea if your stimulus is a single bitmap image. As said before, this is not
a very elegant piece of work. And there still things going wrong here (for
example: the black borders are also treated as valid subimage area). A more
elegant way would be to use a hidden bitmap that has a color map that
mappes the valid subimage areas to a subimage number. Then a simple
getpixel-call would return the selected image. (Also works for
non-rectangular areas.) Another option would be to use a slide with 4x4
separate slide images. This would also simplify the script because EStudio
has a special HitTest function that can be used to test which object was
selected.


Cheers
Paul


2012/11/15 Eszter Kormann <ringril at gmail.com>

> Dear Paul,
>
> thank you for your quick and amazing answer, everything works :)
> However, we faced the problem of marking good and bad answers in this
> case, because we only get the x and y coordinates for the clicks whereas we
> need to compare this with the small pictures coordinates on the screen.
> I don't know if I made it clear or not, but we would like to 1) pinpoint
> the frames for the small pictures 2) define which (small) picture within
> the grid is meant to be a good answer in the trial and 3) then we want the
> program to decide whether the click of the responder was correct or not.
> We thought that we might use something like an *if "mouse coordinate is
> XY" < x1  > x2 then "YES", otherwise NO. * Sorry for the form, but
> unfortunately I still don’t know this language.
>
> I know it sounds awfully complicated, but I really need your help.
>
> Thanks a lot in advance!!!
> All the best,
> Eszter
>
>
> 2012/11/13 Paul Groot <pfc.groot at gmail.com>
>
>> Hi Eszter,
>>
>> You could change the inline script a bit, but you would first have to set
>> the number of allowed responses of the inputmask to 8 (click the advanced
>> button and edit max count). Then use the following script after the
>> stimulus object:
>>
>> Dim iResponse As Integer
>> For iResponse = 1 To Stimulus.InputMasks.Responses.Count
>>     Dim theMouseResponseData As MouseResponseData
>>     Set theMouseResponseData =
>> CMouseResponseData(Stimulus.InputMasks.Responses(iResponse))
>>     If Not theMouseResponseData Is Nothing Then
>>         c.SetAttrib "Stimulus." & CStr(iResponse) & ".RespCursorX",
>> theMouseResponseData.CursorX
>>         c.SetAttrib "Stimulus." & CStr(iResponse) & ".RespCursorY",
>> theMouseResponseData.CursorY
>>         c.SetAttrib "Stimulus." & CStr(iResponse) & ".RT",
>> theMouseResponseData.RT
>>     End If
>> Next
>>
>> I also added the response time to the output because you might need that
>> too. (Or just delete that line if you don't) The attached script contains a
>> working example.
>>
>> Normally I would prefer a separate list object with 8 'subtrials' to
>> handle the individual mouse clicks. The advantage would be a more  more
>> compact edat-output file(because you don't have to generate separate
>> attribute names for sequential responses). Another advantage is that you
>> could implement more sophisticated constructions, like highlighting the
>> selected objects as soon as they are selected or terminating after a
>> specific object was selected. However, the disadvantage is that it is
>> slightly more complex if response time recording should be accurate.
>>
>> Hope this helps.
>>
>> Cheers,
>> Paul
>>
>>
>> 2012/11/13 Eszter Kormann <ringril at gmail.com>
>>
>>>  Hello,
>>>
>>> So, once again :)
>>> I have a very simple problem in connection with collecting multiple
>>> mouse response coordinates. We use a single picture which consists of
>>> several pictures in a 4X4 grid (I've attached a sample). People are asked
>>> to click on those pictures within the grid which we had already shown to
>>> them (8 clicks out of 16). How can I register all of the 8 clicks's
>>> coordinates  with the modification of the script linked below, which in
>>> fact works perfectly well for our experiment.
>>>
>>>
>>>
>>>
>>> If Stimulus.InputMasks.Responses.Count > 0 Then
>>>
>>> Dim theMouseResponseData As MouseResponseData
>>> Set theMouseResponseData =
>>> CMouseResponseData(Stimulus.InputMasks.Responses(1))
>>> If theMouseResponseData Is Nothing Then
>>> c.SetAttrib "Stimulus.RespCursorX", theMouseResponseData.CursorX
>>> c.SetAttrib "Stimulus.RespCursorY", theMouseResponseData.CursorY
>>> End If
>>>
>>> End If
>>>
>>>
>>> Thanks a lot,
>>> Eszter
>>>
>>> * *
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "E-Prime" group.
>>> To post to this group, send email to e-prime at googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> e-prime+unsubscribe at googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "E-Prime" group.
>> To post to this group, send email to e-prime at googlegroups.com.
>> To unsubscribe from this group, send email to
>> e-prime+unsubscribe at googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "E-Prime" group.
> To post to this group, send email to e-prime at googlegroups.com.
> To unsubscribe from this group, send email to
> e-prime+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20121116/d06dde4f/attachment.htm>


More information about the Eprime mailing list