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_PSTHmaker.m

History | View | Annotate | Download (1.23 KB)

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