kschan0214 / sepia

Matlab GUI pipeline application for quantitative susceptibility mapping (QSM)
MIT License
50 stars 10 forks source link

Issue when using LBV background removal and question about reference tissue #76

Closed MHoch96 closed 7 months ago

MHoch96 commented 9 months ago

I am getting an error when I run the LBV for background removal, and I am unsure how to get around it:

Invalid MEX-file '/Users/hochy/Documents/MATLAB/MEDI_toolbox-2/functions/_LBV/mexMGv6.mexmaci64': dlopen(/Users/hochy/Documents/MATLAB/MEDI_toolbox-2/functions/_LBV/mexMGv6.mexmaci64, 0x0006): Library not loaded: @rpath/libMatlabEngine.dylib Referenced from: /Users/hochy/Documents/MATLAB/MEDI_toolbox-2/functions/_LBV/mexMGv6.mexmaci64 Reason: tried: '/Applications/MATLAB_R2022a.app/bin/maci64/libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/bin/maci64/./libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/bin/maci64/../../sys/os/maci64/libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/Contents/MacOS/libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/Contents/MacOS/./libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/Contents/MacOS/../../standalone/bin/maci64/libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/Contents/MacOS/../../sys/os/maci64/libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2022a.app/bin/maci64/libMatlabEngine.dylib' (no such file)

I ran the > mex mexMGv6.cpp and this was the output:

Building with 'Xcode Clang++'. /Users/hochy/Documents/MATLAB/MEDI_toolbox-2/functions/_LBV/mexMGv6.cpp:734:13: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] delete mask_int; ^ [] /Users/hochy/Documents/MATLAB/MEDI_toolbox-2/functions/_LBV/mexMGv6.cpp:725:29: note: allocated with 'new[]' here int* mask_int = new int [this->n_vox[0]](); ^ 1 warning generated.

ld: warning: -undefined error is deprecated ld: warning: -undefined error is deprecated

ld: warning: -undefined error is deprecated ld: warning: -undefined error is deprecated

MEX completed successfully.

I am not sure how to get around this issue?

Also, what does the reference tissue mean? I am working with data for mouse brains, and whenever I pick a reference tissue all of my susceptibility values go to 0.

Sorry for all of the questions!

kschan0214 commented 8 months ago

Hi, sorry for the late reply!

For the LBV issue, I've got the same warning when I build the mex file again (on M2 Pro, macOs 14.2.1, Matlab R2023b):

Building with 'Xcode Clang++'.
/Users/kc020/Documents/tools/sepia/external/MEDI_toolbox/MEDI_toolbox_20200115/functions/_LBV/mexMGv6.cpp:734:13: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
            delete mask_int;
            ^
                  []
/Users/kc020/Documents/tools/sepia/external/MEDI_toolbox/MEDI_toolbox_20200115/functions/_LBV/mexMGv6.cpp:725:29: note: allocated with 'new[]' here
            int* mask_int = new int [this->n_vox[0]]();
                            ^
1 warning generated.

ld: warning: -undefined error is deprecated
ld: warning: -undefined error is deprecated

ld: warning: -undefined error is deprecated
ld: warning: -undefined error is deprecated

MEX completed successfully.

But I was able to run LBV afterward even with these warning messages during the build. Can you use the LBV in your case?

For the (CSF) reference tissue, it works only on in vivo human data. Basically, this step performs: Chimp_final = Chimap - mean(Chimp(mask_reference>0))

Currently we utilise the implementation from the MEDI toolbox for CSF segmentation, which may not work on mouse data. If 'Brain mask' is chosen then the reference mask would be the input mask. Does it give you 0 even when you chose 'Brain mask' as the reference tissue?

ahervouin commented 7 months ago

Hi,

I had the same problem with Matlab R2022b on macOS sonoma 14.3 but resolved it.

This page was really helpful :

https://fr.mathworks.com/matlabcentral/answers/2034829-maci64-libmatlabengine-dylib-not-found-trying-to-call-a-compiled-mexmaci64-function-on-macos

Aurelien

kschan0214 commented 7 months ago

Thanks a lot for the solution Aurelien!