def test(): from blenderneuron.quick import bn with Blender(keep=False): from neuron import h h.load_file(test_hoc_file) tc1 = h.TestCell() tc2 = h.TestCell() ic = h.IClamp(0.5, sec=tc1.soma) ic.delay = 1 ic.dur = 3 ic.amp = 0.5 bn.prepare_for_collection() bn.groups["all"]["3d_data"]["interaction_level"] = "Section" bn.groups["all"]["3d_data"]["color_level"] = "Segment" h.run() bn.to_blender() self.assertTrue( bn.run_command( "return_value = 'TestCell[0].soma' in bpy.data.objects" )) self.assertTrue( bn.run_command( "return_value = 'TestCell[1].soma' in bpy.data.objects" )) self.assertTrue( bn.run_command( "return_value = 'TestCell[0].soma[0]' in bpy.data.materials" )) self.assertTrue( bn.run_command( "return_value = 'TestCell[1].soma[0]' in bpy.data.materials" )) bn.run_command("bpy.data.scenes['Scene'].frame_current = 0") self.assertEqual( bn.run_command( "return_value = bpy.data.materials['TestCell[0].soma[0]'].emit" ), 0.0) self.assertEqual( bn.run_command( "return_value = bpy.data.materials['TestCell[1].soma[0]'].emit" ), 0.0) bn.run_command("bpy.data.scenes['Scene'].frame_current = 7") self.assertEqual( bn.run_command( "return_value = bpy.data.materials['TestCell[0].soma[0]'].emit" ), 2.0) self.assertEqual( bn.run_command( "return_value = bpy.data.materials['TestCell[1].soma[0]'].emit" ), 0.0)
def test(): from blenderneuron.quick import bn with Blender(keep=False): from neuron import h h.load_file(test_hoc_file) tc = h.TestCell() ic = h.IClamp(0.5, sec=tc.soma) ic.delay = 1 ic.dur = 3 ic.amp = 0.5 bn.prepare_for_collection() h.run() bn.to_blender() bn.run_command("bpy.data.scenes['Scene'].frame_current = 1;") self.assertTrue( bn.run_command( "return_value = bpy.data.materials['TestCell[0].dendrites[9][0]'].emit" ) == 0.0) bn.run_command("bpy.data.scenes['Scene'].frame_current = 7;") self.assertTrue( bn.run_command( "return_value = bpy.data.materials['TestCell[0].dendrites[9][0]'].emit" ) == 2.0)
def test(): from blenderneuron.quick import bn with Blender(): from neuron import h h.load_file(test_hoc_file) tc1 = h.TestCell() tc2 = h.TestCell() bn.to_blender() self.assertTrue( bn.run_command( "return_value = 'TestCell[0].soma' in bpy.data.objects" )) self.assertTrue( bn.run_command( "return_value = 'TestCell[1].soma' in bpy.data.objects" ))
def test(): from blenderneuron.quick import bn with Blender(): from neuron import h h.load_file(test_hoc_file) # Add one cell tc1 = h.TestCell() bn.to_blender() # Check if it was exported self.assertTrue( bn.run_command( "return_value = 'TestCell[0].soma' in bpy.data.objects" )) # Add a second cell tc2 = h.TestCell() # Refresh sections bn.refresh() bn.to_blender() # Both cells should be in blender self.assertTrue( bn.run_command( "return_value = 'TestCell[0].soma' in bpy.data.objects" )) self.assertTrue( bn.run_command( "return_value = 'TestCell[1].soma' in bpy.data.objects" )) self.assertTrue( bn.run_command( "return_value = len([i for i in bpy.data.objects if 'soma' in i.name]) == 2" ))
def test(): from blenderneuron.quick import bn with Blender(): from neuron import h h.load_file(test_hoc_file) tc = h.TestCell() bn.to_blender() self.assertTrue( bn.run_command( "return_value = 'TestCell[0].soma' in bpy.data.objects" )) self.assertTrue( bn.run_command( "return_value = len([i for i in bpy.data.objects if 'dendrites' in i.name]) == 31" ))
from neuron import h h.load_file('TestCell.hoc') cell1 = h.TestCell() cell2 = h.TestCell() cell3 = h.TestCell() #Position cells side by side cell1.position(0, -200, 0) cell3.position(0, 200, 0) # Insert electrodes ic1 = h.IClamp(0.5, sec=cell1.soma) # A distant dendrite ic2 = h.IClamp(1, sec=cell2.dendrites[29]) # A dendrite on the opposite side of ic2 ic3 = h.IClamp(1, sec=cell3.dendrites[18]) stims = [ic1, ic2, ic3] # A 1ms long input stimulus at 10ms for ic in stims: ic.delay = 10 ic.dur = 1 ic.amp = 1 # Will run the simulation for 20 ms h.tstop = 20