How to specify a variable trial duration


Author
Message
thomas.biba
thomas.biba
Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)
Group: Forum Members
Posts: 9, Visits: 37
Greetings, 

I am looking to create a task (assuming a 60 Hz refresh rate) that A) presents a cue for 13 frames (200 ms), then B) implements a variable SOA from 13 - 67 frames (200 - 1100 ms), then C) presents a target for 31 frames (500 ms), then D) allows for a response for 124 frames (2000 ms), and E) a variable ITI of 78 - 117 frames (1200-1800 ms). I was able to get A,B, and C, yet I am struggling to implement D and E. My code implementing those steps is below (note that this code ends the trial once a response is make which is not what I am looking for). Any suggestions on how to implement D and E? 

Many thanks, 

Thomas

<item Objects_t1>
/1 = "8ball.jpg"
/2 = "50dollarbill.jpg"
/3 = "accordion01.jpg"
/4 = "aceofdiamond.jpg"
</item>

<picture ObjectsP_t1>
/ items = ObjectsI_t1
/ select = sequence
/ size = (550, 550)
/ position = (50%, 45%)
/ erase = false
</picture>

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

<shape blank>
/ color = (175, 175, 175)
/ shape = rectangle
/ size = (2000, 1000)
</shape>

<defaults>
/ screencolor = (175, 175, 175)
/ fontstyle = ("arial")
</defaults>

<list SOAduration>
/ items = (26, 67, 26, 67)
</list>

<list StimEnd>
/ items = (57, 98, 57, 98)
</list>

<trial testT_1>
/ ontrialbegin = [trial.testT_1.insertstimulusframe(picture.ObjectsP_t1, list.SOAduration.nextvalue);
      trial.testT_1.insertstimulusframe(shape.blank, list.StimEnd.nextvalue);]
/ ontrialend = [trial.mytrial.resetstimulusframes()]
/ stimulusframes = [1=cue; 13=blank]
/ validresponse = (anyresponse)
</trial>

<block TestB_1>
/ trials = [1-4 = sequence(testT_1)]
/ errormessage = false
</block>

<expt>
/ blocks = [1=TestB_1]
</expt>
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
thomas.biba - 11/24/2020
Greetings, 

I am looking to create a task (assuming a 60 Hz refresh rate) that A) presents a cue for 13 frames (200 ms), then B) implements a variable SOA from 13 - 67 frames (200 - 1100 ms), then C) presents a target for 31 frames (500 ms), then D) allows for a response for 124 frames (2000 ms), and E) a variable ITI of 78 - 117 frames (1200-1800 ms). I was able to get A,B, and C, yet I am struggling to implement D and E. My code implementing those steps is below (note that this code ends the trial once a response is make which is not what I am looking for). Any suggestions on how to implement D and E? 

Many thanks, 

Thomas

<item Objects_t1>
/1 = "8ball.jpg"
/2 = "50dollarbill.jpg"
/3 = "accordion01.jpg"
/4 = "aceofdiamond.jpg"
</item>

<picture ObjectsP_t1>
/ items = ObjectsI_t1
/ select = sequence
/ size = (550, 550)
/ position = (50%, 45%)
/ erase = false
</picture>

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

<shape blank>
/ color = (175, 175, 175)
/ shape = rectangle
/ size = (2000, 1000)
</shape>

<defaults>
/ screencolor = (175, 175, 175)
/ fontstyle = ("arial")
</defaults>

<list SOAduration>
/ items = (26, 67, 26, 67)
</list>

<list StimEnd>
/ items = (57, 98, 57, 98)
</list>

<trial testT_1>
/ ontrialbegin = [trial.testT_1.insertstimulusframe(picture.ObjectsP_t1, list.SOAduration.nextvalue);
      trial.testT_1.insertstimulusframe(shape.blank, list.StimEnd.nextvalue);]
