0001 function [time,raw] = loadTiffResample(tiffFileName,speciesNum,freqIn,freqOut)
0002
0003
0004
0005
0006
0007
0008 raw = [];
0009 timeLast = 0;
0010 remainingTiffData = [];
0011 remainingData = [];
0012 remainingT = [];
0013 time = [];
0014 for fileInd = 1:numel(tiffFileName)
0015 fileName = tiffFileName(fileInd);
0016 [rawOutput, remainingTiffData] = ...
0017 mouse.preprocess.loadTiffRaw(fileName,speciesNum,remainingTiffData);
0018 rawT = linspace(timeLast, timeLast + size(rawOutput,4)./freqIn, size(rawOutput,4) + 1);
0019 rawT(1) = [];
0020
0021 rawOutput = cat(4,remainingData,rawOutput);
0022 rawT = [remainingT rawT];
0023
0024
0025
0026
0027
0028 timeLast = rawT(end);
0029
0030
0031 resampledT = (ceil(rawT(1)*freqOut)/freqOut):(1/freqOut):rawT(end);
0032 resampledRaw = mouse.freq.resampledata(rawOutput,rawT,resampledT);
0033 remainingDataStartInd = find(rawT < resampledT(end), 1, 'last');
0034 remainingData = rawOutput(:,:,:,remainingDataStartInd:size(rawOutput,4));
0035 remainingT = rawT(remainingDataStartInd:end);
0036
0037 if fileInd ~= numel(tiffFileName)
0038 resampledT(end) = [];
0039 resampledRaw(:,:,:,size(resampledRaw,4)) = [];
0040 end
0041
0042 rawDim = size(rawOutput);
0043 raw = cat(numel(rawDim),raw,resampledRaw);
0044 time = [time resampledT];
0045 end
0046 end
0047