pybrainsim-activity Mailing List for PyBrainSim - The Brain Phantom Project (Page 4)
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: <rg...@us...> - 2009-08-15 11:14:43
|
Revision: 107 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=107&view=rev Author: rgoj Date: 2009-08-15 11:14:34 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Added a few comments Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-15 11:01:16 UTC (rev 106) +++ trunk/src/Experiment.py 2009-08-15 11:14:34 UTC (rev 107) @@ -91,11 +91,17 @@ return self.recording[sliceChannel][startIndex:endIndex] def getERP(self, stimulusNumber=0): + # 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])) + 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 @@ -158,5 +164,4 @@ #ylabel('Amplitude') #title('Simulated ERP') - #show() 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:01:24
|
Revision: 106 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=106&view=rev Author: rgoj Date: 2009-08-15 11:01:16 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Changed plotRecording so that multiple channels can be plotted at the same time. * Used advice from the matplotlib cookbook: http://www.scipy.org/Cookbook/Matplotlib/MultilinePlots * Only the ongoing activity plot is changed, the ERP plots will be reimplemented in the next few commits. Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-14 12:56:59 UTC (rev 105) +++ trunk/src/Experiment.py 2009-08-15 11:01:16 UTC (rev 106) @@ -110,17 +110,53 @@ return average def plotRecording(self): - subplot(211) - plot(self.timePoints, self.recording[0], linewidth=1.0) - for i in range(len(self.stimulusTimes[0])): - axvline(self.stimulusTimes[0][i], color='r') - xlabel('Time (s)') - ylabel('Amplitude') - title('Simulated EEG recording') - subplot(212) - plot(self.epochTimePoints, self.getERP(), linewidth=1.0) - axvline( 0.0, color='r' ) - xlabel('Time (s)') - ylabel('Amplitude') - title('Simulated ERP') + # Creating a new matplotlib figure for the plots + fig = figure() + + # Each channel will have a plot of the same width and height + plotWidth = 0.8 + plotHeight = 0.4/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)): + # Plotting the recording for each channel + axes.append(fig.add_axes([0.1, 0.55 + plotHeight * channel, + plotWidth, plotHeight], + **axesProperties)) + axes[channel].plot(self.timePoints, self.recording[channel]) + axes[channel].set_ylabel("CH " + str(channel+1)) + + # All channels must be zoomed in/out and moved at the same time + if channel == 0: + axesProperties['sharex'] = axes[0] + 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') + + # 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) + + # + # Event-related activity + # + + #subplot(212) + #plot(self.epochTimePoints, self.getERP(), linewidth=1.0) + #axvline( 0.0, color='r' ) + #xlabel('Time (s)') + #ylabel('Amplitude') + #title('Simulated ERP') + + #show() show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-14 12:57:16
|
Revision: 105 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=105&view=rev Author: rgoj Date: 2009-08-14 12:56:59 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * The sixth example now has two registration sites on the opposite sides of the half-shpere Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-14 12:50:53 UTC (rev 104) +++ trunk/src/PyBrainSim.py 2009-08-14 12:56:59 UTC (rev 105) @@ -156,6 +156,7 @@ exampleHeadModel = HeadModelHalfSphere(exampleHead) exampleHead.setSamplingFrequency(128) exampleHead.addRegistrationSite([0.5, 0, 0.866]) + exampleHead.addRegistrationSite([-0.5, 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]]) @@ -167,8 +168,6 @@ exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) - print("\nSimulations resulted in the following recording:") - print exampleExperiment.getRecording() exampleExperiment.plotRecording() 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-14 12:51:00
|
Revision: 104 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=104&view=rev Author: rgoj Date: 2009-08-14 12:50:53 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * Added a sixth example to PyBrainSim.py that for now replicates a singe sine generator example, but will soon be changed to showcase multi-recording-site functionality. Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-13 17:20:12 UTC (rev 103) +++ trunk/src/PyBrainSim.py 2009-08-14 12:50:53 UTC (rev 104) @@ -30,6 +30,7 @@ from Head import Head from HeadModel import HeadModel +from HeadModelHalfSphere import HeadModelHalfSphere from Experiment import Experiment from Stimulus import Stimulus from StimulusDummy import StimulusDummy @@ -47,7 +48,8 @@ 3. Incrementing numbers, two generators and a stimulus for one of them\n\ 4. A single sinusoidal generator\n\ 5. A hundred sinusoidal generators with random frequencies, some connected\ - to a stimulus.\n" + to a stimulus.\n\ + 6. A single sinusoidal generator but with two registration sites" print(welcomeMessage) userChoice = input("Your choice: ") @@ -149,5 +151,24 @@ exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) exampleExperiment.plotRecording() +elif userChoice == 6: + exampleHead = Head() + exampleHeadModel = HeadModelHalfSphere(exampleHead) + exampleHead.setSamplingFrequency(128) + exampleHead.addRegistrationSite([0.5, 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]]) + + exampleStimulus = Stimulus('Stim', exampleHead) + print exampleExperiment.getStimulusTimes()[0] + exampleStimulus.setStimulusTimes(exampleExperiment.getStimulusTimes()[0]) + exampleGenerator = GeneratorSine('Gen', exampleHead) + exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) + + exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) + print("\nSimulations resulted in the following recording:") + print exampleExperiment.getRecording() + exampleExperiment.plotRecording() 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: PyBrainSim - T. i. <no...@so...> - 2009-08-14 12:44:02
|
#101: Display recordings from multiple channels in the plotRecording() method -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: new Priority: major | Milestone: Spherical head model Component: Simulations | Keywords: -------------------------+-------------------------------------------------- -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/101> 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-13 17:20:23
|
Revision: 103 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=103&view=rev Author: rgoj Date: 2009-08-13 17:20:12 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * With a simple one line change the HeadModel class now is aware of it's "governing class" Head object, so that it's information about positions can be used in the HeadModel. Modified Paths: -------------- trunk/src/HeadModel.py Modified: trunk/src/HeadModel.py =================================================================== --- trunk/src/HeadModel.py 2009-08-13 11:55:33 UTC (rev 102) +++ trunk/src/HeadModel.py 2009-08-13 17:20:12 UTC (rev 103) @@ -25,6 +25,7 @@ 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-13 17:18:25
|
#57: Implement the notion of positions for generators and recording sites in the DummyHeadModel class -------------------------+-------------------------------------------------- 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 Comment: Will be covered by simply using the Head class and it's notion of positions... -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/57#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-13 11:56:42
|
#58: Implement a mechanism for cheching whether a position is correct in the DummyHeadModel -------------------------+-------------------------------------------------- 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/58#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-13 11:55:42
|
Revision: 102 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=102&view=rev Author: rgoj Date: 2009-08-13 11:55:33 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * Adding a checkPosition function in the HeadModel * Using the new function in the PyBrainSim scripts * Correcting comments Modified Paths: -------------- trunk/src/Head.py trunk/src/HeadModel.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-13 09:14:46 UTC (rev 101) +++ trunk/src/Head.py 2009-08-13 11:55:33 UTC (rev 102) @@ -40,21 +40,22 @@ def getSamplingFrequency(self): return self.samplingFrequency - def addGenerator(self, generator): + def addGenerator(self, generator, position = [0,0,0]): + if self.headModel.checkPosition(position): + self.generatorSiteList.append(position) + else: + print("Wrong position of generator!") self.generatorList.append(generator) - self.generatorSiteList.append([0, 0, 0]) + self.generatorSiteList.append(position) 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. 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/scalp region... - self.registrationSiteList.append(position) + if self.headModel.checkPosition(position): + self.registrationSiteList.append(position) + else: + print("Wrong position of registration site!") def setHeadModel(self, headModel): self.headModel = headModel Modified: trunk/src/HeadModel.py =================================================================== --- trunk/src/HeadModel.py 2009-08-13 09:14:46 UTC (rev 101) +++ trunk/src/HeadModel.py 2009-08-13 11:55:33 UTC (rev 102) @@ -26,14 +26,16 @@ class HeadModel: def __init__(self, head): head.setHeadModel(self) + + def checkPosition(self,position): + return position == [0,0,0] def runHeadModel(self, generatorOutput, recording): # Filling all registration sites with the generators' output for i in range(len(recording)): recording[i].append(0) for j in range(len(generatorOutput)): - # The Stimulus class may return a string variable, we can't add - # it to the recording, so we need to look out for it. + # Rejecting generator output that isn't a number if isinstance(generatorOutput[j], str): recording[i][-1] += 0 else: 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-13 09:15:31
|
#45: Separate head model from the head class, making a new class DummyHeadModel -------------------------+-------------------------------------------------- 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/45#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-13 09:14:53
|
Revision: 101 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=101&view=rev Author: rgoj Date: 2009-08-13 09:14:46 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * Using the HeadModel in the PyBrainSim.py examples - creating a HeadModel object in each example Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-13 09:04:53 UTC (rev 100) +++ trunk/src/PyBrainSim.py 2009-08-13 09:14:46 UTC (rev 101) @@ -29,6 +29,7 @@ from random import random from Head import Head +from HeadModel import HeadModel from Experiment import Experiment from Stimulus import Stimulus from StimulusDummy import StimulusDummy @@ -54,6 +55,7 @@ if userChoice == 1: exampleHead = Head() + exampleHeadModel = HeadModel(exampleHead) exampleHead.setSamplingFrequency(10) exampleHead.addRegistrationSite([0, 0, 0]) @@ -66,6 +68,7 @@ print(exampleExperiment.getRecording()) elif userChoice == 2: exampleHead = Head() + exampleHeadModel = HeadModel(exampleHead) exampleHead.setSamplingFrequency(10) exampleHead.addRegistrationSite([0, 0, 0]) @@ -79,6 +82,7 @@ print exampleExperiment.getRecording() elif userChoice == 3: exampleHead = Head() + exampleHeadModel = HeadModel(exampleHead) exampleHead.setSamplingFrequency(10) exampleHead.addRegistrationSite([0, 0, 0]) @@ -100,6 +104,7 @@ print exampleExperiment.getRecording() elif userChoice == 4: exampleHead = Head() + exampleHeadModel = HeadModel(exampleHead) exampleHead.setSamplingFrequency(128) exampleHead.addRegistrationSite([0, 0, 0]) @@ -118,6 +123,7 @@ exampleExperiment.plotRecording() elif userChoice == 5: exampleHead = Head() + exampleHeadModel = HeadModel(exampleHead) exampleHead.setSamplingFrequency(256) exampleHead.addRegistrationSite([0, 0, 0]) exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 100.0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-13 09:05:01
|
Revision: 100 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=100&view=rev Author: rgoj Date: 2009-08-13 09:04:53 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * Added an __init__ method, where the HeadModel is attached to a given Head... * Corrected a small mistake Modified Paths: -------------- trunk/src/HeadModel.py Modified: trunk/src/HeadModel.py =================================================================== --- trunk/src/HeadModel.py 2009-08-13 09:03:49 UTC (rev 99) +++ trunk/src/HeadModel.py 2009-08-13 09:04:53 UTC (rev 100) @@ -24,11 +24,14 @@ """ class HeadModel: + def __init__(self, head): + head.setHeadModel(self) + def runHeadModel(self, generatorOutput, recording): # Filling all registration sites with the generators' output for i in range(len(recording)): recording[i].append(0) - for j in range(len(self.generatorList)): + for j in range(len(generatorOutput)): # The Stimulus class may return a string variable, we can't add # it to the recording, so we need to look out for it. if isinstance(generatorOutput[j], str): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-13 09:04:01
|
Revision: 99 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=99&view=rev Author: rgoj Date: 2009-08-13 09:03:49 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * Removed the runHeadModel code * Added a setHeadModel method * Using the new HeadModel object in runSimulation Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-13 08:34:43 UTC (rev 98) +++ trunk/src/Head.py 2009-08-13 09:03:49 UTC (rev 99) @@ -32,6 +32,7 @@ self.generatorSiteList = [] self.connectionList = [] self.registrationSiteList = [] + self.headModel = None def setSamplingFrequency(self, samplingFrequency): self.samplingFrequency = samplingFrequency @@ -55,20 +56,9 @@ # brain/scalp region... self.registrationSiteList.append(position) - def runHeadModel(self, generatorOutput, recording): - # Filling all registration sites with the generators' output - for i in range(len(recording)): - recording[i].append(0) - for j in range(len(self.generatorList)): - # The Stimulus class may return a string variable, we can't add - # it to the recording, so we need to look out for it. - if isinstance(generatorOutput[j], str): - recording[i][-1] += 0 - else: - recording[i][-1] += generatorOutput[j] + def setHeadModel(self, headModel): + self.headModel = headModel - return recording - 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""" @@ -100,6 +90,6 @@ self.connectionList[i].runConnection(generatorOutput[sourceGeneratorIndex]) # Passing the output of the generators through to the head model - recording = self.runHeadModel(generatorOutput, recording) + recording = self.headModel.runHeadModel(generatorOutput, recording) 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-13 08:34:52
|
Revision: 98 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=98&view=rev Author: rgoj Date: 2009-08-13 08:34:43 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * Adding the HeadModel class to replace the corresponding code in Head.py Added Paths: ----------- trunk/src/HeadModel.py Added: trunk/src/HeadModel.py =================================================================== --- trunk/src/HeadModel.py (rev 0) +++ trunk/src/HeadModel.py 2009-08-13 08:34:43 UTC (rev 98) @@ -0,0 +1,39 @@ +# 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? + +""" +The HeadModel class takes care of what happens to the generators' activity on +it's way to the registration sites - i.e. with impedance of the skull. +""" + +class HeadModel: + def runHeadModel(self, generatorOutput, recording): + # Filling all registration sites with the generators' output + for i in range(len(recording)): + recording[i].append(0) + for j in range(len(self.generatorList)): + # The Stimulus class may return a string variable, we can't add + # it to the recording, so we need to look out for it. + if isinstance(generatorOutput[j], str): + recording[i][-1] += 0 + else: + recording[i][-1] += generatorOutput[j] + + return recording 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-07 10:40:59
|
#47: Write a presentation of phase resetting in the PyBrainSim.py script -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Modelling phase resetting Component: Simulations | Resolution: fixed Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/47#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-07 10:39:40
|
Revision: 97 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=97&view=rev Author: rgoj Date: 2009-08-07 10:39:26 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * Added a fifth simulation example to the PyBrainSim.py script, with a hundred generators of random frequency and initial phase, some connected to a stimulus. This gives very nice results in the form of an ongoing signal that looks very similar to EEG and an ERP that has some nice peaks, and completes a milestone! Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-07 10:21:20 UTC (rev 96) +++ trunk/src/PyBrainSim.py 2009-08-07 10:39:26 UTC (rev 97) @@ -26,6 +26,8 @@ pybrainsim.sourceforge.net """ +from random import random + from Head import Head from Experiment import Experiment from Stimulus import Stimulus @@ -42,7 +44,9 @@ 1. Example dummy simulation\n\ 2. Incrementing numbers, one generator and a stimulus\n\ 3. Incrementing numbers, two generators and a stimulus for one of them\n\ - 4. Sinusoidal generator\n" + 4. A single sinusoidal generator\n\ + 5. A hundred sinusoidal generators with random frequencies, some connected\ + to a stimulus.\n" print(welcomeMessage) userChoice = input("Your choice: ") @@ -112,5 +116,32 @@ print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() exampleExperiment.plotRecording() +elif userChoice == 5: + exampleHead = Head() + exampleHead.setSamplingFrequency(256) + exampleHead.addRegistrationSite([0, 0, 0]) + exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 100.0) + + # Randomizing stimuli times + stimuli = [] + for i in range(100): + stimuli.append( i + 0.2 +random()/2 ) + exampleExperiment.setStimulusTimes([stimuli]) + exampleStimulus = Stimulus('Stim', exampleHead) + exampleStimulus.setStimulusTimes(exampleExperiment.getStimulusTimes()[0]) + + # Creating many generators with random frequencies in the range 2-20 Hz and + # random phases. Connecting some of them to the stimulus generator + exampleGenerators = [] + exampleConnections = [] + for i in range(100): + frequency = 2.0 + random() * 18 + phaseShift = random() + exampleGenerators.append(GeneratorSine('Gen', exampleHead, frequency, phaseShift)) + if(random() > 0.75): + exampleConnections.append(Connection('Con', exampleHead, exampleStimulus, exampleGenerators[i])) + + exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) + exampleExperiment.plotRecording() 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-07 10:21:28
|
Revision: 96 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=96&view=rev Author: rgoj Date: 2009-08-07 10:21:20 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * getRecordingSlice now needs only stimulus time as input * Changed the way start and end indices are calculated in getRecordingSlice * Added a warning to getERP that prints out a message if epochs are of different length * Corrected a mistake that caused the average to not be an average, but just a sum Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-07 10:16:59 UTC (rev 95) +++ trunk/src/Experiment.py 2009-08-07 10:21:20 UTC (rev 96) @@ -82,22 +82,31 @@ if timePoint > self.timePoints[i-1]: return i - def getRecordingSlice(self, sliceStart, sliceDuration, sliceChannel=0): - startIndex = self.findNearestTimeIndex(sliceStart) - endIndex = self.findNearestTimeIndex(sliceStart + sliceDuration) + def getRecordingSlice(self, stimulus, sliceChannel=0): + stimulusIndex = self.findNearestTimeIndex(stimulus) + timeStep = 1.0 / self.samplingFrequency + startIndex = int(stimulusIndex - (self.baseline // timeStep)) + endIndex = int(stimulusIndex + 1 + ((self.epochDuration - self.baseline) // timeStep)) + return self.recording[sliceChannel][startIndex:endIndex] def getERP(self, stimulusNumber=0): stimuli = self.stimulusTimes[stimulusNumber] epochs = [] for i in range(len(stimuli)): - epochs.append(self.getRecordingSlice(stimuli[i] - self.baseline, self.epochDuration)) + epochs.append(self.getRecordingSlice(stimuli[i])) + 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!!!" + average = list(zeros(len(epochs[0]))) for i in range(len(epochs)): for j in range(len(epochs[i])): - average[j] += epochs[i][j] - + average[j] += epochs[i][j] / len(epochs) return average def plotRecording(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-07 10:17:07
|
Revision: 95 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=95&view=rev Author: rgoj Date: 2009-08-07 10:16:59 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * Chagned the method epochTimePoints is calculated in Experiment.__init__() Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-07 10:11:53 UTC (rev 94) +++ trunk/src/Experiment.py 2009-08-07 10:16:59 UTC (rev 95) @@ -38,8 +38,10 @@ timeStep = 1.0/self.samplingFrequency self.timePoints = list(arange( timeStep, self.duration + timeStep, timeStep )) - epochStartTime = - timeStep * (self.baseline // timeStep) - self.epochTimePoints = list(arange( epochStartTime, self.epochDuration + epochStartTime, timeStep)) + + startIndex = int( - (self.baseline // timeStep)) + endIndex = int(1 + ((self.epochDuration - self.baseline) // timeStep)) + self.epochTimePoints = list((arange(endIndex - startIndex) - (self.baseline // timeStep)) * timeStep) def setSamplingFrequency(self, samplingFrequency): self.samplingFrequency = samplingFrequency This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-07 10:12:04
|
Revision: 94 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=94&view=rev Author: rgoj Date: 2009-08-07 10:11:53 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * A warning is printed when findNearestTimeIndex invoked with out of bounds arguments. * Corrected a small mistake in findNearestTimeIndex - it would return the wrong number Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-07 10:09:11 UTC (rev 93) +++ trunk/src/Experiment.py 2009-08-07 10:11:53 UTC (rev 94) @@ -71,11 +71,14 @@ is smaller than the given value timePoint""" if timePoint in self.timePoints: return self.timePoints.index(timePoint) + elif (timePoint > max(self.timePoints)) | (timePoint < min(self.timePoints)): + print("findNearestTimeIndex: Something is WRONG! timePoint: " + str(timePoint) ) + return -1 else: for i in range(len(self.timePoints)): if timePoint < self.timePoints[i]: if timePoint > self.timePoints[i-1]: - return i-1 + return i def getRecordingSlice(self, sliceStart, sliceDuration, sliceChannel=0): startIndex = self.findNearestTimeIndex(sliceStart) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-07 10:09:20
|
Revision: 93 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=93&view=rev Author: rgoj Date: 2009-08-07 10:09:11 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * Importing division from python 3.0 Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-07 09:50:49 UTC (rev 92) +++ trunk/src/Experiment.py 2009-08-07 10:09:11 UTC (rev 93) @@ -14,7 +14,8 @@ # # 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 __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: <rg...@us...> - 2009-08-07 09:50:55
|
Revision: 92 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=92&view=rev Author: rgoj Date: 2009-08-07 09:50:49 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * Upon phase reset sine generators now return to their initial phase, instead of zero phase. Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-07 09:49:12 UTC (rev 91) +++ trunk/src/GeneratorSine.py 2009-08-07 09:50:49 UTC (rev 92) @@ -32,7 +32,8 @@ def __init__(self, name, head, frequency = 2, phaseShift = 0): Generator.__init__(self, name, head) self.frequency = frequency - self.currentPhase = phaseShift + self.phaseShift = phaseShift + self.currentPhase = self.phaseShift self.lastTimePoint = 0 def printInfo(self): @@ -40,7 +41,7 @@ def receiveInput(self, input): if input == 'Stimulus': - self.currentPhase = 0 + self.currentPhase = self.phaseShift def runGenerator(self, time): timeStep = time - self.lastTimePoint This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-07 09:49:22
|
Revision: 91 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=91&view=rev Author: rgoj Date: 2009-08-07 09:49:12 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * Removing small debugging print() call Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-07 09:48:31 UTC (rev 90) +++ trunk/src/Head.py 2009-08-07 09:49:12 UTC (rev 91) @@ -89,8 +89,6 @@ timeStep = 1/self.samplingFrequency timeRange = list(arange(timeStep, duration + timeStep, timeStep)) for timePoint in timeRange: - print("HEAD, time: " + str(timePoint)) - # Recording the output of each generator for i in range(len(self.generatorList)): generatorOutput[i] = (self.generatorList[i]).runGenerator(timePoint) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-07 09:48:38
|
Revision: 90 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=90&view=rev Author: rgoj Date: 2009-08-07 09:48:31 +0000 (Fri, 07 Aug 2009) Log Message: ----------- * Removing small debugging print() call Modified Paths: -------------- trunk/src/Stimulus.py Modified: trunk/src/Stimulus.py =================================================================== --- trunk/src/Stimulus.py 2009-08-06 12:13:46 UTC (rev 89) +++ trunk/src/Stimulus.py 2009-08-07 09:48:31 UTC (rev 90) @@ -39,8 +39,6 @@ def runGenerator(self, time): if self.currentStimulus < len(self.stimulusTimes): if self.stimulusTimes[self.currentStimulus] <= time: - print("Stimulus now: BEEEEEEEP! ... Time is: " + str(time) + ", Stimulus list is: " + str(self.stimulusTimes)) - self.currentStimulus += 1 self.activation = 'Stimulus' else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-06 12:16:03
|
Revision: 89 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=89&view=rev Author: rgoj Date: 2009-08-06 12:13:46 +0000 (Thu, 06 Aug 2009) Log Message: ----------- * Experiment.plotRecording() now has two plots - one with the ongoing EEG activity and another with the ERP. * Both plots have vertical lines to indicate stimulus times Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-05 13:03:11 UTC (rev 88) +++ trunk/src/Experiment.py 2009-08-06 12:13:46 UTC (rev 89) @@ -95,11 +95,17 @@ return average def plotRecording(self): + subplot(211) plot(self.timePoints, self.recording[0], linewidth=1.0) - #plot(self.epochTimePoints, self.getERP(), linewidth=1.0) - + for i in range(len(self.stimulusTimes[0])): + axvline(self.stimulusTimes[0][i], color='r') xlabel('Time (s)') ylabel('Amplitude') title('Simulated EEG recording') - grid(True) + subplot(212) + plot(self.epochTimePoints, self.getERP(), linewidth=1.0) + axvline( 0.0, color='r' ) + xlabel('Time (s)') + ylabel('Amplitude') + title('Simulated ERP') show() 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-06 12:01:30
|
#53: Write a simple "signal browser function" that could easily be used to look at any signal -----------------------+---------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Activity plots Component: Interface | Resolution: fixed Keywords: | -----------------------+---------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/53#comment:2> PyBrainSim <http://sourceforge.net/projects/pybrainsim/> An interactive tool for the simulation and visualization of the electromagnetic activity of the brain. |