Millisecond Forums

Presenting Images

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

By cutkiller - 5/8/2017

I need to make a simple script which displays 20 images and collects 20 answers (one for each image), but I have a lot of trouble figuring it out, I've never used Inquisit and I'm not a programmer. Could anyone help? I'm thinking this is extremely simple to program, I just can't figure out the actual script.

Thank you.
By Dave - 5/8/2017

cutkiller - Monday, May 8, 2017
I need to make a simple script which displays 20 images and collects 20 answers (one for each image), but I have a lot of trouble figuring it out, I've never used Inquisit and I'm not a programmer. Could anyone help? I'm thinking this is extremely simple to program, I just can't figure out the actual script.

Thank you.

At a minimum, you need a <picture> element with the 20 images as its items, a <trial> element that displays the <picture> element and collects a response, and a <block> that runs the <trial> 20 times.

<picture mypicture>
/ items = pictureitems
...
</picture>

<item pictureitems>
/ 1 = "image01.jpg"
...
/ 20 = "image20.jpg"
</item>

<trial mytrial>
/ stimulusframes = [1=mypicture]
...
</trial>

<block myblock>
/ trials = [1-20 = mytrial]
...
</block>

Depending on what kind of "answer" you need to collect, you might want to use either <likert> or <openended> elements instead of <trial>.

The Picture IAT tutorial in the Inquisit documentation might be worth a look, too, you'll find the relevant basics covered there in some greater detail.
By cutkiller - 5/8/2017

Thanks so much, this helps a lot.

I just wanna display 20 pictures and have subjects press a key (enter or whatever other key) to display a field in which they write what they see. I'm guessing that would be <openended>?

I'm displaying the pictures full screen and that's why I want to have the field pop up after they look at it, so they're unobstructed while the subjects look at them.

Not sure what goes in here

<picture mypicture>
/ items = pictureitems
...
</picture>

Right now I'm getting an error saying Could not locate trial 'pictureitems'

Thanks again.


By Dave - 5/8/2017

cutkiller - Monday, May 8, 2017
Thanks so much, this helps a lot.

I just wanna display 20 pictures and have subjects press a key (enter or whatever other key) to display a field in which they write what they see. I'm guessing that would be <openended>?

I'm displaying the pictures full screen and that's why I want to have the field pop up after they look at it, so they're unobstructed while the subjects look at them.

Not sure what goes in here

<picture mypicture>
/ items = pictureitems
...
</picture>

Right now I'm getting an error saying Could not locate trial 'pictureitems'

Thanks again.



> Not sure what goes in here

<picture mypicture>
/ items = pictureitems
...
</picture>

refers to the <item> element in the example code I posted:

<item pictureitems>
/ 1 = "image01.jpg"
...
/ 20 = "image20.jpg"
</item>

That's where you would list your 20 image items.

> I just wanna display 20 pictures and have subjects press a key (enter or whatever other key) to display a field in which they write what they see.

Then you would use *both* a <trial> element -- to display the image full screen and wait for a key press -- followed by an <openended> to collect the description. In a nutshell:

<picture mypicture>
/ items = pictureitems
/ select = noreplace
/ size = (100%, 100%)
</picture>

<item pictureitems>
/ 1 = "image01.jpg"
/ 2 = "image02.jpg"
/ 3 = "image03.jpg"
/ 4 = "image04.jpg"
/ 5 = "image05.jpg"
/ 6 = "image06.jpg"
/ 7 = "image07.jpg"
/ 8 = "image08.jpg"
/ 9 = "image09.jpg"
/ 10 = "image10.jpg"
/ 11 = "image11.jpg"
/ 12 = "image12.jpg"
/ 13 = "image13.jpg"
/ 14 = "image14.jpg"
/ 15 = "image15.jpg"
/ 16 = "image16.jpg"
/ 17 = "image17.jpg"
/ 18 = "image18.jpg"
/ 19 = "image19.jpg"
/ 20 = "image20.jpg"
</item>

// press spacebar to move on
<trial showpicture>
/ stimulusframes = [1=mypicture]
/ validresponse = (57)
</trial>

