Millisecond Forums

Port code not working, how to add variables to data

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

By Christin41 - 12/9/2020

For an experiment I am using the following logic, to display all 5 odors in random order during the 5 different trials. Doing this with text elements also does work, when using this port code, however, only the first odor is presented (so only the first valve [together with the other two valves that that port code opens] is opened). Any idea what I did wrong? 
Also I was wondering how to add a variable to the data that displays what odor was presented to the participant during a given try?
Thank you so much in advance!!

This is the used port code: 
<item odor_items>
/ 1 = "01100001"
/ 2 = "01100010"
/ 3 = "01100100"
/ 4 = "01101000"
/ 5 = "01110000"
</item>

<port all_odors>
/ items = odor_items
/ port = LPT
</port>

<list all_odors>
/ items = (port.all_odors)
</list>

<trial rating>
/ ontrialbegin = [trial.rating.resetstimulusframes();
                 trial.rating.insertstimulustime(list.all_odors.nextvalue, 2850)]
/ stimulustimes = [0=port.air; 0=3; 1000=2; 2000=1; 3000=inhale; 5000=port.air]
/ timeout = 5000
/ pretrialpause = 1000
</trial>
(3, 2, 1 and inhale are all text elements, port.air is the same as the port code of item 5 in the item element)

And here the (working) text code:
<item odor_items>
/ 1 = "Fear1"
/ 2 = "Fear2"
/ 3 = "Neutral1"
/ 4 = "Neutral2"
/ 5 = "Air"
</item>

<text all_odors>
/ items = odor_items
/ fontstyle = ("Arial", 9%, true, false, false, false, 5, 1)
/ position = (50, 65)
/ erase = true(black)
</text>

<list all_odors>
/ items = (text.all_odors)
</list>

<trial rating>
/ ontrialbegin = [trial.rating.resetstimulusframes();
                 trial.rating.insertstimulustime(list.all_odors.nextvalue, 2850)]
/ stimulustimes = [0=3; 1000=2; 2000=1; 3000=inhale]
/ timeout = 5000
/ pretrialpause = 1000
</trial>
(3, 2, 1 and inhale are all text elements)

By Dave - 12/9/2020

Do

<port all_odors>
/ items = ("01100001", "01100010", "01100100", "01101000", "01110000")
/ port = LPT
</port>

instead of using an <item> element.

> Also I was wondering how to add a variable to the data that displays what odor was presented to the participant during a given try?

You already have that in the data file, in the stimulusitem and stimulusnumber column pertaining to the port stimulus.

By Christin41 - 12/14/2020

Dave - 12/9/2020
Do

<port all_odors>
/ items = ("01100001", "01100010", "01100100", "01101000", "01110000")
/ port = LPT
</port>

instead of using an <item> element.

> Also I was wondering how to add a variable to the data that displays what odor was presented to the participant during a given try?

You already have that in the data file, in the stimulusitem and stimulusnumber column pertaining to the port stimulus.


Thank you for your helpful reply!

I am unfortunately unable to see the stimulusitem and stimulusnumber columns pertaining to the port stimulus....

This is the data element that I currently have (with values.reference_odor_item, values.comparison_odor_item and values.is_reference pertaining to another task within the experiment):

<data>
/ columns = (date time group subject session build blocknum blockcode trialnum trialcode values.reference_odor_item values.comparison_odor_item values.is_reference response correct latency pretrialpause posttrialpause trialduration trialtimeout
stimulusnumber stimulusitem stimulusonset)
</data>
By Dave - 12/14/2020

Christin41 - 12/14/2020
Dave - 12/9/2020
Do

<port all_odors>
/ items = ("01100001", "01100010", "01100100", "01101000", "01110000")
/ port = LPT
</port>

instead of using an <item> element.

> Also I was wondering how to add a variable to the data that displays what odor was presented to the participant during a given try?

You already have that in the data file, in the stimulusitem and stimulusnumber column pertaining to the port stimulus.


Thank you for your helpful reply!

I am unfortunately unable to see the stimulusitem and stimulusnumber columns pertaining to the port stimulus....

This is the data element that I currently have (with values.reference_odor_item, values.comparison_odor_item and values.is_reference pertaining to another task within the experiment):

<data>
/ columns = (date time group subject session build blocknum blockcode trialnum trialcode values.reference_odor_item values.comparison_odor_item values.is_reference response correct latency pretrialpause posttrialpause trialduration trialtimeout
stimulusnumber stimulusitem stimulusonset)
</data>

With only one set of stimulusnumber/stimulusitem columns, you're only logging the first stimulus displayed by any trial.
By Dave - 12/14/2020

Dave - 12/14/2020
Christin41 - 12/14/2020
Dave - 12/9/2020
Do

<port all_odors>
/ items = ("01100001", "01100010", "01100100", "01101000", "01110000")
/ port = LPT
</port>

instead of using an <item> element.

> Also I was wondering how to add a variable to the data that displays what odor was presented to the participant during a given try?

You already have that in the data file, in the stimulusitem and stimulusnumber column pertaining to the port stimulus.


Thank you for your helpful reply!

I am unfortunately unable to see the stimulusitem and stimulusnumber columns pertaining to the port stimulus....

This is the data element that I currently have (with values.reference_odor_item, values.comparison_odor_item and values.is_reference pertaining to another task within the experiment):

<data>
/ columns = (date time group subject session build blocknum blockcode trialnum trialcode values.reference_odor_item values.comparison_odor_item values.is_reference response correct latency pretrialpause posttrialpause trialduration trialtimeout
stimulusnumber stimulusitem stimulusonset)
</data>

With only one set of stimulusnumber/stimulusitem columns, you're only logging the first stimulus displayed by any trial.

If you don't want to add further stimulusnumber/stimulusitem columns, you can also use <values> of course.

<values>
...
/ current_odor = 0
</values>

<trial rating>
/ ontrialbegin = [trial.rating.resetstimulusframes();
      trial.rating.insertstimulustime(list.all_odors.nextvalue, 2850)]
/ ontrialend = [values.current_odor = port.all_odors.currentindex;]
/ stimulustimes = [0=port.air; 0=3; 1000=2; 2000=1; 3000=inhale; 5000=port.air]
/ timeout = 5000
/ pretrialpause = 1000
</trial>

<data>
/ columns = (..., values.current_odor, ...)
...
</data>