forked from ibglab/SARGE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildRawSeg.m
More file actions
31 lines (26 loc) · 833 Bytes
/
BuildRawSeg.m
File metadata and controls
31 lines (26 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [stimTime,rawSeg] = BuildRawSeg(rawData, stimTime,maxSegLeng)
nStim = length(stimTime);
dTime = diff(stimTime);
if ~isempty(maxSegLeng)%18.3.14 michal
mTime = min(median(dTime),maxSegLeng);
else
mTime = median(dTime);
end
rawSeg = cell(nStim,1);
for i=1:nStim-1
if (dTime(i)<mTime)
rawSeg{i}(1:dTime(i))=rawData(stimTime(i):stimTime(i)+dTime(i)-1);
rawSeg{i}(dTime(i)+1:mTime) = rawData(stimTime(i)+dTime(i)-1);
else
rawSeg{i}=rawData(stimTime(i):stimTime(i)+mTime-1);
end
rawSeg{i}(end) = 0;
end
% Last stim - set to be the same length as the previous segment
if (stimTime(nStim)+mTime-1>length(rawData))
nStim = nStim - 1;
stimTime = stimTime(1:nStim);
rawSeg = rawSeg (1:nStim);
else
rawSeg{nStim}=rawData(stimTime(nStim):stimTime(nStim)+mTime-1);
end