Contingent trial looping based on keyboard press


Author
Message
SCHAMP
SCHAMP
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 13, Visits: 37
Hi, 

We are showing 16 blocks, with 8 images presented in each block (this is the same image shown 8 times).
The images are facial expressions shown by a child’s caregiver and a stranger, so that:
Block HC = Happy Caregiver. The same image is shown 8 times, before another block is shown in randomized order. For your reference:
HS = Happy Stranger
FC = Fearful Caregiver
FS = Fearful Stranger
AC = Anger Caregiver
AS = Anger Stranger
NS = Neutral Stranger
NC = Neutral Caregiver
The trial starts with a fixation cross (1000ms), followed by the image (3000ms), and an inter-trial interval (1000ms).
We would like each trial to commence with the press of the space bar.
However, we want to add in a “loop” where if the child is not looking at the screen, we can press 1 to initiate a video of a looming ball to engage the child back to the screen. When the child looks back at the screen, we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block.
Can you please point us in the right direction as to how we could best do this?
We have attached our script.

Thank you!


Attachments
EMG_Ariana_2.1.iqx (285 views, 16.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
SCHAMP - 7/11/2019
Hi, 

We are showing 16 blocks, with 8 images presented in each block (this is the same image shown 8 times).
The images are facial expressions shown by a child’s caregiver and a stranger, so that:
Block HC = Happy Caregiver. The same image is shown 8 times, before another block is shown in randomized order. For your reference:
HS = Happy Stranger
FC = Fearful Caregiver
FS = Fearful Stranger
AC = Anger Caregiver
AS = Anger Stranger
NS = Neutral Stranger
NC = Neutral Caregiver
The trial starts with a fixation cross (1000ms), followed by the image (3000ms), and an inter-trial interval (1000ms).
We would like each trial to commence with the press of the space bar.
However, we want to add in a “loop” where if the child is not looking at the screen, we can press 1 to initiate a video of a looming ball to engage the child back to the screen. When the child looks back at the screen, we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block.
Can you please point us in the right direction as to how we could best do this?
We have attached our script.

Thank you!


You need to work with a /stop attribute at the block-level and a /branch:

<values>
/ resetblock = false
</values>

<parameters>
/stimulusduration = 3000
/ITI = 1000
</parameters>

<expt>
/blocks = [1-2 = noreplace(HC, HS)]
</expt>

<block HC>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start,ITI,HC)]
/ branch = [
if (values.resetblock) {
block.HC;
values.resetblock = false;
}
]
</block>

<block HS>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start, ITI,HS)]
/ branch = [
if (values.resetblock) {
block.HS;
values.resetblock = false;
}
]
</block>

<trial start>
/ stimulusframes = [1=instr]
/ validresponse = (57,2)
/ branch = [if (trial.start.response == 2) trial.ball]
/ recorddata = false
</trial>

<trial ball>
/ ontrialend = [
values.resetblock = true;
]
/ stimulusframes = [1=ballanim]
/ validresponse = (57)
</trial>

<text instr>
/ items = ("Press SPACE to start the trial sequence, press 1 to initiate the ball / reset trial.")
</text>

<text ballanim>
/ items = ("Imagine your ball animation here. Press SPACE to restart the block.")
</text>

<trial HC>
/stimulusframes = [1 = H_C]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial HS>
/stimulusframes = [1 = H_S]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial blank>
/ stimulusframes = [1 = blank]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<trial ITI>
/ stimulusframes = [1 = fixation]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<text H_C>
/ items = ("HC")
</text>

<text H_S>
/ items = ("HS")
</text>

<text blank>
/ items = ("  ")
</text>

<text fixation>
/ items = ("+")
</text>






SCHAMP
SCHAMP
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 13, Visits: 37
Dave - 7/12/2019
SCHAMP - 7/11/2019
Hi, 

We are showing 16 blocks, with 8 images presented in each block (this is the same image shown 8 times).
The images are facial expressions shown by a child’s caregiver and a stranger, so that:
Block HC = Happy Caregiver. The same image is shown 8 times, before another block is shown in randomized order. For your reference:
HS = Happy Stranger
FC = Fearful Caregiver
FS = Fearful Stranger
AC = Anger Caregiver
AS = Anger Stranger
NS = Neutral Stranger
NC = Neutral Caregiver
The trial starts with a fixation cross (1000ms), followed by the image (3000ms), and an inter-trial interval (1000ms).
We would like each trial to commence with the press of the space bar.
However, we want to add in a “loop” where if the child is not looking at the screen, we can press 1 to initiate a video of a looming ball to engage the child back to the screen. When the child looks back at the screen, we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block.
Can you please point us in the right direction as to how we could best do this?
We have attached our script.