/ ontrialend = [trial.mytrial.resetstimulusframes()]
/ stimulusframes = [1=cue; 13=blank]
/ validresponse = (anyresponse)
</trial>

<block TestB_1>
/ trials = [1-4 = sequence(testT_1)]
/ errormessage = false
</block>

<expt>
/ blocks = [1=TestB_1]
</expt>

See this recent thread:

https://www.millisecond.com/forums/Topic30232.aspx
thomas.biba
thomas.biba
Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)
Group: Forum Members
Posts: 9, Visits: 37
Hi David, 

Thanks this is very helpful! However, while close, this is not exactly what I am looking to do (see my code at the end [section B] for how I implemented what was outlined in that previous thread). One additional thing I am hoping to do is to pseudo-randomize the SOA interval (and ITI), and also have a certain number of trials for each SOA bin in discrete SOA time bins (one bin every two frames.. e.g. 200, 233.33, 266.66 ...1100 etc..). It doesn't seem this level of control is possible within Inquisit so I was thinking of preparing list elements that contain all the SOA values for subsequent trials that I want and inputing that in on a trial-wise basis. I tried to implement this below [section A], and while it doesn't crash, the total trial times it produces seem to be off (I presume this might have to do with incorrectly resetting the stimulus frames at the beginning of the trial?). I am wondering how to resolve this. 

Many thanks, 

Thomas

[section A] ------------------------ additional step I am looking to implement ----------------------

<list SOA>
/ items = (200, 1100, 200, 1100)
</list>

<list ITI>
/ items = (1200, 1800, 1200, 1800)
</list>

