~ubuntu-branches/ubuntu/wily/brian/wily

« back to all changes in this revision

Viewing changes to brian/hears/filtering/test2.py

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2014-07-30 11:29:44 UTC
  • mfrom: (6.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140730112944-ln0ogbq0kpyyuz47
Tags: 1.4.1-2
* Forgotten upload to unstable
* debian/control
  - policy boost to 3.9.5
  - updated Vcs- fields given migration to anonscm.d.o and provided -b
    debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from time import time
2
 
#http://amtoolbox.sourceforge.net/doc/filters/gammatone.php
3
 
from brian import *
4
 
set_global_preferences(useweave=True)
5
 
from scipy.io import loadmat,savemat
6
 
 
7
 
from brian.hears import *
8
 
#from zilany import *
9
 
 
10
 
if __name__ == '__main__':
11
 
    simulation_duration = 100*ms
12
 
    set_default_samplerate(50*kHz)
13
 
    sound = whitenoise(simulation_duration)
14
 
    #file="/home/bertrand/Data/MatlabProg/brian_hears/Carney/sound.mat"
15
 
    #X=loadmat(file,struct_as_record=False)
16
 
    #sound = Sound(X['sound'].flatten())
17
 
    sound.samplerate = 50*kHz
18
 
    sound = sound.atlevel(120*dB) # level in rms dB SPL
19
 
    X={}
20
 
    X['sound'] = sound.__array__()
21
 
    savemat('/home/bertrand/Data/MatlabProg/brian_hears/Carney/sound.mat',X)
22
 
 
23
 
    #sound = Sound(randn(1000))
24
 
    #plot(sound)
25
 
    #show()
26
 
    #sound.samplerate = 100*kHz
27
 
    cf = array([1000*Hz])#erbspace(100*Hz, 1000*Hz, 50) # centre frequencies
28
 
    #cf = erbspace(100*Hz, 1000*Hz, 500) # centre frequencies
29
 
 
30
 
    param_drnl = {}
31
 
    #param_drnl['lp_nl_cutoff_m'] = 1.1
32
 
    zilany_filter=TAN(sound, cf,1)
33
 
    #zilany_filter=DRNL(sound, cf)
34
 
    t1=time()
35
 
    drnl = zilany_filter.process()
36
 
    print time()-t1
37
 
    print drnl.shape
38
 
    #drnl =zilany_filter.control_cont 
39
 
    #drnl =zilany_filter.signal_cont 
40
 
    X={}
41
 
    X['out_BM'] = drnl[:]
42
 
    #X['out_BM'] = zilany_filter.param
43
 
    savemat('/home/bertrand/Data/MatlabProg/brian_hears/Carney/out_BM.mat',X)
44
 
 
45
 
    #figure()
46
 
    subplot(211)
47
 
    ##print drnl[:]R
48
 
    plot(drnl[:])
49
 
    #imshow(flipud(drnl.T), aspect='auto')
50
 
    subplot(212)
51
 
    #print sound
52
 
    plot(sound)
53
 
    #imshow(flipud(dcgc.T), aspect='auto')
54
 
    show()