brian-team / brian2hears

"Brian Hears" auditory modelling toolbox for the brian2 simulator
Other
25 stars 3 forks source link

ModuleNotFoundError: No module named 'brian2.codegen.runtime.weave_rt' #12

Closed shengchiliu closed 3 years ago

shengchiliu commented 3 years ago

I'm trying to use the example code https://brian2hears.readthedocs.io/en/stable/auto_examples/sound_localisation_model.html?highlight=cochlear%20filter%20hrtf#sphx-glr-download-auto-examples-sound-localisation-model-py to apply cochlear filtering to HRTFs. However, I got an error. (ModuleNotFoundError: No module named 'brian2.codegen.runtime.weave_rt')

mstimberg commented 3 years ago

Hi. Apologies for this, we haven't updated the brian2hears package in a while, so it has not kept up with the demise of Python 2 and weave and the related changes in Brian 2. We will hopefully fix this soon (see PR #11) and then make a new release. Until then you have three options:

  1. install a Python 2 environment together with Brian 2.3.0.2 which should work with the last released version of Brian2Hears.
  2. Install Brian2Hears directly from the branch associated with the above PR by using: pip install https://github.com/brian-team/brian2hears/archive/remove_weave.zip
  3. Apply the "fast fix" mentioned here: https://github.com/brian-team/brian2hears/issues/10#issue-721520476
shengchiliu commented 3 years ago

@mstimberg many thanks for the solutions. Except this module error, there is another question that I hope to use cochlear filtering my HRTFs to get ideal localised HRTFs. Your example code demos how apply the HRTF to a sound (hrtf_fb = hrtf.filterbank(sound)), but for my case I simply want to get the filtered HRTFs. Do you know how to do get the HRTFs without applying to a sound? Thanks in advance.

mstimberg commented 3 years ago

I just made a new release, so if you update brian2hears to version 0.9.2 it should now hopefully work. I cannot comment much on the HRTF question, I'm only helping with the maintenance of this package, I haven't used it myself in a number of years. I think that the htrf variable, i.e. before you call filterbank on it is just the measured HRTF. it is stored as a Sound object which might seem odd, but a Sound is basically just an array of values together with the timing information, i.e. the sampling rate. You can call numpy.array(htrf) to get it as a standard numpy array. You can find out more about this in the documentation.