Changeset 181
- Timestamp:
- 07/23/08 20:25:14 (4 months ago)
- Files:
-
- trunk/src/spikes.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/spikes.py
r180 r181 219 219 self.spike_time = sort(self.spike_time) 220 220 221 # Return a sub SpikeTrain object between two time bounds222 221 def subSpikeTrain(self, t_start, t_stop): 223 """ returns a spike train sliced between t_start and t_stop 224 225 """ 226 idx = numpy.where((self.spike_times >= t_start) & (self.spike_times <= t_stop))[0] 222 """ Returns a spike train sliced between t_start and t_stop 223 t_start and t_stop may either be single values or sequences of start 224 and stop times. 225 """ 226 if hasattr(t_start, '__len__'): 227 assert len(t_start) == len(t_stop) 228 mask = False 229 for t0,t1 in zip(t_start, t_stop): 230 mask = mask | (self.spike_times >= t0) & (self.spike_times <= t1) 231 t_start = t_start[0] 232 t_stop = t_stop[-1] 233 else: 234 mask = (self.spike_times >= t_start) & (self.spike_times <= t_stop) 235 idx = numpy.where(mask)[0] 227 236 spikes = self.spike_times[idx] 228 237 return SpikeTrain(spikes, self.dt, t_start, t_stop) … … 240 249 hist *= 1000.0/time_bin 241 250 return hist 251 252 def rescale(self): 253 """Rescale spike times to make t_start = 0.""" 254 if self.t_start != 0: 255 self.spike_times -= self.t_start 256 self.t_stop -= self.t_start 257 self.t_start = 0.0 242 258 243 259 def tuning_curve(self, var_array, normalized=False, method='sum'): … … 269 285 time_histogram = self.time_histogram(binwidth, normalized=normalized) 270 286 assert len(time_histogram) == len(var_array) 271 #def _orientation_tuning_curve(time_bins, orientations, responses, method='sum'):272 287 tuning_curve = {} 273 288 counts = {}

