Exemplo n.º 1
0
 def run_once(self, job_dir, ** kwargs):
     
     from neuromllite.utils import print_v
     from neuromllite.utils import load_simulation_json,load_network_json
     from neuromllite.NetworkGenerator import generate_and_run
     from pyneuroml.pynml import get_value_in_si
     
     print_v('Running NeuroMLlite simulation in dir: %s...'%job_dir)
     sim = load_simulation_json(self.nmllite_sim)
     import random
     sim.id = '%s%s'%(sim.id, '_%s'%kwargs['reference'] if 'reference' in kwargs else '')
     network = load_network_json(self.base_dir+'/'+sim.network)
     
     for a in kwargs:
         if a in network.parameters:
             print_v('  Setting %s to %s in network...'%(a, kwargs[a]))
             network.parameters[a] = kwargs[a]
         elif a in sim.fields:
             print_v('  Setting %s to %s in simulator...'%(a, kwargs[a]))
             setattr(sim,a,kwargs[a])
         else:
             print_v('  Cannot set parameter %s to %s in network or simulator...'%(a, kwargs[a]))
             
     traces, events = generate_and_run(sim, 
                                       simulator = self.simulator, 
                                       network = network, 
                                       return_results = True,
                                       base_dir = self.base_dir,
                                       target_dir = job_dir)
                                       
                                       
     print_v("Returned traces: %s, events: %s"%(traces.keys(), events.keys()))
     
     return traces, events 
Exemplo n.º 2
0
    def runSimulation(self):
        """Run a simulation in the chosen simulator"""

        simulator = str(self.simulatorComboBox.currentText())
        print(
            "Run button was clicked. Running simulation %s in %s with %s"
            % (self.simulation.id, self.sim_base_dir, simulator)
        )

        self.tabs.setCurrentWidget(self.simTab)

        self.update_net_sim()

        from neuromllite.NetworkGenerator import generate_and_run

        # return
        try:
            self.current_traces, self.current_events = generate_and_run(
                self.simulation,
                simulator=simulator,
                network=self.network,
                return_results=True,
                base_dir=self.sim_base_dir,
            )

            self.replotSimResults()
        except Exception as e:
            self.dialog_popup("Error: %s" % e)
Exemplo n.º 3
0
    def showLemsView(self):
        """Generate lemsView button has been pressed"""
        
        print_v("lemsView button was clicked.")
        
        self.update_net_sim()
        self.tabs.setCurrentWidget(self.all_tabs[self.LEMS_VIEW_TAB])
        self.update_net_sim()
        from neuromllite.NetworkGenerator import generate_neuroml2_from_network
        
        from neuromllite.NetworkGenerator import generate_and_run
       
        lems_file_name = generate_and_run(self.simulation,
                                          simulator='jNeuroML_norun',
                                          network=self.network,
                                          return_results=True,
                                          base_dir=self.sim_base_dir)
                                          
        post_args = "-graph"

        from pyneuroml.pynml import run_jneuroml
        run_jneuroml("", 
                     lems_file_name, 
                     post_args, 
                     verbose = True)
                     
        lems_view_file = lems_file_name.replace('.xml','.png')
                    
        self.add_image(lems_view_file, self.LEMS_VIEW_TAB)   
Exemplo n.º 4
0
    mod_graph = model.graphs[0]

    print("Loaded Graph:")
    print_summary(mod_graph)

    print("------------------")
    nmllite_file = example.replace(".json", ".nmllite.json")
    net, sim = mdf_to_neuroml(mod_graph,
                              save_to=nmllite_file,
                              format=model.format,
                              run_duration_sec=2)

    if run:
        sf = "%s.json" % sim.id
        print("Running the model: %s" % sf)
        from neuromllite.NetworkGenerator import generate_and_run

        simulator = "jNeuroML"
        traces, events = generate_and_run(
            sim,
            simulator,
            network=net,
            return_results=True,
            base_dir=None,
            target_dir=None,
            num_processors=1,
        )
        for t in traces:
            if t != "t":  # the time array
                print("    {} = {}".format(t, traces[t][-1]))