Is it possible to continuously record the status of the mouse buttons during a video?


Is it possible to continuously record the status of the mouse buttons...
Author
Message
ambercat11
ambercat11
Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)Associate Member (180 reputation)
Group: Forum Members
Posts: 1, Visits: 2
Hi there,

I'm new to Inquisit and I am wondering whether my experiment is possible to code in this program. 
The experiment should
1. Play a video clip
2. Record whether or not the right and/or left button is being pressed on the mouse every 100 milliseconds (or at least every second) during the clip. 
 - to clarify, I do not want to measure whether or not the button has been clicked within every 100 milliseconds, but rather whether it is being held down. Participants will be using the mouse buttons to report their emotions, which may continue across 100 millisecond frames.
3. Output time stamped data for the left button and right button throughout the clip. Basically, I want to know every 100 milliseconds or so whether or not the right button is being held down, the left button is being held down, or both, or neither are being held down. 

Can anyone tell me whether this is even possible in Inquisit? I would also be willing to use two keys on the keyboard instead of the mouse if it isn't possible with the mouse. 

So far all I have been able to do is get the video to play and record one mouse click, which is not even close to what I am trying to do, but here is my code anyway:

<values>
/ rightbuttondown= ""
/ leftbuttondown=""
</values>

<data>
/ columns = [date time subject blocknum blockcode trialnum trialcode stimulusitem
values.rightbuttondown values.leftbuttondown]
/ separatefiles = true
</data>

<video BondVid>
/ items = ("BondVid.mpg")
/ position = (50, 50)
</video>

