[Neuroimaging] Using Python libs from MATLAB

Eleftherios Garyfallidis garyfallidis at gmail.com
Mon Jun 13 11:09:37 EDT 2016


Thank you Marmaduke this is really helpful. We get many requests for
running our libraries from inside Matlab or interfacing with Matlab. I hope
we can help resolve the different issues.

Have a great day and thank you for the feedback.
Cheers,
Eleftherios

On Mon, Jun 13, 2016 at 10:58 AM Marmaduke Woodman <
marmaduke.woodman at univ-amu.fr> wrote:

> hi all,
>
> I'm a dev behind the Virtual Brain (TVB) a neuroimaging simulation
> library, written in Python. As part of an effort to reach out to some users
> stuck in MATLAB, I've been testing MATLAB's recent *official* support for
> Python (2014b+). It is notably better than the many other attempts because
> it appears to use Py's C API to expose objects and methods as MATLAB
> objects and methods instead of just providing eval/exec.
>
> Generally it's working, but there are some workarounds to avoid segfaults,
> errors and lack of stdout/err. I've started to collect a series of tips and
> workarounds and figured there might be common interest in the community for
> a "helper" library so all our projects can benefit from a larger user base,
> and maybe ease the transition for potential Python users.
>
> The most important in order,
>
> - Anything touching HDF5 must use exactly the same version as MATLAB or
> segfault
> - Scipy.io.{save,load}mat segfault
> - C++ extension modules whose exception model doesn't match MATLAB's,
> segfault on exception
> - Linalg segfault unless using MKL (which is what MATLAB uses)
> - stdout/err and logging must be redirecting to mexPrintf via a ctypes
> monkey patch
> - Numpy/MATLAB array conversion is O(1) op, but can probably be made zero
> copy with a ctypes + lib mx workaround
>
> Aside from these (for which I sent a service request to MathWorks), it's
> working well and we (TVB) expect our next release to include demo scripts
> in MATLAB.
>
> So, again, if there is common interest in collecting notes and a helper
> library to monkey patch around the segfaults, it'd be great to not do this
> alone ;)
>
> cheers,
> Marmaduke
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20160613/531ae2c3/attachment.html>


More information about the Neuroimaging mailing list