Hi Chris,
I have a question about how to use MWorks’s frame list stimulus (and a quirk about MatLab’s randomness to let you know about). Currently, the code you sent me generates white noise before a trial, and the frame list stimulus uses the white noise within that trial’s folder that was just generated. If I wanted to change it so that it generates enough noise for an arbitrary number of trials before running them, and then uses the correct images for each trial, how would you suggest I go about changing the code?
Furthermore, if I have a fixation period that I want to display dynamic noise with, but I know the fixation period is longer than the monkey will fixate at once, is there a way to generate a bunch of noise (as above), but simply have MWorks pick up where it left off in stimulus presentation, as well as record when and on what image fixation was broken?
Also as far as that MatLab quirk I mentioned earlier goes, MatLab’s randomness is not random - it seems that, at least in R2017b and earlier versions, when the application is closed and reopened, the seed it uses for its rand() function is the same every time. So, if you were to generate a matrix of “random” numbers, close the program, and then reopen it and generate a new matrix with the same dimensions, the numbers in it are the same as before. This is fixed by adding rng(‘shuffle’) before generating the random numbers. I’ve fixed this in my version of the code (and sent a report to MatLab support, seeing as this seems to be unintended!), but thought you might want to know in case you ever deal with something else where the randomness of the values is important.
Thanks!
Yvonne
Hi Yvonne,
If I wanted to change it so that it generates enough noise for an arbitrary number of trials before running them, and then uses the correct images for each trial, how would you suggest I go about changing the code?
There are many ways you could do this. One possibility:
- Add a new protocol that generates all the noise images you want and stores all the filenames in a list (e.g.
dynamic_white_noise_filenames
in the example I gave you.)
- In the main protocol, load files from the list in batches, using a variable to store the index of the last file used.
Furthermore, if I have a fixation period that I want to display dynamic noise with, but I know the fixation period is longer than the monkey will fixate at once, is there a way to generate a bunch of noise (as above), but simply have MWorks pick up where it left off in stimulus presentation,
Use the index variable mentioned in item 2 above.
as well as record when and on what image fixation was broken?
That information is in the event file, but it’s not so easy to determine within the experiment at runtime. You could estimate the number of frames that were displayed before fixation was broken by multiplying the fixation duration by the frame rate, although that may be off by a couple frames.
it seems that, at least in R2017b and earlier versions, when the application is closed and reopened, the seed it uses for its rand() function is the same every time.
Thanks, I didn’t know that. I’m seeing it in R2018a, too. Seems like a strange choice on MATLAB’s part. I’ll update my code to set a seed, too.
Chris
Hi Chris,
Thanks! I’ll try this out today and get back to you if I get stuck.
And on the MatLab seed - they got back to me and said that that was the
intended way for it to work, so it’s not a bug; but definitely not what one
would expect when using rand!
Best,
Yvonne