Welcome! Log In Create A New Profile

Advanced

super large bhv2 files

Posted by Michelle 
super large bhv2 files
August 06, 2020 10:48PM
Hi Jaewon,

The thing is I tried to used the 'MovieGraphic' to run a random dots stimulus, in order to save the dot position in each frame. However, the saved bhv2 file I got was over 90G for around 1300 trials.
PS: I unchecked the 'save stimuli' function, and the dots position I saved was a N*3 matrix per trial (N was around 500), so it should not take too much space.

Do you know why? Thanks very much for your help!
Re: super large bhv2 files
August 07, 2020 08:23AM
Of course, I don't. You should explain every single detail so that I can understand what you did. Otherwise, it is just like you are asking me to guess what you ate for breakfast.

You said you saved the dot positions in each frame. Then how can the size of the matrix be just 500*3 per trial? If you presented 100 dots for 3 s at 60 Hz, that alone requires 100*3*60*2 numbers each trial (since the position is [x y]) and takes ~0.4GB disk space after 1300 trials.
Re: super large bhv2 files
August 07, 2020 11:33AM
Right, I got 7 dots per frame, and the stimulus was displayed for 1200ms, as the refresh rate is 60Hz, so I would have 72 frames here. The length of the random dots aperture was around 200 pixels (square).

The matrix I put in the 'MovieGraphic' was a 4-D matrix with the size of 200-by-200-by-3-by-72, 200-by-200 was the pixels involved in the random dots area, 3 was the RGB, and 72 was the frame number.

But I did not save the 4-D matrix in the 'bhv_variable', instead saved a 504-by-3 matrix, in which the first column refers to the 'y' position of the dots(7*72 = 504), the second column refers to 'x' position, and the last was the frame number.

If I simulate the task with the 'break's before the random dots was shown, the saved bhv file was only 168MB for over 1200 trials, the matrix could be correctly saved in this situation (as it was generated in the 'creat_scene' part, right). However, if I simulate the task with the 'break's after the random dots was displayed, the saved bhv file was around 90G for around 1300 trials.

I tried to read the bhv file (a smaller one with only 35 trials, which is over 2G) with 'mlread', the output 'data' was the big one, but if I tried to save each 'filed' of the 'data' separately, all of them were below 100kb.

That's all what I've done I think, hope it helps. Thanks very much.
Re: super large bhv2 files
August 07, 2020 01:11PM
Thanks for the explanation.

All public properties of adapters that can be assigned by users are saved in the data file to reconstruct initial conditions of scenes later. In your case, you assigned a 4-D matrix to MovieGraphic so the 4-D matrix was stored to the data file, which I believe is the reason of the large file size.

If you have a function that generates the movie out of a few parameters, you can probably create the movie as a GEN TaskObject. Or save the movie as a file first and then assign the filename instead of the movie matrix.

The following post is discussing a similar issue. I think using a function name, not a function handle, can be a general solution, but have not implemented yet.
https://monkeylogic.nimh.nih.gov/board/read.php?3,328


I made changes so that you can plug in a function, instead of a movie matrix. It will reduce the datafile size significantly. I cannot update the packages now due to a network problem, but I will let you know when they are updated, so keep checking this post.
Re: super large bhv2 files
August 07, 2020 07:39PM
That would be very nice, thanks a lot.
Re: super large bhv2 files
August 13, 2020 02:29PM
I uploaded the new packages. Now you can use a function string, instead of a matrix. See the manual for details. Reload the page in the web browser, if you don't see the updated contents.
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#MovieGraphic
Re: super large bhv2 files
August 13, 2020 09:47PM
Great! I'll try it. Thanks a lot~~
Re: super large bhv2 files
August 18, 2020 10:22PM
Hi Jaewon,

I tried this:

'rdm = MovieGraphic(crc2); rdm.List = {'SDMM_port', rdm_location}', in which 'SDMM_port' is a self-defined function, used to export the 4-D matrix.

However, the function 'SDMM_port' need some inputs, so 'rdm = MovieGraphic(crc2); rdm.List = {'SDMM_port(***)', rdm_location}'. In this case, the monkeylogic2 couldn't recognise the 'SDMM_port' function.

What should I do to fix it, Thanks.
Re: super large bhv2 files
August 18, 2020 10:48PM
What is (***)?

Did you see the example 2 in the MovieGraphic manual? Your question is already covered in it.
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#MovieGraphic
Re: super large bhv2 files
August 19, 2020 01:14AM
Hi there,

Maybe it would be better for me to show you the code directly.

[sdmMatrix, dotsPosition] = ShadlenDotsMovieMatrix(coherence/100,radius,dot_size,speed,dir,num_dot,ppd,rdm_holdtime,0.0157);
rdm2 = MovieGraphic(crc2);
rdm2.List = {'SDMM_port(sdmMatrix)', rdm_location };

'ShadlenDotsMovieMatrix' is a self-defined function, the output 'sdmMatrix' is the 4-D matrix required by the 'MovieGraphic', 'dotsPosition' is the n-by-3 matrix which will be saved later.

'SDMM_port' is another self-defined function which was put in the 'MovieGraphic', requires the 'sdmMatrix' created by the 'ShadlenDotsMoiveMatrix'

function currentsdmMatrix = SDMM_port(sdmMatrix)
currentsdmMatrix = sdmMatrix;

If the code was like this, an error would shown as: 'cannot find SdMM_port(sdmMatrix). ...'

Many Thanks~~
Re: super large bhv2 files
August 19, 2020 11:51AM
You cannot use a variable name in the function string which is a char array. Replace sdmMatrix with its value, like sprintf('SDMM_port(%d)',sdmMatrix), as shown in the example.

Please describe every single detail, as I asked above, from the first time.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.