Changeset 1030

Show
Ignore:
Timestamp:
12/13/11 15:04:42 (5 months ago)
Author:
apdavison
Message:

In neo_output branch, fixed some bugs, started updating examples

Location:
branches/neo_output
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • branches/neo_output/examples/IF_cond_exp.py

    r1025 r1030  
    3535connI = connect(spike_sourceI, ifcell, weight=0.02, synapse_type ='inhibitory',delay=4.0) 
    3636     
    37 record_v(ifcell, "Results/IF_cond_exp_%s.v" % simulator_name) 
     37record_v(ifcell, "Results/IF_cond_exp_%s.h5" % simulator_name) 
    3838#try: 
    39 record_gsyn(ifcell, "Results/IF_cond_exp_%s.gsyn" % simulator_name) 
     39#record_gsyn(ifcell, "Results/IF_cond_exp_%s.gsyn" % simulator_name) 
    4040#except (NotImplementedError, RecordingError): 
    4141#    pass 
  • branches/neo_output/examples/VAbenchmarks.py

    r1006 r1030  
    168168simCPUTime = timer.diff() 
    169169 
    170 E_count = exc_cells.meanSpikeCount() 
    171 I_count = inh_cells.meanSpikeCount() 
     170E_count = exc_cells.mean_spike_count() 
     171I_count = inh_cells.mean_spike_count() 
    172172 
    173173# === Print results to file ==================================================== 
     
    178178    os.mkdir('Results') 
    179179 
    180 exc_cells.write_data(PyNNTextIO("Results/VAbenchmark_%s_exc_%s_np%d.ras" % (benchmark, simulator_name, np)), 'spikes') 
    181 inh_cells.write_data(PyNNTextIO("Results/VAbenchmark_%s_inh_%s_np%d.ras" % (benchmark, simulator_name, np)), 'spikes') 
    182 exc_cells[[0, 1]].write_data(PyNNTextIO("Results/VAbenchmark_%s_exc_%s_np%d.v" % (benchmark, simulator_name, np)), 'v') 
     180exc_cells.write_data("Results/VAbenchmark_%s_exc_%s_np%d.txt" % (benchmark, simulator_name, np)) 
     181inh_cells.write_data("Results/VAbenchmark_%s_inh_%s_np%d.txt" % (benchmark, simulator_name, np)) 
    183182writeCPUTime = timer.diff() 
    184183 
  • branches/neo_output/examples/VAbenchmarks2.py

    r915 r1030  
    148148# === Setup recording ========================================================== 
    149149print "%s Setting up recording..." % node_id 
    150 all_cells.record() 
    151 exc_cells[[0, 1]].record_v() 
     150all_cells.record('spikes') 
     151exc_cells[[0, 1]].record('v') 
    152152 
    153153buildCPUTime = timer.diff() 
     
    167167simCPUTime = timer.diff() 
    168168 
    169 E_count = exc_cells.meanSpikeCount() 
    170 I_count = inh_cells.meanSpikeCount() 
     169E_count = exc_cells.mean_spike_count() 
     170I_count = inh_cells.mean_spike_count() 
    171171 
    172172# === Print results to file ==================================================== 
     
    177177    os.mkdir('Results') 
    178178 
    179 exc_cells.printSpikes("Results/VAbenchmark_%s_exc_%s_np%d.ras" % (benchmark, simulator_name, np)) 
    180 inh_cells.printSpikes("Results/VAbenchmark_%s_inh_%s_np%d.ras" % (benchmark, simulator_name, np)) 
    181 exc_cells[[0, 1]].print_v("Results/VAbenchmark_%s_exc_%s_np%d.v" % (benchmark, simulator_name, np)) 
     179all_cells.write_data("Results/VAbenchmark_%s_%s_np%d.txt" % (benchmark, simulator_name, np)) 
     180 
    182181writeCPUTime = timer.diff() 
    183182 
  • branches/neo_output/examples/VAbenchmarks3.py

    r915 r1030  
    149149# === Setup recording ========================================================== 
    150150print "%s Setting up recording..." % node_id 
    151 all_cells.record() 
    152 exc_cells[[0, 1]].record_v() 
     151all_cells.record('spikes') 
     152exc_cells[[0, 1]].record('v') 
    153153 
    154154buildCPUTime = timer.diff() 
     
    168168simCPUTime = timer.diff() 
    169169 
    170 E_count = exc_cells.meanSpikeCount() 
    171 I_count = inh_cells.meanSpikeCount() 
     170E_count = exc_cells.mean_spike_count() 
     171I_count = inh_cells.mean_spike_count() 
    172172 
    173173# === Print results to file ==================================================== 
     
    178178    os.mkdir('Results') 
    179179 
    180 exc_cells.printSpikes("Results/VAbenchmark_%s_exc_%s_np%d.ras" % (benchmark, simulator_name, np)) 
    181 inh_cells.printSpikes("Results/VAbenchmark_%s_inh_%s_np%d.ras" % (benchmark, simulator_name, np)) 
    182 exc_cells[[0, 1]].print_v("Results/VAbenchmark_%s_exc_%s_np%d.v" % (benchmark, simulator_name, np)) 
     180all_cells.write_data("Results/VAbenchmark_%s_%s_np%d.txt" % (benchmark, simulator_name, np)) 
     181 
    183182writeCPUTime = timer.diff() 
    184183 
  • branches/neo_output/examples/simpleNetwork.py

    r933 r1030  
    3333projection.setWeights(1.0) 
    3434 
    35 input_population.record() 
    36 output_population.record() 
    37 output_population.record_v() 
     35input_population.record('spikes') 
     36output_population.record(('spikes', 'v')) 
    3837 
    3938run(tstop) 
    4039 
    41 output_population.printSpikes("Results/simpleNetwork_output_%s.ras" % simulator_name) 
    42 input_population.printSpikes("Results/simpleNetwork_input_%s.ras" % simulator_name) 
    43 output_population.print_v("Results/simpleNetwork_%s.v" % simulator_name) 
     40output_population.write_data("Results/simpleNetwork_output_%s.h5" % simulator_name) 
     41input_population.write_data("Results/simpleNetwork_input_%s.h5" % simulator_name) 
    4442 
    4543end() 
  • branches/neo_output/examples/simpleRandomNetwork.py

    r933 r1030  
    5050projection.saveConnections('%s.conn' % file_stem) 
    5151 
    52 input_population.record() 
    53 output_population.record() 
    54 output_population.sample(n_record, rng).record_v() 
     52input_population.record('spikes') 
     53output_population.record('spikes') 
     54output_population.sample(n_record, rng).record('v') 
    5555 
    5656print "[%d] Running simulation" % node 
     
    5858 
    5959print "[%d] Writing spikes to disk" % node 
    60 output_population.printSpikes('%s_output.ras' % file_stem) 
    61 input_population.printSpikes('%s_input.ras' % file_stem) 
     60output_population.write_data('%s_output.ras' % file_stem, 'spikes') 
     61input_population.write_data('%s_input.ras' % file_stem) 
    6262print "[%d] Writing Vm to disk" % node 
    63 output_population.print_v('%s.v' % file_stem) 
     63output_population.write_data('%s.v' % file_stem, 'v') 
    6464 
    6565print "[%d] Finishing" % node 
  • branches/neo_output/src/common/populations.py

    r1008 r1030  
    1414import tempfile 
    1515from pyNN import random, recording, errors, standardmodels, core, space, descriptions 
    16 from pyNN.recording import files 
    1716from itertools import chain 
    1817 
     
    501500        simulated on the local node. 
    502501        """ 
    503         self.recorder.get(variables, gather, self.record_filter) 
     502        return self.recorder.get(variables, gather, self.record_filter) 
    504503 
    505504    @deprecated("write_data(file, 'spikes')") 
  • branches/neo_output/src/common/projections.py

    r1000 r1030  
    1111import operator 
    1212from pyNN import random, recording, errors, models, core, descriptions 
    13 from pyNN.recording import files 
    1413from populations import BasePopulation, Assembly, is_conductance 
    1514 
  • branches/neo_output/src/connectors.py

    r1003 r1030  
    1212from pyNN import errors, common, core, random, utility, recording, descriptions 
    1313from pyNN.space import Space 
    14 from pyNN.recording import files 
     14#from pyNN.recording import files 
    1515from pyNN.random import RandomDistribution 
    1616from numpy import arccos, arcsin, arctan, arctan2, ceil, cos, cosh, e, exp, \ 
  • branches/neo_output/src/neuron/cells.py

    r957 r1030  
    288288        # insert Brette-Gerstner spike mechanism 
    289289        self.adexp = h.AdExpIF(0.5, sec=self) 
    290         self.source = self.seg._ref_v 
     290        self.source = self.adexp 
    291291         
    292292        self.parameter_names = ['c_m', 'tau_m', 'v_rest', 'v_thresh', 't_refrac', 
     
    330330    def record(self, active): 
    331331        if active: 
    332             self.rec = h.NetCon(self.source, None, 
     332            self.rec = h.NetCon(self.seg._ref_v, None, 
    333333                                self.get_threshold(), 0.0, 0.0, 
    334334                                sec=self) 
  • branches/neo_output/src/neuron/recording.py

    r1026 r1030  
    144144                    get_signal = lambda id: id._cell.gsyn_trace['inhibitory'] 
    145145                else: 
    146                     signal = lambda id: id._cell.traces[variable] 
     146                    get_signal = lambda id: id._cell.traces[variable] 
    147147                segment.analogsignals.extend( 
    148148                    neo.AnalogSignal(get_signal(id), # assuming not using cvode, otherwise need to use IrregularlySampledAnalogSignal 
     
    154154                                     source_id=int(id)) 
    155155                    for id in self.filter_recorded(variable, filter_ids)) 
    156                 assert segment.analogsignals[0].t_stop - simulator.state.t*pq.ms < simulator.state.dt*pq.ms 
     156                assert segment.analogsignals[0].t_stop - simulator.state.t*pq.ms < 2*simulator.state.dt*pq.ms 
    157157                # need to add `Unit` and `RecordingChannel` objects 
    158158        return segment 
  • branches/neo_output/src/recording/__init__.py

    r1025 r1030  
    9090def normalize_variables_arg(variables): 
    9191    """If variables is a single string, encapsulate it in a list.""" 
    92     if isinstance(variables, basestring): 
     92    if isinstance(variables, basestring) and variables != 'all': 
    9393        return [variables] 
    9494    else: 
     
    9999    Return a Neo IO instance, guessing the type based on the filename suffix. 
    100100    """ 
    101     if os.path.splitext(filename)[0] in ('.txt', '.ras', '.v', '.gsyn'): 
    102         return neo.io.PyNNTextIO(filename) 
     101    extension = os.path.splitext(filename)[1] 
     102    if extension in ('.txt', '.ras', '.v', '.gsyn'): 
     103        return neo.io.PyNNTextIO(filename=filename) 
     104    elif extension in ('.h5',): 
     105        return neo.io.NeoHdf5IO(filename=filename) 
    103106    else: # function to be improved later 
    104         return neo.io.PyNNTextIO(filename) 
     107        raise Exception("file extension %s not supported" % extension) 
    105108 
    106109 
     
    167170        if self._simulator.state.mpi_rank == 0 or gather == False: 
    168171            # Open the output file, if necessary and write the data 
    169             logger.debug("Writing data to file %s" % file) 
    170             file.write(data) 
     172            logger.debug("Writing data to file %s" % io) 
     173            io.write(data) 
    171174     
    172175    @property