mean latencies for correct/incorrect trials by trial type?


Author
Message
knr
knr
Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)
Group: Forum Members
Posts: 4, Visits: 27
Hi,

I have a task where people respond to types of stimuli (ex. happy trials, sad trials).  I want to be able to get the mean latencies for each trial type, but separately get the latencies for just the correct trials and for just he incorrect trials (so I'd end up with Happy_correctmeanlatency, Happy_incorrectmeanlatency, Sad_correctmeanlatency, Sad_incorrectmeanlatency, etc).

I was thinking I could use /onblockend and some if statements to calculate the latencies for each, but I'm getting confused on exactly how to do it.

Would it be...

/onblockend =
  [if (trial.Happy.correct == true)
  values.Happy_correctmeanlatency = meanlatency(Happy)]
/onblockend =
  [if (trial.Happy.correct == false)
  values.Happy_incorrectmeanlatency = meanlatency(Happy)]

...and then repeat for other trial types in the block? 

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: 13K, Visits: 104K
knr - Thursday, November 10, 2016
Hi,

I have a task where people respond to types of stimuli (ex. happy trials, sad trials).  I want to be able to get the mean latencies for each trial type, but separately get the latencies for just the correct trials and for just he incorrect trials (so I'd end up with Happy_correctmeanlatency, Happy_incorrectmeanlatency, Sad_correctmeanlatency, Sad_incorrectmeanlatency, etc).

I was thinking I could use /onblockend and some if statements to calculate the latencies for each, but I'm getting confused on exactly how to do it.

Would it be...

/onblockend =
  [if (trial.Happy.correct == true)
  values.Happy_correctmeanlatency = meanlatency(Happy)]
/onblockend =
  [if (trial.Happy.correct == false)
  values.Happy_incorrectmeanlatency = meanlatency(Happy)]

...and then repeat for other trial types in the block? 

No. You need two <values> entries per trial-type: One where you aggregate the sum of correct latencies, one where you count the number of correct responses. You need to update these values /ontrialend. You then calculate the mean via an <expression>, simply dividing the sum by the number of correct responses.

<values>
/ a_sumlatency = 0
/ b_sumlatency = 0
/ a_ncorrect = 0
/ b_ncorrect = 0
</values>

<expressions>
/ a_meanlat_correct = (values.a_sumlatency/values.a_ncorrect)
/ b_meanlat_correct = (values.b_sumlatency/values.b_ncorrect)
</expressions>

<expt>
/ postinstructions = (performance)
/ blocks = [1=myblock]
</expt>

<block myblock>
/ trials = [1-10 = noreplace(a,b)]
</block>

<trial a>
/ ontrialend = [if (trial.a.correct) {values.a_sumlatency += trial.a.latency; values.a_ncorrect += 1}]
/ stimulusframes = [1=atxt]
/ validresponse = ("a", "b")
/ correctresponse = ("a")
</trial>

<trial b>
/ ontrialend = [if (trial.b.correct) {values.b_sumlatency += trial.b.latency; values.b_ncorrect += 1}]
/ stimulusframes = [1=btxt]
/ validresponse = ("a", "b")
/ correctresponse = ("b")
</trial>


<text atxt>
/ items = ("The correct response is A")
/ txcolor = red
</text>

<text atxt>
/ items = ("The correct response is B")
/ txcolor = blue
</text>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency correct values.a_ncorrect values.a_sumlatency values.b_ncorrect values.b_sumlatency expressions.a_meanlat_correct expressions.b_meanlat_correct]
/ separatefiles = true
</data>

Edited 8 Years Ago by Dave
knr
knr
Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)Respected Member (390 reputation)
Group: Forum Members
Posts: 4, Visits: 27
Dave - Thursday, November 10, 2016
knr - Thursday, November 10, 2016
Hi,

