jcohenadad / GBM8378

Polytechnique Montreal course "Principes d'imagerie biomédicales"
https://www.polymtl.ca/etudes/cours/principes-dimagerie-biomedicale
MIT License
2 stars 5 forks source link

Find solution for Field II software #5

Closed jcohenadad closed 3 years ago

jcohenadad commented 3 years ago

Présentement, ce logiciel est utilisé pour le lab US: https://field-ii.dk/?./downloading_8_20.html

Il faut trouver une solution pour rendre le mexfile callable depuis Python.

gaspardcereza commented 3 years ago

Possible solution: https://github.com/SF-Zhou/field-ii-python

Edit: That solution would require Matlab to be installed so it won't solve our problem...

jcohenadad commented 3 years ago

Alternative solutions:

po09i commented 3 years ago

I noticed a new version : Field II pro (2014) which seems available as a c library. I contacted the owner of the website to see if we can get our hands on it.

po09i commented 3 years ago

I'm trying what agah suggested which is to use Matlab compiler to create a standalone app which would then be run with the help of matlab runtime without the need of a license

po09i commented 3 years ago

Good news, I can create an shell executable using django’s matlab version (2019b). Bad news, we need to input number arguments and the command line is converting everything to a string so I’m into a wall.. I think I’ll try to output it as a python package next. Hopefully it fixes it.

agahkarakuzu commented 3 years ago

@po09i worst case you can come up with an intermediary parameter file (e.g. yaml), write a little wrapper and use that as an entrypoint.

po09i commented 3 years ago

So there is a -n flag that can be used in mcc to magically allow numbers as input. I only packaged the mex file for ease of use and I managed to run field_init (field_init is run by sending (5001, 1) as arguments to the package).

Now the problem is that I need to run field_init to initialize the field and then run other commands. Since it's on the command line, the process finishes so when I send other commands, it's saying I need to run field_init first (which I just ran). Any ideas?

agahkarakuzu commented 3 years ago

@po09i only one thread is allowed to access the MCR at a time, but if you'd like to call multiple compiled apps one after another within an MCR session, according to MATLAB, there is a solution:

https://www.mathworks.com/matlabcentral/answers/154372-how-can-i-reuse-an-mcr-instance-for-multiple-matlab-compiler-standalone-application-restarts

I never tried this, but I can see that it is tricky. The apps I compiled so far either had their thread management (through a GUI) or were executed asynchronously, so this was not an issue for me.

po09i commented 3 years ago

Update: Last year's lab used several matlab files in combination with a .mex executable to generate the US fields and figures. 2 files are generated in the notebook: pressureField.m and defineTransducer.m which use the mentioned above files.

By using pressureField.m as an entry point. I am currently able to generate the US field with Matlab mcc and MCR using a standalone Matlab app. I just included the field_init within "pressureField.m".

Some lab questions ask to play with the timings to change the US field. This means changing the pressureField.m file. From what I understand, this is not possible. What is possible is to add inputs for pressureField.m (As if it was a function instead of a script so we can have arguments on the command line). This does limit what can be done but I think we could put an argument that asks for the times to "fire" the different transducers for example.

gaspardcereza commented 3 years ago

Closed by #4