Welcome! Log In Create A New Profile

Advanced

Problem with mlread

Posted by Ming 
Problem with mlread
December 16, 2021 11:59PM
Dear Jaewon,
I used the mlread function of the latest ML version (2.2.22) to read my bhv file produced by old ML version, but it got jumbled. I used the latest ML to produce the new bhv file and it was loaded normally. Is it the structure of the bhv file changed in the new version?

Thanks,
Ming


>> mlread
An error occurred while reading the variable, 'MLConfig'.

An error occurred while reading the variable, 'on_CR.m IO struct   
SignalType char   Reward Adaptor char   nidaq DevID char   Dev1 Subsystem char  DigitalIO Channel double    DIOInfo cell    double    char   out Touchscreen logical    RunMessageLoop logical   USBJoystick char   None
EyeTracker struct     Name char   None ID char ViewPoint struct   
IP_address char   169.254.110.159 Port char   5000 Source double  @ $@ ð? ð? ð? ð? ð? ð? à? à? 4@ 4À ð? ð? ð? ð? ð? ð? EyeLink struct   
Re: Problem with mlread
December 17, 2021 08:20AM
It seems that your file is corrupted due to an error in the storage. I will take a look if you send me the file.
Re: Problem with mlread
December 17, 2021 09:32PM
Thank you for your reply. I have sent you the bhv2 file by email. By the way, I am sure that my bhv2 file isn't corrupted because it can be normally loaded by ML edition NIMH_MonkeyLogic_2(Dec-14-2017).
Re: Problem with mlread
December 18, 2021 04:55PM
Your file contains non-alphabetical characters without the information of their encoding. It is okay as long as you use the localized Windows and MATLAB, but the file may not be readable on the Windows of different languages or other operating systems, even if you try with the old version of NIMH ML. This issue was patched almost three years ago.

Download the NIMH ML package again and you will be able to read the file with the version 2.2 on your computer. However, if you want the file to be compatible with operating systems of different languages, you need to convert them. The following command will create a new BHV2 file with the encoding information in it.
convert_format('bhv2')
See the function manual for more.
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#convert_format

----------

The file also will not be readable in R2020a or later. There is still a way to read it, but just convert the file before upgrading your MATLAB.
Re: Problem with mlread
December 20, 2021 02:27AM
Thank you!
Re: Problem with mlread
December 20, 2021 12:18PM
I came up with another solution. I think this may be better since you don't need to convert the files if you have many of them. Type the following two lines on the MATLAB command window before calling mlread().
setpref('NIMH_MonkeyLogic','DefaultEncoding','GB18030')  % try a different encoding if yours is not 'GB18030'
setpref('NIMH_MonkeyLogic','MachineFormat','ieee-le')

-----

See this link for summary.
https://monkeylogic.nimh.nih.gov/board/read.php?2,1166,1166#msg-1166
Re: Problem with mlread
December 23, 2021 03:02AM
I tried these two methods, but it still got jumbled. I've been told by senior that this file used to open with monkeylogic 2 in 2017, so I download the latest version 2.0.243, and it opened successfully, whatever old bhv file or new bhv file. The root of this bug may be the version differences between 2.0 and 2.2.
Re: Problem with mlread
December 23, 2021 08:39AM
You must update v2.2 again. What you said is not possible, because the related files included in v2.0 and v2.2 are identical.
Re: Problem with mlread
December 31, 2021 04:28AM
Yeah, it opened successfully after I remove ML 2.0 and reload ML 2.2. I'm astonished about it because I found the same problem on two computers of my lab. Now it runs normally. Thank you very much!

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.