%script to run PICS PTV analysis

%% 
pnseq='C:\Users\gracec\Documents\PICS DATA\YR160902\Sequences';  %Path containing the SEQ files
pnout='C:\Users\gracec\Documents\PICS DATA\YR160902\Analysis\'; %Path to write results
if ~exist(pnout,'file')
    mkdir(pnout);
end
files=dir(fullfile(pnseq,'*.seq'));  %List of sequence files
nf=length(files); %number of files
%nf=3;  %file to stop (good for initial testing)
nstart=6; %starting index for list of files%
%Loop for processing files
for k=nstart:nf
   fnseq=fullfile(pnseq,files(k).name); %construct the full path to the SEQ file
   fnout=fullfile(pnout,['ptv_',strrep(files(k).name,'.seq','.mat')]); %same for output file
   hdr=load_SEQ(fnseq); %get HDR information from SEQ file
   fps=hdr.FrameRate; %the framerate
   %ptv=im_ptv(fnseq,fps); %PTV contains the output struct for PTV analysis
   %ptv=im_ptv_kaf(fnseq,fps); %PTV contains the output struct for PTV analysis
   ptv=im_ptv(fnseq,fps); %PTV contains the output struct for PTV analysis-Save "R"
   save(fnout,'ptv','-v7') %save to file
end
