Want to save data stored on a list to the summary data file


Author
Message
EN
EN
Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)
Group: Forum Members
Posts: 45, Visits: 224
Dave - 7/10/2025
Dave - 7/10/2025
EN - 7/10/2025
Hello:

I'm building an experiment to run online. Because it involves many steps, things are compartmentalized into different IQX files (the sub-files), which are all "included" in the main IQX file.
I would like to save the data stored on a list --whose values are computed in one of the sub IQX file-- to the summary data file, which is defined in the main IQX file.

I guess one way to bring the data, so to say, to the main IQX file is to have the list defined in the main IQX file, and only referred to in the sub IQX file.

However, I haven't figure out a good way to save the data on the list to the summary data file. Would appreciate if you have any suggestions!

I know the size of the lists I want to save so I guess I could store the data on the list into named variables, e.g., xxx001, xxx002, xxx003. I wonder if there is a more general way to do that other than manually assign N times the values, as in values.xxx001 = list.randnum.nextValue, values.xxx002 = list.randnum.nextValue, etc. (after resetting the list so that it starts from the beginning...

Thanks in advance,

EN
---

<text myText>
/ items = ("<%list.randnum.nextValue%> -- Press the space bar to continue")
/ fontStyle = ("Arial", 2.08%, false, false, false, false, 5, 1)
</text>

<trial myTrial>
/ preTrialPause = 500
/ stimulusTimes = [1=myText]
/ validResponse = (" ")
</trial>

<list randnum>
/ selectionMode = sequence
</list>

<block myBlock> // that would be defined in a separate IQX file
/ onBlockBegin = [
    // List of random numbers
    list.randnum.appendItem(rand(0, 10)); //1
    list.randnum.appendItem(rand(0, 10)); //2
    list.randnum.appendItem(rand(0, 10)); //3
    list.randnum.appendItem(rand(0, 10)); //4
    list.randnum.appendItem(rand(0, 10)); //5
    list.randnum.appendItem(rand(0, 10)); //6
    list.randnum.appendItem(rand(0, 10)); //7
    list.randnum.appendItem(rand(0, 10)); //8
    list.randnum.appendItem(rand(0, 10)); //9
    list.randnum.appendItem(rand(0, 10)); //10
]

/ trials = [1-10=myTrial]
</block>

<expt myExpt> // I would like to save the values in randnum in the summary data file defined in the IQX where the expt is defined
/ preInstructions = (myPage)
/ blocks = [1=myBlock]
</expt>


<page myPage>
On the following 10 trials, press the space bar
</page>

IQX files you load into another script via <include> are no different than having the code contained in those IQX files in the main script. It does not matter where your <list> resides.

If you want to output every single value contained in a list to the single-line summary data, then you indeed need to either define a variable for each item in the list and log those variables, or -- at a minimum -- loop through the list's items at some point, concat() all its items into a string, and log that string.

Example for the latter:

<values>
/ roundNumber = 0
/ myValue = null
/ listValuesRound1 = null
/ listValuesRound2 = null
/ listValuesRound3 = null
/ listValuesRound4 = null
</values>

<list myList>
</list>

<expt myExpt>
/ blocks = [1-4 = myBlock]
</expt>

<block myBlock>
/ onBlockBegin = [
    values.roundNumber += 1;
    list.myList.reset();
    list.myList.appenditem(round(rand(1,99999999)));
    list.myList.appenditem(round(rand(1,99999999)));
    list.myList.appenditem(round(rand(1,99999999)));
]
/ onBlockEnd = [
    var i = 0;
    if (values.roundNumber == 1) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound1 = concat(values.listValuesRound1, list.myList.item(i));
            values.listValuesRound1 = concat(values.listValuesRound1, "; ");
        };
    } else if (values.roundNumber == 2) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound2 = concat(values.listValuesRound2, list.myList.item(i));
            values.listValuesRound2 = concat(values.listValuesRound2, "; ");
        };
    } else if (values.roundNumber == 3) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound3 = concat(values.listValuesRound3, list.myList.item(i));
            values.listValuesRound3 = concat(values.listValuesRound3, "; ");
        };
    } else if (values.roundNumber == 4) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound4 = concat(values.listValuesRound4, list.myList.item(i));
            values.listValuesRound4 = concat(values.listValuesRound4, "; ");
        };
    }
]
/ trials = [1-3 = myTrial]
</block>+

<trial myTrial>
/ onTrialBegin = [
    values.myValue = list.myList.nextvalue;
]
/ stimulusframes = [1=clearScreen, myText]
/ validresponse = (57)
</trial>

<text myText>
/ items = ("Round #<%values.roundNumber%> | List value in this trial: <%values.myValue%>")
</text>

<data>
/ columns = (date, time, subject, group, session, blocknum, blockcode, trialnum, trialcode, response, latency, correct, values.myValue)
</data>

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.sessionid, script.elapsedtime, script.completed, values.listValuesRound1, values.listValuesRound2, values.listValuesRound3, values.listValuesRound4)
</summarydata>

Thanks for the sample code, Dave!