<openended typeanswer>
/ stimulusframes = [1=typeprompt]
/ size = (70%, 40%)
/ position = (50%, 70%)
/ multiline = true
/ charlimit = 10000
</openended>

<text typeprompt>
/ items = ("Please describe what you saw:")
/ position = (50%, 20%)
</text>

<block myblock>
/ trials = [1-20 = sequence(showpicture, typeanswer)]
</block>



By cutkiller - 5/8/2017

Thank you so much, it works like a charm. One more thing: do you happen to know why they're displayed randomly? Need them to be displayed in that order (1-20), but it starts with a different one each time and it shows them in a random order.
By Dave - 5/8/2017

cutkiller - Monday, May 8, 2017
Thank you so much, it works like a charm. One more thing: do you happen to know why they're displayed randomly? Need them to be displayed in that order (1-20), but it starts with a different one each time and it shows them in a random order.

Random item selection is the default -- and I explicitly set it, because that's what most people want. For sequential selection, simply change

<picture mypicture>
/ items = pictureitems
/ select = noreplace
/ size = (100%, 100%)
</picture>

(noreplace = random selection without replacement)

to 

<picture mypicture>
/ items = pictureitems
/ select = sequence
/ size = (100%, 100%)
</picture>

(sequence = sequential selection, i.e. items are selected in the order given)

Hope this helps.
By cutkiller - 5/8/2017

Helps a lot, it's exactly what I needed. Thank you.
By cutkiller - 5/10/2017

One more question here. If instead of asking participants what they saw in each image, I would want to have them press different keys if they decide they saw something (Y for Yes, where a textbox appears in which they can write their answer and N for No and the image just skips to the next one) how would I do that?

Thank you.
By Dave - 5/10/2017

cutkiller - Wednesday, May 10, 2017
One more question here. If instead of asking participants what they saw in each image, I would want to have them press different keys if they decide they saw something (Y for Yes, where a textbox appears in which they can write their answer and N for No and the image just skips to the next one) how would I do that?

Thank you.

Like this, for example:

<picture mypicture>
/ items = pictureitems
/ select = sequence
/ size = (100%, 100%)
</picture>

<item pictureitems>
/ 1 = "image01.jpg"
/ 2 = "image02.jpg"
/ 3 = "image03.jpg"
/ 4 = "image04.jpg"
/ 5 = "image05.jpg"
/ 6 = "image06.jpg"
/ 7 = "image07.jpg"
/ 8 = "image08.jpg"
/ 9 = "image09.jpg"
/ 10 = "image10.jpg"
/ 11 = "image11.jpg"
/ 12 = "image12.jpg"
/ 13 = "image13.jpg"
/ 14 = "image14.jpg"
/ 15 = "image15.jpg"
/ 16 = "image16.jpg"
/ 17 = "image17.jpg"
/ 18 = "image18.jpg"
/ 19 = "image19.jpg"
/ 20 = "image20.jpg"
</item>

// press y or n
<trial showpicture>
/ stimulusframes = [1=mypicture]
/ validresponse = ("y", "n")
/ correctresponse = ("y")

</trial>

// skip openended if answer in showpicture trial was wrong (= "n"; no, did not see anything)
<openended typeanswer>
/ skip = [trial.showpicture.error]
/ stimulusframes = [1=typeprompt]
/ size = (70%, 40%)
/ position = (50%, 70%)
/ multiline = true
/ charlimit = 10000
</openended>

<text typeprompt>
/ items = ("Please describe what you saw:")
/ position = (50%, 20%)
</text>

<block myblock>
/ trials = [1-20 = sequence(showpicture, typeanswer)]
</block>
By cutkiller - 5/11/2017

This is so great, thank you. Would it be possible to code the written answers in the previous entry? (If a correct answer is provided as Y and then described in the letterbox for image05.jpg, could the entry get a category which contains the answer)

It would be very helpful for moving the data to SPSS afterwards. Right now the text answer is coded in the text stimulus entry (Please describe what you saw:), which follows the image stimulus entry.

Hope it makes sense. Thank you.
By Dave - 5/11/2017

