Inconsistent functioning of "Break if" / "run if" [response]
I'm using OS 3.3.11 on a Mac (OS X 10.15.6) - but am also testing this on Dell (Windows 10). I've tried this with Legacy and Expyriment backends (my only options as my videos in media_player_mpy only work here).
I'm running a task with interleaving blocks with young children as participants. I need to be able to pause a block if the child looks away, and also to skip to the next block if the baseline has been presented for long enough.
To pause a block I followed instructions from here: https://forum.cogsci.nl/discussion/1048/solved-i-would-like-a-pause-button. It works! However, it seem glitchy/inconsistent for me. Sometimes I press the 'p' key to indicate run the pause sequence, and it works, sometimes there's no response (the block just continues as normal). Sometimes I'll press the 'p' key a few times and it eventually works.
To skip to the next block I just used the 'break if' function in the Block_loop. I inserted [response] = space. Again this sometimes works. But sometimes doesn't, or sometimes works after a few presses.
Prior to each block I've used an inline script with exp.set('response', 'None')
to ensure the variable 'response' is known. So the task does run, and the response buttons do work as expected, but only sometimes.
I'm a bit stuck on how to get these working reliably.
Thanks, Robin
Comments
Hi Robin,
The only source of inconsistency that I can imagine is the timing of the response relative to the presentation. How do you structure your experiment? Is there a long response phase where the keyboard item is polling continuously until a response was made? Or is there a fixed response window?
If not, then I guess the responses fall outside the response window, either before or after, so that a key press is not registered. If you show your experimental setup it will be easier to find out what is going on, and whether it is fixable.
Eduard
ah, many thanks for the reply @eduard.
Ok, not sure best way to show the experimental setup. Happy to share the actual experiment if that's easier. But here's a screenshot (I'm an OS newbie so hopefully my design is not too clunky!):
new_inline_script_1 - this is
exp.set('block_starttime', self.time())
to get a time stampfor the block startnew_inline_script_2 - this
exp.set('response', 'None')
to prevent the baseline loop complaining that the variable response is not known.inline_script_baselineBlock -
oxy.WriteEvent("b", "Baseline")
to send a trigger to my fNIRS software (Oxysoft) to indicate start of the baseline block.In the trial_sequence_2 I have this:
Then I have the pause_sequence and this is followed by:
new_inline_script -
import random
var.stim_duration = random.randint(1000,3000)
- i'm presenting a series of jpg's for a random duration controlled by this. The block continues for ~40sec.
new_inline_script_PauseTrigger -
oxy.WriteEvent("p", "pause")
to send a trigger to Oxysoft indicating a pause occurred.Apologies, I'm sure this is not the most efficient way to show you the design. I wonder if I should move anything around? The new_keyboard_response at the end of the block_loop perhaps? Participants do not respond at all - they keyboard is just being used to send triggers and pause the task.
Thanks for any further thoughts you might have.
Robin
Yes, share the experiment please :)
ok no problem here it is :)
Dynamic Social Task_v2_8Aug22.osexp
So, like I thought, you have periods in your experiment in which you don't poll responses. Whatever you press during those phases, will simply be ignored. Specifically, you set the duration of sketchpads to values larger than 0. So, before the experiment will proceed to the keyboard response after, the experiment will stall (be unresponsive) for whatever value you put in duration. If you set that value to 0, you should have more or less direct responsiveness (breaking and pausing a loop).
To make sure you still have stimulus presentation built in (so a response time of 2000 + duration of the sketchpad, you can use that as input to the duration of the keyboard response.
You know what I mean?
Aside of that, I would recommend, that you try to use fewer items in your experiment (combine the inline_scripts, and wrap your baseline, social, nonsocial blocks in a loop), like that the memory foot print of your experiment will be better. (feel free to ignore this advice if you have no problems with the way it is now)
Eduard
Thanks so much @eduard .
1. First on the sketchpad / keyboard response timing. I think you meant to change the sketchpad duration to 0, and then add the variable [stim_duration] for the Timeout value? This seems to work nicely! Thanks so much.
I'm actually a bit unsure of the function of Timeout in keyboard_response. In my original design, i had this set to 2000. does this mean that no response is accepted after 2000 ms (ie it times out)? I think i just inherited this from copying from another task.
2. Next, thanks for the suggestion of using fewer items. I think I have been finding the operation of this task a bit buggy, crashing occasionally - and I wondered if it was too large/cumbersome (I did move videos and jpg's out of the File pool which might've helped a bit. I've combined some of the inline scripts along these lines:
Is that what you had in mind?
My only question here is that I'm trying to get various triggers sent using COM interface. In my baseline block I have one trigger ("p") when I pause the block. And then another trigger when i restart the block ("s"). I think these would need to be in separate inline scripts? (given that in the trial_sequence these are separately set to only Run if [response] = p or [response] = s).
3. Is there anywhere you can point me towards an example of wrapping different blocks in a loop? I sort of get the principle, but can't see how this would happen. Is it in the experimental_loop that this would be controlled, with only 1 baseline sequence, 1 social sequence, 1 non-social sequence needed, but they get run/looped?
Thanks again, this is super helpful.
I'm actually a bit unsure of the function of Timeout in keyboard_response. In my original design, i had this set to 2000. does this mean that no response is accepted after 2000 ms (ie it times out)? I think i just inherited this from copying from another task.
No, it mean that the experiment waits for 2000 ms before it will proceed (and sets the response to
None
), unless of course a key was pressed, then it will proceed immediately.Is that what you had in mind?
Yeah, basically.
I think these would need to be in separate inline scripts? (given that in the trial_sequence these are separately set to only Run if [response] = p or [response] = s
Not entirely sure whether it is that easy, but if you want to send trigger p if the response is p and trigger s if the response is s, you could simply use something like:
with message being a dictionary mapping keys to messages:
Alternatively, it is not a big deal to have multiple inline_scripts. The experiment is just getting a little cluttered.
. Is there anywhere you can point me towards an example of wrapping different blocks in a loop?
Here a generic example. I haven't looked into your code in detail, but it is very well possible that you could even collapse the baseline, social and nonsocial conditions into a single loop/sequence, instead of specific loop/sequence for each condition, but then work with block type variables in the loop table, and variables in the components of the loop that depend on blocktype.
Hope this helps,
Eduard
Thanks again @eduard this is super helpful.
I've economised my blocks by using a loop. I think it's running more reliably now.
I think I might quit while I'm ahead and keep my separate inline scripts to send separate triggers from the keyboard (though I would like to know for the future - in your suggested code, is the second code message
['b': "baseline", 'p': "pause"]
just a new line in the same inline script for the first code you added? or is this inserted somewhere else?More importantly, I hope I could trouble you for one more related question. I have not been able to get one of my inline scripts to send an x trigger to oxysoft (fNIRS software). I just have a simple inline script:
The Inline script appears in a sequence (which is in a loop). The sequence has the inline script, then a video (media_player_mpy) with duration set to 20,000, and then I have a keyboard_response with no correct response and Timeout set to 0.
The idea is that mostly the sequence will run a few videos and no trigger is needed. But occasionally i'll need to send an x trigger.
I have this basic trigger script working in another sequence in a separate loop. The only difference I can see is that this sequence has a sketchpad with duration 0, and then a keyboard_response with Timeout set to variable [stim_duration].
I think maybe it's how i've set up the keyboard_response?
Robin
Just to update, I've put this last question on a new thread given it was not exactly related to the original post.