> IQX files you load into another script via <include> are no different than having the code contained in those IQX files in the main script. It does not matter where your <list> resides.

I see. Good to know.
Best,
EN
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: 108K
Dave - 7/10/2025
EN - 7/10/2025
Hello:

I'm building an experiment to run online. Because it involves many steps, things are compartmentalized into different IQX files (the sub-files), which are all "included" in the main IQX file.
I would like to save the data stored on a list --whose values are computed in one of the sub IQX file-- to the summary data file, which is defined in the main IQX file.

I guess one way to bring the data, so to say, to the main IQX file is to have the list defined in the main IQX file, and only referred to in the sub IQX file.

However, I haven't figure out a good way to save the data on the list to the summary data file. Would appreciate if you have any suggestions!

I know the size of the lists I want to save so I guess I could store the data on the list into named variables, e.g., xxx001, xxx002, xxx003. I wonder if there is a more general way to do that other than manually assign N times the values, as in values.xxx001 = list.randnum.nextValue, values.xxx002 = list.randnum.nextValue, etc. (after resetting the list so that it starts from the beginning...

Thanks in advance,

EN
---

<text myText>
/ items = ("<%list.randnum.nextValue%> -- Press the space bar to continue")
/ fontStyle = ("Arial", 2.08%, false, false, false, false, 5, 1)
</text>

<trial myTrial>
/ preTrialPause = 500
/ stimulusTimes = [1=myText]
/ validResponse = (" ")
</trial>

<list randnum>
/ selectionMode = sequence
</list>

<block myBlock> // that would be defined in a separate IQX file
/ onBlockBegin = [
    // List of random numbers
    list.randnum.appendItem(rand(0, 10)); //1
    list.randnum.appendItem(rand(0, 10)); //2
    list.randnum.appendItem(rand(0, 10)); //3
    list.randnum.appendItem(rand(0, 10)); //4
    list.randnum.appendItem(rand(0, 10)); //5
    list.randnum.appendItem(rand(0, 10)); //6
    list.randnum.appendItem(rand(0, 10)); //7
    list.randnum.appendItem(rand(0, 10)); //8
    list.randnum.appendItem(rand(0, 10)); //9
    list.randnum.appendItem(rand(0, 10)); //10
]

/ trials = [1-10=myTrial]
</block>

<expt myExpt> // I would like to save the values in randnum in the summary data file defined in the IQX where the expt is defined
/ preInstructions = (myPage)
/ blocks = [1=myBlock]
</expt>


<page myPage>
On the following 10 trials, press the space bar
</page>

IQX files you load into another script via <include> are no different than having the code contained in those IQX files in the main script. It does not matter where your <list> resides.

If you want to output every single value contained in a list to the single-line summary data, then you indeed need to either define a variable for each item in the list and log those variables, or -- at a minimum -- loop through the list's items at some point, concat() all its items into a string, and log that string.

Example for the latter:

<values>
/ roundNumber = 0
/ myValue = null
/ listValuesRound1 = null
/ listValuesRound2 = null
/ listValuesRound3 = null
/ listValuesRound4 = null
</values>

<list myList>
</list>

<expt myExpt>
/ blocks = [1-4 = myBlock]
</expt>

<block myBlock>
/ onBlockBegin = [
    values.roundNumber += 1;
    list.myList.reset();
    list.myList.appenditem(round(rand(1,99999999)));
    list.myList.appenditem(round(rand(1,99999999)));
    list.myList.appenditem(round(rand(1,99999999)));
]
/ onBlockEnd = [
    var i = 0;
    if (values.roundNumber == 1) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound1 = concat(values.listValuesRound1, list.myList.item(i));
            values.listValuesRound1 = concat(values.listValuesRound1, "; ");
        };
    } else if (values.roundNumber == 2) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound2 = concat(values.listValuesRound2, list.myList.item(i));
            values.listValuesRound2 = concat(values.listValuesRound2, "; ");
        };
    } else if (values.roundNumber == 3) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound3 = concat(values.listValuesRound3, list.myList.item(i));
            values.listValuesRound3 = concat(values.listValuesRound3, "; ");
        };
    } else if (values.roundNumber == 4) {
        i = 0;
        while (i < list.myList.itemCount) {
            i += 1;
            values.listValuesRound4 = concat(values.listValuesRound4, list.myList.item(i));
            values.listValuesRound4 = concat(values.listValuesRound4, "; ");
        };
    }
]
/ trials = [1-3 = myTrial]
</block>+

<trial myTrial>
/ onTrialBegin = [
    values.myValue = list.myList.nextvalue;
]
/ stimulusframes = [1=clearScreen, myText]
/ validresponse = (57)
</trial>

<text myText>
/ items = ("Round #<%values.roundNumber%> | List value in this trial: <%values.myValue%>")
</text>

<data>
/ columns = (date, time, subject, group, session, blocknum, blockcode, trialnum, trialcode, response, latency, correct, values.myValue)
</data>

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.sessionid, script.elapsedtime, script.completed, values.listValuesRound1, values.listValuesRound2, values.listValuesRound3, values.listValuesRound4)
</summarydata>

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: 108K
EN - 7/10/2025
Hello:

