pyomeca / ezc3d

Easy to use C3D reader/writer for C++, Python and Matlab
https://pyomeca.github.io/Documentation/ezc3d/index.html
MIT License
142 stars 44 forks source link

MATLAB Error with ezc3dRead command: Requested array exceeds MATLAB limits #289

Closed jagusto33 closed 1 year ago

jagusto33 commented 1 year ago

Hello,

I was able to successfully install the ezc3d MATLAB binder (Windows 10, 64-bit) to my workstation, and have access to all of the commands in the binder. However, when I was attempting to run the ezc3dRead command, for ANY .c3d file, I am encountering the following MATLAB error:

ezc3dRead('TRIAL_019.c3d') Error using ezc3dRead Requested array exceeds the maximum possible variable size.

This is very surprising because the files I am trying to read in are not terribly large in terms of storage space, so I am wondering if something with the MEX package is leading to unnecessarily large array sizes for reading the .c3d files I have.

For context, I am currently looking to ONLY read the frameRate data in my .c3d files for confirmation of data collection frame rate for use in other MATLAB scripts I have running. Below is a "temporary" workaround I found using the "DataStorgae" variable type in MATLAB to limit the size of data I am reading:

fds = fileDatastore("TRIAL_008.c3d","ReadFcn",@ezc3dRead) data1 = read(fds)

My data1 variable is a struct with fields "header", "parameters" and "data", and the info I need is easily found in the data1.header.points.frameRate field.

In any case, I figured I would report the issue with ezc3dRead not reading in the data well with the MATLAB binder. Any thoughts on how to resolve this issue?

pariterre commented 1 year ago

Hi @jagusto33 ! Thanks for reporting this bug, can you send me a c3d so I can have a look? You can send it directly to my personal email if you don't want it to be on internet!

jagusto33 commented 1 year ago

What’s the best email to send this to?

Jonathan

Jonathan A. Gustafson, PhD Instructor | IBTS Fellowship Research Director Department of Orthopedic Surgery Rush University Medical Center 1611 W. Harrison Street Chicago, IL. 60612

Office: 312-942-2587 Cell: 708-522-2227 Twitter: @Jonathan_Gusto Email: @.**@.>

From: Pariterre @.> Sent: Tuesday, June 6, 2023 12:19 PM To: pyomeca/ezc3d @.> Cc: Jonathan Gustafson @.>; Mention @.> Subject: Re: [pyomeca/ezc3d] MATLAB Error with ezc3dRead command: Requested array exceeds MATLAB limits (Issue #289)

Rush Email Security

WARNING This email originated from outside of Rush University Medical Center. *DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe. Remember, Rush IS will never ask for user ID information via email communication.

Hi @jagusto33https://urldefense.com/v3/__https:/github.com/jagusto33__;!!OlavHw!42oQ7bg3R9jNc2aWLubAddWg_H7_DxfAjQMucwWf-yGAj7422Bpsyvkr8ssHCTwF9qbFUdEe7G_wJpnXJGRImAtW71g068bvT4s$ ! Thanks for reporting this bug, can you send me a c3d so I can have a look? You can send it directly to my personal email if you don't want it to be on internet!

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/pyomeca/ezc3d/issues/289*issuecomment-1579162836__;Iw!!OlavHw!42oQ7bg3R9jNc2aWLubAddWg_H7_DxfAjQMucwWf-yGAj7422Bpsyvkr8ssHCTwF9qbFUdEe7G_wJpnXJGRImAtW71g0aCjBGiQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AX6KBSZGPWEJQKHWWQEGUOTXJ5RAVANCNFSM6AAAAAAY4VGPEM__;!!OlavHw!42oQ7bg3R9jNc2aWLubAddWg_H7_DxfAjQMucwWf-yGAj7422Bpsyvkr8ssHCTwF9qbFUdEe7G_wJpnXJGRImAtW71g0bnPN7W0$. You are receiving this because you were mentioned.Message ID: @.**@.>>

pariterre commented 1 year ago

pariterre@hotmail.com

pariterre commented 1 year ago

Hi there!

Your C3D loads well here.

Since you are on Windows, did you try to load the file using \ in the quotes? For instance:

path = 'C:\\folder1\\folder2\\my_c3d.c3d';

as opposed to

path = 'C:\folder1\folder2\my_c3d.c3d';

if you did not, what may be trying to load an invalid path

jagusto33 commented 1 year ago

Thanks for the quick responses: I have been using MATLAB's "fullfile" built-in function to handle any potential "path" issues, so I'm not sure this is the issue. I think it may be something with either i) how I originally installed ezc3d (VS 2022, stored on my C: drive by running VS as an administrator), or ii) where I am pulling the data from, which is a shared laboratory server. You can see an example of the server I am trying to pull from in the screenshot and the path of the data. I'm not quite sure how you got yours to run correctly. I will quick try copying the .c3d files "locally" on my computer from the server and see if it is something to do with trying to grab the path from the server ezc3d_troubleshoot

