Mwel translation issue

Hi Chris,

I have an experiment (attached) that I recently tried to translate into MWEL- the experiment uses a range replicator to load a folder of images, and also has a couple of stimuli that are used on a different location on the screen to track stimulus timing on the monitor. The MWEL code gives an error after a few trials that one of the stimuli is not loading and will not be presented (attached). It only reports the error for one of the two stimuli- but this just depends on which is called first. It’s also weird because if I let it keep going, there are some trials that it works- but most fail.

I’ve tried a couple of things to troubleshoot including:

  1. Changing the category of stimulus presented (it is currently a rectangle, but the original version was a drifting_grating stimulus). This doesn’t seem to matter.
  2. Moving the two stimuli outside of the stimulus_group with the range replicator. This causes a different error where it can’t load the images.

Are you able to replicate this error? Do you have any idea what might be the cause?

Thanks,
Lindsey.

Hi Lindsey,

I think you sent the wrong attachments. (I received a pair of PDF’s that looked like journal submissions.) Can you try sending the experiment XML and error messages again?

Thanks,
Chris

Oh no! Can you delete those??
Here are the correct files. Please let me know if having a variable set (or set of image files) would be useful in troubleshooting.
Thanks,
Lindsey.

bunnies6-backup-rectangle-20230106.mwel (10.5 KB)

Screen Shot 2023-01-06 at 12.53.56 PM.png

Hi Lindsey,

Oh no! Can you delete those??

Of course! Already done.

Here are the correct files.

Thanks. I see a couple issues in your code, though it’s not clear how they would result from XML to MWEL translation:

  1. The selection variable svStimNumber has values ranging from 1 to 6, but you use it (via assignments to variable tstimOne) to access elements of the images stimulus group. Stimulus group indices, like all indices in MWorks, start at 0, so for six elements, the range should be 0 to 5.

    Also, the variables stimOne, stimTwo, tstimOne, and tstimTwo are all initially set to 1. If the intent is to default to the first stimulus, those should be set to zero.

  2. photoDiodeBlack and photoDiodeWhite are both declared inside the images stimulus group, but they shouldn’t be.

The combination of these two issues means that when svStimNumber is 6, instead of getting the sixth image, you’re getting photoDiodeBlack. Since your code unloads the images when you’re done with them (e.g. at line 329), photoDiodeBlack is being unloaded, too, which results in the “not loaded” errors you’re seeing.

Like I said, I don’t know how XML-to-MWEL translation could have introduced these issues, but it’s worth investigating whether it did. If you can send me the original XML file from which you created the MWEL, I can run it through xml2mwel and see if things go wrong.

Thanks,
Chris

Hi Chris,
Thanks so much - that makes a lot of sense.
I noticed that the stimuli were inside the stimulus group- but when I tried to move them outside of it I got a different error. I had thought it was because they needed to be inside for some reason, but that must just be because then issue #1 kicks in.
Here is the original xml in case you want to see how it translated.
I’ll fix #1 and #2 and see if it now works…
Lindsey.

bunnies6.xml (21.2 KB)

Hi Chris,
I made those changes, but am still having crashing issues where it complains about the photodiode stimulus.
Strangely, it crashes after different numbers of trials on each run- sometimes after only 2 and sometimes after 9.
One thing that is consistent is that on the trial that it crashes it fails to load the image- in the console this is reported between “Initializing” and “Iti”, and on trials that it crashes there is no report of image loading.
Any sense of what might cause this error?
Thanks,
Lindsey.

Hi Lindsey,

Here is the original xml in case you want to see how it translated.

Thanks for sharing that. Both of the issues I mentioned previously are present in the XML, too, so the XML-to-MWEL translation definitely was not the problem.

I made those changes, but am still having crashing issues where it complains about the photodiode stimulus.

Can you clarify what you mean by “crashing”? Do you mean the whole MWServer application is crashing, and you’re getting a “MWServer quit unexpectedly” dialog (or something similar)? Or do you just mean you’re seeing errors in the MWServer console window?

One thing that is consistent is that on the trial that it crashes it fails to load the image- in the console this is reported between “Initializing” and “Iti”, and on trials that it crashes there is no report of image loading.

The most likely reason for that is that the image wasn’t unloaded on a previous trial, which suggests another error in the stimulus-group indexing.

One thing that has me a little confused: If doStimOneOffChance is true, then the “off” state is handled by setting tstimOne to zero. How is that supposed to work? Is the first image (Image/0.png) empty? If that’s the case, then maybe I led you astray by saying the range of svStimNumber should be 0 to 5. If image 0 is blank, then svStimNumber should range from 1 to 5. (This would also explain why variable numImages, which is defined but not used in the experiment, is set to 5 instead of 6.)

Also, when doRandStimTwo is true, you get a stimulus index from variable stimList. That’s currently an array containing integers from 1 to 6, but it needs to match the values in svStimNumber (either 0 to 5 or 1 to 5, depending on the previous question).

Cheers,
Chris

Hi Chris,
You were right- 1) there was a mismatch in the indexing across different lists and 2) it was not a translation issue, just too many changes at once.
We’ve figured it out- thanks for your help!
Lindsey.