def test_network_plot(self): # Generate test signal brunel_ai = ninemlcatalog.load('network/Brunel2000/AI.xml').as_network( 'Brunel2000AI') scaled_brunel_ai_path = os.path.join(self.work_dir, 'brunel_scaled.xml') brunel_ai.scale(0.01).write(scaled_brunel_ai_path) argv = ("{} nest 100.0 0.1 " "--record Exc.spike_output {}".format( scaled_brunel_ai_path, self.network_signal_path)) simulate.run(argv.split()) # Run plotting command for pop_name in self.recorded_pops: out_path = '{}/{}.png'.format(self.work_dir, pop_name) argv = ("{in_path} --save {out_path} --hide --dims 5 5 " "--resolution 100.0".format( in_path=self.network_signal_path, out_path=out_path, name='v')) plot.run(argv.split()) image = img.imread(out_path) self._ref_network_plot() ref_image = img.imread(self.ref_network_path) self.assertEqual(image.shape, ref_image.shape) self.assertTrue( (image == ref_image).all(), "Plotted spike data using 'plot' command (saved to '{}') " "did not match loaded image from '{}'".format( out_path, self.ref_network_path))
def test_network_plot(self): # Generate test signal brunel_ai = ninemlcatalog.load( 'network/Brunel2000/AI.xml').as_network('Brunel2000AI') scaled_brunel_ai_path = os.path.join(self.work_dir, 'brunel_scaled.xml') brunel_ai.scale(0.01).write(scaled_brunel_ai_path) argv = ("{} nest 100.0 0.1 " "--record Exc.spike_output {}" .format(scaled_brunel_ai_path, self.network_signal_path)) simulate.run(argv.split()) # Run plotting command for pop_name in self.recorded_pops: out_path = '{}/{}.png'.format(self.work_dir, pop_name) argv = ("{in_path} --save {out_path} --hide --dims 5 5 " "--resolution 100.0" .format(in_path=self.network_signal_path, out_path=out_path, name='v')) plot.run(argv.split()) image = img.imread(out_path) self._ref_network_plot() ref_image = img.imread(self.ref_network_path) self.assertEqual( image.shape, ref_image.shape) self.assertTrue( (image == ref_image).all(), "Plotted spike data using 'plot' command (saved to '{}') " "did not match loaded image from '{}'" .format(out_path, self.ref_network_path))
def test_single_cell_plot(self): in_path = os.path.join(self.data_dir, 'v.neo.pkl') out_path = '{}/single_cell.png'.format(self.tmpdir) argv = ("{data_file} --name {name} --save {out_path} --hide" .format(data_file=in_path, out_path=out_path, name='v')) plot.run(argv.split()) image = img.imread(out_path) ref_image = img.imread(self.ref_single_cell_path) self.assertTrue( all(image == ref_image), "Ploted single cell data using 'plot' command did not match " "loaded image from '{}'".format(self.ref_single_cell_path))
def test_single_cell_plot(self, show=False): # First simulate input signal to have something to play into # izhikevich cell argv = ("catalog://input/StepCurrent#StepCurrent " "nest {t_stop} {dt} " "--record current_output {out_path} {rec_t_start} " "--prop amplitude {amp} " "--prop onset {onset} " "--init_value current_output {init} " "--build_mode force " "--build_version Plot ".format( out_path=self.cell_input_path, rec_t_start='{} {}'.format(*self.rec_t_start), t_stop=self.t_stop, dt=self.dt, amp='{} {}'.format(*self.isyn_amp), onset='{} {}'.format(*self.isyn_onset), init='{} {}'.format(*self.isyn_init))) # Run input signal simulation simulate.run(argv.split()) argv = ("catalog://neuron/Izhikevich#SampleIzhikevichFastSpiking " "nest {} {} " "--record V {} " "--init_value U 1.625 pA " "--init_value V -65.0 mV " "--play iSyn {in_path} " "--init_regime subVb " "--build_version Plot " "--device_delay 0.5 ms " "--min_delay 0.5 ms ".format(self.t_stop, self.dt, self.cell_signal_path, in_path=self.cell_input_path)) simulate.run(argv.split()) # Run plotting command out_path = '{}/single_cell.png'.format(self.work_dir) argv = ("{in_path} --save {out_path} --dims 5 5 " "--resolution 100.0 {hide}".format( in_path=self.cell_signal_path, out_path=out_path, name='v', hide=('' if show else '--hide'))) plot.run(argv.split()) image = img.imread(out_path) self._ref_single_cell_plot() ref_image = img.imread(self.ref_single_cell_path) self.assertEqual(image.shape, ref_image.shape) self.assertTrue( (image == ref_image).all(), "Ploted single cell data using 'plot' command (saved to '{}') did " "not match loaded image from '{}'".format( out_path, self.ref_single_cell_path))
def test_network_plot(self): in_path = os.path.join(self.data_dir, 'brunel.neo.pkl') for pop_name in self.recorded_pops: out_path = '{}/{}.png'.format(self.tmpdir) argv = ("{data_file} --name {name} --save {out_path} --hide" .format(in_path=in_path, out_path=out_path, name='v')) plot.run(argv.split()) image = img.imread(out_path) ref_image = img.imread(self.ref_single_cell_path) self.assertTrue( all(image == ref_image), "Ploted spike data from '{name}' using 'plot' command did not " "match loaded image from '{ref_dir}/{name}'" .format(name=pop_name, ref_dir=self.data_dir))
def test_single_cell_plot(self, show=False): # First simulate input signal to have something to play into # izhikevich cell argv = ("catalog://input/StepCurrent#StepCurrent " "nest {t_stop} {dt} " "--record current_output {out_path} {rec_t_start} " "--prop amplitude {amp} " "--prop onset {onset} " "--init_value current_output {init} " "--build_mode force " "--build_version Plot " .format(out_path=self.cell_input_path, rec_t_start='{} {}'.format(*self.rec_t_start), t_stop=self.t_stop, dt=self.dt, amp='{} {}'.format(*self.isyn_amp), onset='{} {}'.format(*self.isyn_onset), init='{} {}'.format(*self.isyn_init))) # Run input signal simulation simulate.run(argv.split()) argv = ( "catalog://neuron/Izhikevich#SampleIzhikevichFastSpiking " "nest {} {} " "--record V {} " "--init_value U 1.625 pA " "--init_value V -65.0 mV " "--play iSyn {in_path} " "--init_regime subVb " "--build_version Plot " "--device_delay 0.5 ms " "--min_delay 0.5 ms " .format(self.t_stop, self.dt, self.cell_signal_path, in_path=self.cell_input_path)) simulate.run(argv.split()) # Run plotting command out_path = '{}/single_cell.png'.format(self.work_dir) argv = ("{in_path} --save {out_path} --dims 5 5 " "--resolution 100.0 {hide}" .format(in_path=self.cell_signal_path, out_path=out_path, name='v', hide=('' if show else '--hide'))) plot.run(argv.split()) image = img.imread(out_path) self._ref_single_cell_plot() ref_image = img.imread(self.ref_single_cell_path) self.assertEqual(image.shape, ref_image.shape) self.assertTrue( (image == ref_image).all(), "Ploted single cell data using 'plot' command (saved to '{}') did " "not match loaded image from '{}'" .format(out_path, self.ref_single_cell_path))