cutkiller - Thursday, May 11, 2017
This is so great, thank you. Would it be possible to code the written answers in the previous entry? (If a correct answer is provided as Y and then described in the letterbox for image05.jpg, could the entry get a category which contains the answer)

It would be very helpful for moving the data to SPSS afterwards. Right now the text answer is coded in the text stimulus entry (Please describe what you saw:), which follows the image stimulus entry.

Hope it makes sense. Thank you.

> This is so great, thank you. Would it be possible to code the written answers in the previous entry?
> (If a correct answer is provided as Y and then described in the letterbox for image05.jpg, could the entry get a category which contains the answer)

Not sure I fully understand this description. Specifically, with respect to "could the entry get a category which contains the answer":
(1) Which "entry"?
(2) What do you mean by "category"?

Perhaps give me a concrete example of how you want the data output to look in *both* the case of a "y" response plus written description and the case of a "n" response.
By cutkiller - 5/11/2017


I'd need the "cat on the right side" and "raindeer in the center" to be encoded in the 03.png and 06.png lines, respectively. After 50pct and 20pct, I would need an extra category which says "answer". Maybe that means it should be associated with the image stimulus and just have a textbox pop up over the image when you press Y? (might not be possible, but having the response in the same line as the yes/no answer would help when dealing with larger amounts of data).

Thanks.

By Dave - 5/11/2017

cutkiller - Thursday, May 11, 2017

I'd need the "cat on the right side" and "raindeer in the center" to be encoded in the 03.png and 06.png lines, respectively. After 50pct and 20pct, I would need an extra category which says "answer". Maybe that means it should be associated with the image stimulus and just have a textbox pop up over the image when you press Y? (might not be possible, but having the response in the same line as the yes/no answer would help when dealing with larger amounts of data).

Thanks.


To do this, you should make use of a bunch of global variables (<values>), a dedicated <trial> run after the showpicture-trial and openended to dump the data, and lastly the <data> element's /columns attribute, which allows you to specify exactly what you do and do not want recorded:

<picture mypicture>
/ items = pictureitems
/ select = sequence
/ size = (100%, 100%)
</picture>

<item pictureitems>
/ 1 = "image01.jpg"
/ 2 = "image02.jpg"
/ 3 = "image03.jpg"
/ 4 = "image04.jpg"
/ 5 = "image05.jpg"
/ 6 = "image06.jpg"
/ 7 = "image07.jpg"
/ 8 = "image08.jpg"
/ 9 = "image09.jpg"
/ 10 = "image10.jpg"
/ 11 = "image11.jpg"
/ 12 = "image12.jpg"
/ 13 = "image13.jpg"
/ 14 = "image14.jpg"
/ 15 = "image15.jpg"
/ 16 = "image16.jpg"
/ 17 = "image17.jpg"
/ 18 = "image18.jpg"
/ 19 = "image19.jpg"
/ 20 = "image20.jpg"
</item>

// press y or n
<trial showpicture>
/ ontrialend = [
    values.pictrialnumber += 1;
    values.picitem = picture.mypicture.currentitem;
    values.picdescription = "";
    values.picdescriptionlatency = "";
    values.showpiclatency = trial.showpicture.latency;
]
/ ontrialend = [if(trial.showpicture.correct) values.showpicresponse = "y" else values.showpicresponse = "n"]
/ stimulusframes = [1=mypicture]
/ validresponse = ("y", "n")
/ correctresponse = ("y")
/ recorddata = false
</trial>

// skip openended if answer in showpicture trial was wrong (= "n"; no, did not see anything)
<openended typeanswer>
/ skip = [trial.showpicture.error]
/ ontrialend = [
    values.picdescription = openended.typeanswer.response;
    values.picdescriptionlatency = openended.typeanswer.latency;
]
/ stimulusframes = [1=typeprompt]
/ size = (70%, 40%)
/ position = (50%, 70%)
/ multiline = true
/ charlimit = 10000
/ recorddata = false
</openended>

// record data for the two above elements in a single line
<trial picdata>
/ recorddata = true
/ trialduration = 0
/ validresponse = (0)
</trial>

<text typeprompt>
/ items = ("Please describe what you saw:")
/ position = (50%, 20%)
</text>

