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 @ 0:f233164f4c86

History | View | Annotate | Download (1.13 KB)

1
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
%	PSTH is the reduced matrix, the sum of all elements in the bin
10
%
11
% mandatory fileds:
12
%	method.dt
13
% 	method.PSTHbinWidth
14
[numChannels numDataPoints]= size(inputData);
15

    
16
% Multiple fibers is the same as repeat trials
17
% Consolidate data into a histogram 
18
dataPointsPerBin=round(PSTHbinWidth/dt);
19
if dataPointsPerBin<=1;
20
% 	Too few data points
21
	PSTH=inputData;
22
	return
23
end
24

    
25
numBins=floor(numDataPoints/dataPointsPerBin);
26
PSTH=zeros(numChannels,numBins);
27

    
28
% take care that signal length is an integer multiple of bin size
29
%  by dropping the last unuseable values
30
useableDataLength=numBins*dataPointsPerBin;
31
inputData=inputData(:,1:useableDataLength);
32

    
33
for ch=1:numChannels
34
	% Convert each channel into a matrix where each column represents 
35
	% the content of a single PSTH bin
36
	PSTH2D=reshape (inputData(ch,:), dataPointsPerBin, numBins );
37
	% and sum within each bin (across the rows
38
	PSTH(ch,:)=sum (PSTH2D,1);
39
end
40