[Pybrainsim-activity] SF.net SVN: pybrainsim:[140] trunk/src/PyBrainSim.py
Status: Planning
Brought to you by:
rgoj
From: <rg...@us...> - 2010-06-27 16:33:51
|
Revision: 140 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=140&view=rev Author: rgoj Date: 2010-06-27 16:33:45 +0000 (Sun, 27 Jun 2010) Log Message: ----------- * Added an example usage of the work in progress dipole single sphere head model. This example will be modified later to actually show something interesting. Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2010-06-27 15:56:09 UTC (rev 139) +++ trunk/src/PyBrainSim.py 2010-06-27 16:33:45 UTC (rev 140) @@ -38,11 +38,13 @@ from Head import Head from HeadModel import HeadModel from HeadModelHalfSphere import HeadModelHalfSphere +from HeadModelDipoleSphere import HeadModelDipoleSphere from Experiment import Experiment from Stimulus import Stimulus from StimulusDummy import StimulusDummy from GeneratorDummy import GeneratorDummy from GeneratorNumberIncrementing import GeneratorNumberIncrementing +from GeneratorNoisy import GeneratorNoisy from GeneratorSine import GeneratorSine from Connection import Connection from ConnectionDummy import ConnectionDummy @@ -61,6 +63,7 @@ self.frame.Bind(wx.EVT_BUTTON, self.menuButton6, id=xrc.XRCID("menuButton6")) self.frame.Bind(wx.EVT_BUTTON, self.menuButton7, id=xrc.XRCID("menuButton7")) self.frame.Bind(wx.EVT_BUTTON, self.menuButton8, id=xrc.XRCID("menuButton8")) + self.frame.Bind(wx.EVT_BUTTON, self.menuButton9, id=xrc.XRCID("menuButton9")) self.frame.Bind(wx.EVT_BUTTON, self.menuButtonQuit, id=xrc.XRCID("menuButtonQuit")) self.frame.Show() @@ -276,6 +279,38 @@ pylab.plot(recording[i][firstPointToDisplay:]) pylab.show() + def menuButton9(self, control): + # head will hold sources, registrations sites and the head model + head = Head() + + # headModel will be our single sphere head model + headModel = HeadModelDipoleSphere(head, 10.0) + + # We need only one data point per simulation + head.setSamplingFrequency(1) + + # Adding registration sites + head.addRegistrationSite([-numpy.pi/2, numpy.pi/2]) + head.addRegistrationSite([-numpy.pi/4, numpy.pi/2]) + head.addRegistrationSite([0, numpy.pi/2]) + head.addRegistrationSite([numpy.pi/4, numpy.pi/2]) + head.addRegistrationSite([numpy.pi/2, numpy.pi/2]) + + # Adding generators + generator = GeneratorNoisy('Gen', head, position = [ 0.3, 0, 0, 0, 0], mean=1, stddev=0.1) + generator = GeneratorNoisy('Gen', head, position = [ 0.3, 0, 0, 0, 0], mean=1, stddev=0.1) + generator = GeneratorNoisy('Gen', head, position = [ 0.3, 0, 0, 0, 0], mean=1, stddev=0.1) + + # Run the simulation just once (or, equivalently for one second with the sampling rate of 1 Hz) + simulatedData = numpy.array(head.runSimulation(5)) + + # Add Gaussian noise with mean 0 and variance 1 + electrodeNoise = numpy.random.normal(0, 0.0000001, simulatedData.shape); + simulatedData = simulatedData + electrodeNoise + + print(simulatedData) + + def menuButtonQuit(self, control): self.Exit() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |