Skip to content

Commit

Permalink
Synapses on improvments complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlotte Weaver committed Oct 21, 2015
1 parent 8c03d66 commit 46fec2a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
9 changes: 7 additions & 2 deletions Source/Scripts/Synapses.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@
regionA = network.createRegion(name = 'A')
regionB = network.createRegion(name = 'B')

neuron1 = network.createNeuron(name = '1', neurotransmitters = [library.neurotransmitter('GABA')], functions = [Neuron.Function.SENSORY])
neuron1 = network.createNeuron(name = '1', neurotransmitters = [library.neurotransmitter('GABA')], functions = [Neuron.Function.SENSORY], activation = 'excitatory')
neuron1.arborize(regionA, True, False)
neuron1.arborize(regionB, True, False)

neuron2 = network.createNeuron(name = '2', functions = [Neuron.Function.SENSORY])
neuron2.arborize(regionA, True, False)
neuron2.arborize(regionB, True, False)

neuron1.synapseOn(neuron2)
neuron1.synapseOn(neuron2, preSynapticRegion=regionA, postSynapticRegion=regionB)

neuron2.synapseOn(neuron1)

neuron3 = network.createNeuron(name = '3', functions = [Neuron.Function.INTERNEURON])
neuron3.arborize(regionA)
neuron3.arborize(regionB)

neuron1.synapseOn(neuron3)

neuron4 = network.createNeuron(name = '4', neurotransmitters = [library.neurotransmitter('ACh')], functions = [Neuron.Function.MOTOR])
neuron4.arborize(regionA, False, True)
neuron4.arborize(regionB, False, True)

neuron1.synapseOn(neuron4)

neuron5 = network.createNeuron(name = '5', neurotransmitters = [library.neurotransmitter('ACh')], functions = [Neuron.Function.MOTOR])
neuron5.arborize(regionA, False, True)
neuron5.arborize(regionB, False, True)
Expand Down
45 changes: 26 additions & 19 deletions Source/network/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,44 +459,51 @@ def searchPost(self, preRegion = None, postRegion = None, postNeuron = None, act
"""
Searches for post-synaptic sites
"""
from re import search
# limit synapse to where neuron is presynaptic
synapses = [connection for connection in self.connections() if isinstance(connection, Synapse) and connection.preSynapticNeuron() == self]
if preRegion:
synapses = [synapse for synapse in synapses if search(preRegion, synapse.preSynapticRegion)]
if postRegion:
synapses = [synapse for synapse in synapses if search(postRegion, synapse.postSynapticRegion)]
if activation:
synapses = [synapse for synapse in synapses if synapse.activation == activation]
synapses = [connection for connection in self.synapses() if connection.preSynapticNeuron() == self]
synapses = self._filterSynapsesForSearch(synapses, preRegion = preRegion, postRegion = postRegion, activation = activation)
# get post synaptic neurons
neurons = []
for synapse in synapses:
neurons.extend(synapse.postSynapticNeurons())
if neurotransmitter:
neurons = [neuron for neuron in neurons if neurotransmitter in neuron.neurotransmitters]
neurons = self._filterNeuronsForSearch(neurons, neurotransmitter=neurotransmitter, name=postNeuron)
return neurons

def searchPre(self, preRegion = None, postRegion = None, preNeuron = None, activation = None, neurotransmitter = None):
"""
Searches for pre-synaptic sites
"""
# limit synapse to where neuron is postsynaptic
synapses = [connection for connection in self.connections() if isinstance(connection, Synapse) and self in connection.postSynapticNeurons()]
# Filter synapses
if preRegion:
synapses = [synapse for synapse in synapses if search(preRegion, synapse.preSynapticRegion)]
if postRegion:
synapses = [synapse for synapse in synapses if search(postRegion, synapse.postSynapticRegion)]
if activation:
synapses = [synapse for synapse in synapses if synapse.activation == activation]
synapses = [connection for connection in self.synapses() if self in connection.postSynapticNeurons()]
synapses = self._filterSynapsesForSearch(synapses, preRegion = preRegion, postRegion = postRegion, activation = activation)
# get pre synaptic neurons
neurons = []
for synapse in synapses:
neurons.append(synapse.preSynapticNeuron())
neurons = self._filterNeuronsForSearch(neurons, neurotransmitter = neurotransmitter, name = preNeuron)
return neurons


def _filterNeuronsForSearch(self, neurons, neurotransmitter = None, name = None):
from re import search
if neurotransmitter:
neurons = [neuron for neuron in neurons if neurotransmitter in neuron.neurotransmitters]
if name:
neurons = [neuron for neuron in neurons if search(name, neuron.name)]
return neurons



def _filterSynapsesForSearch(self, synapses, preRegion = None, postRegion = None, activation = None):
from re import search
if preRegion:
synapses = [synapse for synapse in synapses if synapse.preSynapticRegion and search(preRegion, synapse.preSynapticRegion.name)]
if postRegion:
synapses = [synapse for synapse in synapses if synapse.postSynapticRegion and search(postRegion, synapse.postSynapticRegion.name)]
if activation:
synapses = [synapse for synapse in synapses if synapse.activation and synapse.activation == activation]
return synapses


@classmethod
def _defaultVisualizationParams(cls):
params = NeuroObject._defaultVisualizationParams()
Expand Down
6 changes: 3 additions & 3 deletions Source/network/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class Synapse(NeuroObject):
def __init__(self, network, preSynapticNeurite = None, postSynapticPartners = [], activation = None, presynapticRegion = None, postsynapticRegion = None, *args, **keywords):
def __init__(self, network, preSynapticNeurite = None, postSynapticPartners = [], activation = None, preSynapticRegion = None, postSynapticRegion = None, *args, **keywords):
"""
A Synapse object represents a chemical synapse between a single pre-synaptic neurite and one or more post-synaptic neurites.
Expand All @@ -28,8 +28,8 @@ def __init__(self, network, preSynapticNeurite = None, postSynapticPartners = []
self.preSynapticNeurite = preSynapticNeurite
self.postSynapticPartners = postSynapticPartners
self.activation = activation
self.preSynapticRegion = presynapticRegion
self.postSynapticRegion = postsynapticRegion
self.preSynapticRegion = preSynapticRegion
self.postSynapticRegion = postSynapticRegion


def defaultName(self):
Expand Down

0 comments on commit 46fec2a

Please sign in to comment.