<trial testT_1>
/ ontrialbegin = [
    trial.testT_1.resetstimulusframes();
    trial.testT_1.insertstimulustime(text.cue, parameters.start);
    trial.testT_1.insertstimulustime(picture.ObjectsP_t1, parameters.cueDur + list.SOA.nextvalue);
    trial.testT_1.insertstimulustime(shape.blank, parameters.cueDur + list.SOA.nextvalue + parameters.targDur);
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + list.SOA.nextvalue + parameters.targDur
/ trialduration = parameters.cueDur + list.SOA.nextvalue + parameters.targDur + parameters.respDur + list.ITI.nextvalue
/ validresponse = (anyresponse)
</trial>

[section B] ----------------------- code that runs (fully randomizing SOA and ITI) ---------------------

<parameters>
/ start = 0
/ cueDur = 200
/ targDur = 500
/ respDur = 2000
</parameters>

<values>
/ SOA = -1
/ ITI = -1
</values>

<trial testT_1>
/ ontrialbegin = [
    trial.testT_1.resetstimulusframes();
    trial.testT_1.insertstimulustime(text.cue, parameters.start);
    values.SOA = round(rand(200, 1100));
    trial.testT_1.insertstimulustime(picture.ObjectsP_t1, parameters.cueDur + values.SOA);
    trial.testT_1.insertstimulustime(shape.blank, parameters.cueDur + values.SOA + parameters.targDur);
    values.ITI = parameters.respDur + round(rand(1200, 1800));
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + values.SOA + parameters.targDur
/ trialduration = parameters.cueDur + values.SOA + parameters.targDur + values.ITI
/ validresponse = (anyresponse)
</trial>

<block TestB_1>
/ trials = [1-4 = sequence(testT_1)]
/ errormessage = false
</block>

<expt>
/ blocks = [1=TestB_1]
</expt>
thomas.biba
thomas.biba
Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)
Group: Forum Members
Posts: 9, Visits: 37
Whoops I noticed there is an error in the code that works [section B]. It should be (the only change is adding parameters.respDur to total trial time computation):

<trial testT_1>
/ ontrialbegin = [
  trial.testT_1.resetstimulusframes();
  trial.testT_1.insertstimulustime(text.cue, parameters.start);
  values.SOA = round(rand(200, 1100));
  trial.testT_1.insertstimulustime(picture.ObjectsP_t1, parameters.cueDur + values.SOA);
  trial.testT_1.insertstimulustime(shape.blank, parameters.cueDur + values.SOA + parameters.targDur);
  values.ITI = parameters.respDur + round(rand(1200, 1800));
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + values.SOA + parameters.targDur
/ trialduration = parameters.cueDur + values.SOA + parameters.targDur + parameters.respDur + values.ITI
/ validresponse = (anyresponse)
</trial>
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
thomas.biba - 11/25/2020
Hi David, 

Thanks this is very helpful! However, while close, this is not exactly what I am looking to do (see my code at the end [section B] for how I implemented what was outlined in that previous thread). One additional thing I am hoping to do is to pseudo-randomize the SOA interval (and ITI), and also have a certain number of trials for each SOA bin in discrete SOA time bins (one bin every two frames.. e.g. 200, 233.33, 266.66 ...1100 etc..). It doesn't seem this level of control is possible within Inquisit so I was thinking of preparing list elements that contain all the SOA values for subsequent trials that I want and inputing that in on a trial-wise basis. I tried to implement this below [section A], and while it doesn't crash, the total trial times it produces seem to be off (I presume this might have to do with incorrectly resetting the stimulus frames at the beginning of the trial?). I am wondering how to resolve this. 

Many thanks, 

Thomas

[section A] ------------------------ additional step I am looking to implement ----------------------

<list SOA>
/ items = (200, 1100, 200, 1100)
</list>

<list ITI>
/ items = (1200, 1800, 1200, 1800)
</list>

<trial testT_1>
/ ontrialbegin = [
    trial.testT_1.resetstimulusframes();
    trial.testT_1.insertstimulustime(text.cue, parameters.start);
    trial.testT_1.insertstimulustime(picture.ObjectsP_t1, parameters.cueDur + list.SOA.nextvalue);
    trial.testT_1.insertstimulustime(shape.blank, parameters.cueDur + list.SOA.nextvalue + parameters.targDur);
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + list.SOA.nextvalue + parameters.targDur
/ trialduration = parameters.cueDur + list.SOA.nextvalue + parameters.targDur + parameters.respDur + list.ITI.nextvalue
/ validresponse = (anyresponse)
</trial>

[section B] ----------------------- code that runs (fully randomizing SOA and ITI) ---------------------

<parameters>
/ start = 0
/ cueDur = 200
/ targDur = 500
/ respDur = 2000
</parameters>

<values>
/ SOA = -1
/ ITI = -1
</values>

<trial testT_1>
/ ontrialbegin = [
    trial.testT_1.resetstimulusframes();
    trial.testT_1.insertstimulustime(text.cue, parameters.start);
    values.SOA = round(rand(200, 1100));
    trial.testT_1.insertstimulustime(picture.ObjectsP_t1, parameters.cueDur + values.SOA);
    trial.testT_1.insertstimulustime(shape.blank, parameters.cueDur + values.SOA + parameters.targDur);
    values.ITI = parameters.respDur + round(rand(1200, 1800));
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + values.SOA + parameters.targDur
/ trialduration = parameters.cueDur + values.SOA + parameters.targDur + values.ITI
/ validresponse = (anyresponse)
</trial>

<block TestB_1>
/ trials = [1-4 = sequence(testT_1)]
/ errormessage = false
</block>

<expt>
/ blocks = [1=TestB_1]
</expt>


You can sample your SOAs and ITIs from lists without any problem whatsoever.

<trial testT_1>
/ ontrialbegin = [
  trial.testT_1.resetstimulusframes();
  trial.testT_1.insertstimulustime(text.cue, parameters.start);
  values.SOA =list.SOA.nextvalue;
  trial.testT_1.insertstimulustime(picture.ObjectsP_t1, parameters.cueDur + values.SOA);
  trial.testT_1.insertstimulustime(shape.blank, parameters.cueDur + values.SOA + parameters.targDur);
  values.ITI = parameters.respDur + list.ITI.nextvalue;
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + values.SOA + parameters.targDur
/ trialduration = parameters.cueDur + values.SOA + parameters.targDur + values.ITI
/ validresponse = (anyresponse)
</trial>

Not sure what makes you think the times are off.

Edited 4 Years Ago by Dave
thomas.biba
thomas.biba
Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)
Group: Forum Members
Posts: 9, Visits: 37
Great! I see, I didn't realize you could pipe list elements into the values element to call that within ontrialbegin. However, when I run this I get the correct trail times in my output when SOA's and ITI's value are the same across trials. However, when I change them to be different each time, I don't get the total trial time I would expect (see two scenarios below). Am I missing something here?

Thanks,

T

------------- same times ------------

<list SOA>
/ items = (200, 200, 200, 200)
</list>

<list ITI>
/ items = (1200, 1200, 1200, 1200)
</list>

trial times = (4100, 4100, 4100, 4100)   *** what I get

------------- diff times ------------

<list SOA>
/ items = (200, 200, 1100, 1100)
</list>

<list ITI>
/ items = (1200, 1200, 1800, 1800)
</list>

trial times = (5600, 4700, 5000, 4100)   *** what I get
trial times = (4100, 4100, 5600, 5600)  *** what I would expect

thomas.biba
thomas.biba
Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)
Group: Forum Members
Posts: 9, Visits: 37
Wait sorry I figured it out! I just had to add sequence! Thanks for your help here!

<list SOA>
/ items = (200, 200, 1100, 1100)
/ select = sequence
</list>

<list ITI>
/ items = (1200, 1200, 1800, 1800)
/ select = sequence
</list>
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
thomas.biba - 11/25/2020
Wait sorry I figured it out! I just had to add sequence! Thanks for your help here!

<list SOA>
/ items = (200, 200, 1100, 1100)
/ select = sequence
</list>

<list ITI>
/ items = (1200, 1200, 1800, 1800)
/ select = sequence
</list>

Wasn't clear to me from your description that you wanted the SOAs and ISIs linked . To do that, you don't have to set the lists to sequential selection, you just need to link the 2nd list to the 1st. I.e.

<list SOA>
/ items = (200, 200, 1100, 1100)
</list>

<list ITI>
/ items = (1200, 1200, 1800, 1800)
/ selectionmode = list.SOA.currentindex
</list>

A SOA value will be sampled randomly (without replacement) from the SOA list and the corresponding ITI value will be selected in the ITI list.

thomas.biba
thomas.biba
Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)Associate Member (108 reputation)
Group: Forum Members
Posts: 9, Visits: 37
Hi Dave,

I have another question related to this thread. I am looking to get the timing information in my data file indicating when each of the stimuli are presented within the trial (since time is key for this experiment). Also, I am looking to present the stimuli based on the frame rather than the time, which I have successfully implemented in the code below. Therefore, is there a way to get a read out of when a stimulus is presented - using  insertstimulusframe() nesting within the onstrialbegin[] attribute - for each trail in the data output file? Specifically, I want to get a read out in milliseconds when the following stimuli (e.g., text.cue, picture.ObjectsP_t1, and shape.blank) are presented. Is there a way to get this info? If not, is there an alternate way to present stimuli in this way such that these data are recorded and accessible?

Many thanks, 
Thomas 

<parameters>
/ start = 0
/ cueDur = 200
/ targDur = 500
/ respDur = 2000
</parameters>

<parameters>
/ start_FR = 1
/ cueDur_FR = 13
/ targDur_FR = 31
/ respDur_FR = 122
</parameters>

<values>
/ SOA = 0
/ ITI = 0
</values>

<values>
/ SOA_FR = 0
/ ITI_FR = 0
</values>

<list SOA>
/ items = (200, 200, 1100, 1100)
/ select = sequence
</list>

<list SOA_FR>
/ items = (13, 13, 67, 67)
/ select = sequence
</list>

<list ITI>
/ items = (1200, 1200, 1800, 1800)
/ select = sequence
</list>

<list ITI_FR>
/ items = (74, 74, 110, 110)
/ select = sequence
</list>

<trial testT_1>
/ ontrialbegin = [
trial.testT_1.resetstimulusframes();
trial.testT_1.insertstimulusframe(text.cue, parameters.start_FR);
values.SOA =list.SOA.nextvalue;
values.SOA_FR =list.SOA_FR.nextvalue;
trial.testT_1.insertstimulusframe(picture.ObjectsP_t1, parameters.cueDur_FR + values.SOA_FR);
trial.testT_1.insertstimulusframe(shape.blank, parameters.cueDur_FR + values.SOA_FR + parameters.targDur_FR);
values.ITI = parameters.respDur + list.ITI.nextvalue;
values.ITI_FR = parameters.respDur_FR + list.ITI_FR.nextvalue;
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + values.SOA + parameters.targDur
/ trialduration = parameters.cueDur + values.SOA + parameters.targDur + values.ITI
/ validresponse = (anyresponse)
</trial>
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
thomas.biba - 1/31/2021
Hi Dave,

I have another question related to this thread. I am looking to get the timing information in my data file indicating when each of the stimuli are presented within the trial (since time is key for this experiment). Also, I am looking to present the stimuli based on the frame rather than the time, which I have successfully implemented in the code below. Therefore, is there a way to get a read out of when a stimulus is presented - using  insertstimulusframe() nesting within the onstrialbegin[] attribute - for each trail in the data output file? Specifically, I want to get a read out in milliseconds when the following stimuli (e.g., text.cue, picture.ObjectsP_t1, and shape.blank) are presented. Is there a way to get this info? If not, is there an alternate way to present stimuli in this way such that these data are recorded and accessible?

Many thanks, 
Thomas 

<parameters>
/ start = 0
/ cueDur = 200
/ targDur = 500
/ respDur = 2000
</parameters>

<parameters>
/ start_FR = 1
/ cueDur_FR = 13
/ targDur_FR = 31
/ respDur_FR = 122
</parameters>

<values>
/ SOA = 0
/ ITI = 0
</values>

<values>
/ SOA_FR = 0
/ ITI_FR = 0
</values>

<list SOA>
/ items = (200, 200, 1100, 1100)
/ select = sequence
</list>

<list SOA_FR>
/ items = (13, 13, 67, 67)
/ select = sequence
</list>

<list ITI>
/ items = (1200, 1200, 1800, 1800)
/ select = sequence
</list>

<list ITI_FR>
/ items = (74, 74, 110, 110)
/ select = sequence
</list>

<trial testT_1>
/ ontrialbegin = [
trial.testT_1.resetstimulusframes();
trial.testT_1.insertstimulusframe(text.cue, parameters.start_FR);
values.SOA =list.SOA.nextvalue;
values.SOA_FR =list.SOA_FR.nextvalue;
trial.testT_1.insertstimulusframe(picture.ObjectsP_t1, parameters.cueDur_FR + values.SOA_FR);
trial.testT_1.insertstimulusframe(shape.blank, parameters.cueDur_FR + values.SOA_FR + parameters.targDur_FR);
values.ITI = parameters.respDur + list.ITI.nextvalue;
values.ITI_FR = parameters.respDur_FR + list.ITI_FR.nextvalue;
]
/ stimulustimes = [0=clearscreen]
/ beginresponsetime = parameters.cueDur + values.SOA + parameters.targDur
/ trialduration = parameters.cueDur + values.SOA + parameters.targDur + values.ITI
/ validresponse = (anyresponse)
</trial>

You can use the stimuli's respective timestamp and/or stimulusonset properties.

https://www.millisecond.com/support/docs/v6/html/language/properties/timestamp.htm
https://www.millisecond.com/support/docs/v6/html/language/properties/stimulusonset.htm



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search