To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / utilities / UTIL_makePSTH.m

History | View | Annotate | Download (1.11 KB)

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