- Timestamp:
- 03/24/11 12:45:12 (14 months ago)
- Files:
-
- 1 modified
-
trunk/src/signals/spikes.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/signals/spikes.py
r483 r484 563 563 else: 564 564 hist, edges = numpy.histogram(self.spike_times, bins) 565 if normalized and isinstance(time_bin, int): # what about normalization if time_bin is a sequence? 566 hist *= 1000.0/time_bin 565 hist = hist.astype(float) 566 if normalized: # what about normalization if time_bin is a sequence? 567 hist *= 1000.0/float(time_bin) 567 568 return hist 568 569 … … 769 770 """ 770 771 hist = self.time_histogram(time_bin, normalized=False) 772 from NeuroTools import analysis 771 773 freq_spect = analysis.simple_frequency_spectrum(hist) 772 774 freq_bin = 1000.0/self.duration() # Hz … … 1192 1194 id_list = numpy.sort(self.id_list) 1193 1195 N = len(id_list) 1194 1195 for idx in xrange(1,len(id_list)+1): 1196 id = id_list[N-idx] 1197 spk = self.spiketrains.pop(id) 1198 self.spiketrains[id + offset] = spk 1196 if (offset > 0): 1197 for idx in xrange(1, len(id_list)+1): 1198 id = id_list[N-idx] 1199 spk = self.spiketrains.pop(id) 1200 self.spiketrains[id + offset] = spk 1201 if (offset < 0): 1202 for idx in xrange(0, len(id_list)): 1203 id = id_list[idx] 1204 spk = self.spiketrains.pop(id) 1205 self.spiketrains[id + offset] = spk 1199 1206 1200 1207 def first_spike_time(self): … … 1882 1889 hist_2 = pairs_generator.spk2[pairs[idx,1]].time_histogram(time_bin) 1883 1890 if not average: 1891 from NeuroTools import analysis 1884 1892 results[idx,:] = analysis.ccf(hist_1,hist_2) 1885 1893 else: 1894 from NeuroTools import analysis 1886 1895 results += analysis.ccf(hist_1,hist_2) 1887 1896 if not subplot or not HAVE_PYLAB: … … 2186 2195 for ev in events: 2187 2196 ev = numpy.floor(ev/time_bin) 2188 if ((ev - t_min_l )> t_start) and (ev + t_max_l ) < t_stop: 2197 if ((ev - t_min_l )> t_start) and (ev + t_max_l ) < t_stop: 2189 2198 count += 1 2190 result += spk_hist[:,(ev-t_ min_l):ev+t_max_l]2199 result += spk_hist[:,(ev-t_start-t_min_l):ev-t_start+t_max_l] 2191 2200 result /= count 2192 2201 if average: … … 2256 2265 else: 2257 2266 files = [] 2258 activity_map = numpy.zeros(self.dimensions) 2259 im = subplot.imshow(activity_map, **kwargs) 2260 im.set_clim(bounds[0],bounds[1]) 2261 pylab.colorbar(im) 2267 if float_positions is None: 2268 activity_map = numpy.zeros(self.dimensions) 2269 im = subplot.imshow(activity_map, **kwargs) 2270 im.set_clim(bounds[0],bounds[1]) 2271 pylab.colorbar(im) 2272 else: 2273 rates = [0]*len(self) 2274 im = subplot.scatter(float_positions[0,:], float_positions[1,:], c=rates, **kwargs) 2275 im.set_clim(bounds[0],bounds[1]) 2276 pylab.colorbar(im) 2262 2277 count = 0 2263 2278 idx = 0 … … 2286 2301 im.set_array(activity_map) 2287 2302 subplot.title("time = %d ms" %t_start) 2288 manager.canvas.draw()2289 2303 im.set_clim(bounds[0],bounds[1]) 2304 manager.canvas.draw() 2290 2305 fname = "_tmp_spikes_%05d.png" %count 2291 2306 #logging.debug("Saving Frame %s", fname) … … 2294 2309 files.append(fname) 2295 2310 t_start += time_bin 2296 count += 1 2311 count += 1 2312 elif isinstance(float_positions, numpy.ndarray): 2313 if not len(self) == len(float_positions[0]): 2314 raise Exception("Error, the number of flotting positions does not match the number of cells in the SpikeList") 2315 while (t_start < t_stop): 2316 rates = [0]*len(self) 2317 while ((time[idx] < t_start + time_bin) and (idx < max_idx)): 2318 rates[pos[idx]] += 1 2319 idx += 1 2320 im = subplot.scatter(float_positions[0,:], float_positions[1,:], c=rates, **kwargs) 2321 subplot.title("time = %d ms" %t_start) 2322 im.set_clim(bounds[0],bounds[1]) 2323 manager.canvas.draw() 2324 fname = "_tmp_spikes_%05d.png" %count 2325 #logging.debug("Saving Frame %s", fname) 2326 progress_bar(float(t_start)/t_stop) 2327 pylab.savefig(fname) 2328 files.append(fname) 2329 t_start += time_bin 2330 count += 1 2297 2331 command = "mencoder 'mf://_tmp_*.png' -mf type=png:fps=%d -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o %s" %(fps,output) 2298 2332 logging.debug(command)
