[Pybrainsim-activity] SF.net SVN: pybrainsim:[81] trunk/src
Status: Planning
Brought to you by:
rgoj
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. |