<trial trial1>
/ inputdevice = mousekey
/ ontrialbegin = [values.rightbuttondown= ""; values.leftbuttondown ="" ]
/responsetime = 0
/ validresponse = (lbuttondown, rbuttondown, lbuttonup, rbuttonup)
/ isvalidresponse = [if(trial.trial1.response == "lbuttondown") then
{values.leftbuttondown = TRUE} else
{values.leftbuttondown = FALSE}
/isvalidresponse = [if(trial.trial1.response == "rbuttondown") then
{values.rightbuttondown = TRUE} else
{values.rightbuttondown = FALSE}
/ responseinterrupt = trial
/ timeout = 8000
/ stimulusframes = [1=BondVid]
</trial>

<block Block1>
/ trials = [1=Trial1]
</block>

<expt Expt1>
/ blocks = [1=Block1]
</expt>




Dave
Dave
Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)
Group: Administrators
Posts: 10K, Visits: 59K
You have several options. The simpler one: Display your video via the <block> /bgstim and start a new trial whenever one of the 4 mouse events occurs.

<data>
/ columns = [date time subject blocknum blockcode trialnum trialcode stimulusitem response]
/ separatefiles = true
</data>

<video BondVid>
/ items = ("BondVid.mpg")
/ position = (50, 50)
</video>

<trial mousevent>
/ inputdevice = mousekey
/ validresponse = (lbuttondown, rbuttondown, lbuttonup, rbuttonup)
/ branch = [trial.mousevent]
</trial>

<block Block1>
/ bgstim = (BonVid)
/ trials = [1=mousevent]
/ timeout = 8000
</block>

The other option is to employ /isvalidresponse trickery, i.e., treat each of the 4 responses as invalid ("false") so that the trial keeps accepting responses, but store the response and associated time in a <value> nonetheless. You can find an example here:
<data>
/ columns = [date time subject blocknum blockcode trialnum trialcode stimulusitem response values.event values.eventtime]
/ separatefiles = true
</data>

<values>
/ event = ""
/ eventtime = ""
</values>


<text BonVid>
/ items = ("Imagine video here...")
</text>

<trial mouseevent>
/ stimulusframes = [1=Bonvid]
/ responsetime = 0
/ inputdevice = mousekey
/ validresponse = (lbuttondown, rbuttondown, lbuttonup, rbuttonup)
/ isvalidresponse = [if (trial.mouseevent.response=="lbuttondown" || trial.mouseevent.response=="rbuttondown" || trial.mouseevent.response=="lbuttonup" || trial.mouseevent.response=="rbuttonup") {
    values.event=concat(concat(values.event,","), trial.mouseevent.response);
    values.eventtime=concat(concat(values.eventtime,","), trial.mouseevent.latency);
    false; }]
/ timeout = 8000
</trial>

<block Block1>
/ trials = [1=mouseevent]
</block>


leluxe
leluxe
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 18, Visits: 85
I would like to be able to change the size of a stimulus (e.g. a line like in the script below) not only by clicking on certain text stimuli ("smaller", "larger"). It would also be great if the participant could click on one of the text stimuli and keep the mouse button pressed, effecting e.g. an enlargement of the line every let's say 200ms. Is there any way to adapt your idea above to reach this point?
Here's the script. At this point of course it doesn't work out at all. I fuddled around with the two solutions you indicated here at first, without any success. To be honest I failed to understand the role of the /isvalidresponse argument, especially in this case, though. Then I tried some workarounds by creating a value that is supposed to change when lbuttondown was pressed together with the "smaller" stimulus and then effect a diminishment every second. Well... as you can guess, with no success. I'd really appreciate if you could help me out here.

Greets,
Pablo

<text smaller>
/ items = ("-")
/ position = (15,55)
/ erase = false
/ fontstyle = ("Arial", 35pt, true)
</text>

<text larger>
/ items = ("+")
/ position = (35,55)
/ erase = false
/ fontstyle = ("Arial", 35pt, true)
</text>

<text confirm>
/ items = ("Confirm: <%values.linelength_px%>px")
/ position = (25,55)
/ erase = false
</text>

<values>
/ sbuttonpressed = 0
</values>

<trial changelinelength>
/ stimulusframes = [1 = eraser, instructions, line, arrow, smaller, larger, confirm]
/ validresponse = (smaller, larger, confirm, lbuttondown, lbuttonup)
/ inputdevice = mouse
/ ontrialend = [if (trial.changelinelength.response == "smaller") values.linelength_px -= 4]
/ ontrialend = [if(trial.changelinelength.response == "smaller") values.sbuttonpressed += 1]
/ ontrialend = [if(trial.changelinelength.response == "larger" || trial.changelinelength.response == "confirm") values.sbuttonpressed = 0]
/ ontrialend = [if (values.sbuttonpressed == 1 &&
                trial.changelinelength.response != "lbuttonup" && {block.lineblock.elapsedtime == 1000 || block.lineblock.elapsedtime == 2000 || block.lineblock.elapsedtime == 3000 || block.lineblock.elapsedtime == 4000})
                values.linelength_px -= 4]
/ ontrialend = [if (trial.changelinelength.response == "larger") values.linelength_px += 4]
/ ontrialend = [expressions.displaysize = expressions.displaysizebyline]
/ branch = [trial.changelinelength]
/ branch = [if (values.linelength_px<400 || values.linelength_px>500) trial.doesntwork]
</trial>          

<block lineblock>
/ trials = [1-100=changelinelength]
/ timeout = 10000
/ ontrialend = [if({block.lineblock.currenttrialnumber == 2 || block.lineblock.currenttrialnumber == 4 || block.lineblock.currenttrialnumber == 6
                && trial.changelinelength.response == "smaller"})values.sbuttonpressed -= 1]
</block>

<values>
/ linelength_px = 400
</values>

<item instructions>
/ 1 = "Take a credit card or another card with the same measures (Cash Card, ID, etc...)
and hold its long side against the line on the screen.
Click the buttons to change its size. When the line has the same size as the side of your credit card, click 'Confirm' and proceed
with the experiment."
</item>

<text instructions>
/ items = instructions
/ position = (50%, 75%)
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txcolor = (0, 0, 0)
/ erase = false
</text>

<shape line>
/ shape = rectangle
/ color = (black)
/ erase = false
/ size = (1px*values.linelength_px,10px)
/ position = (10%, 50%)
/ halign = left
/ erase = false
</shape>

<shape eraser>
/ shape = rectangle
/ color = white
/ position = (50%, 50%)
/ size = (100%, 100%)
/ erase = false
</shape>

<text arrow>
/ items = ("↓ Align corner here")
/ position = (9.9%, 48%)
/ halign = left
/ valign = bottom
/ erase = false
/ fontstyle = ("Arial", 1.5%, false, false, false, false, 5, 1)
/ txcolor = (0, 0, 0)
</text>


Dave
Dave
Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)
Group: Administrators
Posts: 10K, Visits: 59K
You do:

<text smaller>
/ items = ("-")
/ position = (15,55)
/ erase = false
/ fontstyle = ("Arial", 35pt, true)
</text>

<text larger>
/ items = ("+")
/ position = (35,55)
/ erase = false
/ fontstyle = ("Arial", 35pt, true)
</text>

<text confirm>
/ items = ("Confirm: <%values.linelength_px%>px")
/ position = (25,55)
/ erase = false
</text>

<trial changelinelength>
/ stimulusframes = [1 = eraser, instructions, line, arrow, smaller, larger, confirm]
/ validresponse = (smaller, larger, confirm)
/ inputdevice = mouse
/ ontrialend = [if (trial.changelinelength.response == "smaller") values.linelength_px -= 4]
/ ontrialend = [if (trial.changelinelength.response == "larger") values.linelength_px += 4]
/ branch = [if (trial.changelinelength.response=="smaller") trial.smaller]
/ branch = [if (trial.changelinelength.response=="larger") trial.larger]
</trial>         