I'm building an experiment to run online. Because it involves many steps, things are compartmentalized into different IQX files (the sub-files), which are all "included" in the main IQX file.
I would like to save the data stored on a list --whose values are computed in one of the sub IQX file-- to the summary data file, which is defined in the main IQX file.

I guess one way to bring the data, so to say, to the main IQX file is to have the list defined in the main IQX file, and only referred to in the sub IQX file.

However, I haven't figure out a good way to save the data on the list to the summary data file. Would appreciate if you have any suggestions!

I know the size of the lists I want to save so I guess I could store the data on the list into named variables, e.g., xxx001, xxx002, xxx003. I wonder if there is a more general way to do that other than manually assign N times the values, as in values.xxx001 = list.randnum.nextValue, values.xxx002 = list.randnum.nextValue, etc. (after resetting the list so that it starts from the beginning...

Thanks in advance,

EN
---

<text myText>
/ items = ("<%list.randnum.nextValue%> -- Press the space bar to continue")
/ fontStyle = ("Arial", 2.08%, false, false, false, false, 5, 1)
</text>

<trial myTrial>
/ preTrialPause = 500
/ stimulusTimes = [1=myText]
/ validResponse = (" ")
</trial>

<list randnum>
/ selectionMode = sequence
</list>

<block myBlock> // that would be defined in a separate IQX file
/ onBlockBegin = [
    // List of random numbers
    list.randnum.appendItem(rand(0, 10)); //1
    list.randnum.appendItem(rand(0, 10)); //2
    list.randnum.appendItem(rand(0, 10)); //3
    list.randnum.appendItem(rand(0, 10)); //4
    list.randnum.appendItem(rand(0, 10)); //5
    list.randnum.appendItem(rand(0, 10)); //6
    list.randnum.appendItem(rand(0, 10)); //7
    list.randnum.appendItem(rand(0, 10)); //8
    list.randnum.appendItem(rand(0, 10)); //9
    list.randnum.appendItem(rand(0, 10)); //10
]

/ trials = [1-10=myTrial]
</block>

<expt myExpt> // I would like to save the values in randnum in the summary data file defined in the IQX where the expt is defined
/ preInstructions = (myPage)
/ blocks = [1=myBlock]
</expt>


<page myPage>
On the following 10 trials, press the space bar
</page>

IQX files you load into another script via <include> are no different than having the code contained in those IQX files in the main script. It does not matter where your <list> resides.

If you want to output every single value contained in a list to the single-line summary data, then you indeed need to either define a variable for each item in the list and log those variables, or -- at a minimum -- loop through the list's items at some point, concat() all its items into a string, and log that string.
Edited 2 days ago @ 4:14 AM by Dave
EN
EN
Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)
Group: Forum Members
Posts: 45, Visits: 224
Hello:

I'm building an experiment to run online. Because it involves many steps, things are compartmentalized into different IQX files (the sub-files), which are all "included" in the main IQX file.
I would like to save the data stored on a list --whose values are computed in one of the sub IQX file-- to the summary data file, which is defined in the main IQX file.

I guess one way to bring the data, so to say, to the main IQX file is to have the list defined in the main IQX file, and only referred to in the sub IQX file.

However, I haven't figure out a good way to save the data on the list to the summary data file. Would appreciate if you have any suggestions!

I know the size of the lists I want to save so I guess I could store the data on the list into named variables, e.g., xxx001, xxx002, xxx003. I wonder if there is a more general way to do that other than manually assign N times the values, as in values.xxx001 = list.randnum.nextValue, values.xxx002 = list.randnum.nextValue, etc. (after resetting the list so that it starts from the beginning...

Thanks in advance,

EN
---

<text myText>
/ items = ("<%list.randnum.nextValue%> -- Press the space bar to continue")
/ fontStyle = ("Arial", 2.08%, false, false, false, false, 5, 1)
</text>

<trial myTrial>
/ preTrialPause = 500
/ stimulusTimes = [1=myText]
/ validResponse = (" ")
</trial>

<list randnum>
/ selectionMode = sequence
</list>

<block myBlock> // that would be defined in a separate IQX file
/ onBlockBegin = [
    // List of random numbers
    list.randnum.appendItem(rand(0, 10)); //1
    list.randnum.appendItem(rand(0, 10)); //2
    list.randnum.appendItem(rand(0, 10)); //3
    list.randnum.appendItem(rand(0, 10)); //4
    list.randnum.appendItem(rand(0, 10)); //5
    list.randnum.appendItem(rand(0, 10)); //6
    list.randnum.appendItem(rand(0, 10)); //7
    list.randnum.appendItem(rand(0, 10)); //8
    list.randnum.appendItem(rand(0, 10)); //9
    list.randnum.appendItem(rand(0, 10)); //10
]

/ trials = [1-10=myTrial]
</block>

<expt myExpt> // I would like to save the values in randnum in the summary data file defined in the IQX where the expt is defined
/ preInstructions = (myPage)
/ blocks = [1=myBlock]
</expt>


<page myPage>
On the following 10 trials, press the space bar
</page>
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search