% Code to construct a list of 9999 or less filenames and get the capture time for each image file
% Programmed by Rob
% Last revision: 4/2/2007
clear all;
clc;
% Prompt user for images to be used for analysis
prompt = {'Enter the number of the first image (i.e. "3" for PIC10003):','Enter the number of the last image (i.e. "100" for PIC10100):'};
dlg_title = 'Input image range';
num_lines = 1;
def = {'1','100'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
F2 = str2num(cell2mat(answer(1,1)));
F = str2num(cell2mat(answer(2,1)));
if F >= 10000;
error0 = menu('!!! ERROR - Code will only work properly for 9999 or less image files !!!','Restart');
if error0 == 1;
RJT_master;
end;
end;
% Define prefix string
G = 'PIC1';
% Assembly of prefix string
g = waitbar(0,'Creating filenames; a pause of up to 1 minute may occur');
for H = 1:F;
waitbar(H/(F+1000));
FilePrefixList(H,:) = G;
end;
% Suffix string generation
if F >= 1000;
for I4 = 1000:F;
T4((I4-999),:) = [num2str(I4),'.TIF'];
end;
end;
if F > 999;
for I3 = 100:999;
T3((I3-99),:) = ['0',num2str(I3),'.TIF'];
end;
elseif 100 <= F <= 999;
for I3 = 100:F;
T3((I3-99),:) = ['0',num2str(I3),'.TIF'];
end;
end;
if F > 99;
for I2 = 10:99;
T2((I2-9),:) = ['00',num2str(I2),'.TIF'];
end;
elseif 10 <= F <= 99;
for I2 = 10:F;
T2((I2-9),:) = ['00',num2str(I2),'.TIF'];
end;
end;
if F > 9;
for I1 = 1:9;
T1(I1,:) = ['000',num2str(I1),'.TIF'];
end;
elseif F <= 9;
for I1 = 1:F;
T1(I1,:) = ['000',num2str(I1),'.TIF'];
end;
end;
% Assembly of suffix string
if F > 999;
FileNumberList = strvcat(T1,T2,T3,T4);
elseif F > 99;
FileNumberList = strvcat(T1,T2,T3);
elseif F > 9;
FileNumberList = strvcat(T1,T2);
else;
FileNumberList = T1;
end;
FileNameList = strcat(FilePrefixList,FileNumberList);
close(g);
% Creation of final results; then save the completed list
h = waitbar(0,'Assembling a list of all filenames');
for i = F2:F;
waitbar(i/F);
filenamelist((i-F2+1),:) = FileNameList(i,:);
end
close(h);
save filenamelist.mat filenamelist;
% Ask user if imaging was started after temperature DAQ
prompt = {'If imaging was started after temperature DAQ, enter the offset time value in [seconds] below. If not, use 0:'};
dlg_title = 'Input data offset time';
num_lines = 1;
def = {'0'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
OT = str2num(cell2mat(answer(1,1)));
% Loop through all images in filenamelist to get all image capture times
[ri,ci] = size(filenamelist);
o = waitbar(0,'Extracting image capture times');
for q = 1:ri;
waitbar(q/ri);
info = imfinfo(filenamelist(q,:));
time = datevec(info.FileModDate,13);
seconds(q) = time(1,4)*3600+time(1,5)*60+time(1,6);
end;
rel_sec = seconds-seconds(1)+OT;
close(o);
% Configure and then save image number vs. image capture time text file
im_num_im_cap_time = [(1:ri)' rel_sec'];
save time_image.txt im_num_im_cap_time -ascii -tabs;