Thank you!


You need to work with a /stop attribute at the block-level and a /branch:

<values>
/ resetblock = false
</values>

<parameters>
/stimulusduration = 3000
/ITI = 1000
</parameters>

<expt>
/blocks = [1-2 = noreplace(HC, HS)]
</expt>

<block HC>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start,ITI,HC)]
/ branch = [
if (values.resetblock) {
block.HC;
values.resetblock = false;
}
]
</block>

<block HS>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start, ITI,HS)]
/ branch = [
if (values.resetblock) {
block.HS;
values.resetblock = false;
}
]
</block>

<trial start>
/ stimulusframes = [1=instr]
/ validresponse = (57,2)
/ branch = [if (trial.start.response == 2) trial.ball]
/ recorddata = false
</trial>

<trial ball>
/ ontrialend = [
values.resetblock = true;
]
/ stimulusframes = [1=ballanim]
/ validresponse = (57)
</trial>

<text instr>
/ items = ("Press SPACE to start the trial sequence, press 1 to initiate the ball / reset trial.")
</text>

<text ballanim>
/ items = ("Imagine your ball animation here. Press SPACE to restart the block.")
</text>

<trial HC>
/stimulusframes = [1 = H_C]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial HS>
/stimulusframes = [1 = H_S]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial blank>
/ stimulusframes = [1 = blank]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<trial ITI>
/ stimulusframes = [1 = fixation]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<text H_C>
/ items = ("HC")
</text>

<text H_S>
/ items = ("HS")
</text>

<text blank>
/ items = ("  ")
</text>

<text fixation>
/ items = ("+")
</text>






Thank you! Really appreciate it.
Instead of going back to the start of the block that was being presented, is it possible to write the script so that the experiment goes back to the same trial that was presented in the block prior to the child looking away?

I.e., Child looks away on trial 3 on block HS. We initiate looming ball to engage the child back to the screen, they look back at the screen, we press space to re-initiate/present trial 3 on block HS (same point where they initially disengaged)? Trial 3 of block HS is then shown, then trial 4... etc. 

Thanks again.


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
SCHAMP - 7/12/2019
Dave - 7/12/2019
SCHAMP - 7/11/2019
Hi, 

We are showing 16 blocks, with 8 images presented in each block (this is the same image shown 8 times).
The images are facial expressions shown by a child’s caregiver and a stranger, so that:
Block HC = Happy Caregiver. The same image is shown 8 times, before another block is shown in randomized order. For your reference:
HS = Happy Stranger
FC = Fearful Caregiver
FS = Fearful Stranger
AC = Anger Caregiver
AS = Anger Stranger
NS = Neutral Stranger
NC = Neutral Caregiver
The trial starts with a fixation cross (1000ms), followed by the image (3000ms), and an inter-trial interval (1000ms).
We would like each trial to commence with the press of the space bar.
However, we want to add in a “loop” where if the child is not looking at the screen, we can press 1 to initiate a video of a looming ball to engage the child back to the screen. When the child looks back at the screen, we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block.
Can you please point us in the right direction as to how we could best do this?
We have attached our script.

Thank you!


You need to work with a /stop attribute at the block-level and a /branch:

<values>
/ resetblock = false
</values>

<parameters>
/stimulusduration = 3000
/ITI = 1000
</parameters>

<expt>
/blocks = [1-2 = noreplace(HC, HS)]
</expt>

<block HC>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start,ITI,HC)]
/ branch = [
if (values.resetblock) {
block.HC;
values.resetblock = false;
}
]
</block>

<block HS>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start, ITI,HS)]
/ branch = [
if (values.resetblock) {
block.HS;
values.resetblock = false;
}
]
</block>

<trial start>
/ stimulusframes = [1=instr]
/ validresponse = (57,2)
/ branch = [if (trial.start.response == 2) trial.ball]
/ recorddata = false
</trial>

<trial ball>
/ ontrialend = [
values.resetblock = true;
]
/ stimulusframes = [1=ballanim]
/ validresponse = (57)
</trial>