I have a task where people respond to types of stimuli (ex. happy trials, sad trials).  I want to be able to get the mean latencies for each trial type, but separately get the latencies for just the correct trials and for just he incorrect trials (so I'd end up with Happy_correctmeanlatency, Happy_incorrectmeanlatency, Sad_correctmeanlatency, Sad_incorrectmeanlatency, etc).

I was thinking I could use /onblockend and some if statements to calculate the latencies for each, but I'm getting confused on exactly how to do it.

Would it be...

/onblockend =
  [if (trial.Happy.correct == true)
  values.Happy_correctmeanlatency = meanlatency(Happy)]
/onblockend =
  [if (trial.Happy.correct == false)
  values.Happy_incorrectmeanlatency = meanlatency(Happy)]

...and then repeat for other trial types in the block? 

No. You need two <values> entries per trial-type: One where you aggregate the sum of correct latencies, one where you count the number of correct responses. You need to update these values /ontrialend. You then calculate the mean via an <expression>, simply dividing the sum by the number of correct responses.

<values>
/ a_sumlatency = 0
/ b_sumlatency = 0
/ a_ncorrect = 0
/ b_ncorrect = 0
</values>

<expressions>
/ a_meanlat_correct = (values.a_sumlatency/values.a_ncorrect)
/ b_meanlat_correct = (values.b_sumlatency/values.b_ncorrect)
</expressions>

<expt>
/ postinstructions = (performance)
/ blocks = [1=myblock]
</expt>

<block myblock>
/ trials = [1-10 = noreplace(a,b)]
</block>

<trial a>
/ ontrialend = [if (trial.a.correct) {values.a_sumlatency += trial.a.latency; values.a_ncorrect += 1}]
/ stimulusframes = [1=atxt]
/ validresponse = ("a", "b")
/ correctresponse = ("a")
</trial>

<trial b>
/ ontrialend = [if (trial.b.correct) {values.b_sumlatency += trial.b.latency; values.b_ncorrect += 1}]
/ stimulusframes = [1=btxt]
/ validresponse = ("a", "b")
/ correctresponse = ("b")
</trial>


<text atxt>
/ items = ("The correct response is A")
/ txcolor = red
</text>

<text atxt>
/ items = ("The correct response is B")
/ txcolor = blue
</text>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency correct values.a_ncorrect values.a_sumlatency values.b_ncorrect values.b_sumlatency expressions.a_meanlat_correct expressions.b_meanlat_correct]
/ separatefiles = true
</data>

Thanks, Dave.  This will give me the mean latencies for the various trial types for correct trials.  Is there a way to also get the latencies for the incorrect trials?

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: 13K, Visits: 104K
knr - Thursday, November 10, 2016
Dave - Thursday, November 10, 2016
knr - Thursday, November 10, 2016
Hi,

