Welcome! Log In Create A New Profile

Advanced

Corrupted .bhv2 file, 'End of file' error

Posted by AAmeloot 
Corrupted .bhv2 file, 'End of file' error
March 06, 2025 05:55PM
Hi Jaweon,

While running a MonkeyLogic task, the computer ran out of memory. The task did not stop, but the .bhv2 file for this session cannot be read with the mlread function and generates the following error:

Error using mlbhv2/read_variable (line 293)
End of file.

Is there a way to retrieve some data from this file? At least the trials performed before the memory was full. The corrupted .bhv2 file is quite large, as it contains webcam videos.


By the way, I really like MonkeyLogic, it's a very powerful and easy to use tool. Thanks a lot for sharing it.

Have a great day smiling smiley

Antoine
Re: Corrupted .bhv2 file, 'End of file' error
March 07, 2025 01:00AM
Try to read again with the latest NIMH ML.
Re: Corrupted .bhv2 file, 'End of file' error
March 10, 2025 02:35PM
I tried to open the file with version 2.2.49 and got the same error.
Re: Corrupted .bhv2 file, 'End of file' error
March 10, 2025 03:16PM
It means you are still running the old version. If you ran the new version, at least the line number in the error message would be different. Please check the MATLAB path and make sure that the commands in the new version are called. The new version returns the readable portion of data even when an error occurs.
Re: Corrupted .bhv2 file, 'End of file' error
March 10, 2025 04:30PM
I installed the latest version on a computer other than the one used to run the experiment and when I launch the application the first line is:

<<< MonkeyLogic >>> NIMH MonkeyLogic 2.2.49 (Dec 19, 2024)

The error was at line 293 and is now at line 298.
Re: Corrupted .bhv2 file, 'End of file' error
March 10, 2025 07:22PM
Now the message is supposed to be a warning, not an error, and anything readable up until the warning should be in the return value of mlread(). Did you see anything in the return value?
Re: Corrupted .bhv2 file, 'End of file' error
March 11, 2025 02:55PM
There is no return value created, the Workspace is empty. Here's the full error message:

Error using mlbhv2/read_variable (line 298)
End of file.

Error in mlbhv2/read_index (line 204)
[obj.var_pos,name] = read_variable(obj);

Error in mlbhv2/open (line 31)
[~,info] = read_index(obj);

Error in mlbhv2 (line 18)
if exist('filename','var'), obj.open(filename,mode); end

Error in mlfileopen (line 8)
case '.bhv2', fp = mlbhv2(filepath,mode);

Error in mlread (line 22)
otherwise, fid = mlfileopen(filename);
Re: Corrupted .bhv2 file, 'End of file' error
March 12, 2025 03:27PM
I sent you a modified version of mlbhv2.m by email. Please check your inbox. The data could be read up to Trial200. The new mlbhv2.m will be included in the future release of NIMH ML, so you do not need to keep the file.

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.