<text instr>
/ items = ("Press SPACE to start the trial sequence, press 1 to initiate the ball / reset trial.")
</text>

<text ballanim>
/ items = ("Imagine your ball animation here. Press SPACE to restart the block.")
</text>

<trial HC>
/stimulusframes = [1 = H_C]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial HS>
/stimulusframes = [1 = H_S]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial blank>
/ stimulusframes = [1 = blank]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<trial ITI>
/ stimulusframes = [1 = fixation]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<text H_C>
/ items = ("HC")
</text>

<text H_S>
/ items = ("HS")
</text>

<text blank>
/ items = ("  ")
</text>

<text fixation>
/ items = ("+")
</text>






Thank you! Really appreciate it.
Instead of going back to the start of the block that was being presented, is it possible to write the script so that the experiment goes back to the same trial that was presented in the block prior to the child looking away?

I.e., Child looks away on trial 3 on block HS. We initiate looming ball to engage the child back to the screen, they look back at the screen, we press space to re-initiate/present trial 3 on block HS (same point where they initially disengaged)? Trial 3 of block HS is then shown, then trial 4... etc. 

Thanks again.


Yes, that's possible, but it's not what you asked? You specifically said in your original post:

"we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block. "

So I'm confused: What is it that you want? Restart the entire block or rather pause and resume the block at the given trial?

If you merely want to pause/resume, you would do something like this:

<parameters>
/stimulusduration = 3000
/ITI = 1000
</parameters>

<expt>
/blocks = [1-2 = noreplace(HC, HS)]
</expt>

<block HC>
/ trials = [1-8 = start]
</block>

<block HS>
/ trials = [1-8 = start]
</block>

<trial start>
/ stimulusframes = [1=instr]
/ validresponse = (57,2)
/ branch = [if (trial.start.response == 2) trial.ball else trial.ITI]
/ recorddata = false
</trial>

<trial ball>
/ stimulusframes = [1=ballanim]
/ validresponse = (57)
/ branch = [
trial.start;
]
/ recorddata = false
</trial>

<text instr>
/ items = ("Press SPACE to start the trial sequence, press 1 for the ball animation if child is disengaged.")
</text>

<text ballanim>
/ items = ("Imagine your ball animation here. Press SPACE to resume the block.")
</text>

<trial HC>
/stimulusframes = [1 = H_C]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial HS>
/stimulusframes = [1 = H_S]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial blank>
/ stimulusframes = [1 = blank]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<trial ITI>
/ stimulusframes = [1 = fixation]
/trialduration = parameters.ITI
/recorddata = false
/ branch = [
if (script.currentblock == "HC") trial.HC
else if (script.currentblock == "HS") trial.HS;
]
</trial>

<text H_C>
/ items = ("HC")
</text>

<text H_S>
/ items = ("HS")
</text>

<text blank>
/ items = (" ")
</text>

<text fixation>
/ items = ("+")
</text>



Edited 5 Years Ago by Dave
SCHAMP
SCHAMP
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 13, Visits: 37
Dave - 7/12/2019
SCHAMP - 7/12/2019
Dave - 7/12/2019
SCHAMP - 7/11/2019
Hi, 

We are showing 16 blocks, with 8 images presented in each block (this is the same image shown 8 times).
The images are facial expressions shown by a child’s caregiver and a stranger, so that:
Block HC = Happy Caregiver. The same image is shown 8 times, before another block is shown in randomized order. For your reference:
HS = Happy Stranger
FC = Fearful Caregiver
FS = Fearful Stranger
AC = Anger Caregiver
AS = Anger Stranger
NS = Neutral Stranger
NC = Neutral Caregiver
The trial starts with a fixation cross (1000ms), followed by the image (3000ms), and an inter-trial interval (1000ms).
We would like each trial to commence with the press of the space bar.
However, we want to add in a “loop” where if the child is not looking at the screen, we can press 1 to initiate a video of a looming ball to engage the child back to the screen. When the child looks back at the screen, we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block.
Can you please point us in the right direction as to how we could best do this?
We have attached our script.

Thank you!


You need to work with a /stop attribute at the block-level and a /branch:

<values>
/ resetblock = false
</values>

<parameters>
/stimulusduration = 3000
/ITI = 1000
</parameters>

