Beispiel #1
0
        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)
Beispiel #2
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)
Beispiel #3
0
        def test():
            from blenderneuron.quick import bn

            with Blender():
                from neuron import h
                soma = h.Section(name="Soma")
                soma.L = soma.diam = 10

                bn.to_blender()

                self.assertTrue(
                    bn.run_command(
                        "return_value = 'Soma' in bpy.data.objects"))
                self.assertTrue(
                    bn.run_command(
                        "return_value = bpy.data.objects['Soma'].dimensions == mathutils.Vector((10.020000457763672, 10.0, 10.0))"
                    ))
Beispiel #4
0
        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"
                    ))
Beispiel #5
0
        def test():
            from blenderneuron.quick import bn

            with Blender():
                from neuron import h
                soma1 = h.Section(name="Soma1")
                soma2 = h.Section(name="Soma2")

                soma1.L = soma2.L = soma1.diam = soma2.diam = 5

                bn.to_blender()

                self.assertTrue(
                    bn.run_command(
                        "return_value = 'Soma1' in bpy.data.objects"))
                self.assertTrue(
                    bn.run_command(
                        "return_value = 'Soma2' in bpy.data.objects"))
Beispiel #6
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"
                    ))
Beispiel #7
0
        def test():
            from blenderneuron.quick import bn

            with Blender(keep=False):

                from neuron import h

                s1 = h.Section(name="Soma1")
                s2 = h.Section(name="Soma2")
                s1.L = s1.diam = s2.L = s2.diam = 10

                syn = h.Exp2Syn(0.5, sec=s2)
                syn.g = 10

                nc = h.NetCon(s1(0.5)._ref_v, syn, sec=s1)
                nc.weight[0] = 1

                bn.to_blender()

                self.assertTrue(
                    bn.run_command(
                        "return_value = bpy.data.objects['SynapsesGroup'].dimensions == mathutils.Vector((4.0, 4.0, 101.02000427246094))"
                    ))
Beispiel #8
0
        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"
                    ))