pybrainsim-activity Mailing List for PyBrainSim - The Brain Phantom Project (Page 5)
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-08-06 11:52:48
|
#52: Display stimuli on the plot of ongoing activity as a way of visualizing stimuli/epoch lengths ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Activity plots Component: Visualizations | Resolution: fixed Keywords: | ----------------------------+----------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/52#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-05 13:05:13
|
#44: Make the Recording class produce an ERP out of ongoing simulated activity and information about stimuli -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Activity plots Component: Simulations | Resolution: fixed Keywords: | -------------------------+-------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/44#comment:3> 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-05 13:03:19
|
Revision: 88 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=88&view=rev Author: rgoj Date: 2009-08-05 13:03:11 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Calculating epoch time points * Added a commented out line that allows plotting of an ERP signal instead of the continous signal Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-05 13:01:36 UTC (rev 87) +++ trunk/src/Experiment.py 2009-08-05 13:03:11 UTC (rev 88) @@ -35,7 +35,10 @@ self.baseline = baseline self.epochDuration = epochDuration - self.timePoints = list(arange( 1.0/self.samplingFrequency, self.duration + 1.0/self.samplingFrequency, 1.0/self.samplingFrequency )) + 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)) def setSamplingFrequency(self, samplingFrequency): self.samplingFrequency = samplingFrequency @@ -76,7 +79,6 @@ def getRecordingSlice(self, sliceStart, sliceDuration, sliceChannel=0): startIndex = self.findNearestTimeIndex(sliceStart) endIndex = self.findNearestTimeIndex(sliceStart + sliceDuration) - #print str(startIndex) + " " + str(endIndex) return self.recording[sliceChannel][startIndex:endIndex] def getERP(self, stimulusNumber=0): @@ -94,6 +96,7 @@ def plotRecording(self): plot(self.timePoints, self.recording[0], linewidth=1.0) + #plot(self.epochTimePoints, self.getERP(), linewidth=1.0) xlabel('Time (s)') ylabel('Amplitude') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-05 13:01:49
|
Revision: 87 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=87&view=rev Author: rgoj Date: 2009-08-05 13:01:36 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Added more stimulus times for fourth example simulation * In example 3 and 4 the simulation is now correctly run with the duration specified in the Experiment class object Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-05 11:59:20 UTC (rev 86) +++ trunk/src/PyBrainSim.py 2009-08-05 13:01:36 UTC (rev 87) @@ -91,7 +91,7 @@ exampleConnection1 = Connection('Con1', exampleHead, exampleStimulus1, exampleGenerator1) exampleConnection2 = Connection('Con2', exampleHead, exampleStimulus2, exampleGenerator2) - exampleExperiment.setRecording(exampleHead.runSimulation()) + exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() elif userChoice == 4: @@ -99,8 +99,8 @@ exampleHead.setSamplingFrequency(128) exampleHead.addRegistrationSite([0, 0, 0]) - exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0) - exampleExperiment.setStimulusTimes([[0.3, 0.6]]) + 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] @@ -108,7 +108,7 @@ exampleGenerator = GeneratorSine('Gen', exampleHead) exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) - exampleExperiment.setRecording(exampleHead.runSimulation()) + exampleExperiment.setRecording(exampleHead.runSimulation(exampleExperiment.getDuration())) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() exampleExperiment.plotRecording() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-05 11:59:32
|
Revision: 86 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=86&view=rev Author: rgoj Date: 2009-08-05 11:59:20 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Changes to Experiment class: ** timePoints is now a member of the class ** added baseline and epochDuration as members ** added the findNearestTimeIndex method ** added the getRecordingSlice method ** added the getERP method Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-05 11:54:07 UTC (rev 85) +++ trunk/src/Experiment.py 2009-08-05 11:59:20 UTC (rev 86) @@ -27,12 +27,16 @@ from pylab import * class Experiment: - def __init__(self, samplingFrequency = 128, duration = 1, recording = [], stimulusTimes = []): + def __init__(self, samplingFrequency = 128, duration = 1, recording = [], stimulusTimes = [], baseline = 0.1, epochDuration = 0.3): self.samplingFrequency = samplingFrequency self.duration = duration self.recording = recording self.stimulusTimes = stimulusTimes + self.baseline = baseline + self.epochDuration = epochDuration + self.timePoints = list(arange( 1.0/self.samplingFrequency, self.duration + 1.0/self.samplingFrequency, 1.0/self.samplingFrequency )) + def setSamplingFrequency(self, samplingFrequency): self.samplingFrequency = samplingFrequency @@ -52,14 +56,44 @@ return self.recording def setStimulusTimes(self, stimulusTimes): + #TODO: If dimension of stimulusTimes is 1... it needs to be two :/ self.stimulusTimes = stimulusTimes def getStimulusTimes(self): return self.stimulusTimes + def findNearestTimeIndex(self, timePoint): + """ Returns the index of the closest time point within timePoints that + is smaller than the given value timePoint""" + if timePoint in self.timePoints: + return self.timePoints.index(timePoint) + else: + for i in range(len(self.timePoints)): + if timePoint < self.timePoints[i]: + if timePoint > self.timePoints[i-1]: + return i-1 + + def getRecordingSlice(self, sliceStart, sliceDuration, sliceChannel=0): + startIndex = self.findNearestTimeIndex(sliceStart) + endIndex = self.findNearestTimeIndex(sliceStart + sliceDuration) + #print str(startIndex) + " " + str(endIndex) + 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)) + + average = list(zeros(len(epochs[0]))) + for i in range(len(epochs)): + for j in range(len(epochs[i])): + average[j] += epochs[i][j] + + return average + def plotRecording(self): - timePoints = arange( 1.0/self.samplingFrequency, self.duration + 1.0/self.samplingFrequency, 1.0/self.samplingFrequency ) - plot(timePoints, self.recording[0], linewidth=1.0) + plot(self.timePoints, self.recording[0], linewidth=1.0) xlabel('Time (s)') ylabel('Amplitude') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-05 11:54:15
|
Revision: 85 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=85&view=rev Author: rgoj Date: 2009-08-05 11:54:07 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * The fourth example now also uses the Experiment class to set the stimulus times Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-05 10:23:11 UTC (rev 84) +++ trunk/src/PyBrainSim.py 2009-08-05 11:54:07 UTC (rev 85) @@ -98,13 +98,17 @@ exampleHead = Head() exampleHead.setSamplingFrequency(128) exampleHead.addRegistrationSite([0, 0, 0]) + + exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0) + exampleExperiment.setStimulusTimes([[0.3, 0.6]]) exampleStimulus = Stimulus('Stim', exampleHead) - exampleStimulus.setStimulusTimes([0.3, 0.6]) + print exampleExperiment.getStimulusTimes()[0] + exampleStimulus.setStimulusTimes(exampleExperiment.getStimulusTimes()[0]) exampleGenerator = GeneratorSine('Gen', exampleHead) exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) - exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0, exampleHead.runSimulation( 1.0 )) + exampleExperiment.setRecording(exampleHead.runSimulation()) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() exampleExperiment.plotRecording() 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-05 10:25:20
|
#44: Make the Recording class produce an ERP out of ongoing simulated activity and information about stimuli -------------------------+-------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: new Priority: major | Milestone: Activity plots Component: Simulations | Keywords: -------------------------+-------------------------------------------------- Changes (by rgoj): * milestone: Modelling phase resetting => Activity plots -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/44#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-05 10:23:52
|
#51: Enable the user to choose the scale of the plots -----------------------+---------------------------------------------------- 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/51#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-05 10:23:20
|
#50: Write a scrolling activity viewer ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Activity plots Component: Visualizations | Resolution: fixed Keywords: | ----------------------------+----------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/50#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-05 10:23:17
|
Revision: 84 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=84&view=rev Author: rgoj Date: 2009-08-05 10:23:11 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * The plotRecording function now plots the first channel of the recording Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-05 10:06:51 UTC (rev 83) +++ trunk/src/Experiment.py 2009-08-05 10:23:11 UTC (rev 84) @@ -58,13 +58,11 @@ return self.stimulusTimes def plotRecording(self): - t = arange( 0.0, 2.0, 0.01 ) - #t = arange( 1.0/128, 1.0 + 1.0/128, 1.0/128 ) - s = sin(2*pi*t) - plot(t, s, linewidth=1.0) + timePoints = arange( 1.0/self.samplingFrequency, self.duration + 1.0/self.samplingFrequency, 1.0/self.samplingFrequency ) + plot(timePoints, self.recording[0], linewidth=1.0) - xlabel('time (s)') - ylabel('voltage (mV)') + xlabel('Time (s)') + ylabel('Amplitude') title('Simulated EEG recording') grid(True) 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-05 10:22:18
|
#49: Write a function that would take care of displaying a simple plot ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Activity plots Component: Visualizations | Resolution: fixed Keywords: | ----------------------------+----------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/49#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-05 10:06:59
|
Revision: 83 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=83&view=rev Author: rgoj Date: 2009-08-05 10:06:51 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * All examples in PyBrainSim.py updated to use the new Experiment class Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-05 10:03:30 UTC (rev 82) +++ trunk/src/PyBrainSim.py 2009-08-05 10:06:51 UTC (rev 83) @@ -57,7 +57,7 @@ exampleGenerator = GeneratorDummy('Gen', exampleHead) exampleConnection = ConnectionDummy('Con', exampleHead, exampleStimulus, exampleGenerator) - exampleExperiment = Experiment(exampleHead.runSimulation( 1 )) + exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0, exampleHead.runSimulation( 1.0 )) print("\nSimulations resulted in the following recording:") print(exampleExperiment.getRecording()) elif userChoice == 2: @@ -70,7 +70,7 @@ exampleGenerator = GeneratorNumberIncrementing('Gen', exampleHead) exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) - exampleExperiment = Experiment(exampleHead.runSimulation( 1 )) + exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0, exampleHead.runSimulation( 1.0 )) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() elif userChoice == 3: @@ -78,7 +78,7 @@ exampleHead.setSamplingFrequency(10) exampleHead.addRegistrationSite([0, 0, 0]) - exampleExperiment = Experiment() + exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0) exampleExperiment.setStimulusTimes([[0.3, 0.6], [0.5]]) exampleStimulus1 = Stimulus('Stim1', exampleHead) @@ -91,7 +91,7 @@ exampleConnection1 = Connection('Con1', exampleHead, exampleStimulus1, exampleGenerator1) exampleConnection2 = Connection('Con2', exampleHead, exampleStimulus2, exampleGenerator2) - exampleExperiment.setRecording(exampleHead.runSimulation( 1 )) + exampleExperiment.setRecording(exampleHead.runSimulation()) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() elif userChoice == 4: @@ -107,7 +107,6 @@ exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0, exampleHead.runSimulation( 1.0 )) 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-05 10:03:39
|
Revision: 82 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=82&view=rev Author: rgoj Date: 2009-08-05 10:03:30 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * added getSamplingFrequency() * removed an outdated comment Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-05 10:02:26 UTC (rev 81) +++ trunk/src/Head.py 2009-08-05 10:03:30 UTC (rev 82) @@ -36,9 +36,10 @@ def setSamplingFrequency(self, samplingFrequency): self.samplingFrequency = samplingFrequency + def getSamplingFrequency(self): + return self.samplingFrequency + def addGenerator(self, generator): - # TODO: We must check for equal generator names - two identical names - # can't currently be allowed to happen! self.generatorList.append(generator) self.generatorSiteList.append([0, 0, 0]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-05 10:02:36
|
Revision: 81 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=81&view=rev Author: rgoj Date: 2009-08-05 10:02:26 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Experiment class now has duration and samplingFrequency parameters * Experiment class now holds a method for plotting the recording... which for now holds the matplotlib example of plotting a sinusoid, to be used for plotting the real recording soon. * The fourth example in PyBrainSim is updated to use the updated Experiment class Modified Paths: -------------- trunk/src/Experiment.py trunk/src/PyBrainSim.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-05 07:14:20 UTC (rev 80) +++ trunk/src/Experiment.py 2009-08-05 10:02:26 UTC (rev 81) @@ -24,11 +24,27 @@ interface to Neuroscan, e.g. by providing an export to .cnt files feature. """ +from pylab import * + class Experiment: - def __init__(self, recording = [], stimulusTimes = []): + def __init__(self, samplingFrequency = 128, duration = 1, recording = [], stimulusTimes = []): + self.samplingFrequency = samplingFrequency + self.duration = duration self.recording = recording self.stimulusTimes = stimulusTimes + def setSamplingFrequency(self, samplingFrequency): + self.samplingFrequency = samplingFrequency + + def getSamplingFrequency(self): + return self.samplingFrequency + + def setDuration(self, duration): + self.duration = duration + + def getDuration(self): + return self.duration + def setRecording(self, recording): self.recording = recording @@ -38,9 +54,17 @@ def setStimulusTimes(self, stimulusTimes): self.stimulusTimes = stimulusTimes - def addStimulusTime(self, stimulusTime): - self.stimulusTimes.append(stimulusTime) - self.stimulusTimes.sort() - def getStimulusTimes(self): return self.stimulusTimes + + def plotRecording(self): + t = arange( 0.0, 2.0, 0.01 ) + #t = arange( 1.0/128, 1.0 + 1.0/128, 1.0/128 ) + s = sin(2*pi*t) + plot(t, s, linewidth=1.0) + + xlabel('time (s)') + ylabel('voltage (mV)') + title('Simulated EEG recording') + grid(True) + show() Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-05 07:14:20 UTC (rev 80) +++ trunk/src/PyBrainSim.py 2009-08-05 10:02:26 UTC (rev 81) @@ -104,8 +104,10 @@ exampleGenerator = GeneratorSine('Gen', exampleHead) exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) - exampleExperiment = Experiment(exampleHead.runSimulation( 1 )) + exampleExperiment = Experiment(exampleHead.getSamplingFrequency(), 1.0, exampleHead.runSimulation( 1.0 )) 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-05 09:01:44
|
#48: Decide on a library that could be used to produce the desired plots ----------------------------+----------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Activity plots Component: Visualizations | Resolution: fixed Keywords: | ----------------------------+----------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed Comment: This will of course have to be matplotlib - which seems to be the standard for Python scientific computing, when it comes to plotting 2D figures... -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/48#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-05 08:50:41
|
#100: The Experiment class should allow for different stimulus times for different stimuli objects -------------------------+-------------------------------------------------- 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/100#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-05 07:14:27
|
Revision: 80 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=80&view=rev Author: rgoj Date: 2009-08-05 07:14:20 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Example 3 now also shows how the Experiment class can be used to keep track of stimulus times for two separate stimulus objects. This is more of a hack for now, but should take more shape later. Modified Paths: -------------- trunk/src/PyBrainSim.py Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-05 06:58:57 UTC (rev 79) +++ trunk/src/PyBrainSim.py 2009-08-05 07:14:20 UTC (rev 80) @@ -78,16 +78,20 @@ exampleHead.setSamplingFrequency(10) exampleHead.addRegistrationSite([0, 0, 0]) + exampleExperiment = Experiment() + exampleExperiment.setStimulusTimes([[0.3, 0.6], [0.5]]) + exampleStimulus1 = Stimulus('Stim1', exampleHead) exampleStimulus2 = Stimulus('Stim2', exampleHead) - exampleStimulus1.setStimulusTimes([0.3, 0.6]) - exampleStimulus2.setStimulusTimes([0.5]) + exampleStimulus1.setStimulusTimes(exampleExperiment.getStimulusTimes()[0]) + exampleStimulus2.setStimulusTimes(exampleExperiment.getStimulusTimes()[1]) + exampleGenerator1 = GeneratorNumberIncrementing('Gen1', exampleHead) exampleGenerator2 = GeneratorNumberIncrementing('Gen2', exampleHead) exampleConnection1 = Connection('Con1', exampleHead, exampleStimulus1, exampleGenerator1) exampleConnection2 = Connection('Con2', exampleHead, exampleStimulus2, exampleGenerator2) - exampleExperiment = Experiment(exampleHead.runSimulation( 1 )) + exampleExperiment.setRecording(exampleHead.runSimulation( 1 )) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() elif userChoice == 4: 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-05 06:59:36
|
#39: Write a simple phase-resetting stimulus for the sinusoidal generator --------------------+------------------------------------------------------- Reporter: rgoj | Owner: rgoj Type: task | Status: closed Priority: major | Milestone: Modelling phase resetting Component: Design | Resolution: fixed Keywords: | --------------------+------------------------------------------------------- Changes (by rgoj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://sourceforge.net/apps/trac/pybrainsim/ticket/39#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-05 06:59:09
|
Revision: 79 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=79&view=rev Author: rgoj Date: 2009-08-05 06:58:57 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Reworking GeneratorSine: ** added printInfo method ** corrected the receiveInput method ** the runGenerator method is now much cleaner Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-03 18:36:14 UTC (rev 78) +++ trunk/src/GeneratorSine.py 2009-08-05 06:58:57 UTC (rev 79) @@ -23,28 +23,29 @@ stimulus. """ -import math +from math import pi +from math import sin + from Generator import Generator class GeneratorSine(Generator): def __init__(self, name, head, frequency = 2, phaseShift = 0): Generator.__init__(self, name, head) self.frequency = frequency - self.phaseShift = phaseShift + self.currentPhase = phaseShift + self.lastTimePoint = 0 + + def printInfo(self): + print(self.name + ": A GeneratorSine object") def receiveInput(self, input): if input == 'Stimulus': - self.phaseShift = -self.activation - else: - self.activation += input + self.currentPhase = 0 def runGenerator(self, time): -# self.phase = (2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) \ -# % (2 * math.pi / self.frequency) / (2 * math.pi) - self.phase = ((2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) \ - % (2 * math.pi)) / (2 * math.pi) -# self.activation += math.sin(self.phase * 2 * math.pi) - self.activation = math.sin(self.phase * 2 * math.pi) - print("Output is now: " + str(self.activation)) - + timeStep = time - self.lastTimePoint + self.lastTimePoint = time + self.currentPhase += self.frequency * timeStep + self.activation = sin(self.currentPhase * 2 * pi) + return self.activation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-03 18:36:27
|
Revision: 78 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=78&view=rev Author: rgoj Date: 2009-08-03 18:36:14 +0000 (Mon, 03 Aug 2009) Log Message: ----------- * Corrected mistake: __init__ must be also called with the head argument * Corrected mistake: the phase of the sine is now correctly calculated Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-03 18:14:42 UTC (rev 77) +++ trunk/src/GeneratorSine.py 2009-08-03 18:36:14 UTC (rev 78) @@ -27,8 +27,8 @@ from Generator import Generator class GeneratorSine(Generator): - def __init__(self, name, frequency = 2, phaseShift = 0): - Generator.__init__(self, name) + def __init__(self, name, head, frequency = 2, phaseShift = 0): + Generator.__init__(self, name, head) self.frequency = frequency self.phaseShift = phaseShift @@ -39,6 +39,12 @@ self.activation += input def runGenerator(self, time): - self.phase = (2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) % (2 * math.pi / self.frequency) / (2 * math.pi) - print("Phase is now: " + str(self.phase)) - return math.sin(self.phase * 2 * math.pi) +# self.phase = (2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) \ +# % (2 * math.pi / self.frequency) / (2 * math.pi) + self.phase = ((2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) \ + % (2 * math.pi)) / (2 * math.pi) +# self.activation += math.sin(self.phase * 2 * math.pi) + self.activation = math.sin(self.phase * 2 * math.pi) + print("Output is now: " + str(self.activation)) + + return self.activation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-03 18:14:49
|
Revision: 77 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=77&view=rev Author: rgoj Date: 2009-08-03 18:14:42 +0000 (Mon, 03 Aug 2009) Log Message: ----------- * Removed the obsolete sendOutput() method * Wrote a proper receiveInput() method, so that a stimulus will reset the phase of the generated sine Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-03 18:10:19 UTC (rev 76) +++ trunk/src/GeneratorSine.py 2009-08-03 18:14:42 UTC (rev 77) @@ -32,12 +32,11 @@ self.frequency = frequency self.phaseShift = phaseShift - def sendOutput(self): - print("Sending output: " + str(self.phase)) - return self.phase - - def receiveInput(self, newPhaseShift): - self.phaseShift = newPhaseShift + def receiveInput(self, input): + if input == 'Stimulus': + self.phaseShift = -self.activation + else: + self.activation += input def runGenerator(self, time): self.phase = (2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) % (2 * math.pi / self.frequency) / (2 * math.pi) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-03 18:10:27
|
Revision: 76 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=76&view=rev Author: rgoj Date: 2009-08-03 18:10:19 +0000 (Mon, 03 Aug 2009) Log Message: ----------- * Made a better __init__ method, invoking the parent class Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-03 18:07:46 UTC (rev 75) +++ trunk/src/GeneratorSine.py 2009-08-03 18:10:19 UTC (rev 76) @@ -24,12 +24,12 @@ """ import math +from Generator import Generator -class GeneratorSine: - def __init__(self, frequency = 1, phaseShift = 0): - self.activation = 0 +class GeneratorSine(Generator): + def __init__(self, name, frequency = 2, phaseShift = 0): + Generator.__init__(self, name) self.frequency = frequency - self.phase = phaseShift self.phaseShift = phaseShift def sendOutput(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-03 18:07:55
|
Revision: 75 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=75&view=rev Author: rgoj Date: 2009-08-03 18:07:46 +0000 (Mon, 03 Aug 2009) Log Message: ----------- * Proper column width of license and beginning commentary Modified Paths: -------------- trunk/src/GeneratorSine.py trunk/src/PyBrainSim.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-03 17:57:45 UTC (rev 74) +++ trunk/src/GeneratorSine.py 2009-08-03 18:07:46 UTC (rev 75) @@ -3,23 +3,24 @@ # # 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 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. +# 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/>. +# 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 GeneratorSine class is an example generator that simply generates a single sine. +The GeneratorSine class is a reimplementation of the Generator class. It +provides a sine generator and allows the phase of the sine to be zeroed by a +stimulus. """ import math Modified: trunk/src/PyBrainSim.py =================================================================== --- trunk/src/PyBrainSim.py 2009-08-03 17:57:45 UTC (rev 74) +++ trunk/src/PyBrainSim.py 2009-08-03 18:07:46 UTC (rev 75) @@ -28,16 +28,14 @@ from Head import Head from Experiment import Experiment - from Stimulus import Stimulus from StimulusDummy import StimulusDummy from GeneratorDummy import GeneratorDummy from GeneratorNumberIncrementing import GeneratorNumberIncrementing +from GeneratorSine import GeneratorSine from Connection import Connection from ConnectionDummy import ConnectionDummy -#from GeneratorSine import GeneratorSine - welcomeMessage = "\n\ Welcome to this early version of PyBrainSim\n\n\ Choose the type of simulation you would like to perform:\n\ @@ -92,27 +90,18 @@ exampleExperiment = Experiment(exampleHead.runSimulation( 1 )) print("\nSimulations resulted in the following recording:") print exampleExperiment.getRecording() -#elif userChoice == 2: -# exampleExperiment = Experiment() -# exampleExperiment.addStimulusTime( 0.2341 ) -# -# exampleHead = Head() -# exampleHead.setSamplingFrequency( 10 ) -# exampleHead.addRegistrationSite([0, 0, 0]) -# -# exampleGenerator1 = GeneratorSine() -# exampleHead.addGenerator(exampleGenerator1) -# -# exampleStimulus = GeneratorStimulusPhaseReset() -# exampleStimulus.setStimulusTimes(exampleExperiment.getStimulusTimes()) -# exampleHead.addGenerator(exampleStimulus) -# -# exampleStimulusToGeneratorConnection = ConnectionSimple(exampleStimulus, exampleGenerator1) -# exampleGeneratorToStimulusConnection = ConnectionSimple(exampleGenerator1, exampleStimulus) -# exampleHead.addConnection(exampleGeneratorToStimulusConnection) -# exampleHead.addConnection(exampleStimulusToGeneratorConnection) -# -# exampleExperiment.setRecording(exampleHead.runSimulation( 1.1 )) -# print exampleExperiment.getRecording() +elif userChoice == 4: + exampleHead = Head() + exampleHead.setSamplingFrequency(128) + exampleHead.addRegistrationSite([0, 0, 0]) + + exampleStimulus = Stimulus('Stim', exampleHead) + exampleStimulus.setStimulusTimes([0.3, 0.6]) + exampleGenerator = GeneratorSine('Gen', exampleHead) + exampleConnection = Connection('Con', exampleHead, exampleStimulus, exampleGenerator) + + exampleExperiment = Experiment(exampleHead.runSimulation( 1 )) + print("\nSimulations resulted in the following recording:") + print exampleExperiment.getRecording() 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-03 17:57:52
|
Revision: 74 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=74&view=rev Author: rgoj Date: 2009-08-03 17:57:45 +0000 (Mon, 03 Aug 2009) Log Message: ----------- * Removing the no longer needed methods: ** getSourceName() ** getTargetName() * Instead it is now possible to run Connection.getSource().getName() Modified Paths: -------------- trunk/src/Connection.py Modified: trunk/src/Connection.py =================================================================== --- trunk/src/Connection.py 2009-08-03 17:56:27 UTC (rev 73) +++ trunk/src/Connection.py 2009-08-03 17:57:45 UTC (rev 74) @@ -45,11 +45,5 @@ def getTarget(self): return self.targetGenerator - def getSourceName(self): - return self.sourceGenerator.getName() - - def getTargetName(self): - return self.targetGenerator.getName() - def runConnection(self, sourceGeneratorOutput): self.targetGenerator.receiveInput(sourceGeneratorOutput) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rg...@us...> - 2009-08-03 17:56:35
|
Revision: 73 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=73&view=rev Author: rgoj Date: 2009-08-03 17:56:27 +0000 (Mon, 03 Aug 2009) Log Message: ----------- * Prepared a new method for checking which generator's output must a connection recieve in the runSimulation method, using the new getSource() method in the Connection class * Removed the old method Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-03 17:31:21 UTC (rev 72) +++ trunk/src/Head.py 2009-08-03 17:56:27 UTC (rev 73) @@ -96,26 +96,11 @@ # Sending the output of generators through connections for i in range(len(self.connectionList)): - # All the generator names are checked against names of the - # source generators of all the connections, to find which - # generator's output should be passed on to the connection. - # There must be a better way to do this... - sourceGeneratorIndex = 0 - for j in range(len(self.generatorList)): - if self.connectionList[i].getSourceName() == self.generatorList[j].getName(): - sourceGeneratorIndex = j - - # Perhaps this is a nicer method of doing the same thing as - # above... but leaving this here for further testing. Besides - # it breaks the encapsulation of the connection class - - # directly communicating with one of it's members... - sourceGeneratorIndex2 = self.generatorList.index(self.connectionList[i].sourceGenerator) - print("Established method: " + str(sourceGeneratorIndex) + ", new method: " + str(sourceGeneratorIndex2)) - + # Checking which generator's output must a connection recieve + sourceGeneratorIndex = self.generatorList.index(self.connectionList[i].getSource()) self.connectionList[i].runConnection(generatorOutput[sourceGeneratorIndex]) - # Passing the output of the generators through to the head model to - # get the recording + # Passing the output of the generators through to the head model recording = self.runHeadModel(generatorOutput, recording) return recording This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |