[Pybrainsim-activity] SF.net SVN: pybrainsim:[5] trunk/src
Status: Planning
Brought to you by:
rgoj
From: <rg...@us...> - 2009-07-17 11:55:01
|
Revision: 5 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=5&view=rev Author: rgoj Date: 2009-07-17 11:54:57 +0000 (Fri, 17 Jul 2009) Log Message: ----------- * Registration sites added to the Head class, changing the runSimulation method. * Two registration sites added to the example in the PyBrainSim.py script, * A second generator added to the PyBrainSim.py script to better test the runSimulation method. Modified Paths: -------------- trunk/src/Head.py trunk/src/PyBrainSim.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-07-16 19:42:43 UTC (rev 4) +++ trunk/src/Head.py 2009-07-17 11:54:57 UTC (rev 5) @@ -28,6 +28,7 @@ def __init__(self): self.samplingFrequency = 128; self.generatorList = [] + self.registrationSiteList = [] def setSamplingFrequency(self, samplingFrequency): self.samplingFrequency = samplingFrequency @@ -35,13 +36,34 @@ def addGenerator(self, generator): self.generatorList.append(generator) + 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. + # The class must somehow provide a means to accessing the size of the brain, the available positions, etc. + # One interesting thing to do would be to implement a method returning a position for a name of a given brain region... + self.registrationSiteList.append(position) + def runSimulation(self, duration=1): """Queries all generators and connections, sends the generators' output to the head model and then to the specified registration sites""" - recording = []; + # Preparing a variable to hold the recording for all registration sites + recording = [] + for i in range(len(self.registrationSiteList)): + recording.append([]) + + # Preparing a variable where the output of each of the generators will be stored + generatorOutput = [] + for generator in self.generatorList: + generatorOutput.append(0) + + # Querying all generators for timePoint in range(duration * self.samplingFrequency): - recording.append(0) - for generator in self.generatorList: - recording[timePoint] += generator.runGenerator() + for i in range(len(self.generatorList)): + generatorOutput[i] = (self.generatorList[i]).runGenerator() + # Filling all registration sites with the generators' output + for i in range(len(self.registrationSiteList)): + recording[i].append(0) + for klupek in range(len(self.generatorList)): + recording[i][timePoint] += generatorOutput[klupek] + return recording Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-07-16 19:42:43 UTC (rev 4) +++ trunk/src/PyBrainSim.py 2009-07-17 11:54:57 UTC (rev 5) @@ -29,9 +29,13 @@ exampleHead = Head() exampleHead.setSamplingFrequency(32) +exampleHead.addRegistrationSite([0, 0, 0]) +exampleHead.addRegistrationSite([0, 0, 0]) -exampleGenerator = Generator() -exampleHead.addGenerator(exampleGenerator) +exampleGenerator1 = Generator() +exampleGenerator2 = Generator() +exampleHead.addGenerator(exampleGenerator1) +exampleHead.addGenerator(exampleGenerator2) recording = exampleHead.runSimulation(1) print recording This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |