Changeset 486
- Timestamp:
- 07/14/11 18:32:11 (10 months ago)
- bzr:base-revision:
- svn-v4:400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk:485
- bzr:committer:
- Michael Pereira <michael.fsp@gmail.com>
- bzr:file-ids:
debian/rules 351@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fdebian%2Frules
doc/signals.txt 273@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fdoc%2Fsignals.txt
examples/retina/retina.py 77@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fexamples%2Fretina%2Fretina.py
examples/single_neuron/simple_single_neuron.py 78@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fexamples%2Fsingle_neuron%2Fsimple_single_neuron.py
src/analysis.py 106@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fanalysis.py
src/datastore/__init__.py 213@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fdatastore%2F__init__.py
src/datastore/django_orm/__init__.py 213@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fdatastore%2Fdjango_orm%2F__init__.py
src/datastore/django_orm/models.py 213@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fdatastore%2Fdjango_orm%2Fmodels.py
src/datastore/interface.py 213@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fdatastore%2Finterface.py
src/datastore/shelve_ds.py 213@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fdatastore%2Fshelve_ds.py
src/facets/mixedutils.py 284@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Ffacets%2Fmixedutils.py
src/plotting.py 106@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fplotting.py
src/signals/intervals.py 390@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fsignals%2Fintervals.py
src/signals/spikes.py 375@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fsignals%2Fspikes.py
src/spike2/__init__.py 214@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fspike2%2F__init__.py
src/spike2/sonpy/README 214@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fspike2%2Fsonpy%2FREADME
src/spike2/sonpy/__init__.py 214@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fspike2%2Fsonpy%2F__init__.py
src/spike2/sonpy/_marker.py 214@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fspike2%2Fsonpy%2F_marker.py
src/spike2/sonpy/_waveform.py 214@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fspike2%2Fsonpy%2F_waveform.py
src/spike2/sonpy/son.py 214@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Fspike2%2Fsonpy%2Fson.py
src/utilities/__init__.py 225@400bb3d0-8d2e-0410-a2c0-f692ac833539:trunk%2Fsrc%2Futilities%2F__init__.py- bzr:mapping-version:
- v4
- bzr:merge:
michael.fsp@gmail.com-20110714162651-g03c2jgqof2dangy- bzr:repository-uuid:
- 400bb3d0-8d2e-0410-a2c0-f692ac833539
- bzr:revision-id:
- michael.fsp@gmail.com-20110714163140-v3qk0357xh8xn2zv
- bzr:revno:
- 430
- bzr:revprop:branch-nick:
- trunk
- bzr:root:
- trunk
- bzr:text-revisions:
debian/rules michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
doc/signals.txt michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
examples/retina/retina.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
examples/single_neuron/simple_single_neuron.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/analysis.py michael.fsp@gmail.com-20110714162651-g03c2jgqof2dangy
src/datastore/__init__.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/datastore/django_orm/__init__.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/datastore/django_orm/models.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/datastore/interface.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/datastore/shelve_ds.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/facets/mixedutils.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/plotting.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/signals/intervals.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/signals/spikes.py michael.fsp@gmail.com-20110714162651-g03c2jgqof2dangy
src/spike2/__init__.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/spike2/sonpy/README michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/spike2/sonpy/__init__.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/spike2/sonpy/_marker.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/spike2/sonpy/_waveform.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/spike2/sonpy/son.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah
src/utilities/__init__.py michael.fsp@gmail.com-20110526110242-ofx6nnkfmr7delah- bzr:timestamp:
- 2011-07-14 18:31:40.723999977 +0200
- bzr:user-agent:
- bzr2.3.1+bzr-svn1.0.5dev0
- svn:original-date:
- 2011-07-14T16:31:40.724000Z
- Location:
- trunk
- Files:
-
- 21 modified
-
debian/rules (modified) (1 prop)
-
doc/signals.txt (modified) (1 prop)
-
examples/retina/retina.py (modified) (1 prop)
-
examples/single_neuron/simple_single_neuron.py (modified) (1 prop)
-
src/analysis.py (modified) (4 diffs)
-
src/datastore/__init__.py (modified) (1 prop)
-
src/datastore/django_orm/__init__.py (modified) (1 prop)
-
src/datastore/django_orm/models.py (modified) (1 prop)
-
src/datastore/interface.py (modified) (1 prop)
-
src/datastore/shelve_ds.py (modified) (1 prop)
-
src/facets/mixedutils.py (modified) (1 prop)
-
src/plotting.py (modified) (1 prop)
-
src/signals/intervals.py (modified) (3 diffs)
-
src/signals/spikes.py (modified) (5 diffs)
-
src/spike2/__init__.py (modified) (1 prop)
-
src/spike2/sonpy/README (modified) (1 prop)
-
src/spike2/sonpy/__init__.py (modified) (1 prop)
-
src/spike2/sonpy/_marker.py (modified) (1 prop)
-
src/spike2/sonpy/_waveform.py (modified) (1 prop)
-
src/spike2/sonpy/son.py (modified) (1 prop)
-
src/utilities/__init__.py (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/debian/rules
- Property svn:executable deleted
-
trunk/doc/signals.txt
- Property svn:executable deleted
-
trunk/examples/retina/retina.py
- Property svn:executable deleted
-
trunk/examples/single_neuron/simple_single_neuron.py
- Property svn:executable deleted
-
trunk/src/analysis.py
r482 r486 143 143 sua2. Thus positive values of int relate to events of sua2 that 144 144 lead events of sua1. Units are the same as the input arrays. 145 int_ - predict ior: accumulated differences based on the prediction145 int_ - predictor: accumulated differences based on the prediction 146 146 method. The length of int_ is n_pred * length(int). Units are 147 147 the same as the input arrays. … … 216 216 217 217 # Plot the results if display=True 218 subplot = get_display(display) 219 if not subplot or not HAVE_PYLAB: 218 if display: 219 subplot = get_display(display) 220 if not subplot or not HAVE_PYLAB: 221 return int, int_, norm 222 else: 223 # Plot the cross-correlation 224 try: 225 counts, bin_edges = numpy.histogram(int, **kwargs) 226 edge_distances = numpy.diff(bin_edges) 227 bin_centers = bin_edges[1:] - edge_distances/2 228 counts = counts / norm 229 xlabel = "Time" 230 ylabel = "Cross-correlation coefficient" 231 #NOTE: the x axis corresponds to the upper edge of each bin 232 subplot.plot(bin_centers, counts, label='cross-correlation', color='b') 233 if predictor is None: 234 set_labels(subplot, xlabel, ylabel) 235 pylab.draw() 236 elif predictor is 'shuffle': 237 # Plot the predictor 238 norm_ = norm * n_pred 239 counts_, bin_edges_ = numpy.histogram(int_, **kwargs) 240 counts_ = counts_ / norm_ 241 subplot.plot(bin_edges_[1:], counts_, label='predictor') 242 subplot.legend() 243 pylab.draw() 244 except ValueError: 245 print "There are no correlated events within the selected lag"\ 246 " window of %s" % lag 247 else: 220 248 return int, int_, norm 221 else: 222 # Plot the cross-correlation 223 try: 224 counts, bin_edges = numpy.histogram(int, **kwargs) 225 counts = counts / norm 226 xlabel = "Time" 227 ylabel = "Cross-correlation coefficient" 228 #NOTE: the x axis corresponds to the upper edge of each bin 229 subplot.plot(bin_edges[1:], counts, label='cross-correlation') 230 if predictor is None: 231 set_labels(subplot, xlabel, ylabel) 232 pylab.draw() 233 elif predictor is 'shuffle': 234 # Plot the predictor 235 norm_ = norm * n_pred 236 counts_, bin_edges_ = numpy.histogram(int_, **kwargs) 237 counts_ = counts_ / norm_ 238 subplot.plot(bin_edges_[1:], counts_, label='predictor') 239 subplot.legend() 240 pylab.draw() 241 except ValueError: 242 print "There are no correlated events within the selected lag"\ 243 " window of %s" % lag 249 244 250 def _dict_max(D): 245 251 """ … … 254 260 return k 255 261 256 def make_kernel(form, sigma, time_stamp_resolution, direction=1, kernel=None, 257 m_idx=None): 262 def make_kernel(form, sigma, time_stamp_resolution, direction=1): 258 263 """ 259 264 Constructs a numeric linear convolution kernel of basic shape to be used … … 312 317 m_idx - index of the numerically determined median (center of gravity) 313 318 of the kernel function 319 320 Further comments: 321 322 Assume matrix X of n spike trains represented as binary vector (0/1). 323 324 To obtain single trial rate function of trial one should use 325 r = norm * numpy.convolve(sua, kernel) 326 To obtain trial-averaged spike train one should use 327 r_avg = norm * numpy.convolve(sua, np.mean(X,1)) 328 329 where X is an array of shape (l,n), where n is the number of trials and 330 l the length of each trial 331 332 Note that filter assumes a causal filtering. To represent the resulting 333 firing rate function at center of gravity (acausal) use 334 335 r=r(length(kernel):end); -> discard first length(kernel)-1 336 elements which considered zero entries 337 (border effect) 338 t=((1:length(r))+m_idx)*TimeStampResolution -> in seconds 339 plot(t,r) -> in second time scale 314 340 """ 315 341 assert form.upper() in ('BOX','TRI','GAU','EPA','EXP','ALP'), "form must \ 316 be one either 'BOX','TRI','GAU','EPA','EXP' or 'ALP'!"342 be one of either 'BOX','TRI','GAU','EPA','EXP' or 'ALP'!" 317 343 318 344 assert direction in (1,-1), "direction must be either 1 or -1" -
trunk/src/datastore/__init__.py
- Property svn:executable deleted
-
trunk/src/datastore/django_orm/__init__.py
- Property svn:executable deleted
-
trunk/src/datastore/django_orm/models.py
- Property svn:executable deleted
-
trunk/src/datastore/interface.py
- Property svn:executable deleted
-
trunk/src/datastore/shelve_ds.py
- Property svn:executable deleted
-
trunk/src/facets/mixedutils.py
- Property svn:executable deleted
-
trunk/src/plotting.py
- Property svn:executable deleted
-
trunk/src/signals/intervals.py
r401 r486 4 4 5 5 if HAVE_INTERVAL: 6 from interval import * 6 from interval import * 7 7 8 8 import numpy … … 31 31 self.end_times = end_times 32 32 # write the intervals to an interval object (pyinterval) 33 test = isinstance(start_times, int) or isinstance(start_times, float) 33 scalar_types = (int, float, numpy.float, numpy.float32, numpy.float64, numpy.int, numpy.int8, 34 numpy.int16, numpy.int32, numpy.int64) 35 test = isinstance(start_times, scalar_types) 34 36 if test: 35 s tart_times = [start_times]36 test = isinstance(end_times, int) or isinstance(end_times, float)37 self.start_times = [self.start_times] 38 test = isinstance(end_times, scalar_types) 37 39 if test: 38 end_times = [end_times]39 if len(s tart_times) != len(end_times) :40 self.end_times = [self.end_times] 41 if len(self.start_times) != len(self.end_times) : 40 42 raise Exception("There sould be an equal number of starts and stops") 41 43 self.interval_data = interval(*numpy.transpose(numpy.array([start_times,end_times]))) … … 45 47 test = isinstance(end_times, int) or isinstance(end_times, float) 46 48 assert test, "Interval package not present, end_times should be a number !" 47 self.start_times = start_times48 self.end_times = end_times49 self.start_times = [start_times] 50 self.end_times = [end_times] 49 51 50 52 def intersect(self, itv) : -
trunk/src/signals/spikes.py
r485 r486 27 27 28 28 import os, re, numpy 29 import scipy.signal 29 30 import logging 30 31 from NeuroTools import check_dependency, check_numpy_version … … 85 86 ####################################################################### 86 87 def __init__(self, spike_times, t_start=None, t_stop=None): 88 #TODO: add information about sampling rate at time of creation 89 87 90 """ 88 91 Constructor of the SpikeTrain object … … 449 452 if not subplot or not HAVE_PYLAB: 450 453 print PYLAB_ERROR 451 return452 454 else: 453 455 if len(spikes) > 0: … … 570 572 hist = hist.astype(bool).astype(int) 571 573 return hist 572 574 575 def instantaneous_rate(self, resolution, kernel, norm, t_start=None, 576 t_stop=None, acausal=True, m_idx=None, 577 trim=False): 578 """ 579 Estimate instantaneous firing rate by kernel convolution. 580 581 Inputs: 582 resolution - time stamp resolution of the spike times (ms). the 583 same resolution will be assumed for the kernel 584 kernel - kernel function used to convolve with 585 norm - normalization factor associated with kernel function 586 (see analysis.make_kernel for details) 587 t_start - start time of the interval used to compute the firing 588 rate 589 t_stop - end time of the interval used to compute the firing 590 rate (included) 591 acausal - if True, acausal filtering is used, i.e., the gravity 592 center of the filter function is aligned with the 593 spike to convolve 594 m_idx - index of the value in the kernel function vector that 595 corresponds to its gravity center. this parameter is 596 not mandatory for symmetrical kernels but it is 597 required when assymmetrical kernels are to be aligned 598 at their gravity center with the event times 599 trim - if True, only the 'valid' region of the convolved 600 signal are returned, i.e., the points where there 601 isn't complete overlap between kernel and spike train 602 are discarded 603 NOTE: if True and an assymetrical kernel is provided 604 the output will not be aligned with [t_start, t_stop] 605 """ 606 607 if t_start is None: 608 t_start = self.t_start 609 610 if t_stop is None: 611 t_stop = self.t_stop 612 613 if m_idx is None: 614 m_idx = kernel.size / 2 615 616 time_vector = numpy.zeros((t_stop - t_start)/resolution + 1) 617 618 spikes_slice = self.spike_times[(self.spike_times >= t_start) & ( 619 self.spike_times <= t_stop)] 620 621 for spike in spikes_slice: 622 index = (spike - t_start) / resolution 623 time_vector[index] = 1 624 625 r = norm * scipy.signal.fftconvolve(time_vector, kernel, 'full') 626 627 if acausal is True: 628 if trim is False: 629 r = r[m_idx:-(kernel.size - m_idx)] 630 t_axis = numpy.linspace(t_start, t_stop, r.size) 631 return t_axis, r 632 633 elif trim is True: 634 r = r[2 * m_idx:-2*(kernel.size - m_idx)] 635 t_start = t_start + m_idx * resolution 636 t_stop = t_stop - ((kernel.size) - m_idx) * resolution 637 t_axis = numpy.linspace(t_start, t_stop, r.size) 638 return t_axis, r 639 640 if acausal is False: 641 if trim is False: 642 r = r[m_idx:-(kernel.size - m_idx)] 643 t_axis = (numpy.linspace(t_start, t_stop, r.size) + 644 m_idx * resolution) 645 return t_axis, r 646 647 elif trim is True: 648 r = r[2 * m_idx:-2*(kernel.size - m_idx)] 649 t_start = t_start + m_idx * resolution 650 t_stop = t_stop - ((kernel.size) - m_idx) * resolution 651 t_axis = (numpy.linspace(t_start, t_stop, r.size) + 652 m_idx * resolution) 653 return t_axis, r 654 573 655 def relative_times(self): 574 656 """ … … 845 927 ## using a generator to build the SpikeList... 846 928 847 if not hasattr(spikes, 'size'): # is an array:929 if not isinstance(spikes, numpy.ndarray): # is an array: 848 930 spikes = numpy.array(spikes, numpy.float32) 849 931 N = len(spikes) -
trunk/src/spike2/__init__.py
- Property svn:executable deleted
-
trunk/src/spike2/sonpy/README
- Property svn:executable deleted
-
trunk/src/spike2/sonpy/__init__.py
- Property svn:executable deleted
-
trunk/src/spike2/sonpy/_marker.py
- Property svn:executable deleted
-
trunk/src/spike2/sonpy/_waveform.py
- Property svn:executable deleted
-
trunk/src/spike2/sonpy/son.py
- Property svn:executable deleted
-
trunk/src/utilities/__init__.py
- Property svn:executable deleted
