Home > BauerLab > MATLAB > lib > +mouse > +preprocess > loadTiffResample.m

loadTiffResample

PURPOSE ^

loadTiffResample Loads multiple tiff files and resample it to lower

SYNOPSIS ^

function [time,raw] = loadTiffResample(tiffFileName,speciesNum,freqIn,freqOut)

DESCRIPTION ^

loadTiffResample Loads multiple tiff files and resample it to lower
frequency. There are no extraneous parts like getting rid of bad frames or
such.
   Detailed explanation goes here

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [time,raw] = loadTiffResample(tiffFileName,speciesNum,freqIn,freqOut)
0002 %loadTiffResample Loads multiple tiff files and resample it to lower
0003 %frequency. There are no extraneous parts like getting rid of bad frames or
0004 %such.
0005 %   Detailed explanation goes here
0006 
0007 
0008 raw = [];
0009 timeLast = 0; % last time point
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 %     if fileInd == 1 % get rid of first frame if first file
0025 %         rawOutput(:,:,:,1) = [];
0026 %         rawT(1) = [];
0027 %     end
0028     timeLast = rawT(end);
0029     
0030     % resampling
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'); % index of rawT that is before last resampledT
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

Generated on Fri 28-Dec-2018 21:42:50 by m2html © 2005