[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python from Matlab (was: *cochlea*: inner ear models in Python)



Hi Alain,

"calling" python from matlab is easy (as you are probably aware, you
can all anything from Matlab using the dos() function, and I often
conjure up little python helpers from matlab in this way). The hard
part is shifting data between python and matlab in a way that is
efficient, elegant and easy to implement, and which works on UNIX
based systems as well as on Windows (i.e. no proprietary OLE). You can
always hack together a kludge that writes temporary binary files in
one environment and reads it in the other (which is what I tend to
do), but that is inelegant and has nontrivial overheads. Or you could
python and matlab work together on some sort of client/server model.
That would be more elegant - the matlab and python parts then wouldn't
even have to be on the same machine, but the programming investment is
very large. I don't know of any developments to make this sort of
stuff easier that are even on the distant horizon. If other list
members know of any I would be interested to hear about them.

Cheers,

J

On 22 August 2014 08:44, Alain de Cheveigne <alain.de.cheveigne@xxxxxx> wrote:
> Hi Marek,
>
> I am looking for the opposite: an easy, efficient  and reliable way to call Python from Matlab.  My programming environment nowdays is matlab and I can't easily change.  The best course that I see is to implement new code in Python and call it from matlab, and make the switch to Python when Python code reaches critical mass.  I suspect many people are in a similar position.
>
> Alain
>
>
>
> On 21 Aug 2014, at 11:20, Marek Rudnicki <marek.rudnicki@xxxxxx> wrote:
>
>> Etienne Gaudrain <e.p.c.gaudrain@xxxxxxx> writes:
>>
>>> Dear Marek,
>>>
>>> This looks very promising, I'm glad to finally see the first signs of a
>>> shift from Matlab to Python. Thanks a lot for sharing this!!
>>
>> Dear Etienne
>>
>> I'm glad you like it.
>>
>> BTW, if you still have some MATLAB legacy code that you would like to
>> use in Python, then matlab_wrapper [1] could be helpful.  It allows you
>> to call MATLAB functions directly from Python environment (the MATLAB
>> process is started in the background), e.g.:
>>
>> matlab.workspace.sin([0.1, 0.2, 0.3])
>>
>>
>> Cheers
>> Marek
>>
>>
>> [1] https://github.com/mrkrd/matlab_wrapper
>>
>>
>>
>>> On 19/08/2014 14:50, Marek Rudnicki wrote:
>>>> Hi all,
>>>>
>>>> we would like to announce *cochlea* -- a collection of inner ear
>>>> models in Python.  It was developed in the group of Werner Hemmert [1]
>>>> at the Technische Universität München.  After a few years of
>>>> development, we decided that it is stable and would like to contribute
>>>> it to the auditory community.
>>>>
>>>>
>>>>
>>>> The main features of the package are:
>>>>
>>>>   - simple to use (each model is implemented as a single Python
>>>>     function: sound in, spikes out)
>>>>   - fast (you can generate responses of hundreds or even thousands of
>>>>     nerve fibers)
>>>>   - all models have the same interface (easy to make comparisons and
>>>>     pick the one that best suits your needs)
>>>>   - up-to-date (recent models included)
>>>>
>>>>
>>>>
>>>> Currently implemented models are:
>>>>
>>>>   - Zilany, M. S., Bruce, I. C., & Carney, L. H. (2014). Updated
>>>>     parameters and expanded simulation options for a model of the
>>>>     auditory periphery. The Journal of the Acoustical Society of
>>>>     America, 135(1), 283-286.
>>>>   - Zilany, M. S., Bruce, I. C., Nelson, P. C., & Carney,
>>>>     L. H. (2009). A phenomenological model of the synapse between the
>>>>     inner hair cell and auditory nerve: long-term adaptation with
>>>>     power-law dynamics. The Journal of the Acoustical Society of
>>>>     America, 126(5), 2390-2412.
>>>>   - Holmberg, M. (2007). Speech Encoding in the Human Auditory
>>>>     Periphery: Modeling and Quantitative Assessment by Means of
>>>>     Automatic Speech Recognition. PhD thesis, Technical University
>>>>     Darmstadt.
>>>>   - MATLAB Auditory Periphery by Meddis et al. (external model, not
>>>>     implemented in the package, but easily accessible through
>>>>     matlab_wrapper).
>>>>
>>>>
>>>>
>>>> We are really grateful to the authors of those models for allowing us
>>>> to use their code it in *cochlea*.  We release the package under the
>>>> GNU General Public License, so that you are free to copy, use and
>>>> modify the code.  We also encourage you to contribute back your
>>>> changes.
>>>>
>>>>
>>>> The code is distributed on GitHub [2] and the package/documentation
>>>> are hosted on the Python Package Index [3].  Check also our demo [4]!
>>>>
>>>>
>>>> If you would like to give a feedback, have questions or found some
>>>> problem, do not hesitate to email me or open an issue on GitHub [2].
>>>>
>>>>
>>>> Thank you and best regards
>>>> Marek Rudnicki
>>>>
>>>>
>>>> [1] http://www.imetum.tum.de/research/bai/home/?L=1
>>>> [2] https://github.com/mrkrd/cochlea
>>>> [3] https://pythonhosted.org/cochlea/
>>>> [4] http://nbviewer.ipython.org/github/mrkrd/cochlea/blob/master/examples/cochlea_demo.ipynb



-- 
Prof Jan Schnupp
University of Oxford
Dept. of Physiology, Anatomy and Genetics
Sherrington Building - Parks Road
Oxford OX1 3PT - UK
+44-1865-282012
http://jan.schnupp.net