Millisecond Forums

Task Breaks Upon User Input

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

By DCole9 - 3/10/2015

Hey Inquisiteers,
I'm having an issue where my task will suddenly quit when a user inputs a value.  I had the experiment working but made some (what I thought were) minor changes and now it will not continue to the next trial.  Here is the problem code.. I would very much appreciate any help you could offer.


<trial InitialSelect>

/ontrialbegin = [values.responseRT = 0; values.numtrials += 1; values.numblock += 1]
/ontrialbegin = [values.startcolor = list.startcolor.nextvalue]
/ontrialbegin = [values.numcolor = values.startcolor]
/ontrialbegin = [values.lownumcolor = values.numcolor]
/ontrialbegin = [values.highnumcolor = values.numcolor]
/ontrialbegin = [text.highnumber.textcolor = values.numcolor]
/ontrialbegin = [text.lownumber.textcolor = values.numcolor]

/ontrialbegin = [text.highnumber.item.1 = list.numberlist.nextvalue]
/ontrialbegin = [text.lownumber.item.1 = text.highnumber.item.1]
/ontrialbegin = [values.number = text.highnumber.item.1]

/ontrialbegin = [values.stiminterval = list.stimulusinterval.nextvalue]
/ontrialbegin = [values.randomposition = list.randomposition.nextvalue]
/ontrialbegin = [values.randomdemand = list.randomdemand.nextvalue]


/ontrialbegin = [if ((values.number == "1") || (values.number == "3") || (values.number == "7") || (values.number == "9")) values.odd = 1 else values.odd = 0]
/ontrialbegin = [if ((values.number == "2") || (values.number == "4") || (values.number == "6") || (values.number == "8")) values.even = 1 else values.even = 0]
/ontrialbegin = [if ((values.number == "1") || (values.number == "2") || (values.number == "3") || (values.number == "4")) values.lowerthan = 1 else values.lowerthan = 0]
/ontrialbegin = [if ((values.number == "6") || (values.number == "7") || (values.number == "8") || (values.number == "9")) values.greaterthan = 1 else values.greaterthan = 0]

/ontrialbegin = [values.topchosen = 0; values.bottomchosen = 0; values.choiceRT = 0;
values.topchosenRT = 0; values.bottomchosenRT = 0; values.lowdemandchoiceRT = 0; values.highdemandchoiceRT = 0; values.trialelapsedtime = 0;
values.failed = 0; values.patch1chosencount = 0; values.patch2chosencount = 0; values.lowdemandchosen = 0; values.highdemandchosen = 0
]

/ontrialbegin = [if (values.randomposition == "1") values.patch1y = 40%]
/ontrialbegin = [if (values.randomposition == "1") values.patch2y = 60%]
/ontrialbegin = [if (values.randomposition == "2") values.patch1y = 60%]
/ontrialbegin = [if (values.randomposition == "2") values.patch2y = 40%]


/ontrialbegin = [text.diceroll.item.1 = list.rolldice.nextvalue]
/ontrialbegin = [values.diceoutcome = text.diceroll.item.1]

/ontrialbegin = [if (values.numblock == 1) {trial.initialselect.insertstimulusframe(picture.patch2, 1); trial.initialselect.insertstimulusframe(picture.patch1, 1)}]
/ontrialbegin = [if (values.numblock == 2) {trial.initialselect.insertstimulusframe(picture.patch3, 1); trial.initialselect.insertstimulusframe(picture.patch4, 1)}]
/ontrialbegin = [if (values.numblock == 3) {trial.initialselect.insertstimulusframe(picture.patch5, 1); trial.initialselect.insertstimulusframe(picture.patch6, 1)}]
/ontrialbegin = [if (values.numblock == 4) {trial.initialselect.insertstimulusframe(picture.patch7, 1); trial.initialselect.insertstimulusframe(picture.patch8, 1)}]


/stimulusframes = [1 = choose]
/validresponse = (20, 48)

/timeout = 5000

