Millisecond Forums

Port open during the experiment

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

By Athanasia - 1/26/2021

Dear Dave,
For our experiment, we have 5 different ports. 4 with odors and 1 with air. We want the air port to be open during instructions/break pages and pretrial jittered intervals. Then, within the trial at stimulus times 0 we still want it open, then change at stimulustimes 2850 to one of the other 4 ports in a random way (solved) and then go back to air port at stimulustime 5000 till the end of the trial.
I thought about the /onexptbegin attribute, to ensure that the port will be also open during the non-trial parts, but I am not sure if this command interferes to the trial stimulustimes command.

<trial xx>
/ ontrialbegin = [trial.xx.resetstimulusframes();
         trial.xx.insertstimulustime(list.xx_odors.nextvalue, 2850);]
/ stimulustimes = [0=port.V5;** 0 = 3; 1000 = 2; 2000 = 1; 3000 = inhale; 5000 = Square; 5000 = port.V5; 7000 = list.Fear_Pictures; 7200 = Square; 7200 = Answer;]
/ pretrialpause = noreplace(1050,1550,2050,2550)

</trial>
<expt complete>
/onexptbegin = [port.V5]

<expt>
** is this necessary or it’s interpreted as a way to close the port when the same command with onexpt begin is repeated at the beginning of the trial?
Thank you in advance for your help.
By Dave - 1/26/2021

Athanasia - 1/26/2021
Dear Dave,
For our experiment, we have 5 different ports. 4 with odors and 1 with air. We want the air port to be open during instructions/break pages and pretrial jittered intervals. Then, within the trial at stimulus times 0 we still want it open, then change at stimulustimes 2850 to one of the other 4 ports in a random way (solved) and then go back to air port at stimulustime 5000 till the end of the trial.
I thought about the /onexptbegin attribute, to ensure that the port will be also open during the non-trial parts, but I am not sure if this command interferes to the trial stimulustimes command.

<trial xx>
/ ontrialbegin = [trial.xx.resetstimulusframes();
         trial.xx.insertstimulustime(list.xx_odors.nextvalue, 2850);]
/ stimulustimes = [0=port.V5;** 0 = 3; 1000 = 2; 2000 = 1; 3000 = inhale; 5000 = Square; 5000 = port.V5; 7000 = list.Fear_Pictures; 7200 = Square; 7200 = Answer;]
/ pretrialpause = noreplace(1050,1550,2050,2550)

</trial>
<expt complete>
/onexptbegin = [port.V5]

<expt>
** is this necessary or it’s interpreted as a way to close the port when the same command with onexpt begin is repeated at the beginning of the trial?
Thank you in advance for your help.

A <port> element is a stimulus. It can be displayed by a <trial>'s /stimulustimes or -frames or by a block's /bgstim. There is no way to display stimuli via /onexptbegin, that's not its purpose.
By Athanasia - 1/26/2021


So, there is no way to have this port open during non trial parts (Instructions, break pages, jittered intervals in between trials)? 
By Athanasia - 1/26/2021


Sorry for my mispell, I mean non-block parts (like instruction pages). 
By Dave - 1/26/2021

> So, there is no way to have this port open during non trial parts (Instructions, break pages, jittered intervals in between trials)?

Make your instructions, break pages, and jittered intervals regular <trial> elements and you can have the port open just like in any other <trial> element. Otherwise, no.
By Athanasia - 1/28/2021

Sorry that I ‘m reaching out for the same issue, but there is a lot of struggle here with no light at the end of the tunnel.
So,
block's /bgstim seemed that it would solve the problem at least of instructions, because they are at the beginning of each block so the port would open and stay on till at least the trials start. However, this didn’t work and the port does not open when the instruction pages appear.
Also, when another port opens during trial, bgstim is overwritten.
Then, trying to make instruction/ break pages and jittered intervals trial elements has also troubled me. Instruction pages are not considered stimuli, so they can be displayed by a <trial>'s /stimulustimes or –frames. Converting them to <text> stimuli is also inconvenient because the layout is messed up and   / responseinterrupt does not seem to work either.
Same with break pages. Then, regarding jittered intervals I cannot think of a way that different time intervals could be presented as stimuli or trial elements.
I am attaching the script if this is of any help
I really appreciate your help so far and thank you for your time.
By Dave - 1/28/2021

Athanasia - 1/28/2021
Sorry that I ‘m reaching out for the same issue, but there is a lot of struggle here with no light at the end of the tunnel.
So,
block's /bgstim seemed that it would solve the problem at least of instructions, because they are at the beginning of each block so the port would open and stay on till at least the trials start. However, this didn’t work and the port does not open when the instruction pages appear.
Also, when another port opens during trial, bgstim is overwritten.
Then, trying to make instruction/ break pages and jittered intervals trial elements has also troubled me. Instruction pages are not considered stimuli, so they can be displayed by a <trial>'s /stimulustimes or –frames. Converting them to <text> stimuli is also inconvenient because the layout is messed up and   / responseinterrupt does not seem to work either.
Same with break pages. Then, regarding jittered intervals I cannot think of a way that different time intervals could be presented as stimuli or trial elements.
I am attaching the script if this is of any help
I really appreciate your help so far and thank you for your time.

> block's /bgstim seemed that it would solve the problem at least of instructions, because they are at the beginning of each block so the port would open and stay on till at least the trials > start. However, this didn’t work and the port does not open when the instruction pages appear.

No. That's the expected behavior. /bgstim is executed before the *trials* start, not before any instruction pages.

> Also, when another port opens during trial, bgstim is overwritten.

/bgstim is executed exactly once, at the time explained above, so this is again the expected behavior.

Again, as mentioned before:
- Present your instructions via regular <trial> elements in a <block>, not <page> or the like.
- Same with any "break" pages.
- Regarding
> Then, regarding jittered intervals I cannot think of a way that different time intervals could be presented as stimuli or trial elements.

Just branch to a <trial iti> from every regular trial and set that ITI <trial>'s /trialduration via a variable. You'll get jittered intervals implemented as a regular trial and that trial can open the air port just like any other.