Mercurial > hg > map
annotate utilities/UTIL_PSTHmakerb.m @ 38:c2204b18f4a2 tip
End nov big change
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Mon, 28 Nov 2011 13:34:28 +0000 |
parents | 6cce421531e2 |
children |
rev | line source |
---|---|
rmeddis@23 | 1 function [PSTH ]=UTIL_PSTHmakerb(inputData, dt, PSTHbinWidth) |
rmeddis@23 | 2 % UTIL_PSTHmakerb averages mean values into bins. |
rmeddis@23 | 3 % No corrections are applied |
rmeddis@23 | 4 % usage: |
rmeddis@23 | 5 % PSTH=UTIL_PSTHmaker(inputData, method) |
rmeddis@23 | 6 % |
rmeddis@23 | 7 % arguments |
rmeddis@23 | 8 % inputData is a channel x time matrix |
rmeddis@23 | 9 % PSTH is the reduced matrix, the sum of all elements in the bin |
rmeddis@23 | 10 % |
rmeddis@23 | 11 |
rmeddis@23 | 12 [numChannels numDataPoints]= size(inputData); |
rmeddis@23 | 13 |
rmeddis@23 | 14 % Multiple fibers is the same as repeat trials |
rmeddis@23 | 15 % Consolidate data into a histogram |
rmeddis@23 | 16 dataPointsPerBin=round(PSTHbinWidth/dt); |
rmeddis@23 | 17 if dataPointsPerBin<=1; |
rmeddis@23 | 18 % Too few data points |
rmeddis@23 | 19 PSTH=inputData; |
rmeddis@23 | 20 return |
rmeddis@23 | 21 end |
rmeddis@23 | 22 |
rmeddis@23 | 23 numBins=floor(numDataPoints/dataPointsPerBin); |
rmeddis@23 | 24 PSTH=zeros(numChannels,numBins); |
rmeddis@23 | 25 |
rmeddis@23 | 26 % take care that signal length is an integer multiple of bin size |
rmeddis@23 | 27 % by dropping the last unuseable values |
rmeddis@23 | 28 useableDataLength=numBins*dataPointsPerBin; |
rmeddis@23 | 29 inputData=inputData(:,1:useableDataLength); |
rmeddis@23 | 30 |
rmeddis@23 | 31 for ch=1:numChannels |
rmeddis@23 | 32 % Convert each channel into a matrix where each column represents |
rmeddis@23 | 33 % the content of a single PSTH bin |
rmeddis@23 | 34 PSTH2D=reshape (inputData(ch,:), dataPointsPerBin, numBins ); |
rmeddis@23 | 35 % and sum within each bin (across the rows |
rmeddis@23 | 36 PSTH(ch,:)=mean (PSTH2D,1); |
rmeddis@23 | 37 end |