/ontrialend = [if ((trial.InitialSelect.response == "20") && (values.randomposition == "1")) values.topchosen = 1; values.patch1chosencount = 1; values.patch2chosencount = 0]
/ontrialend = [if ((trial.InitialSelect.response == "20") && (values.randomposition == "1")) values.totaltopchosencount += 1; values.totalpatch1chosencount += 1]
/ontrialend = [if ((trial.InitialSelect.response == "20") && (values.randomposition == "1")) values.topchosenRT = trial.initialselect.elapsedtime; values.responseRT = trial.initialselect.elapsedtime]

/ontrialend = [if ((trial.InitialSelect.response == "48") && (values.randomposition == "1")) values.bottomchosen = 1; values.patch2chosencount = 1; values.patch1chosencount = 0]
/ontrialend = [if ((trial.InitialSelect.response == "48") && (values.randomposition == "1")) values.totalbottomchosencount += 1; values.totalpatch2chosencount += 1]
/ontrialend = [if ((trial.InitialSelect.response == "48") && (values.randomposition == "1")) values.bottomchosenRT = trial.initialselect.elapsedtime; values.responseRT = trial.initialselect.elapsedtime]

/ontrialend = [if ((trial.InitialSelect.response == "48") && (values.randomposition == "2")) values.bottomchosen = 1; values.patch1chosencount = 1; values.patch2chosencount = 0]
/ontrialend = [if ((trial.InitialSelect.response == "48") && (values.randomposition == "2")) values.totalbottomchosencount += 1; values.totalpatch1chosencount += 1]
/ontrialend = [if ((trial.InitialSelect.response == "48") && (values.randomposition == "2")) values.bottomchosenRT = trial.initialselect.elapsedtime; values.responseRT = trial.initialselect.elapsedtime]

/ontrialend = [if ((trial.InitialSelect.response == "20") && (values.randomposition == "2")) values.topchosen = 1; values.patch2chosencount = 1; values.patch1chosencount = 0]
/ontrialend = [if ((trial.InitialSelect.response == "20") && (values.randomposition == "2")) values.totaltopchosencount += 1; values.totalpatch2chosencount += 1]
/ontrialend = [if ((trial.InitialSelect.response == "20") && (values.randomposition == "2")) values.topchosenRT = trial.initialselect.elapsedtime; values.responseRT = trial.initialselect.elapsedtime]

/ontrialend = [values.response = trial.InitialSelect.response]
/ontrialend = [values.choicert = trial.InitialSelect.elapsedtime]
/ontrialend = [if ((values.topchosen == 0) && (values.bottomchosen == 0)) values.totalfailed += 1; values.failed = 1]
/ontrialend = [trial.initialselect.resetstimulusframes()]

/branch = [if (trial.initialselect.elapsedtime < 5000) trial.patchtrial]
/branch = [if (trial.initialselect.elapsedtime > 4999) trial.reselecttrial]
By Dave - 3/10/2015

I'm fairly sure that question cannot be answered without (a) you detailing the changes you made between the two versions (working vs. non-working) and (b) providing code that's complete enough to actually run instead of an isolated excerpt.
By DCole9 - 3/10/2015

Hi Dave,
Thanks for the quick response.  I've uploaded the whole experiment.

The only change I have made is adding the lines that insert stimulus frames for different patches on different values of "numblock".
The issue comes when the user gives input for a trial.InitialSelect or trial.ReselectTrial.


By Dave - 3/10/2015

Thanks for attaching the script. As far as I can tell, the script behaves and proceeds as it should. Could you please explain in more detail what exactly you mean by "[...] my task will suddenly quit when a user inputs a value [...]", i.e. what are you inputting (which key), what is the behavior you expect upon each input, what does "suddenly quit" mean specifically? The script just ends? Inquisit crashes? Something else?

In this context, I'm not sure how "suddenly quits" jibes with "it will not continue to the next trial". Does "quit" mean the script gets stuck in a specific trial, or does it simply terminate after a single trial? If the latter, I'm not sure how you would be able to tell that the problem occurs in both trial.initialselect and trial.reselecttrial.

