Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maximum recursion limit reached #20

Open
lauraf94 opened this issue May 27, 2024 · 6 comments
Open

maximum recursion limit reached #20

lauraf94 opened this issue May 27, 2024 · 6 comments

Comments

@lauraf94
Copy link

Warning: Maximum recursion limit of 500 reached.

In dataSourceXDF (line 487)
In mobilabApplication>onSet (line 771)
Warning: Maximum recursion limit of 500 reached.
In dataSourceXDF (line 487)
In mobilabApplication>onSet (line 771)
Warning: Maximum recursion limit of 500 reached.
In dataSourceXDF (line 487)
In mobilabApplication>onSet (line 771)

@arnodelorme
Copy link
Contributor

Hi @neuromechanist , I have the same problem with the test file (test.xdf in sample_data/test_data).

I think this might be due to how new versions of MATLAB handles objects. In the old version, there was no recursive call when accessing object properties, but now there might be. Would you mind to investigate?

@neuromechanist neuromechanist self-assigned this Aug 13, 2024
@neuromechanist
Copy link
Member

neuromechanist commented Aug 13, 2024

Thanks, @lauraf94 for pointing out this issue.

Could you provide a sample XDF that you were using and encountered this error?

Also, please provide more details, including the MATLAB version and the OS you are running on your machine, so I can replicate the problem.

You can use this OneDrive folder to upload the sample dataset.

@arnodelorme
Copy link
Contributor

You may use eeglab/sample_data/test_data/test.xdf tx

@lauraf94
Copy link
Author

Hi @neuromechanist, I am using MATLAB R2024a, on Windows 11. I have tried with multiple xdf files, always obtaining the same error. It must be indeed a problem with the new MATLAB version; since when I try to open the same files with MATLAB R2023a it works.

@neuromechanist
Copy link
Member

neuromechanist commented Sep 11, 2024

I was able to reproduce the error. I could make the error both with 2024a (both Mac and Windows) and 2023b (both Mac and Windows). Matlab 2022b (on Windows 64-bit) worked as expected.
The problem occurs at

obj.connect;

when Matlab tries to get obj.timeStamp.

To put a little bit of background, the xdf metadata is temporarily stored in hear .hdr files. on line

obj.header = header;

The path to the header file is added to the obj. The same class has getters (obj.get.timeStamp for example) that call the obj.retrieveProperty method (also defined under the same class) to load the property from the header file.

My inspection using 2023b showed that obj.retrieveProperty correctly works reutring the var value, but the assignment to obj.timeStamp does not happen correctly on line 148

if isempty(obj.timeStamp), obj.timeStamp = retrieveProperty(obj,'timeStamp');end

, causing recursive calls.

This is a lazy implementation that would pull the variables as needed. Surprisingly, running the same plug-in, I would get all obj fields populated after line 98, which suggests that the way that objects were handled in earlier versions was non-lazy.

I am not currently sure about a solution. Putting almost some hours on possible solutions, including removing the lazy implementation and adding all fields together to the obj did not immediately resolve the issue, although the issue seem to move to another portion of the code, likely because there are other places where the same problem happens.

I think a more effective way to answer this problem is to investigate what has changed in Maltab that causes this problem. Also, we could look into alternative approaches, like the xdf_import plug-in that seems to be successful in importing the EEG file even using the latest Matlab.

@neuromechanist
Copy link
Member

Modifying the getter methods may be the way to resolve this issue. For example, the particular problem that occurred above goes away with changing the timeStamp getter methods.

        function timeStamp = get.timeStamp(obj)
            if isempty(obj.timeStamp)
                timeStamp = retrieveProperty(obj,'timeStamp');
            else
                timeStamp = obj.timeStamp;
            end
        end

The challenge, however, is that there are many of these getter methods that may need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants