pybrainsim-activity Mailing List for PyBrainSim - The Brain Phantom Project (Page 3)
Status: Planning
Brought to you by:
rgoj
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(123) |
Aug
(114) |
Sep
(44) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: PyBrainSim - T. i. <no...@so...> - 2009-09-02 09:00:04
|
#102: Add a bottom to the 3D halved sphere -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: minor | Milestone: 3D visualization of head model Component: Simulations | Resolution: duplicate Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => duplicate -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/102#comment:1> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: PyBrainSim - T. i. <no...@so...> - 2009-09-02 08:58:31
|
#103: Add a bottom to the 3D halved sphere ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: new Priority: minor | Milestone: 3D visualization of head model Component: Visualizations | Keywords: ----------------------------+----------------------------------------------- -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/103> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: PyBrainSim - T. i. <no...@so...> - 2009-09-02 08:58:24
|
#102: Add a bottom to the 3D halved sphere -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: new Priority: minor | Milestone: 3D visualization of head model Component: Simulations | Keywords: -------------------------+-------------------------------------------------- -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/102> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: <rg...@us...> - 2009-09-02 08:51:30
|
Revision: 123 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=123&view=rev Author: rgoj Date: 2009-09-02 08:51:22 +0000 (Wed, 02 Sep 2009) Log Message: ----------- * Changed the 3d object that is presented when testing 3d visualizations to be half a sphere, only for now without a bottom, which looks silly. Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-18 11:07:56 UTC (rev 122) +++ trunk/src/Head.py 2009-09-02 08:51:22 UTC (rev 123) @@ -61,17 +61,15 @@ self.headModel = headModel def displayHead(self): - dphi, dtheta = pi/250.0, pi/250.0 - [phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta] - m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4; - r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7 + dphi, dtheta = pi/10.0, pi/10.0 + #[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta] + [phi,theta] = mgrid[0:pi/2+dphi:dphi,0:2*pi+dtheta:dtheta] + r = 1 x = r*sin(phi)*cos(theta) - y = r*cos(phi) - z = r*sin(phi)*sin(theta) + y = r*sin(phi)*sin(theta) + z = r*cos(phi) - # View it. - - s = mlab.mesh(x, y, z) + s = mlab.mesh(x, y, z, opacity=1, color = ( 0.5,0.5,1.0 )) mlab.show() def runSimulation(self, duration=1): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: PyBrainSim - T. i. <no...@so...> - 2009-08-18 11:10:11
|
#63: Write a 3D view showing a random 3D object ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: 3D visualization of head model Component: Visualizations | Resolution: fixed Keywords: | ----------------------------+----------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/63#comment:1> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: <rg...@us...> - 2009-08-18 11:08:04
|
Revision: 122 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=122&view=rev Author: rgoj Date: 2009-08-18 11:07:56 +0000 (Tue, 18 Aug 2009) Log Message: ----------- * Adding the mayavi import * Adding displayHead() method, that currently only shows an example of how to use mayavi (from the mayavi wiki), by displaying an object in 3D. Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-18 11:05:08 UTC (rev 121) +++ trunk/src/Head.py 2009-08-18 11:07:56 UTC (rev 122) @@ -15,7 +15,8 @@ # PyBrainSim. If not, see <http://www.gnu.org/licenses/>. from __future__ import division -from numpy import arange +from numpy import pi, sin, cos, mgrid, arange +from enthought.mayavi import mlab __metaclass__ = type # New style classes. Is this necessary? """ @@ -59,6 +60,20 @@ def setHeadModel(self, headModel): self.headModel = headModel + def displayHead(self): + dphi, dtheta = pi/250.0, pi/250.0 + [phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta] + m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4; + r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7 + x = r*sin(phi)*cos(theta) + y = r*cos(phi) + z = r*sin(phi)*sin(theta) + + # View it. + + s = mlab.mesh(x, y, z) + mlab.show() + def runSimulation(self, duration=1): """Queries all generators, sends the generators' output to connections, to the head model and then to the specified registration sites""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-18 11:05:16
|
Revision: 121 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=121&view=rev Author: rgoj Date: 2009-08-18 11:05:08 +0000 (Tue, 18 Aug 2009) Log Message: ----------- * Added a new example to the PyBrainSim.py scritpt, that will be used to showcase the 3d head model display features. Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-18 11:04:12 UTC (rev 120) +++ trunk/src/PyBrainSim.py 2009-08-18 11:05:08 UTC (rev 121) @@ -49,7 +49,8 @@ 4. A single sinusoidal generator\n\ 5. A hundred sinusoidal generators with random frequencies, some connected\ to a stimulus.\n\ - 6. A single sinusoidal generator but with two registration sites" + 6. A single sinusoidal generator but with two registration sites\n\ + 7. A presentation of the 3d head model." print(welcomeMessage) userChoice = input("Your choice: ") @@ -170,5 +171,8 @@ exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) exampleExperiment.plotRecording() +elif userChoice == 7: + exampleHead = Head() + exampleHead.displayHead() else: print("No such option unfortunately...") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-18 11:04:21
|
Revision: 120 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=120&view=rev Author: rgoj Date: 2009-08-18 11:04:12 +0000 (Tue, 18 Aug 2009) Log Message: ----------- * Changning from Numeric to from numpy, because Numeric is obsolete (works under Debian Lenny, doesn't work under Ubuntuy Jaunty Jackalope...) Modified Paths: -------------- trunk/src/Head.py trunk/src/HeadModel.py trunk/src/HeadModelHalfSphere.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-15 16:15:42 UTC (rev 119) +++ trunk/src/Head.py 2009-08-18 11:04:12 UTC (rev 120) @@ -15,7 +15,7 @@ # PyBrainSim. If not, see <http://www.gnu.org/licenses/>. from __future__ import division -from Numeric import arange +from numpy import arange __metaclass__ = type # New style classes. Is this necessary? """ Modified: trunk/src/HeadModel.py =================================================================== --- trunk/src/HeadModel.py 2009-08-15 16:15:42 UTC (rev 119) +++ trunk/src/HeadModel.py 2009-08-18 11:04:12 UTC (rev 120) @@ -15,7 +15,7 @@ # PyBrainSim. If not, see <http://www.gnu.org/licenses/>. from __future__ import division -from Numeric import arange +from numpy import arange __metaclass__ = type # New style classes. Is this necessary? """ Modified: trunk/src/HeadModelHalfSphere.py =================================================================== --- trunk/src/HeadModelHalfSphere.py 2009-08-15 16:15:42 UTC (rev 119) +++ trunk/src/HeadModelHalfSphere.py 2009-08-18 11:04:12 UTC (rev 120) @@ -15,7 +15,7 @@ # PyBrainSim. If not, see <http://www.gnu.org/licenses/>. from __future__ import division -from Numeric import arange +from numpy import arange __metaclass__ = type # New style classes. Is this necessary? """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: PyBrainSim - T. i. <no...@so...> - 2009-08-16 13:06:51
|
#62: Which library to use for 3D visualizations? ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: 3D visualization of head model Component: Visualizations | Resolution: fixed Keywords: | ----------------------------+----------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed Comment: Mayavi2... of course. -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/62#comment:1> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: PyBrainSim - T. i. <no...@so...> - 2009-08-15 16:39:20
|
#61: Write an example of using the SphericalHeadModel in the PyBrainSim.py script -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Spherical head model Component: Simulations | Resolution: fixed Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/61#comment:1> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: PyBrainSim - T. i. <no...@so...> - 2009-08-15 16:16:59
|
#60: Make the recorded activity be lower depending on distance from a given generator -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Spherical head model Component: Simulations | Resolution: fixed Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/60#comment:2> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: PyBrainSim - T. i. <no...@so...> - 2009-08-15 16:16:02
|
#59: Write a SphericalHeadModel class with 3D positions and limits for positions -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Spherical head model Component: Simulations | Resolution: fixed Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/59#comment:1> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: <rg...@us...> - 2009-08-15 16:15:49
|
Revision: 119 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=119&view=rev Author: rgoj Date: 2009-08-15 16:15:42 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Added a third registration site in example 6 in PyBrainSim, to showcase the new functionality (HeadModelHalfSphere) even better. Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-15 16:12:35 UTC (rev 118) +++ trunk/src/PyBrainSim.py 2009-08-15 16:15:42 UTC (rev 119) @@ -155,8 +155,9 @@ exampleHead = Head() exampleHeadModel = HeadModelHalfSphere(exampleHead) exampleHead.setSamplingFrequency(128) - exampleHead.addRegistrationSite([0.5, 0, 0.866]) - exampleHead.addRegistrationSite([-0.5, 0, 0.866]) + exampleHead.addRegistrationSite([ 0.5, 0.0, 0.866]) + exampleHead.addRegistrationSite([ 0.0, 0.0, 0.866]) + exampleHead.addRegistrationSite([-0.5, 0.0, 0.866]) exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 10.0) exampleExperiment.setStimulusTimes([[0.3, 1.75, 2.16, 3.87, 4.31, 5.183, 6.34, 7.13]]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 16:12:44
|
Revision: 118 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=118&view=rev Author: rgoj Date: 2009-08-15 16:12:35 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Correcting error in example 5 from PyBrainSim.py caused by changing the GeneratorSine __init__() method: a new parameter was added and this was not correctly set by the example. Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-15 16:04:26 UTC (rev 117) +++ trunk/src/PyBrainSim.py 2009-08-15 16:12:35 UTC (rev 118) @@ -143,9 +143,9 @@ exampleGenerators = [] exampleConnections = [] for i in range(100): - frequency = 2.0 + random() * 18 - phaseShift = random() - exampleGenerators.append(GeneratorSine('Gen', exampleHead, frequency, phaseShift)) + randomFrequency = 2.0 + random() * 18 + randomPhaseShift = random() + exampleGenerators.append(GeneratorSine('Gen', exampleHead, frequency=randomFrequency, phaseShift=randomPhaseShift)) if(random() > 0.75): exampleConnections.append(Connection('Con', exampleHead, exampleStimulus, exampleGenerators[i])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 16:04:38
|
Revision: 117 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=117&view=rev Author: rgoj Date: 2009-08-15 16:04:26 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Changed the example for HeadModelHalfSphere to show off that activity is now recorded differently depending on distance between recording site and generator Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-15 16:02:11 UTC (rev 116) +++ trunk/src/PyBrainSim.py 2009-08-15 16:04:26 UTC (rev 117) @@ -163,7 +163,8 @@ exampleStimulus = Stimulus('Stim', exampleHead) exampleStimulus.setStimulusTimes(exampleExperiment.getStimulusTimes()[0]) - exampleGenerator = GeneratorSine('Gen', exampleHead) + exampleGenerator = GeneratorSine('Gen', exampleHead, position = [0.5, 0, 0.366], frequency = 7) + exampleGenerator = GeneratorSine('Gen', exampleHead, position = [-0.5, 0, 0.366], frequency = 4) exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 16:02:19
|
Revision: 116 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=116&view=rev Author: rgoj Date: 2009-08-15 16:02:11 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Adding a new class: HeadModelHalfSphere that makes it possible to add generators and registration sites in a half sphere of radius 1. The recorded activity is lowered depending on distance between generator and registration site. Added Paths: ----------- trunk/src/HeadModelHalfSphere.py Added: trunk/src/HeadModelHalfSphere.py =================================================================== --- trunk/src/HeadModelHalfSphere.py (rev 0) +++ trunk/src/HeadModelHalfSphere.py 2009-08-15 16:02:11 UTC (rev 116) @@ -0,0 +1,71 @@ +# 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/>. + +from __future__ import division +from Numeric import arange +__metaclass__ = type # New style classes. Is this necessary? + +""" +This reimplemenation of the HeadModel class provides a half sphere model of a +head. The checkPosition() and runHeadModel() methods have been modified, so +that only positions within one half of a sphere of radius 1 are allowed and +recorded activity is smaller when generator is further from registration site. +""" + +from HeadModel import HeadModel + +class HeadModelHalfSphere(HeadModel): + def __init__(self, head): + HeadModel.__init__(self, head) + self.head = head + + def checkPosition(self,position): + # Checking if position is a list of three numbers + if not isinstance(position, list): + return False + if len(position) != 3: + return False + for i in range(3): + if (not isinstance(position[i], float)) and (not isinstance(position[i], int)): + return False + # Checking if position is smaller than the sphere radius of 1 + positionLength = position[0] ** 2 + position[1] ** 2 + position[2] ** 2 + if positionLength > 1: + return False + # If none of the conditions above fail, the position is correct + return True + + def runHeadModel(self, generatorOutput, recording): + # Filling all registration sites with the generators' output + for channel in range(len(recording)): + recording[channel].append(0) + for generator in range(len(generatorOutput)): + # Rejecting generator output that isn't a number + if isinstance(generatorOutput[generator], str): + recording[channel][-1] += 0 + else: + distance = 0 + # Distance between generator and registration site + for dimension in range(3): + distance += ((self.head.generatorSiteList[generator][dimension] + - + self.head.registrationSiteList[channel][dimension]) + ** 2) + # The recorded activity is smaller when the generator is + # far from the registration site. + recording[channel][-1] += generatorOutput[generator] / distance + + return recording This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 15:57:41
|
Revision: 115 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=115&view=rev Author: rgoj Date: 2009-08-15 15:57:34 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * It is now possible to set position of GeneratorSine upon initialization. Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-15 15:56:42 UTC (rev 114) +++ trunk/src/GeneratorSine.py 2009-08-15 15:57:34 UTC (rev 115) @@ -29,8 +29,8 @@ from Generator import Generator class GeneratorSine(Generator): - def __init__(self, name, head, frequency = 2, phaseShift = 0): - Generator.__init__(self, name, head) + def __init__(self, name, head, position = [0,0,0], frequency = 2, phaseShift = 0): + Generator.__init__(self, name, head, position) self.frequency = frequency self.phaseShift = phaseShift self.currentPhase = self.phaseShift This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 15:56:49
|
Revision: 114 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=114&view=rev Author: rgoj Date: 2009-08-15 15:56:42 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * It is now possible to define position of generator upon initialization, this is forwarded to the addGenerator method in the Head object passed upon initialization. Modified Paths: -------------- trunk/src/Generator.py Modified: trunk/src/Generator.py =================================================================== --- trunk/src/Generator.py 2009-08-15 15:55:24 UTC (rev 113) +++ trunk/src/Generator.py 2009-08-15 15:56:42 UTC (rev 114) @@ -22,10 +22,10 @@ """ class Generator: - def __init__(self, name, head): + def __init__(self, name, head, position = [0, 0, 0]): self.name = name self.activation = 0 - head.addGenerator(self) + head.addGenerator(self, position) def printInfo(self): print(self.name + ": A Generator object") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 15:55:37
|
Revision: 113 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=113&view=rev Author: rgoj Date: 2009-08-15 15:55:24 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Correcting a mistake that would cause an uncorrect position to be added to position list anyway Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-15 15:06:17 UTC (rev 112) +++ trunk/src/Head.py 2009-08-15 15:55:24 UTC (rev 113) @@ -43,10 +43,9 @@ def addGenerator(self, generator, position = [0,0,0]): if self.headModel.checkPosition(position): self.generatorSiteList.append(position) + self.generatorList.append(generator) else: print("Wrong position of generator!") - self.generatorList.append(generator) - self.generatorSiteList.append(position) def addConnection(self, connection): self.connectionList.append(connection) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 15:06:25
|
Revision: 112 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=112&view=rev Author: rgoj Date: 2009-08-15 15:06:17 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Removing unused self.head member Modified Paths: -------------- trunk/src/HeadModel.py Modified: trunk/src/HeadModel.py =================================================================== --- trunk/src/HeadModel.py 2009-08-15 14:54:55 UTC (rev 111) +++ trunk/src/HeadModel.py 2009-08-15 15:06:17 UTC (rev 112) @@ -25,7 +25,6 @@ class HeadModel: def __init__(self, head): - self.head = head head.setHeadModel(self) def checkPosition(self,position): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: PyBrainSim - T. i. <no...@so...> - 2009-08-15 14:57:55
|
#101: Display recordings from multiple channels in the plotRecording() method -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Spherical head model Component: Simulations | Resolution: fixed Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/101#comment:1> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |
From: <rg...@us...> - 2009-08-15 14:55:06
|
Revision: 111 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=111&view=rev Author: rgoj Date: 2009-08-15 14:54:55 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Moved the matplotlib functions responsible for multiple axes, plotting, etc. to a new plotChannels() method. * The plotChannels() method is now called from plotRecording() to plot both ongoing and event-related activity. Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-15 11:32:34 UTC (rev 110) +++ trunk/src/Experiment.py 2009-08-15 14:54:55 UTC (rev 111) @@ -118,28 +118,21 @@ return channelERPs - def plotRecording(self): - # Creating a new matplotlib figure for the plots - fig = figure() + def plotChannels(self, channelData, time, stimuli, fig, bottom, height): + # Multiple axes will be created, all sharing the same properties + axes = [] + axesProperties = dict([]) # Each channel will have a plot of the same width and height plotWidth = 0.8 - plotHeight = 0.4/len(self.recording) + plotHeight = height/len(self.recording) - # - # Ongoing activity - # - - # Multiple axes will be created, all sharing the same properties - axes = [] - axesProperties = dict([]) - - for channel in range(len(self.recording)): + for channel in range(len(channelData)): # Plotting the recording for each channel - axes.append(fig.add_axes([0.1, 0.55 + plotHeight * channel, + axes.append(fig.add_axes([0.1, bottom + plotHeight * channel, plotWidth, plotHeight], **axesProperties)) - axes[channel].plot(self.timePoints, self.recording[channel]) + axes[channel].plot(time, channelData[channel]) axes[channel].set_ylabel("CH " + str(channel+1)) # All channels must be zoomed in/out and moved at the same time @@ -148,25 +141,32 @@ axesProperties['sharey'] = axes[0] # Plotting vertical lines to indicate times of stimuli - for i in range(len(self.stimulusTimes[0])): - axvline(self.stimulusTimes[0][i], color='r') + if isinstance(stimuli, float): + axvline(stimuli, color='r') + else: + for i in range(len(stimuli)): + axvline(stimuli[i], color='r') # Time values will be printed only for the lowest axis axes[0].set_xlabel("Time") for axis in axes[1:]: setp(axis.get_xticklabels(), visible=False) + + def plotRecording(self): + # Creating a new matplotlib figure for the plots + fig = figure() + + # Ongoing activity + self.plotChannels(self.recording, self.timePoints, + self.stimulusTimes[0], fig, 0.55, 0.4) + figtext( 0.93, 0.75, 'Ongoing activity', rotation = 'vertical', + verticalalignment = 'center') - # # Event-related activity - # + self.plotChannels(self.getERP(), self.epochTimePoints, + 0.0, fig, 0.075, 0.4) + figtext( 0.93, 0.275, 'Event-related activity', rotation = 'vertical', + verticalalignment = 'center' ) - print self.getERP() - - #subplot(212) - #plot(self.epochTimePoints, self.getERP(), linewidth=1.0) - #axvline( 0.0, color='r' ) - #xlabel('Time (s)') - #ylabel('Amplitude') - #title('Simulated ERP') - + # Showing the prepared figure show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 11:32:41
|
Revision: 110 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=110&view=rev Author: rgoj Date: 2009-08-15 11:32:34 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * The getERP() method now returns a list of ERPs for each channel instead of just the ERP of channel 0. * Now we are ready to plot ERPs with the plotRecording function. Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-15 11:20:44 UTC (rev 109) +++ trunk/src/Experiment.py 2009-08-15 11:32:34 UTC (rev 110) @@ -91,27 +91,32 @@ return self.recording[sliceChannel][startIndex:endIndex] def getERP(self, stimulusNumber=0): + # We will be returning a list of ERPs for each channel + channelERPs = [] + # Choosing the stimulus that will be used to make ERPs stimuli = self.stimulusTimes[stimulusNumber] - #for channel in range(len(self.recording)): - channel = 0 - # Retrieving slices of recordings around each stimulus (epochs) - epochs = [] - for i in range(len(stimuli)): - epochs.append(self.getRecordingSlice(stimuli[i], channel)) + for channel in range(len(self.recording)): + # Retrieving slices of recordings around each stimulus (epochs) + epochs = [] + for i in range(len(stimuli)): + epochs.append(self.getRecordingSlice(stimuli[i], channel)) + + # Making sure all epochs are of the same length + for i in range(len(epochs))[1:]: + if (len(epochs[i]) != len(epochs[i-1])): + print("Not all epochs are of the same length: " + + str(len(epochs[i])) + " " + str(len(epochs[i-1]))) + + # Calculating the average of all the epochs + average = list(zeros(len(epochs[0]))) + for i in range(len(epochs)): + for j in range(len(epochs[i])): + average[j] += epochs[i][j] / len(epochs) + channelERPs.append(average) - # Making sure all epochs are of the same length - for i in range(len(epochs))[1:]: - if (len(epochs[i]) != len(epochs[i-1])): - print("Not all epochs are of the same length: " + - str(len(epochs[i])) + " " + str(len(epochs[i-1]))) - - average = list(zeros(len(epochs[0]))) - for i in range(len(epochs)): - for j in range(len(epochs[i])): - average[j] += epochs[i][j] / len(epochs) - return average + return channelERPs def plotRecording(self): # Creating a new matplotlib figure for the plots @@ -154,6 +159,8 @@ # # Event-related activity # + + print self.getERP() #subplot(212) #plot(self.epochTimePoints, self.getERP(), linewidth=1.0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 11:20:51
|
Revision: 109 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=109&view=rev Author: rgoj Date: 2009-08-15 11:20:44 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Simplified the code for comparing epoch lengths Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-15 11:15:50 UTC (rev 108) +++ trunk/src/Experiment.py 2009-08-15 11:20:44 UTC (rev 109) @@ -101,14 +101,12 @@ for i in range(len(stimuli)): epochs.append(self.getRecordingSlice(stimuli[i], channel)) - # Making sure all epochs are the same length - for i in range(len(epochs)): - if i == 0: - continue - elif (len(epochs[i]) != len(epochs[i-1])): - print str(len(epochs[i])) + " " + str(len(epochs[i-1])) - print "EPOCHS OF DIFFERENT LENGTHS!!!" - + # Making sure all epochs are of the same length + for i in range(len(epochs))[1:]: + if (len(epochs[i]) != len(epochs[i-1])): + print("Not all epochs are of the same length: " + + str(len(epochs[i])) + " " + str(len(epochs[i-1]))) + average = list(zeros(len(epochs[0]))) for i in range(len(epochs)): for j in range(len(epochs[i])): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-15 11:15:57
|
Revision: 108 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=108&view=rev Author: rgoj Date: 2009-08-15 11:15:50 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Removed a print command left over from some testing Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-15 11:14:34 UTC (rev 107) +++ trunk/src/PyBrainSim.py 2009-08-15 11:15:50 UTC (rev 108) @@ -162,7 +162,6 @@ exampleExperiment.setStimulusTimes([[0.3, 1.75, 2.16, 3.87, 4.31, 5.183, 6.34, 7.13]]) exampleStimulus = Stimulus('Stim', exampleHead) - print exampleExperiment.getStimulusTimes()[0] exampleStimulus.setStimulusTimes(exampleExperiment.getStimulusTimes()[0]) exampleGenerator = GeneratorSine('Gen', exampleHead) exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |