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