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 @ 38:c2204b18f4a2

History | View | Annotate | Download (1.23 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
%   dt is the sampling interval of the input signal (not clear why this is
10
%   returned?!)
11
%	PSTH is the reduced matrix, the sum of all elements in the bin
12
%
13
% e.g.
14
% [PSTH dt]=UTIL_PSTHmaker(inputData, dt, PSTHbinWidth)
15

    
16
[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
42