.Shape() does not result until end of execution

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
Ohad.Dan
Posts: 2
Joined: Tue Jun 25, 2013 9:39 am
Location: Hebrew University of Jerusalem
Contact:

.Shape() does not result until end of execution

Post by Ohad.Dan »

My scenario is as such : I am loading a morphology (an exported swc file), create a *shape* graph of the morphology and would like to iterate over the dendrite's branches coloring each in its turn.
The code that performs the task is as follows :

Code: Select all

from neuron import * 
from nrn import *
from time import sleep 

# Load a saved seesion with morphology
h('load_file("./morphologies/morphologySession.hoc")')

# Create a shape with the loaded morphology
h('objref sectionList')
h('sectionList = new SectionList()')
h('soma[0] sectionList.subtree()')    
h('objref shape')
h('shape = new Shape(sectionList)')

#Color each dendrite branch in orange
for i in range (len(h.dend)):
    h('access dend[' + str(i) + ']')
    h.shape.color(5)
    sleep(0.1)
    # Print to screen so we know the program runs
    print(i)
This all works well except that while the iteration is occurring, the branches do not get colored each in its turn but rather the shape screen freezes until the iteration is complete then all the branches are colored.
I have tried to use flush() or observe() within the loop and increasing the sleep time, but neither had any effect.

My question is, what should be changed in the above implementation in order to see the color changes occur in real time (and not wait for the end of the iteration to observe the changes)?

Thanks!
Post Reply