[Pybrainsim-activity] SF.net SVN: pybrainsim:[7] trunk/src
Status: Planning
Brought to you by:
rgoj
|
From: <rg...@us...> - 2009-07-21 13:43:06
|
Revision: 7
http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=7&view=rev
Author: rgoj
Date: 2009-07-21 13:42:54 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
* Added two methods to the Generator class:
** sendOutput - returns the current output of the generator
** receiveInput - adds a given input value to the generator's current output
* Added an implenentation of connection between generators in the Connection.py file
** with a runConnection function that sends the output of one generator into another
* Modified the Head class, so that it is capable of using connections
** added an addConnection method, appending a new list of connections
** each connection is now queried in the Head.runSimulation method
* An example connection is added to the example Head object in the PyBrainSim.py script
Modified Paths:
--------------
trunk/src/Generator.py
trunk/src/Head.py
trunk/src/PyBrainSim.py
Added Paths:
-----------
trunk/src/Connection.py
Added: trunk/src/Connection.py
===================================================================
--- trunk/src/Connection.py (rev 0)
+++ trunk/src/Connection.py 2009-07-21 13:42:54 UTC (rev 7)
@@ -0,0 +1,35 @@
+# PyBrainSim
+# Copyright 2009 Roman Goj
+#
+# This file is part of PyBrainSim.
+#
+# PyBrainSim is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PyBrainSim is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with PyBrainSim. If not, see <http://www.gnu.org/licenses/>.
+
+__metaclass__ = type # New style classes. Is this necessary?
+
+"""
+The Connection class is used for describing communication between two generators - i.e. inhibitory or excitatory connections between simulated neural populations.
+
+This class is only the simplest implementation of these ideas, intended to serve as an example and a starting point for creating complex derived classes, ready for real simulation tasks.
+"""
+
+class Connection:
+ def __init__(self, sourceGenerator, targetGenerator):
+ self.sourceGenerator = sourceGenerator
+ self.targetGenerator = targetGenerator
+
+ def runConnection(self):
+ """Sends the output of the source generator to the target generator, without any changes."""
+
+ self.targetGenerator.receiveInput(self.sourceGenerator.sendOutput())
Modified: trunk/src/Generator.py
===================================================================
--- trunk/src/Generator.py 2009-07-17 12:23:35 UTC (rev 6)
+++ trunk/src/Generator.py 2009-07-21 13:42:54 UTC (rev 7)
@@ -26,6 +26,12 @@
def __init__(self):
self.output = 0
+ def sendOutput(self):
+ return self.output
+
+ def receiveInput(self, input):
+ self.output += input
+
def runGenerator(self):
self.output = self.output + 1
return self.output
Modified: trunk/src/Head.py
===================================================================
--- trunk/src/Head.py 2009-07-17 12:23:35 UTC (rev 6)
+++ trunk/src/Head.py 2009-07-21 13:42:54 UTC (rev 7)
@@ -29,6 +29,7 @@
self.samplingFrequency = 128;
self.generatorList = []
self.generatorSiteList = []
+ self.connectionList = []
self.registrationSiteList = []
def setSamplingFrequency(self, samplingFrequency):
@@ -37,6 +38,9 @@
def addGenerator(self, generator):
self.generatorList.append(generator)
self.generatorSiteList.append([0, 0, 0])
+
+ def addConnection(self, connection):
+ self.connectionList.append(connection)
def addRegistrationSite(self, position):
# We should be checking whether the position is within the boundaries of the brain, which need to be defined somewhere somehow.
@@ -67,10 +71,12 @@
for generator in self.generatorList:
generatorOutput.append(0)
- # Querying all generators
+ # Querying all generators and connections
for timePoint in range(duration * self.samplingFrequency):
for i in range(len(self.generatorList)):
generatorOutput[i] = (self.generatorList[i]).runGenerator()
+ for i in range(len(self.connectionList)):
+ self.connectionList[i].runConnection()
recording = self.runHeadModel(generatorOutput, recording)
Modified: trunk/src/PyBrainSim.py
===================================================================
--- trunk/src/PyBrainSim.py 2009-07-17 12:23:35 UTC (rev 6)
+++ trunk/src/PyBrainSim.py 2009-07-21 13:42:54 UTC (rev 7)
@@ -26,6 +26,7 @@
from Head import Head
from Generator import Generator
+from Connection import Connection
exampleHead = Head()
exampleHead.setSamplingFrequency(32)
@@ -37,5 +38,8 @@
exampleHead.addGenerator(exampleGenerator1)
exampleHead.addGenerator(exampleGenerator2)
+exampleConnection = Connection(exampleGenerator1, exampleGenerator2)
+exampleHead.addConnection(exampleConnection)
+
recording = exampleHead.runSimulation(1)
print recording
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|