It would be great if you could clarify that for me. Thanks!

Finally, to make sure we're on the same page, which Inquisit version are you running this under? If it is not the latest release (4.0.8.0), please update your installation.
By DCole9 - 3/10/2015

Hey Dave-
I am using Inquisit 4.0.8.

After going through the instructions trials the script brings me to my first trial which is the trial.InitialSelect.  Upon selecting one of the patches (through one of the valid response keys 'b' or 't') the script immediately closes/experiment stops running with no error message and the Inquisit program stays open.  If I wait for a timeout then the experiment continues running until I press a valid response key.
By Dave - 3/10/2015

Hmm, weird. Not seeing that behavior, the script progresses as expected for me (upon pressing "t" or "b"). No error messages in the output? Any indications in the data file (what does it say in the trials response column, etc.)?
By DCole9 - 3/10/2015

I can't look at the output file since my trial version has run out and we have only purchased a web license version.  That is odd that you are able to progress to the next trial without issue though... Not sure what could be different between our two setups.
By Dave - 3/10/2015

I'm not sure either. At any rate, I am unfortunately unable to reproduce the behavior you're experiencing using the script you attached. The only change I made to that script is switching the <picture> elements to <text> elements because I don't have your image files. I'm attaching that script as a reference. I don't see any obvious mistakes in the script and -- more importantly -- there is no reason why the added insertstimulusframe() logic should cause the script to disregard input. A couple of suggestion for moving on:
(1) Try rebooting your machine and see if the issue persists. Perhaps some system library crashed silently in the background or the like.
(2) Try if the attached <text>-only version exhibits the same issue for you.
(3) Try running the script via your web license if possible. The resulting data file might offer additional clues in case the issue also occurs when the script is run via the web on your machine.

Let me know what you find.
By DCole9 - 3/10/2015

Thanks a ton for all the help Dave.  I'll keep you posted.
By DCole9 - 3/10/2015

The <text> script you provided works... I guess something is off with my pictures or picture elements.
By Dave - 3/10/2015

Interesting. Can you put those files in a ZIP archive and attach the archive to this thread. I'll see if I can reproduce the issue / narrow it down then.
By DCole9 - 3/10/2015

Here is the zipped files.  Thanks a lot for looking into this Dave.  It is a very weird issue.
By Dave - 3/11/2015

Thanks for providing the files. I'll get back to you ASAP, but I suspect this is going to take a while to figure out...
By Dave - 3/11/2015

Okay, here's what I've got so far. Using the image files you provided:

(1) I am *not* able to reproduce the issue with the script version you initially provided (attached here: https://www.millisecond.com/forums/FindPost15727.aspx ).
(2) I am able to reproduce the issue using the script included in the ZIP archive (attached here: https://www.millisecond.com/forums/FindPost15745.aspx ).
(3) As far as I can tell, the issue is *not* caused by either <trial initialselect> or <trial reselecttrial>. It is <trial patchtrial>'s setup.
(3a) In the latest script version (under #2 above), you insert a <clock> element into <trial patchtrial>'s frames

/ontrialbegin = [if (...)
{trial.patchtrial.insertstimulusframe(clock.choose, 1); ...}
...

while you already have that <clock> in the trial's regular /stimulusframes attribute:

/stimulusframes = [1 = choose]

This is what causes the crash for me. You can provoke the same behavior by foregoing insertstimulusframe() and simply doing

/stimulusframes = [1 = choose, choose]

(3b) With that said, removing the redundant clock insertion-logic from the /ontrialbegin attributes resolves the issue for me. The script then runs as expected. A file with those modifications is attached to this response and I'd be interested to learn how that script behaves on your system.
By DCole9 - 3/11/2015

That worked Dave!  I don't know how you find these things but you are truly an Inquisit guru.  I owe you one big time.
By Dave - 3/11/2015

Awesome -- glad to hear that!

> I don't know how you find these things [...]

I can neither confirm nor deny that my methods involve a healthy portion of black magic. No animals were harmed in the process. :)