Changeset 13014


Ignore:
Timestamp:
03/08/12 11:24:57 (13 years ago)
Author:
lusterma
Message:
bugs fixed, looks o.k., but more detailed testing needed, threshold = 7.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/pyfact/drs_spikes.py

    r13012 r13014  
    1717    """
    1818   
    19     def __init__(self, threshold=10.,
     19    def __init__(self, threshold=7.,
    2020                 single_pattern=np.array( [-0.5, 1.0, -0.5]) ,
    2121                 double_pattern=np.array([-1., 1., 1., -1.]),
     
    4242        doubles = []
    4343
    44         cc = candidates = np.where(a > self.threshold)
    45         print 'candidates: ', candidates[0]-1
     44        # a spike in the first or last channel is considered as a filter artefact
     45        candidates = np.where(a[1:-2] > self.threshold)
     46        # candidates = np.where(a[1:1022] > self.threshold)
     47        cc = candidates[0]
     48        #print 'cc: ', cc
    4649        #: find single spikes
    4750        p = self.single_pattern * np.sign( self.single_pattern )
    48         for i, can in enumerate( zip(a[cc[0]-1], a[cc[0]], a[cc[0]+1]) ):
    49             print 'can : p', can, p
     51        for i, can in enumerate( zip(a[cc], a[cc+1], a[cc+2]) ):
     52            #print 'can : p', can, p
    5053            can = can * np.sign(self.single_pattern)
    5154            if all(can > p):
    52                 singles.append(candidates[0][i] - 1)
     55                singles.append(cc[i])
    5356
    5457        #: find double spikes
    5558        p = self.double_pattern * np.sign( self.double_pattern )
    56         for i, can in enumerate( zip(a[cc[0]-1], a[cc[0]],
    57                                      a[cc[0]+1], a[cc[0]+2]) ):
    58             print 'can : p', can, p
     59        for i, can in enumerate( zip(a[cc], a[cc+1], a[cc+2], a[cc+3]) ):
     60            #print 'data:  ', [data[0,cc[i]+k] for k in range(3)]
     61            #print 'can : p', can, p
    5962            can = can * np.sign(self.double_pattern)
    6063            if all(can > p):
    61                 doubles.append(candidates[0][i] - 1)
     64                doubles.append(cc[i])
    6265
    6366        if self.debug:
Note: See TracChangeset for help on using the changeset viewer.