[Pybrainsim-activity] SF.net SVN: pybrainsim:[110] trunk/src/Experiment.py
Status: Planning
Brought to you by:
rgoj
From: <rg...@us...> - 2009-08-15 11:32:41
|
Revision: 110 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=110&view=rev Author: rgoj Date: 2009-08-15 11:32:34 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * The getERP() method now returns a list of ERPs for each channel instead of just the ERP of channel 0. * Now we are ready to plot ERPs with the plotRecording function. Modified Paths: -------------- trunk/src/Experiment.py Modified: trunk/src/Experiment.py =================================================================== --- trunk/src/Experiment.py 2009-08-15 11:20:44 UTC (rev 109) +++ trunk/src/Experiment.py 2009-08-15 11:32:34 UTC (rev 110) @@ -91,27 +91,32 @@ return self.recording[sliceChannel][startIndex:endIndex] def getERP(self, stimulusNumber=0): + # We will be returning a list of ERPs for each channel + channelERPs = [] + # 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], channel)) + for channel in range(len(self.recording)): + # Retrieving slices of recordings around each stimulus (epochs) + epochs = [] + for i in range(len(stimuli)): + epochs.append(self.getRecordingSlice(stimuli[i], channel)) + + # Making sure all epochs are of the same length + for i in range(len(epochs))[1:]: + if (len(epochs[i]) != len(epochs[i-1])): + print("Not all epochs are of the same length: " + + str(len(epochs[i])) + " " + str(len(epochs[i-1]))) + + # Calculating the average of all the epochs + average = list(zeros(len(epochs[0]))) + for i in range(len(epochs)): + for j in range(len(epochs[i])): + average[j] += epochs[i][j] / len(epochs) + channelERPs.append(average) - # Making sure all epochs are of the same length - for i in range(len(epochs))[1:]: - if (len(epochs[i]) != len(epochs[i-1])): - print("Not all epochs are of the same length: " + - str(len(epochs[i])) + " " + str(len(epochs[i-1]))) - - average = list(zeros(len(epochs[0]))) - for i in range(len(epochs)): - for j in range(len(epochs[i])): - average[j] += epochs[i][j] / len(epochs) - return average + return channelERPs def plotRecording(self): # Creating a new matplotlib figure for the plots @@ -154,6 +159,8 @@ # # Event-related activity # + + print self.getERP() #subplot(212) #plot(self.epochTimePoints, self.getERP(), linewidth=1.0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |