Changeset 97
- Timestamp:
- 11/19/08 12:11:35 (2 months ago)
- Files:
-
- trunk/pyssdh/OpenElectrophy/computing/spikesorting/clustering/sc.py (modified) (2 diffs)
- trunk/pyssdh/OpenElectrophy/computing/spikesorting/clustering/superparamagneticclustering.py (modified) (1 diff)
- trunk/pyssdh/OpenElectrophy/computing/spikesorting/detection.py (modified) (1 diff)
- trunk/pyssdh/OpenElectrophy/computing/spikesorting/filtering.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pyssdh/OpenElectrophy/computing/spikesorting/clustering/sc.py
r45 r97 21 21 22 22 class SC : 23 list_param = ['Tmin', 'Tmax', 'deltaT', 'schwelle' ]24 default_param = [ 0., 0.03, 0.01, 0.3 ]25 list_label = ['Temp min', 'Temp max', 'Temp step', 'schwelle' ]23 list_param = ['Tmin', 'Tmax', 'deltaT', 'schwelle', 'regroup_small' ] 24 default_param = [ 0., 0.03, 0.01, 0.3 , 5 ] 25 list_label = ['Temp min', 'Temp max', 'Temp step', 'schwelle', 'regroup small cluster' ] 26 26 27 27 name = 'SuperParamagneticClustering' … … 29 29 def compute(self , waveform, **karg) : 30 30 allcluster = superparamagneticclustering(waveform , **karg ) 31 return allcluster[:,int(allcluster.shape[1]/2)] 31 32 regroup_small = karg['regroup_small'] 33 34 cluster = allcluster[:,int(allcluster.shape[1]/2)] 35 36 u = unique(cluster) 37 nb, c = histogram(cluster, u) 38 for i in u[ nb<karg['regroup_small'] ]: 39 cluster[cluster == i] = u.size 40 41 return cluster 32 42 trunk/pyssdh/OpenElectrophy/computing/spikesorting/clustering/superparamagneticclustering.py
r93 r97 154 154 Tmin=0., 155 155 deltaT=0.005, 156 **karg 156 157 ): 157 158 trunk/pyssdh/OpenElectrophy/computing/spikesorting/detection.py
r45 r97 51 51 52 52 53 list_method = [ StdThreshold ] 53 class MedianThreshold : 54 list_param = ['sign', 'median_thresh', 'refractory_period' ] 55 default_param = [ '+-', 3., 0.004 ] 56 list_label = [ 'Sign (+/-/+-)', 'median tresh', 'Refractory period (s.)' ] 54 57 58 name = 'Median threshold detection' 59 60 def compute(self , sig_f , fs , 61 sign=None, median_thresh = None, refractory_period = None ) : 62 if sign == '-' : 63 sig_f2 = -sig_f 64 elif sign =='+' : 65 sig_f2 = sig_f 66 elif sign == '+-' or sign == '-+' : 67 sig_f2 = abs(sig_f) 68 69 abs_thresh = median(abs(sig_f)/.6745) 70 pos_spike = where( ( sig_f2[1:-1] >=abs_thresh ) & 71 (sig_f2[1:-1] >sig_f2[:-2]) & (sig_f2[1:-1] >=sig_f2[2:] ) 72 )[0] +1 73 pos_spike = eliminate_refractory_period(pos_spike,sig_f ,fs,refractory_period) 74 return pos_spike 75 76 77 78 79 80 list_method = [ StdThreshold, MedianThreshold ] 81 trunk/pyssdh/OpenElectrophy/computing/spikesorting/filtering.py
r45 r97 44 44 45 45 46 def compute(self , sig , fs , win_size ) :46 def compute(self , sig , fs , win_size = None ) : 47 47 sig_f = sig - signal.medfilt(sig , kernel_size = int(win_size/2.*fs)*2+1) 48 return sig_f 49 50 51 class NoFiltering : 52 list_param = [ ] 53 default_param = [ ] 54 list_label = [ ] 55 56 name = 'No filtering' 57 58 def compute(self , sig , fs ) : 59 return sig.copy() 60 61 62 63 64 class ButterworthFiltering : 65 list_param = ['f_low', 'f_hight', 'N', ] 66 default_param = [300., inf, 5, ] 67 list_label = ['Low Freq Cut', 'Hight Freq Cut', 'Order N', ] 68 69 name = 'N order Butterworth Filter' 70 71 def compute(self , sig , fs , f_low = None , f_hight = None, N = 5 ) : 72 if isinf(f_hight): 73 f_hight = .95*fs/2. 74 #Wn = [f_low/(fs/2.) , f_hight/(fs/2.)] 75 #b,a = signal.iirfilter(N, Wn, btype = 'band', analog = 0, ftype = 'butter', output = 'ba') 76 77 Wn = f_low/(fs/2.) 78 b,a = signal.iirfilter(N, Wn, btype = 'high', analog = 0, ftype = 'butter', output = 'ba') 79 80 sig_f = signal.lfilter(b, a, sig, zi = None) 81 return sig_f 82 83 84 class BesselFiltering : 85 list_param = ['f_low', 'f_hight', 'N', ] 86 default_param = [300., inf, 5, ] 87 list_label = ['Low Freq Cut', 'Hight Freq Cut', 'Order N', ] 88 89 name = 'N order Bessel Filter' 90 91 def compute(self , sig , fs , f_low = None , f_hight = None, N = 5 ) : 92 if isinf(f_hight): 93 f_hight = .95*fs/2. 94 #Wn = [f_low/(fs/2.) , f_hight/(fs/2.)] 95 #b,a = signal.iirfilter(N, Wn, btype = 'band', analog = 0, ftype = 'bessel', output = 'ba') 96 97 Wn = f_low/(fs/2.) 98 b,a = signal.iirfilter(N, Wn, btype = 'high', analog = 0, ftype = 'bessel', output = 'ba') 99 100 101 sig_f = signal.lfilter(b, a, sig, zi = None) 48 102 return sig_f 49 103 50 104 51 105 52 list_method = [ MethodFFT , MedianFilter ]106 list_method = [ MethodFFT , MedianFilter, NoFiltering, ButterworthFiltering, BesselFiltering ] 53 107