schoondw commented 1 year ago

Hi, I have a similar issue. I think it may be related to the new facility to load rotation data (for Theia markerless) from the c3d, which is a custom format.

When I use the ezc3dRead command without arguments, you can see that the rotation data is initialized with a huge amount of frames (see attached figure). Perhaps that is the culprit? The file I tried to open was quite small (10s), and contained only analog data/force samples.

I am using Matlab version 9.10.0.1710957 (R2021a) Update 4. I used a compiled version of ezc3d (let me know if you need more detailed information about that, then I can ask my colleague to provide the details).

matlab-ezc3d-error

BR, Erwin Schoonderwaldt (Qualisys)

pariterre commented 1 year ago

Dear @schoondw Can you confirm you are using 1.5.3 or 1.5.4? This bug was fixed lately. I just pushed 1.5.4 few minutes ago.

@jagusto33 I would be highly surprised that network files can be read out of the box. If so, that is from pure luck (and to be honest, I don't believe in luck when it comes to programming!)

jagusto33 commented 1 year ago

Just to clarify, our files are on a shared network drive, so only thing it should affect is speed. I tested this by saving all my files locally and still had the same read error due to memory issues, even though some of the trials are quite short.

My workaround with a dataStorage format in Matlab is also not working for every file, it works for maybe one third. Any thoughts or insight on what I could try and do? Short of un-installing everything and starting from scratch....

Jonathan A. Gustafson, PhD

Instructor | IBTS Fellowship Research Director

Orthopedic Surgery

Rush University Medical Center

Phone: 708-522-2227


From: Pariterre @.> Sent: Wednesday, June 7, 2023 8:22 AM To: pyomeca/ezc3d @.> Cc: Jonathan Gustafson @.>; Mention @.> Subject: Re: [pyomeca/ezc3d] MATLAB Error with ezc3dRead command: Requested array exceeds MATLAB limits (Issue #289)

Rush Email Security

WARNING This email originated from outside of Rush University Medical Center. *DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe. Remember, Rush IS will never ask for user ID information via email communication.

Dear @schoondwhttps://urldefense.com/v3/__https://github.com/schoondw__;!!OlavHw!_DcnvMEw6HnpKhPWTySvgsDQOo8YhfnK-0A0ZqW4O2YLOyDDtEKH1h6f1Y-7nQIZM7WU3BOZ20QT3SafWxTKiAH-v9CGyvOgVZ4$ Can you confirm you are using 1.5.3 or 1.5.4? This bug was fixed lately. I just pushed 1.5.4 few minutes ago.

@jagusto33https://urldefense.com/v3/__https://github.com/jagusto33__;!!OlavHw!_DcnvMEw6HnpKhPWTySvgsDQOo8YhfnK-0A0ZqW4O2YLOyDDtEKH1h6f1Y-7nQIZM7WU3BOZ20QT3SafWxTKiAH-v9CGi6LchH8$ I would be highly surprised that network files can be read out of the box. If so, that is from pure luck (and to be honest, I don't believe in luck when it comes to programming!)

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/pyomeca/ezc3d/issues/289*issuecomment-1580814077__;Iw!!OlavHw!_DcnvMEw6HnpKhPWTySvgsDQOo8YhfnK-0A0ZqW4O2YLOyDDtEKH1h6f1Y-7nQIZM7WU3BOZ20QT3SafWxTKiAH-v9CGK23gE7M$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AX6KBS5ZLDB3KFPIZX5LHO3XKB6DDANCNFSM6AAAAAAY4VGPEM__;!!OlavHw!_DcnvMEw6HnpKhPWTySvgsDQOo8YhfnK-0A0ZqW4O2YLOyDDtEKH1h6f1Y-7nQIZM7WU3BOZ20QT3SafWxTKiAH-v9CGxl6bTIw$. You are receiving this because you were mentioned.Message ID: @.***>

pariterre commented 1 year ago

@jagusto33 Can you confirm that the file you sent me won't open in the current setup? I tried from both the C++ side and the Matlab side here, and the 1.5.4 work just fine... If it does not, we may need to meet online so I debug from your computer, if possible :S

jagusto33 commented 1 year ago

It does not read correctly. I could send a video of my setup and how I am running everything through my Matlab script if that would help?

If you could meet online that would be great!

Jonathan A. Gustafson, PhD

Instructor | IBTS Fellowship Research Director

Orthopedic Surgery

Rush University Medical Center

Phone: 708-522-2227


From: Pariterre @.> Sent: Wednesday, June 7, 2023 8:59 AM To: pyomeca/ezc3d @.> Cc: Jonathan Gustafson @.>; Mention @.> Subject: Re: [pyomeca/ezc3d] MATLAB Error with ezc3dRead command: Requested array exceeds MATLAB limits (Issue #289)

Rush Email Security

WARNING This email originated from outside of Rush University Medical Center. *DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe. Remember, Rush IS will never ask for user ID information via email communication.

@jagusto33https://urldefense.com/v3/__https://github.com/jagusto33__;!!OlavHw!8B4CARV704yNinB4n7W7ayV66dS8l7dhkga1JkMNIdK8Z64B3rfNQ-weoSJZpC9lwF7-j-EfvW-5i5OKlYQYD5bNVE2wyiBgLMY$ Can you confirm that the file you sent me won't open in the current setup? I tried from both the C++ side and the Matlab side here, and the 1.5.4 work just fine... If it does not, we may need to meet online so I debug from your computer, if possible :S

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/pyomeca/ezc3d/issues/289*issuecomment-1580883560__;Iw!!OlavHw!8B4CARV704yNinB4n7W7ayV66dS8l7dhkga1JkMNIdK8Z64B3rfNQ-weoSJZpC9lwF7-j-EfvW-5i5OKlYQYD5bNVE2ww6u2WDM$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AX6KBS5TBDXKE7NYYZIY64LXKCCKZANCNFSM6AAAAAAY4VGPEM__;!!OlavHw!8B4CARV704yNinB4n7W7ayV66dS8l7dhkga1JkMNIdK8Z64B3rfNQ-weoSJZpC9lwF7-j-EfvW-5i5OKlYQYD5bNVE2wAjOQWSg$. You are receiving this because you were mentioned.Message ID: @.***>

pariterre commented 1 year ago

A video could definitely help! Though I think I will need to use the debugger from Visual Studio to actually diagnose what is going on. I could be available now if you have time (please make sure Visual Studio 2022 is installed, which I assume it is since you compile ezc3d by yourself!). If you have access to a software where remote desktop is available (such as Zoom), you can send me a link to my email, otherwise, we can use TeamViewer :)

jagusto33 commented 1 year ago

@pariterre I just sent you a zoom link to your hotmail. Let me know if you did not get it

jagusto33 commented 1 year ago

@pariterre I am back online, did you want to try this later?

pariterre commented 1 year ago

I am on the waiting room :)

jagusto33 commented 1 year ago

@pariterre that worked, I found some old versions of the ezc3d.dll that are automatically installed with newest versions of the OpenSim platform (both v4.3 and v4.4)...my MATLAB path had these locations specified and that was why the changes you were making were not working, because MATLAB was still referencing one of the .dll files in those folders.

One question: what is the easiest way to get rid of the changes you made directly in VS 2022 to troubleshoot the ezc3dRead function by printing the Coucou followed by several "0" values?

Thanks again for all your help! I might suggest you push the newest ezc3d.dll file to the OpenSim team to make sure they update it with their installs, because this will likely be a problem for people using it :-)

pariterre commented 1 year ago

Good to hear @jagusto33 :) The easiest way is to revert all the changes in Git.

I am supposed to push soon in OpenSim, though they want to implement an EMG reader using ezc3d. I'll suggest they update at the same time!

If everything is good, you are invited to close the issue!