<trial larger>
/ ontrialbegin = [values.linelength_px += 4]
/ trialduration = 200
/ stimulusframes = [1 = eraser, instructions, line, arrow, smaller, larger, confirm]
/ validresponse = (0, lbuttonup)
/ inputdevice = mouse
/ branch = [if (trial.larger.response!="lbuttonup") trial.larger else trial.changelinelength]
/ recorddata = false
</trial>

<trial smaller>
/ ontrialbegin = [values.linelength_px -= 4]
/ trialduration = 200
/ stimulusframes = [1 = eraser, instructions, line, arrow, smaller, larger, confirm]
/ validresponse = (0, lbuttonup)
/ inputdevice = mouse
/ branch = [if (trial.smaller.response!="lbuttonup") trial.smaller else trial.changelinelength]
/ recorddata = false
</trial>


<block lineblock>
/ trials = [1=changelinelength]
</block>

<values>
/ linelength_px = 400
</values>

<item instructions>
/ 1 = "Take a credit card or another card with the same measures (Cash Card, ID, etc...)
and hold its long side against the line on the screen.
Click the buttons to change its size. When the line has the same size as the side of your credit card, click 'Confirm' and proceed
with the experiment."
</item>

<text instructions>
/ items = instructions
/ position = (50%, 75%)
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txcolor = (0, 0, 0)
/ erase = false
</text>

<shape line>
/ shape = rectangle
/ color = (black)
/ erase = false
/ size = (1px*values.linelength_px,10px)
/ position = (10%, 50%)
/ halign = left
/ erase = false
</shape>

<shape eraser>
/ shape = rectangle
/ color = white
/ position = (50%, 50%)
/ size = (100%, 100%)
/ erase = false
</shape>

<text arrow>
/ items = ("↓ Align corner here")
/ position = (9.9%, 48%)
/ halign = left
/ valign = bottom
/ erase = false
/ fontstyle = ("Arial", 1.5%, false, false, false, false, 5, 1)
/ txcolor = (0, 0, 0)
</text>


leluxe
leluxe
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 18, Visits: 85
Thanks Dave, that's very helpful, as always. Still I am not able to adjust this for a series of Ebbinghaus-Tasks I conducted. I have this feeling that it has to do something with a predefined succession of trials but can't figure out what it is exactly. The participants are supposed to adjust the shape on the right side to the size of the one on the left. I implemented "samller" and "larger" trials the same way you did with the line adjustment. But in this case as soon as I click on either button, the program directly skips to the next trial. I thought this might be the case because I originally conducted a block with
/trials = [1=ebbinghausinstruct;2-9=noreplace(all 8 versions of the ebbinghaus task)]
which I thought could cause the problem of not letting the smaller and larger trials start because of the predefined succession in the block element (you once helped me out with a problem like this). But then I defined every Ebbinghaus version as a standalone block, only indicating the first trial (e.g. floweradjustbig) so that the conditional branching could work but I still have the same problem that it skips to the next version after the first click.

What am I doing wrong?

I attached the script and the pictures needed in a zip file. The lower part of the script is irrelevant for this problem, still I always have to include it because the picture presentation depends on it.

Best regards,
Pablo

Attachments
Ebbinghaus Task.zip (188 views, 290.00 KB)
Dave
Dave
Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)Supreme Being (855K reputation)
Group: Administrators
Posts: 10K, Visits: 59K
<trial floweradjustbig>
/ stimulusframes = [1=flowerbigarrow, flowersmall, floweradjustb, flowercompareb, smallere, largere, confirme]
/ inputdevice = mouse
/ validresponse = (smallere, largere, confirme)
/ ontrialend = [if (values.flowersizeb_px >= 100) values.flowersizeb_px = 100]
/ ontrialend = [if (values.flowersizeb_px <= 40) values.flowersizeb_px = 40]
/ ontrialend = [if (trial.floweradjustbig.response == "smallere") values.flowersizeb_px -= 1]
/ ontrialend = [if (trial.floweradjustbig.response == "largere") values.flowersizeb_px += 1]
/ branch = [if (trial.changelinelength.response=="smallere") trial.smallerfb]
/ branch = [if (trial.changelinelength.response=="largere") trial.largerfb]
</trial>

I'm pretty sure you want to /branch based on the response to trial.floweradjustbig here, not trial.changelinelength. The analogous applies to all your other <trial> elements.

leluxe
leluxe
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 18, Visits: 85
Oh, of course. I spent hours looking at this script and managed to not see that I simply forgot to alter this part of the element, I'm sorry for posting this. Guess I didn't see the wood for all the trees. Still many thanks though for pointing it out to me :-) Now it works perfectly, of course. Why wouldn't it...

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search