Changeset 320
- Timestamp:
- 11/11/08 13:17:55 (2 months ago)
- Files:
-
- trunk/doc/io.txt (modified) (4 diffs)
- trunk/src/io.py (modified) (4 diffs)
- trunk/src/signals.py (modified) (2 diffs)
- trunk/test/test_signals.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/io.txt
r280 r320 41 41 If you want to read a data file with spikes, and return a SpikeList object:: 42 42 43 >>> spklist = textfile.read_spikes( id_list=range(11), t_start = 0, t_stop=1000)43 >>> spklist = textfile.read_spikes({'id_list' :range(11), 't_start' : 0, 't_stop' : 1000}) 44 44 45 45 More generally, the ``read_spikes()`` method of an object inheriting from ``FileHandler`` accepts arguments … … 49 49 Similar syntax is used for reading a analog signal object:: 50 50 51 >>> aslist = textfile.read_analog ('vm', range(11))51 >>> aslist = textfile.read_analogs('vm', {'id_list':range(11)}) 52 52 53 53 In the case of an ``AnalogSignal``, the type here, selected in [vm, conductance, current] will specified … … 80 80 If you want to read a data file with spikes, and return a SpikeList object:: 81 81 82 >>> spklist = pickfile.read_spikes( id_list=range(11), t_start = 0, t_stop=1000)82 >>> spklist = pickfile.read_spikes({'id_list' : range(11), 't_start' : 0, 't_stop' : 1000}) 83 83 84 84 Since this object inherits from ``FileHandler``, the idea is that its behavior is *exactly* the 85 85 same than the ``StandardTextFile``. Similar syntax is used for reading a analog signal object:: 86 86 87 >>> aslist = pickfile.read_analog ('vm', range(11))87 >>> aslist = pickfile.read_analogs('vm', {'id_list' : range(11)}) 88 88 89 89 In the case of an ``AnalogSignal``, the type here, selected in [vm, conductance, current] will specified … … 104 104 105 105 >>> class YOURStandardFormatFile(FileHandler): 106 def write(self, object): 107 ### Your method here ######### 108 ### Should save an object to the file self.filename### 106 109 107 def write(self, object): 108 ### Your method here ######### 109 ### Should save an object to the file self.filename### 110 def read_spikes(self, params): 111 ### Your method here, reading data from self.filename ######### 112 ### Should read data and return a SpikeList object constrained by params 113 from NeuroTools import signals 114 return signals.SpikeList(...) 110 115 111 def read_spikes(self, params): 112 ### Your method here, reading data from self.filename ######### 113 ### Should read data and return a SpikeList object constrained by params 114 from NeuroTools import signals 115 return signals.SpikeList(...) 116 117 def read_analogs(self, type, params): 118 if not type in ["vm", "current", "conductance"]: 119 raise Exception("The type %s is not available for the Analogs Signals" %type) 120 ### Your method here reading data from self.filename ######### 121 from NeuroTools import signals 122 if type == 'vm': 123 return signals.VmList(...) 124 elif type == 'conductance': 125 return signals.ConductanceList(...) 126 elif type == 'current': 127 return signals.CurrentList(...) 116 def read_analogs(self, type, params): 117 if not type in ["vm", "current", "conductance"]: 118 raise Exception("The type %s is not available for the Analogs Signals" %type) 119 ### Your method here reading data from self.filename ######### 120 from NeuroTools import signals 121 if type == 'vm': 122 return signals.VmList(...) 123 elif type == 'conductance': 124 return signals.ConductanceList(...) 125 elif type == 'current': 126 return signals.CurrentList(...) 128 127 129 128 trunk/src/io.py
r313 r320 135 135 logging.debug("dt is infered from the file header") 136 136 params['dt'] = self.metadata['dt'] 137 if params['id_list'] is None:137 if not ('id_list' in params) or (params['id_list'] is None): 138 138 if ('first_id' in self.metadata) and ('last_id' in self.metadata): 139 139 logging.debug("id_list is infered from the file header") … … 145 145 elif not isinstance(params['id_list'], list): 146 146 raise Exception("id_list should be an int or a list !") 147 if params['dims'] is None:147 if not ('dims' in params) or (params['dims'] is None): 148 148 if 'dimensions' in self.metadata: 149 149 params['dims'] = self.metadata['dimensions'] … … 220 220 self.metadata['first_id'] = numpy.min(object.id_list()) 221 221 self.metadata['last_id'] = numpy.max(object.id_list()) 222 if hasattr(object, "dt"):222 if hasattr(object, 'dt'): 223 223 self.metadata['dt'] = object.dt 224 224 225 225 def __reformat(self, params, object): 226 226 self.__fill_metadata(object) 227 if params['id_list'] != None:227 if 'id_list' in params and params['id_list'] != None: 228 228 if isinstance(params['id_list'], int): # allows to just specify the number of neurons 229 229 params['id_list'] = range(params['id_list']) … … 233 233 t_start = object.t_start 234 234 t_stop = object.t_stop 235 if params['t_start'] is not None and params['t_start'] != object.t_start:235 if 't_start' in params and params['t_start'] is not None and params['t_start'] != object.t_start: 236 236 t_start = params['t_start'] 237 237 do_slice = True 238 if params['t_stop'] is not None and params['t_stop'] != object.t_stop:238 if 't_stop' in params and params['t_stop'] is not None and params['t_stop'] != object.t_stop: 239 239 t_stop = params['t_stop'] 240 240 do_slice = True trunk/src/signals.py
r317 r320 1201 1201 """ 1202 1202 Return the list of all the CV coefficients for each SpikeTrains object 1203 within the SpikeList. 1203 within the SpikeList. Return NaN when not enough spikes are present 1204 1204 1205 1205 Inputs: … … 1261 1261 subplot.plot(xaxis, values, **kwargs) 1262 1262 pylab.draw() 1263 1264 1265 1266 1267 1263 1268 1264 def cv_local(self, t_start=None, t_stop=None, length=12, step=6): trunk/test/test_signals.py
r315 r320 137 137 def testCvKL(self): 138 138 poisson_param = 1./10 # 1 / firing_frequency 139 isi = numpy.random.exponential(poisson_param, 1000 0)139 isi = numpy.random.exponential(poisson_param, 1000) 140 140 poisson_times = numpy.cumsum(isi)*1000. # To convert the spikes_time in ms 141 141 spk1 = signals.SpikeTrain(poisson_times) … … 145 145 # does not depend on time 146 146 poisson_param = 1./4 147 isi = numpy.random.exponential(poisson_param, 1000 0)147 isi = numpy.random.exponential(poisson_param, 1000) 148 148 poisson_times = numpy.cumsum(isi)*1000. # To convert the spikes_time in ms 149 149 spk1 = signals.SpikeTrain(poisson_times) … … 154 154 def testHistogram(self): 155 155 poisson_param = 1./40 156 isi = numpy.random.exponential(poisson_param, 1000 0)156 isi = numpy.random.exponential(poisson_param, 1000) 157 157 poisson_times = numpy.cumsum(isi)*1000. # To convert the spikes_time in ms 158 158 spk = signals.SpikeTrain(poisson_times)