<block myblock>
/ trials = [1-20 = sequence(showpicture, typeanswer, picdata)]
</block>

<values>
/ pictrialnumber = 0
/ picitem = ""
/ showpicresponse = ""
/ showpiclatency = ""
/ picdescription = ""
/ picdescriptionlatency = ""
</values>

<data>
/ columns = [date, time, subject, group, values.pictrialnumber, values.showpiclatency, values.showpicresponse,
    values.picitem, values.picdescription, values.picdescriptionlatency]
</data>

By cutkiller - 5/12/2017

Ah, this is perfect. Thank you so much.

I just need a briefing intro page and after that, before the images are displayed, a drop down/bulletpoint list with 3 entries asking the participants what their emotional state at the time of the testing is (bad/neutral/good) and that would be everything. How would I do that?

Thanks again and have a great weekend.
By Dave - 5/12/2017

cutkiller - Friday, May 12, 2017
Ah, this is perfect. Thank you so much.

I just need a briefing intro page and after that, before the images are displayed, a drop down/bulletpoint list with 3 entries asking the participants what their emotional state at the time of the testing is (bad/neutral/good) and that would be everything. How would I do that?

Thanks again and have a great weekend.

For the briefing page set up a <page> element and display it via an <expt>'s /preinstructions.

For the emotional state question, set up a <surveypage> with a <dropdown>, put the page in a <block>, run the now two <block>s via the <expt>.

<picture mypicture>
/ items = pictureitems
/ select = sequence
/ size = (100%, 100%)
</picture>

<item pictureitems>
/ 1 = "image01.jpg"
/ 2 = "image02.jpg"
/ 3 = "image03.jpg"
/ 4 = "image04.jpg"
/ 5 = "image05.jpg"
/ 6 = "image06.jpg"
/ 7 = "image07.jpg"
/ 8 = "image08.jpg"
/ 9 = "image09.jpg"
/ 10 = "image10.jpg"
/ 11 = "image11.jpg"
/ 12 = "image12.jpg"
/ 13 = "image13.jpg"
/ 14 = "image14.jpg"
/ 15 = "image15.jpg"
/ 16 = "image16.jpg"
/ 17 = "image17.jpg"
/ 18 = "image18.jpg"
/ 19 = "image19.jpg"
/ 20 = "image20.jpg"
</item>

// press y or n
<trial showpicture>
/ ontrialend = [
    values.pictrialnumber += 1;
    values.picitem = picture.mypicture.currentitem;
    values.picdescription = "";
    values.picdescriptionlatency = "";
    values.showpiclatency = trial.showpicture.latency;
]
/ ontrialend = [if(trial.showpicture.correct) values.showpicresponse = "y" else values.showpicresponse = "n"]
/ stimulusframes = [1=mypicture]
/ validresponse = ("y", "n")
/ correctresponse = ("y")
/ recorddata = false
</trial>

// skip openended if answer in showpicture trial was wrong (= "n"; no, did not see anything)
<openended typeanswer>
/ skip = [trial.showpicture.error]
/ ontrialend = [
    values.picdescription = openended.typeanswer.response;
    values.picdescriptionlatency = openended.typeanswer.latency;
]
/ stimulusframes = [1=typeprompt]
/ size = (70%, 40%)
/ position = (50%, 70%)
/ multiline = true
/ charlimit = 10000
/ recorddata = false
</openended>

// record data for the two above elements in a single line
<trial picdata>
/ recorddata = true
/ trialduration = 0
/ validresponse = (0)
</trial>

<text typeprompt>
/ items = ("Please describe what you saw:")
/ position = (50%, 20%)
</text>

<block picblock>
/ trials = [1-20 = sequence(showpicture, typeanswer, picdata)]
</block>

<block emoblock>
/ trials = [1=emopage]
</block>

<surveypage emopage>
/ ontrialend = [values.emostate = dropdown.emoquestion.response]
/ questions = [1=emoquestion]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown emoquestion>
/ caption = "Your current emotional state:"
/ options = ("bad", "neutral", "good")
</dropdown>


<expt>
/ preinstructions = (intro)
/ blocks = [1=emoblock; 2=picblock]
</expt>

