Command Line Selection - JaneliaSciComp/Neuroptikon GitHub Wiki
Select a Neuron From Command Prompt
# Find the neuron on the command line
n = network.findNeuron( name=‘name’ )
# Select the neuron you found
display.selectObject(n)
# ctrl-i opens the inspector now that the neuron is selected
Selecting multiple neurons
Finding the neurons
To find multiple neurons you have a couple of options. If they all have the same name you can use network.findObjects otherwise you can use network.findObjectsRegex to use a regular expression to search. The first parameter is always the class of the object (in this case Neuron, but you can use this same method to find Regions or anything else). The second parameter is the name for findObjects or the regular expression for findObjectsRegex
# find the neurons with the name "R3"
r3Neurons = network.findObjects(Neuron, "R3")
# Result: [<network.neuron.Neuron object at 0x0D954610>, <network.neuron.Neuron object at 0x0D948C70>, <network.neuron.Neuron object at 0x0D954A30>, <network.neuron.Neuron object at 0x0D954DB0>, <network.neuron.Neuron object at 0x0D960610>, <network.neuron.Neuron object at 0x0D960BF0>]
# find the neurons that match "PBG"
pbgNeurons = network.findObjectsRegex(Neuron, "^PBG*")
# Result: [<network.neuron.Neuron object at 0x0D7E85D0>, <network.neuron.Neuron object at 0x0D7E8330>, <network.neuron.Neuron object at 0x0D7E8C50>, <network.neuron.Neuron object at 0x0D8A8450>, <network.neuron.Neuron object at 0x0D8A8C30>, <network.neuron.Neuron object at 0x0D8B6430>
Selecting multiple neurons
Once you have found your neurons you need to highlight them on the display. In this case you need to use display.selectObjects(). The first parameter is a list, set, or tuple containing the network objects you want to select. The second parameter is options and is a boolean that should be True if you want to extend the current selection or False to replace the current selection. By default it is set to False so that your new selection replaces the old one.
# Replacing the current selection
display.selectObjects(r3Neurons)
# Add to the current selection
display.selectObjects(pbgNeurons, True)
Removing neurons from the selection
You can also remove a neuron or neurons from your current selection from the command line. If it it just one object you can use display.deselectObject if it is more than one object you use display.deselectObjects. If the object(s) are not currently in the selection nothing will happen. The deselectObject function takes a single network object while deselectObjects takes a list of network objects.
# Deselect a single neuron
display.deselectObject(n)
# Deselect multiple neurons
display.deselectObjects(pbgNeurons)
Specifying a color for your selection
You can specify a color to highlight the neuron(s) that you select. All connections will be highlighted in this color. The color will be forgotten when you deselect the neuron. The color should be a tuple in the format of (Red, Green, Blue, Alpha) where each value ranges from 0-1 ex. (1, 0.5, 0, 0.4) for a tranlucent orange.
# Specifying a color for a single neuron
display.selectObject(selectedNeuron, color=(1,1,0,0.4))
# With multiple neurons in your selection
display.selectObjects(selectedNeurons, color=(1,0,1,0.4))
# Multiple selections with different colors
#If you extend the selection, your newly selected neurons and connections will be highlighted in a different color than the original selection
display.selectObjects(selectedNeurons, extend=True, color=(0,1,1,0.4))
Selecting Neurons Based On Synapses
You can search for neurons that are pre and post-synaptic to another neuron.
# Find the neuron on the command line
n = network.findNeuron( name=‘name’ )
# Find neurons pre-synaptic to current neuron
presynapticPartners = n.searchPre()
# Find neurons post-synaptic to current neuron
postsynapticPartners = n.searchPost()
# Select the presynaptic partners in red and post synaptic partners in green
display.selectObjects(presynapticPartners, color=(1,0,0,0.4))
display.selectObjects(postsynapticPartners, color=(0,1,0,0.4))
You can filter search results by region, activation, neurotransmitter, and neuron name.
presynapticPartners = n.searchPre(preRegion = 'Regex matching presynaptic region', postRegion = 'Regex matching postsynaptic region', postNeuron = 'Regex matching postsynaptic neuron name', activation = 'excititory', neurotransmitter = library.neurotransmitter('ACh'))
presynapticPartners = n.searchPre(preRegion = 'Regex matching presynaptic region', postRegion = 'Regex matching postsynaptic region', preNeuron = 'Regex matching presynaptic neuron name', activation = 'excititory', neurotransmitter = library.neurotransmitter('ACh'))