Changeset 314

Show
Ignore:
Timestamp:
11/10/08 15:01:55 (2 months ago)
Author:
pierre
Message:

Fix a bug in my fix for the commit on the CV ticket. I mean, the problem is that I agree we can return NaN values, but then it has to be catched in cv_isi_hist(). So I add a parameter to cv_isi() to say if you want to have all the CV (and some may be Nan) or just the non NaN one :-)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/signals.py

    r313 r314  
    308308            return numpy.std(isi)/numpy.mean(isi) 
    309309        else: 
    310             print "Warning, a CV can't be computed because there are not enough spikes" 
    311             return nan 
     310            logging.debug("Warning, a CV can't be computed because there are not enough spikes") 
     311            return numpy.nan 
    312312 
    313313    def fano_factor_isi(self): 
     
    11251125 
    11261126     
    1127     def cv_isi(self): 
     1127    def cv_isi(self, float_only=False): 
    11281128        """ 
    11291129        Return the list of all the cv coefficients for all the SpikeTrains objects 
    1130         within the SpikeList. 
    1131          
     1130        within the SpikeList. Return NaN when not enough spikes are present 
     1131         
     1132        Inputs: 
     1133            float_only - False by default. If true, NaN values are automatically 
     1134                         removed 
     1135         
     1136        Examples: 
     1137            >> spklist.cv_isi() 
     1138                [0.2,0.3,Nan,2.5,Nan,1.,2.5] 
     1139            >> spklist.cv_isi(True) 
     1140                [0.2,0.3,2.5,1.,2.5] 
     1141 
    11321142        See also: 
    11331143            cv_isi_hist, cv_local, cv_kl 
    11341144        """ 
    1135         cvs_isi = numpy.empty(self.N) 
     1145        cvs_isi = [] 
    11361146        for id in self.id_list(): 
    1137             cvs_isi[id] = self.spiketrains[id].cv_isi() 
     1147            cvs_isi.append(self.spiketrains[id].cv_isi()) 
     1148        cvs_isi = numpy.array(cvs_isi) 
     1149        if float_only: 
     1150            cvs_isi = numpy.extract(numpy.logical_not(numpy.isnan(cvs_isi)),cvs_isi) 
    11381151        return cvs_isi 
    11391152 
     
    11581171            cv_isi, cv_local, cv_kl 
    11591172        """ 
    1160         cvs           = numpy.array(self.cv_isi()
     1173        isi = self.cv_isi(float_only=True
    11611174        if newnum: 
    11621175            values, xaxis = numpy.histogram(cvs, bins=bins, normed=True, new=newnum)