<page intro>
^intro goes here.
</page>

<values>
/ pictrialnumber = 0
/ picitem = ""
/ showpicresponse = ""
/ showpiclatency = ""
/ picdescription = ""
/ picdescriptionlatency = ""
/ emostate = ""
</values>

<data>
/ columns = [date, time, subject, group, blocknum, blockcode, trialnu, trialcode, values.emostate, values.pictrialnumber, values.showpiclatency, values.showpicresponse,
    values.picitem, values.picdescription, values.picdescriptionlatency]
</data>

You will find most of those basics -- setting up trials, blocks, expts, instruction pages, survey questions, etc. -- covered in the tutorials in the Inquisit documentation. I recommend you give those a look if you haven't done so yet.
By cutkiller - 5/12/2017

This hepled a lot. Thank you. I'm getting an error message saying "Invalid expression trialnu". I'm guessing it has something to do with

/ columns = [date, time, subject, group, blocknum, blockcode, trialnu, trialcode, ?
By cutkiller - 5/14/2017

Managed to make that work. Is there any way to collect these answers horizontally for each subject, so I can have the vertical dimension reserved for separate subjects? Also, can I get the results to be associated with 0 for no and 1 for yes? I've been searching in the documentation, but I haven't found anything.

Thank you.


By Dave - 5/14/2017

cutkiller - Sunday, May 14, 2017
Managed to make that work. Is there any way to collect these answers horizontally for each subject, so I can have the vertical dimension reserved for separate subjects? Also, can I get the results to be associated with 0 for no and 1 for yes? I've been searching in the documentation, but I haven't found anything.

Thank you.



> Managed to make that work. Is there any way to collect these answers horizontally for each subject.

No. You will need to restructure the data using e.g SPSS. See e.g. http://www.tqmp.org/RegularArticles/vol02-1/p020/index.html

> Also, can I get the results to be associated with 0 for no and 1 for yes?

Yes, change

// press y or n
<trial showpicture>
/ ontrialend = [
    values.pictrialnumber += 1;
    values.picitem = picture.mypicture.currentitem;
    values.picdescription = "";
    values.picdescriptionlatency = "";
    values.showpiclatency = trial.showpicture.latency;
]
/ ontrialend = [if(trial.showpicture.correct) values.showpicresponse = "y" else values.showpicresponse = "n"]
/ stimulusframes = [1=mypicture]
/ validresponse = ("y", "n")
/ correctresponse = ("y")
/ recorddata = false
</trial>

to
// press y or n
<trial showpicture>
/ ontrialend = [
    values.pictrialnumber += 1;
    values.picitem = picture.mypicture.currentitem;
    values.picdescription = "";
    values.picdescriptionlatency = "";
    values.showpiclatency = trial.showpicture.latency;
]
/ ontrialend = [if(trial.showpicture.correct) values.showpicresponse = 1 else values.showpicresponse = 0]
/ stimulusframes = [1=mypicture]
/ validresponse = ("y", "n")
/ correctresponse = ("y")
/ recorddata = false
</trial>

By cutkiller - 5/15/2017

Ah, thanks for the info. Great help.

I tried adding an additional survey to collect the gender, but I can't make it work and I don't find anything in the help documentation. Any idea how I would do that?
By Dave - 5/15/2017

cutkiller - Monday, May 15, 2017
Ah, thanks for the info. Great help.

I tried adding an additional survey to collect the gender, but I can't make it work and I don't find anything in the help documentation. Any idea how I would do that?

In the same way as the emotional state is collected. To keep things simple, just add the gender question to the already existing surveypage. For an introduction to the various survey features, see the survey tutorial in the documentation: https://www.millisecond.com/support/docs/v4/html/tutorials/demographic_survey/surveytutorial.htm
By cutkiller - 5/15/2017

I tried adding another survey

<surveypage genderpage>
/ ontrialend = [values.emostate = dropdown.emoquestion.response]
/ questions = [1=genderquestion]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown genderquestion>
/ caption = "Gender:"
/ options = ("Male", "Female")
</dropdown>

But when I run it, nothing appears. Any clue why?
By Dave - 5/15/2017

cutkiller - Monday, May 15, 2017
I tried adding another survey

<surveypage genderpage>
/ ontrialend = [values.emostate = dropdown.emoquestion.response]
/ questions = [1=genderquestion]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown genderquestion>
/ caption = "Gender:"
/ options = ("Male", "Female")
</dropdown>

But when I run it, nothing appears. Any clue why?

A <surveypage> is a kind of <trial>. That trial needs to be run by a block (a <block> or <survey> element). That block needs to be run by the <expt>.

<picture mypicture>
/ items = pictureitems
/ select = sequence
/ size = (100%, 100%)
</picture>

<item pictureitems>
/ 1 = "image01.jpg"
/ 2 = "image02.jpg"
/ 3 = "image03.jpg"
/ 4 = "image04.jpg"
/ 5 = "image05.jpg"
/ 6 = "image06.jpg"
/ 7 = "image07.jpg"
/ 8 = "image08.jpg"
/ 9 = "image09.jpg"
/ 10 = "image10.jpg"
/ 11 = "image11.jpg"
/ 12 = "image12.jpg"
/ 13 = "image13.jpg"
/ 14 = "image14.jpg"
/ 15 = "image15.jpg"
/ 16 = "image16.jpg"
/ 17 = "image17.jpg"
/ 18 = "image18.jpg"
/ 19 = "image19.jpg"
/ 20 = "image20.jpg"
</item>

// press y or n
<trial showpicture>
/ ontrialend = [
    values.pictrialnumber += 1;
    values.picitem = picture.mypicture.currentitem;
    values.picdescription = "";
    values.picdescriptionlatency = "";
    values.showpiclatency = trial.showpicture.latency;
]
/ ontrialend = [if(trial.showpicture.correct) values.showpicresponse = "y" else values.showpicresponse = "n"]
/ stimulusframes = [1=mypicture]
/ validresponse = ("y", "n")
/ correctresponse = ("y")
/ recorddata = false
</trial>

// skip openended if answer in showpicture trial was wrong (= "n"; no, did not see anything)
<openended typeanswer>
/ skip = [trial.showpicture.error]
/ ontrialend = [
    values.picdescription = openended.typeanswer.response;
    values.picdescriptionlatency = openended.typeanswer.latency;
]
/ stimulusframes = [1=typeprompt]
/ size = (70%, 40%)
/ position = (50%, 70%)
/ multiline = true
/ charlimit = 10000
/ recorddata = false
</openended>

// record data for the two above elements in a single line
<trial picdata>
/ recorddata = true
/ trialduration = 0
/ validresponse = (0)
</trial>

<text typeprompt>
/ items = ("Please describe what you saw:")
/ position = (50%, 20%)
</text>

<block picblock>
/ trials = [1-20 = sequence(showpicture, typeanswer, picdata)]
</block>

<block emoblock>
/ trials = [1=emopage; 2=genderpage]
</block>

<surveypage emopage>
/ ontrialend = [values.emostate = dropdown.emoquestion.response]
/ questions = [1=emoquestion]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown emoquestion>
/ caption = "Your current emotional state:"
/ options = ("bad", "neutral", "good")
</dropdown>

<surveypage genderpage>
/ ontrialend = [values.gender = dropdown.genderquestion.response]
/ questions = [1=genderquestion]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown genderquestion>
/ caption = "Gender:"
/ options = ("Male", "Female")
</dropdown>

<expt>
/ preinstructions = (intro)
/ blocks = [1=emoblock; 2=picblock]
</expt>

<page intro>
^intro goes here.
</page>

<values>
/ pictrialnumber = 0
/ picitem = ""
/ showpicresponse = ""
/ showpiclatency = ""
/ picdescription = ""
/ picdescriptionlatency = ""
/ emostate = ""
/ gender = ""
</values>

<data>
/ columns = [date, time, subject, group, blocknum, blockcode, trialnum, trialcode, values.emostate, values.gender, values.pictrialnumber, values.showpiclatency, values.showpicresponse,
    values.picitem, values.picdescription, values.picdescriptionlatency]
</data>
By cutkiller - 5/15/2017

Makes sense. Thank you.