<expt>
/blocks = [1-2 = noreplace(HC, HS)]
</expt>

<block HC>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start,ITI,HC)]
/ branch = [
if (values.resetblock) {
block.HC;
values.resetblock = false;
}
]
</block>

<block HS>
/ stop = [
values.resetblock;
]
/ trials = [1-8 = sequence(start, ITI,HS)]
/ branch = [
if (values.resetblock) {
block.HS;
values.resetblock = false;
}
]
</block>

<trial start>
/ stimulusframes = [1=instr]
/ validresponse = (57,2)
/ branch = [if (trial.start.response == 2) trial.ball]
/ recorddata = false
</trial>

<trial ball>
/ ontrialend = [
values.resetblock = true;
]
/ stimulusframes = [1=ballanim]
/ validresponse = (57)
</trial>

<text instr>
/ items = ("Press SPACE to start the trial sequence, press 1 to initiate the ball / reset trial.")
</text>

<text ballanim>
/ items = ("Imagine your ball animation here. Press SPACE to restart the block.")
</text>

<trial HC>
/stimulusframes = [1 = H_C]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial HS>
/stimulusframes = [1 = H_S]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial blank>
/ stimulusframes = [1 = blank]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<trial ITI>
/ stimulusframes = [1 = fixation]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<text H_C>
/ items = ("HC")
</text>

<text H_S>
/ items = ("HS")
</text>

<text blank>
/ items = ("  ")
</text>

<text fixation>
/ items = ("+")
</text>






Thank you! Really appreciate it.
Instead of going back to the start of the block that was being presented, is it possible to write the script so that the experiment goes back to the same trial that was presented in the block prior to the child looking away?

I.e., Child looks away on trial 3 on block HS. We initiate looming ball to engage the child back to the screen, they look back at the screen, we press space to re-initiate/present trial 3 on block HS (same point where they initially disengaged)? Trial 3 of block HS is then shown, then trial 4... etc. 

Thanks again.


Yes, that's possible, but it's not what you asked? You specifically said in your original post:

"we want to press space to initiate the trial (as per above), but back to the start of the block that was being presented prior to the child looking away from the screen. So, if they don’t look at any time during the block, we want to initiate the looming ball and when they re-engage, we want to restart the block. "

So I'm confused: What is it that you want? Restart the entire block or rather pause and resume the block at the given trial?

If you merely want to pause/resume, you would do something like this:

<parameters>
/stimulusduration = 3000
/ITI = 1000
</parameters>

<expt>
/blocks = [1-2 = noreplace(HC, HS)]
</expt>

<block HC>
/ trials = [1-8 = start]
</block>

<block HS>
/ trials = [1-8 = start]
</block>

<trial start>
/ stimulusframes = [1=instr]
/ validresponse = (57,2)
/ branch = [if (trial.start.response == 2) trial.ball else trial.ITI]
/ recorddata = false
</trial>

<trial ball>
/ stimulusframes = [1=ballanim]
/ validresponse = (57)
/ branch = [
trial.start;
]
/ recorddata = false
</trial>

<text instr>
/ items = ("Press SPACE to start the trial sequence, press 1 for the ball animation if child is disengaged.")
</text>

<text ballanim>
/ items = ("Imagine your ball animation here. Press SPACE to resume the block.")
</text>

<trial HC>
/stimulusframes = [1 = H_C]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial HS>
/stimulusframes = [1 = H_S]
/timeout = parameters.stimulusduration
/branch = [trial.blank]
/recorddata = true
</trial>

<trial blank>
/ stimulusframes = [1 = blank]
/trialduration = parameters.ITI
/recorddata = false
</trial>

<trial ITI>
/ stimulusframes = [1 = fixation]
/trialduration = parameters.ITI
/recorddata = false
/ branch = [
if (script.currentblock == "HC") trial.HC
else if (script.currentblock == "HS") trial.HS;
]
</trial>

<text H_C>
/ items = ("HC")
</text>

<text H_S>
/ items = ("HS")
</text>

<text blank>
/ items = (" ")
</text>

<text fixation>
/ items = ("+")
</text>



Hi Dave,

Apologies, I asked that second question (pause/resume) as we aren't 100% sure which option to go with - either pausing/resuming or starting at a new block.
So, it's great to have both options for when we make a final decision after pilot testing.

Thanks a lot - appreciate your help!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search