UCL / STIR

Software for Tomographic Image Reconstruction
http://stir.sourceforge.net/
Other
115 stars 95 forks source link

STIR swig MATLAB interface problems #290

Open bathomas opened 6 years ago

bathomas commented 6 years ago

Both @robbietuk and I are having an issue with the MATLAB interface. The .m files try to call an unknown function stirMEX, whereas it should be stirMATLAB_wrap. A temporary, dirty fix was to symlink the mex file:

ln -s stirMATLAB_wrap.mexmaci64 stirMEX.mexmaci64 

@robbietuk is using R2018b and I am using R2016b.

eliseemond commented 6 years ago

I have compiled the STIR master branch on centOS using gcc 4.9.2 (devtoolset-2) and boost 1.68.0 and I have a similar issue (?):

>> stir.Scanner.list_all_names()
Undefined function or variable 'stirsetup'.

Error in stir.Scanner.list_all_names (line 392)
      [varargout{1:max(1,nargout)}] = stirMATLAB_wrap(210, varargin{:});

ans =

ECAT 931
ECAT 951
ECAT 953
ECAT 921 , ECAT EXACT , EXACT
ECAT 925 , ECAT ART
ECAT 961 , ECAT HR
ECAT 962 , ECAT HR+
ECAT EXACT 3D , EXACT 3D , ECAT HR++ , ECAT 966
ECAT 1080 , Biograph 16 , 1080
Siemens mMR , mMR , 2008
PRT-1 , RPT
HiDAC
GE Advance , Advance
GE Discovery LS , Discovery LS
GE Discovery ST , Discovery ST
GE Discovery STE , Discovery STE
GE Discovery RX , Discovery RX
GE Discovery 600 , Discovery 600
GE Discovery 690 , Discovery 690 , GE Discovery 710 , Discovery 710
Positron HZL/R
RATPET
PANDA
HYPERimage
nanoPET
HRRT
Allegro , Philips Allegro
GeminiTF , Philips GeminiTF
Userdefined
KrisThielemans commented 6 years ago

these are 2 different but related issues. Can you say which swig and CMake version you used? I only got this to work with my fork of SWIG (which is now hopelessly out of date). I had some trouble when using the newer version of the matlab branch on swig itself (but run-time trouble, not what you say here).

Module name etc is set around here. Possibly some of this code needs updating for more recent CMake.

@eliseemond, can you check if stirsetup.m is generated in your build directory? It's possible that it isn't installed.

bathomas commented 6 years ago

CMake: 3.12.2; swig 3.0.11 (matlab branch).

eliseemond commented 6 years ago

@KrisThielemans Indeed, stirsetup.m is generated in the build directory but was not copied over to the install directory.

KrisThielemans commented 5 years ago

@eliseemond, I think we can just modify this line to say

  file(GLOB SwigMatlabFiles "${CMAKE_CURRENT_BINARY_DIR}/*.m")

could you try and generate a PR?

KrisThielemans commented 5 years ago

@bathomas @robbietuk. can you be more specific about the swig version, i.e. which repo? @eliseemond and I are using https://github.com/KrisThielemans/swig.git, the wiki recommends https://github.com/jaeandersson/swig.git, and there is now https://github.com/swig/swig/tree/matlab. The jaeandersson fork is the most recent, and mine the oldest.

There was a change on the jaeandersson fork that our CMake doesn't yet take into account. The default name for the mex file changed, but a new option was introduced -mexname which we should use (but we'd have to detect if the option is present or not).

However, last time I checked (more than 2 years ago) the matlab module generated by the jaeandersson fork didn't work. I'd hugely appreciate it if someone could check that. It'd be wonderful to be able to ditch my fork.

robbietuk commented 5 years ago

I am using https://github.com/swig/swig/tree/matlab which is Swig version 3.0.11

KrisThielemans commented 5 years ago

could you switch to the jaeanderson fork ? (if you git cloned, you can add a remote and pull from there, which mean fewer recompilations). then try the tests in STIR\src\swig\test\matlab\ in a few of the demos.

ludovicabrusaferri commented 5 years ago

I compiled STIR with the Swig version 3.0.11, and the option "to_matlab()" disappeared from almost all the exported functions.

It was only present in:

Size3BasicCoordinate.m Size2BasicCoordinate.m ProjData.m Int3BasicCoordinate.m Int2Basic Coordinate.m FloatArray3D.m Float3BasicCoordinate.m

KrisThielemans commented 5 years ago

@ludovicabrusaferri, please add which fork and branch you mean with swig 3.0.11, as the matlab capability hasn't been merged into swig master yet. Same as @robbietuk ? i.e. https://github.com/swig/swig/tree/matlab

ludovicabrusaferri commented 5 years ago

@KrisThielemans Yes I used the same as @robbietuk . Recompiling with https://github.com/KrisThielemans/swig solved the issue.

robbietuk commented 5 years ago

I also only have to_matlab() present in those functions. I guess had not run other functions to test functionality.

ludovicabrusaferri commented 5 years ago

I had an issue with Matlab, that was freezing every time I was calling STIR functions.

The terminal was showing the following errors: Break bus error Generating stack trace... 0x000000011ef5470a in JavaCalls::call_helper(JavaValue, methodHandle, JavaCallArguments, Thread) (in libjvm.dylib) + 1710 0x000000011ef54eae in JavaCalls::call_virtual(JavaValue, KlassHandle, Symbol, Symbol, JavaCallArguments, Thread) (in libjvm.dylib) + 356 0x000000011ef5505a in JavaCalls::call_virtual(JavaValue, Handle, KlassHandle, Symbol, Symbol, Thread) (in libjvm.dylib) + 74 0x000000011efaf7b1 in thread_entry(JavaThread, Thread) (in libjvm.dylib) + 124 0x000000011f1d20b3 in JavaThread::thread_main_inner() (in libjvm.dylib) + 155 0x000000011f1d37a0 in JavaThread::run() (in libjvm.dylib) + 450 0x000000011f0f1aee in java_start(Thread) (in libjvm.dylib) + 246 0x00007fff7b5a8339 in _pthread_body (in libsystem_pthread.dylib) + 126 Failed to start process notifications for pid 95600 (19) 0x00007fff7b5ab2a7 in _pthread_start (in libsystem_pthread.dylib) + 70 Failed to start process notifications for pid 95600 (19) 0x00007fff7b5a7445 in thread_start (in libsystem_pthread.dylib) + 13

Break segmentation violation Generating stack trace... Failed to start process notifications for pid 95600 (19) 0x0000000186a0ccb4 in TCint::ResetGlobals() (in libCore.5.so) + 52 Failed to start process notifications for pid 95600 (19) 0x00000001869ab473 in TROOT::EndOfProcessCleanups(bool) (in libCore.5.so) + 51 Failed to start process notifications for pid 95600 (19) 0x0000000186a46e70 in TUnixSystem::Exit(int, bool) (in libCore.5.so) + 64 Failed to start process notifications for pid 95600 (19) 0x0000000186a4552d in TUnixSystem::DispatchSignals(ESignals) (in libCore.5.so) + 221 Failed to start process notifications for pid 95600 (19)

The issue disappeared when I recompiled with "DISABLE_CERN_ROOT_SUPPORT".