- Timestamp:
- 06/08/11 16:44:37 (12 months ago)
- Location:
- trunk/src/signals
- Files:
-
- 2 modified
-
analogs.py (modified) (3 diffs)
-
spikes.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/signals/analogs.py
r468 r485 398 398 399 399 Inputs: 400 signals - a list of t he AnalogSignals objects400 signals - a list of tuples (id, value) with all the values sorted in time of the analog signals 401 401 id_list - the list of the ids of all recorded cells (needed for silent cells) 402 402 dt - if dt is specified, time values should be floats … … 423 423 424 424 signals = numpy.array(signals) 425 426 425 for id in id_list: 427 426 signal = numpy.transpose(signals[signals[:,0] == id, 1:])[0] … … 821 820 if v_thresh is not None: 822 821 to_be_plot = pylab.where(to_be_plot>=v_thresh-0.02, v_thresh+0.5, to_be_plot) 822 if len(time_axis) > len(to_be_plot): 823 time_axis = time_axis[:-1] 824 if len(to_be_plot) > len(time_axis): 825 to_be_plot = to_be_plot[:-1] 823 826 subplot.plot(time_axis, to_be_plot, **kwargs) 824 827 subplot.hold(1) -
trunk/src/signals/spikes.py
r484 r485 148 148 149 149 def __del__(self): 150 pass150 del self.spike_times 151 151 152 152 def __len__(self): … … 534 534 535 535 536 def time_histogram(self, time_bin=10, normalized=True ):536 def time_histogram(self, time_bin=10, normalized=True, binary=False): 537 537 """ 538 538 Bin the spikes with the specified bin width. The first and last bins … … 544 544 in spikes/second, otherwise otherwise it's the number of spikes 545 545 per bin. 546 binary - if True, a binary matrix of 0/1 is returned 546 547 547 548 Examples: … … 566 567 if normalized: # what about normalization if time_bin is a sequence? 567 568 hist *= 1000.0/float(time_bin) 569 if binary: 570 hist = hist.astype(bool).astype(int) 568 571 return hist 569 572 … … 867 870 868 871 def __del__(self): 869 pass 872 for id in self.id_list: 873 del self.spiketrains[id] 870 874 871 875 @property … … 1071 1075 spiketrain.relative_times() 1072 1076 self.append(id, spiketrain) 1073 1077 self.__calc_startstop() 1074 1078 1075 1079 def complete(self, id_list): … … 1617 1621 1618 1622 1619 def spike_histogram(self, time_bin, normalized=False, display=False, kwargs={}):1623 def spike_histogram(self, time_bin, normalized=False, binary=False, display=False, kwargs={}): 1620 1624 """ 1621 1625 Generate an array with all the spike_histograms of all the SpikeTrains … … 1628 1632 display - if True, a new figure is created. Could also be a subplot. The averaged 1629 1633 spike_histogram over the whole population is then plotted 1634 binary - if True, a binary matrix of 0/1 is returned 1630 1635 kwargs - dictionary contening extra parameters that will be sent to the plot 1631 1636 function … … 1639 1644 if newnum: 1640 1645 M -= 1 1641 spike_hist = numpy.zeros((N, M), numpy.float32) 1646 if binary: 1647 spike_hist = numpy.zeros((N, M), numpy.int) 1648 else: 1649 spike_hist = numpy.zeros((N, M), numpy.float32) 1642 1650 subplot = get_display(display) 1651 1643 1652 for idx,id in enumerate(self.id_list): 1644 spike_hist[idx,:] = self.spiketrains[id].time_histogram(time_bin, normalized) 1653 if newnum: 1654 if not hist_new: 1655 hist, edges = numpy.histogram(self.spiketrains[id].spike_times, nbins) 1656 else: 1657 hist, edges = numpy.histogram(self.spiketrains[id].spike_times, nbins, new=newnum) 1658 else: 1659 hist, edges = numpy.histogram(self.spike_times, bins) 1660 hist = hist.astype(float) 1661 if normalized: # what about normalization if time_bin is a sequence? 1662 hist *= 1000.0/float(time_bin) 1663 if binary: 1664 hist = hist.astype(bool) 1665 spike_hist[idx,:] = hist 1645 1666 if not subplot or not HAVE_PYLAB: 1646 1667 return spike_hist … … 1659 1680 1660 1681 1661 def firing_rate(self, time_bin, display=False, average=False, kwargs={}):1682 def firing_rate(self, time_bin, display=False, average=False, binary=False, kwargs={}): 1662 1683 """ 1663 1684 Generate an array with all the instantaneous firing rates along time (in Hz) … … 1670 1691 display - if True, a new figure is created. Could also be a subplot. The averaged 1671 1692 spike_histogram over the whole population is then plotted 1693 binary - If True, a binary matrix with 0/1 is returned. 1672 1694 kwargs - dictionary contening extra parameters that will be sent to the plot 1673 1695 function … … 1676 1698 spike_histogram, time_axis 1677 1699 """ 1678 result = self.spike_histogram(time_bin, normalized=True, display=display, kwargs=kwargs)1700 result = self.spike_histogram(time_bin, normalized=True, binary=False, display=display, kwargs=kwargs) 1679 1701 if average: 1680 1702 return numpy.mean(result, axis=0)
