Changeset 287
- Timestamp:
- 11/05/08 14:14:42 (2 months ago)
- Files:
-
- trunk/src/signals.py (modified) (3 diffs)
- trunk/test/test_signals.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/signals.py
r281 r287 2165 2165 def min(self): 2166 2166 return self.signal.min() 2167 2168 def mean(self): 2169 return numpy.mean(self.signal) 2167 2170 2168 2171 def copy(self): … … 2321 2324 2322 2325 Inputs: 2323 events - Can be a SpikeTrain object (and events will be the spikes) or just a list2326 events - Can be a SpikeTrain object (and events will be the spikes) or just a list 2324 2327 of times 2325 2328 t_min - Time (>0) to cut the signal before an event, in ms (default 100) 2326 2329 t_max - Time (>0) to cut the signal after an event, in ms (default 100) 2327 2330 2331 Examples: 2332 >> res = aslist.slice_by_events([100,200,300], t_min=0, t_max =100) 2333 >> print len(res) 2334 3 2328 2335 """ 2329 2336 if isinstance(events, SpikeTrain): … … 2545 2552 new_AnalogSignalList.__calc_startstop() 2546 2553 return new_AnalogSignalList 2554 2555 def select_ids(self, criteria=None): 2556 """ 2557 Return the list of all the cells in the AnalogSignalList that will match the criteria 2558 expressed with the following syntax. 2559 2560 Inputs : 2561 criteria - a string that can be evaluated on a AnalogSignal object, where the 2562 AnalogSignal should be named ``cell''. 2563 2564 Exemples: 2565 >> aslist.select_ids("mean(cell.signal) > 20") 2566 >> aslist.select_ids("cell.std() < 0.2") 2567 """ 2568 selected_ids = [] 2569 for id in self.id_list(): 2570 cell = self.analog_signals[id] 2571 if eval(criteria): 2572 selected_ids.append(id) 2573 return selected_ids 2547 2574 2548 2575 def convert(self, format="[values, ids]"): trunk/test/test_signals.py
r279 r287 508 508 assert len(self.analog.std()) == len(self.analog[0]) 509 509 510 def testSelectIds(self): 511 assert type(self.analog.select_ids("cell.mean() > 0")) == list 510 512 511 513 … … 604 606 p1.print_v("Simulation/p1.v") 605 607 p1.print_c("Simulation/p1.c") 606 p2.printSpikes( rec.StandardPickleFile("Simulation/p2.spikes"))607 p2.print_v( rec.StandardPickleFile("Simulation/p2.v"))608 p2.print_c( rec.StandardPickleFile("Simulation/p2.c"))608 p2.printSpikes("Simulation/p2.spikes") 609 p2.print_v("Simulation/p2.v") 610 p2.print_c("Simulation/p2.c") 609 611 610 612 def testLoadFirstPopulationData(self): 611 spikes = signals.load( io.StandardTextFile("Simulation/p1.spikes"),'s')612 vm = signals.load( io.StandardTextFile("Simulation/p1.v"),'v')613 ge, gi = signals.load( io.StandardTextFile("Simulation/p1.c"),'g')613 spikes = signals.load("Simulation/p1.spikes",'s') 614 vm = signals.load("Simulation/p1.v",'v') 615 ge, gi = signals.load("Simulation/p1.c",'g') 614 616 assert len(spikes) == 10 and len(vm) == 10 and len(ge) == 10 and len(gi) == 10 615 617 616 618 def testLoadSecondPopulationData(self): 617 spikes = signals.load(io.StandardPickleFile("Simulation/p2.spikes"),'s') 618 vm = signals.load(io.StandardPickleFile("Simulation/p2.v"),'v') 619 ge = signals.load(io.StandardPickleFile("Simulation/p2.c.ge"),'g') 620 gi = signals.load(io.StandardPickleFile("Simulation/p2.c.gi"),'g') 619 spikes = signals.load("Simulation/p2.spikes",'s') 620 vm = signals.load("Simulation/p2.v",'v') 621 ge, gi = signals.load("Simulation/p2.c",'g') 621 622 assert len(spikes) == 10 and len(vm) == 10 and len(ge) == 10 and len(gi) == 10 622 623

