Millisecond Forums

Sending event markers for correct and incorrect responses

https://forums.millisecond.com/Topic35880.aspx

By emily_ahne - 1/17/2024

I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>
By Dave - 1/17/2024

emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.
By emily_ahne - 1/17/2024

Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?
By Dave - 1/17/2024

emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?

You obviously need to define different markers (i.e. port elements) for correct and incorrect, and then specify your /responsemessage attributes in the <trial> elements such that the correct marker is sent for the applicable correct key in the given trial and the incorrect marker is sent for the other keys.
By emily_ahne - 1/17/2024

Dave - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?

You obviously need to define different markers (i.e. port elements) for correct and incorrect, and then specify your /responsemessage attributes in the <trial> elements such that the correct marker is sent for the applicable correct key in the given trial and the incorrect marker is sent for the other keys.

I believe I set it up correctly (see below). When I run the validate script option, no errors are produced. However, when I try to run it to collect data, the program shuts down completely (the task closes itself out and doesn't return any error codes for me to check). Am I missing something? I'm sorry if this is a simple question, I'm not the most experienced with writing code. Thanks again. 

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ responsemessage = (parameters.keyred, 0, correct_response)
/ responsemessage = (parameters.keygreen, 0, incorrect_response)
/ responsemessage = (parameters.keyblue, 0, incorrect_response)
/ responsemessage = (parameters.keyblack, 0, incorrect_response)

/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
<port correct_response>
/ port = LPT
/ subport = data
/ items = ("00000100")
</port>

<port incorrect_response>
/ port = LPT
/ subport = data
/ items = ("00000101")
</port>
By emily_ahne - 1/17/2024

emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?

You obviously need to define different markers (i.e. port elements) for correct and incorrect, and then specify your /responsemessage attributes in the <trial> elements such that the correct marker is sent for the applicable correct key in the given trial and the incorrect marker is sent for the other keys.

I believe I set it up correctly (see below). When I run the validate script option, no errors are produced. However, when I try to run it to collect data, the program shuts down completely (the task closes itself out and doesn't return any error codes for me to check). Am I missing something? I'm sorry if this is a simple question, I'm not the most experienced with writing code. Thanks again. 

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ responsemessage = (parameters.keyred, 0, correct_response)
/ responsemessage = (parameters.keygreen, 0, incorrect_response)
/ responsemessage = (parameters.keyblue, 0, incorrect_response)
/ responsemessage = (parameters.keyblack, 0, incorrect_response)

/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
<port correct_response>
/ port = LPT
/ subport = data
/ items = ("00000100")
</port>

<port incorrect_response>
/ port = LPT
/ subport = data
/ items = ("00000101")
</port>

I also tried using the keys for the corresponding color (below) and the same this is happening.

/ responsemessage = ("D", 0, correct_response)
/ responsemessage = ("F", 0, incorrect_response)
/ responsemessage = ("J", 0, incorrect_response)
/ responsemessage = ("K", 0, incorrect_response)
By Dave - 1/17/2024

emily_ahne - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?

You obviously need to define different markers (i.e. port elements) for correct and incorrect, and then specify your /responsemessage attributes in the <trial> elements such that the correct marker is sent for the applicable correct key in the given trial and the incorrect marker is sent for the other keys.

I believe I set it up correctly (see below). When I run the validate script option, no errors are produced. However, when I try to run it to collect data, the program shuts down completely (the task closes itself out and doesn't return any error codes for me to check). Am I missing something? I'm sorry if this is a simple question, I'm not the most experienced with writing code. Thanks again. 

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ responsemessage = (parameters.keyred, 0, correct_response)
/ responsemessage = (parameters.keygreen, 0, incorrect_response)
/ responsemessage = (parameters.keyblue, 0, incorrect_response)
/ responsemessage = (parameters.keyblack, 0, incorrect_response)

/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
<port correct_response>
/ port = LPT
/ subport = data
/ items = ("00000100")
</port>

<port incorrect_response>
/ port = LPT
/ subport = data
/ items = ("00000101")
</port>

I also tried using the keys for the corresponding color (below) and the same this is happening.

/ responsemessage = ("D", 0, correct_response)
/ responsemessage = ("F", 0, incorrect_response)
/ responsemessage = ("J", 0, incorrect_response)
/ responsemessage = ("K", 0, incorrect_response)

You have the order of arguments in /responsemessage wrong.

https://www.millisecond.com/support/docs/current/html/language/attributes/responsemessage.htm

It's (key, stimulus, duration), not (key, duration, stimulus), i.e.:

/ responsemessage = (parameters.keyred, port.correct_response, 100)


Also, you need to give it some duration, 0 will not work and be too short for your EEG setup to pick anything up.
By emily_ahne - 1/17/2024

Dave - 1/17/2024
emily_ahne - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?

You obviously need to define different markers (i.e. port elements) for correct and incorrect, and then specify your /responsemessage attributes in the <trial> elements such that the correct marker is sent for the applicable correct key in the given trial and the incorrect marker is sent for the other keys.

I believe I set it up correctly (see below). When I run the validate script option, no errors are produced. However, when I try to run it to collect data, the program shuts down completely (the task closes itself out and doesn't return any error codes for me to check). Am I missing something? I'm sorry if this is a simple question, I'm not the most experienced with writing code. Thanks again. 

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ responsemessage = (parameters.keyred, 0, correct_response)
/ responsemessage = (parameters.keygreen, 0, incorrect_response)
/ responsemessage = (parameters.keyblue, 0, incorrect_response)
/ responsemessage = (parameters.keyblack, 0, incorrect_response)

/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
<port correct_response>
/ port = LPT
/ subport = data
/ items = ("00000100")
</port>

<port incorrect_response>
/ port = LPT
/ subport = data
/ items = ("00000101")
</port>

I also tried using the keys for the corresponding color (below) and the same this is happening.

/ responsemessage = ("D", 0, correct_response)
/ responsemessage = ("F", 0, incorrect_response)
/ responsemessage = ("J", 0, incorrect_response)
/ responsemessage = ("K", 0, incorrect_response)

You have the order of arguments in /responsemessage wrong.

https://www.millisecond.com/support/docs/current/html/language/attributes/responsemessage.htm


It's (key, stimulus, duration), not (key, duration, stimulus). So,

/ responsemessage = (parameters.keyred, port.correct_response, 100)

Also, you need to give it some duration, 0 will not work and be too short for your EEG setup to pick anything up.

THANK YOU! This resolved the issue and the markers are being captured correctly! I really appreciate your help!
By Dave - 1/17/2024

emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
Dave - 1/17/2024
emily_ahne - 1/17/2024
I am running an experiment using the Color Word Stroop with Keyboard Responding from the Inquisit library (https://www.millisecond.com/download/library/stroop). Because I am also collecting simultaneous EEG recordings, I have set up stimulus event markers to identify trial-type onset using the port attribute (see highlighted portion below for an example of a congruent trial). I also need to have event markers sent via a port attribute that differentiates correct and incorrect responses (the EEG analyzing software identifies incorrect events via markers not trial numbers). The raw data already outputs these values based on each trial (e.g., trial 1 = correct, trial 2 = incorrect, so on), however, I need these to be identified in the EEG data via incorrect response event markers. How would I go about sending incorrect response event markers? Thank you. 
An example trial is included below:

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
# s 1 congruent trial onset marker
<port congruent_trial_onset>
/ port = LPT
/ subport = data
/ items = ("00000001")
</port>

You can send event markers on response via /responsemessage.

Will this differentiate between correct and incorrect responses?

You obviously need to define different markers (i.e. port elements) for correct and incorrect, and then specify your /responsemessage attributes in the <trial> elements such that the correct marker is sent for the applicable correct key in the given trial and the incorrect marker is sent for the other keys.

I believe I set it up correctly (see below). When I run the validate script option, no errors are produced. However, when I try to run it to collect data, the program shuts down completely (the task closes itself out and doesn't return any error codes for me to check). Am I missing something? I'm sorry if this is a simple question, I'm not the most experienced with writing code. Thanks again. 

<trial redcongruent>
/ontrialbegin = [
    values.congruency = 1;
]
/ pretrialpause = 400
/ stimulustimes = [0=redcongruent, redreminder, greenreminder, bluereminder, blackreminder, congruent_trial_onset]
/ correctresponse = (parameters.keyred)
/ validresponse = (parameters.keyred, parameters.keygreen, parameters.keyblue, parameters.keyblack)
/ responsemessage = (parameters.keyred, 0, correct_response)
/ responsemessage = (parameters.keygreen, 0, incorrect_response)
/ responsemessage = (parameters.keyblue, 0, incorrect_response)
/ responsemessage = (parameters.keyblack, 0, incorrect_response)

/ errormessage = true(x, 400)
/ontrialend = [
    if (trial.redcongruent.responsetext == "D"){
        values.responseCategory = "red";
    } else if (trial.redcongruent.responsetext == "F"){
        values.responseCategory = "green";
    } else if (trial.redcongruent.responsetext == "J"){
        values.responseCategory = "blue";
    } else if (trial.redcongruent.responsetext == "K"){
        values.responseCategory = "black";
    };    

    //summary data:
    
    list.responses.appenditem(trial.redcongruent.correct);
    list.responses_congruent.appenditem(trial.redcongruent.correct);

    if (trial.redcongruent.correct) {
        list.latencies.appenditem(trial.redcongruent.latency);
        list.latencies_congruent.appenditem(trial.redcongruent.latency);
    }
]
</trial>
...
<port correct_response>
/ port = LPT
/ subport = data
/ items = ("00000100")
</port>

<port incorrect_response>
/ port = LPT
/ subport = data
/ items = ("00000101")
</port>

I also tried using the keys for the corresponding color (below) and the same this is happening.

/ responsemessage = ("D", 0, correct_response)
/ responsemessage = ("F", 0, incorrect_response)
/ responsemessage = ("J", 0, incorrect_response)
/ responsemessage = ("K", 0, incorrect_response)

You have the order of arguments in /responsemessage wrong.

https://www.millisecond.com/support/docs/current/html/language/attributes/responsemessage.htm


It's (key, stimulus, duration), not (key, duration, stimulus). So,

/ responsemessage = (parameters.keyred, port.correct_response, 100)

Also, you need to give it some duration, 0 will not work and be too short for your EEG setup to pick anything up.

THANK YOU! This resolved the issue and the markers are being captured correctly! I really appreciate your help!

Glad to hear you're up and running!