rmeddis@19
|
1 function [PSTH dataPointsPerBin]= ...
|
rmeddis@19
|
2 UTIL_makePSTH(inputData, dt, PSTHbinWidth)
|
rmeddis@0
|
3 % UTIL_PSTHmaker accumulates values into bins.
|
rmeddis@0
|
4 % No corrections are applied
|
rmeddis@0
|
5 % usage:
|
rmeddis@0
|
6 % PSTH=UTIL_makePSTH(inputData, dt, PSTHbinWidth)
|
rmeddis@0
|
7 %
|
rmeddis@0
|
8 % arguments
|
rmeddis@0
|
9 % inputData is a channel x time matrix
|
rmeddis@0
|
10 % PSTH is the reduced matrix, the sum of all elements in the bin
|
rmeddis@0
|
11 %
|
rmeddis@0
|
12
|
rmeddis@0
|
13 [numChannels numDataPoints]= size(inputData);
|
rmeddis@0
|
14
|
rmeddis@0
|
15 % Multiple fibers is the same as repeat trials
|
rmeddis@0
|
16 % Consolidate data into a histogram
|
rmeddis@0
|
17 dataPointsPerBin=round(PSTHbinWidth/dt);
|
rmeddis@0
|
18 if dataPointsPerBin<=1;
|
rmeddis@0
|
19 % Too few data points
|
rmeddis@0
|
20 PSTH=inputData;
|
rmeddis@0
|
21 return
|
rmeddis@0
|
22 end
|
rmeddis@0
|
23
|
rmeddis@0
|
24 numBins=floor(numDataPoints/dataPointsPerBin);
|
rmeddis@0
|
25 PSTH=zeros(numChannels,numBins);
|
rmeddis@0
|
26
|
rmeddis@0
|
27 % take care that signal length is an integer multiple of bin size
|
rmeddis@0
|
28 % by dropping the last unuseable values
|
rmeddis@0
|
29 useableDataLength=numBins*dataPointsPerBin;
|
rmeddis@0
|
30 inputData=inputData(:,1:useableDataLength);
|
rmeddis@0
|
31
|
rmeddis@0
|
32 for ch=1:numChannels
|
rmeddis@0
|
33 % Convert each channel into a matrix where each column represents
|
rmeddis@0
|
34 % the content of a single PSTH bin
|
rmeddis@0
|
35 PSTH2D=reshape (inputData(ch,:), dataPointsPerBin, numBins );
|
rmeddis@0
|
36 % and sum within each bin (across the rows
|
rmeddis@0
|
37 PSTH(ch,:)=sum (PSTH2D,1);
|
rmeddis@0
|
38 end
|
rmeddis@0
|
39
|