I have a task where people respond to types of stimuli (ex. happy trials, sad trials).  I want to be able to get the mean latencies for each trial type, but separately get the latencies for just the correct trials and for just he incorrect trials (so I'd end up with Happy_correctmeanlatency, Happy_incorrectmeanlatency, Sad_correctmeanlatency, Sad_incorrectmeanlatency, etc).

I was thinking I could use /onblockend and some if statements to calculate the latencies for each, but I'm getting confused on exactly how to do it.

Would it be...

/onblockend =
  [if (trial.Happy.correct == true)
  values.Happy_correctmeanlatency = meanlatency(Happy)]
/onblockend =
  [if (trial.Happy.correct == false)
  values.Happy_incorrectmeanlatency = meanlatency(Happy)]

...and then repeat for other trial types in the block? 

No. You need two <values> entries per trial-type: One where you aggregate the sum of correct latencies, one where you count the number of correct responses. You need to update these values /ontrialend. You then calculate the mean via an <expression>, simply dividing the sum by the number of correct responses.

<values>
/ a_sumlatency = 0
/ b_sumlatency = 0
/ a_ncorrect = 0
/ b_ncorrect = 0
</values>

<expressions>
/ a_meanlat_correct = (values.a_sumlatency/values.a_ncorrect)
/ b_meanlat_correct = (values.b_sumlatency/values.b_ncorrect)
</expressions>

<expt>
/ postinstructions = (performance)
/ blocks = [1=myblock]
</expt>

<block myblock>
/ trials = [1-10 = noreplace(a,b)]
</block>

<trial a>
/ ontrialend = [if (trial.a.correct) {values.a_sumlatency += trial.a.latency; values.a_ncorrect += 1}]
/ stimulusframes = [1=atxt]
/ validresponse = ("a", "b")
/ correctresponse = ("a")
</trial>

<trial b>
/ ontrialend = [if (trial.b.correct) {values.b_sumlatency += trial.b.latency; values.b_ncorrect += 1}]
/ stimulusframes = [1=btxt]
/ validresponse = ("a", "b")
/ correctresponse = ("b")
</trial>


<text atxt>
/ items = ("The correct response is A")
/ txcolor = red
</text>

<text atxt>
/ items = ("The correct response is B")
/ txcolor = blue
</text>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency correct values.a_ncorrect values.a_sumlatency values.b_ncorrect values.b_sumlatency expressions.a_meanlat_correct expressions.b_meanlat_correct]
/ separatefiles = true
</data>

Thanks, Dave.  This will give me the mean latencies for the various trial types for correct trials.  Is there a way to also get the latencies for the incorrect trials?

Sure, you can aggregate those in the exact same way:

<values>
/ a_sumlatency_correct = 0
/ b_sumlatency_correct = 0
/ a_ncorrect = 0
/ b_ncorrect = 0

/ a_sumlatency_incorrect = 0
/ b_sumlatency_incorrect = 0
/ a_nincorrect = 0
/ b_nincorrect = 0
</values>

<expressions>
/ a_meanlat_correct = (values.a_sumlatency_correct/values.a_ncorrect)
/ b_meanlat_correct = (values.b_sumlatency_correct/values.b_ncorrect)

/ a_meanlat_incorrect = (values.a_sumlatency_incorrect/values.a_nincorrect)
/ b_meanlat_incorrect = (values.b_sumlatency_incorrect/values.b_nincorrect)
</expressions>

<expt>
/ postinstructions = (performance)
/ blocks = [1=myblock]
</expt>

<block myblock>
/ trials = [1-10 = noreplace(a,b)]
</block>

<trial a>
/ ontrialend = [if (trial.a.correct) {values.a_sumlatency_correct += trial.a.latency; values.a_ncorrect += 1}]
/ ontrialend = [if (trial.a.error) {values.a_sumlatency_incorrect += trial.a.latency; values.a_nincorrect += 1}]
/ stimulusframes = [1=atxt]
/ validresponse = ("a", "b")
/ correctresponse = ("a")
</trial>

<trial b>
/ ontrialend = [if (trial.b.correct) {values.b_sumlatency_correct += trial.b.latency; values.b_ncorrect += 1}]
/ ontrialend = [if (trial.b.error) {values.b_sumlatency_incorrect += trial.b.latency; values.b_nincorrect += 1}]
/ stimulusframes = [1=btxt]
/ validresponse = ("a", "b")
/ correctresponse = ("b")
</trial>


<text atxt>
/ items = ("The correct response is A")
/ txcolor = red
</text>

<text atxt>
/ items = ("The correct response is B")
/ txcolor = blue
</text>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency correct
    values.a_ncorrect values.a_sumlatency_correct values.a_nincorrect values.a_sumlatency_incorrect
    values.b_ncorrect values.b_sumlatency_correct values.b_nincorrect values.b_sumlatency_incorrect
    expressions.a_meanlat_correct expressions.a_meanlat_incorrect
    expressions.b_meanlat_correct expressions.b_meanlat_incorrect]
/ separatefiles = true
</data>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search