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.
root / utilities / UTIL_PSTHmaker.m @ 26:b03ef38fe497
History | View | Annotate | Download (1.08 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 |
|
| 12 |
[numChannels numDataPoints]= size(inputData); |
| 13 |
|
| 14 |
% Multiple fibers is the same as repeat trials |
| 15 |
% Consolidate data into a histogram |
| 16 |
dataPointsPerBin=round(PSTHbinWidth/dt); |
| 17 |
if dataPointsPerBin<=1; |
| 18 |
% Too few data points |
| 19 |
PSTH=inputData; |
| 20 |
return |
| 21 |
end |
| 22 |
|
| 23 |
numBins=floor(numDataPoints/dataPointsPerBin); |
| 24 |
PSTH=zeros(numChannels,numBins); |
| 25 |
|
| 26 |
% take care that signal length is an integer multiple of bin size |
| 27 |
% by dropping the last unuseable values |
| 28 |
useableDataLength=numBins*dataPointsPerBin; |
| 29 |
inputData=inputData(:,1:useableDataLength); |
| 30 |
|
| 31 |
for ch=1:numChannels |
| 32 |
% Convert each channel into a matrix where each column represents |
| 33 |
% the content of a single PSTH bin |
| 34 |
PSTH2D=reshape (inputData(ch,:), dataPointsPerBin, numBins ); |
| 35 |
% and sum within each bin (across the rows |
| 36 |
PSTH(ch,:)=sum (PSTH2D,1); |
| 37 |
end |
| 38 |
|