1 | %'check_files': check the existence and status of the files selected by series.fig |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function GUI_input=check_data_files(num_i1,num_i2,num_j1,num_j2,Series) |
---|
4 | % |
---|
5 | %OUTPUT |
---|
6 | % GUI_input=list of options in the GUI series.fig needed for the function |
---|
7 | % |
---|
8 | %INPUT: |
---|
9 | %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
10 | %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
11 | %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) |
---|
12 | %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) |
---|
13 | %Series: Matlab structure containing information set by the series interface |
---|
14 | % |
---|
15 | function GUI_input=check_data_files(Param) %(filecell,filecell_1,num_i,num_j,vel_type,field,param); |
---|
16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
17 | %detect the chosen series of files and check their date of modification: |
---|
18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
19 | %INPUT: |
---|
20 | %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
21 | %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
22 | %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) |
---|
23 | %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) |
---|
24 | %OTHER INPUTS given by the structure Series |
---|
25 | |
---|
26 | %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) |
---|
27 | if ~exist('Param','var') |
---|
28 | GUI_input={'RootPath';'many';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') |
---|
29 | 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) |
---|
30 | 'RootFile';'on';... %root input file name ('on' by default) |
---|
31 | 'FileExt';'on';... %input file extension ('on' by default) |
---|
32 | 'NomType';'on';...%type of file indexing ('on' by default) |
---|
33 | 'NbSlice';'on'; ...%nbre of slices ('off' by default) |
---|
34 | %'VelTypeMenu';'on';...% menu for selecting the velocity type (civ1,..) 'off' by default) |
---|
35 | %'FieldMenu';'on';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
36 | %'CoordType';'on'...%can use a transform function 'off' by default |
---|
37 | %'GetObject';'on'...%can use projection object ,'off' by default |
---|
38 | %'GetMask';'on'...%can use mask option ,'off' by default |
---|
39 | %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter |
---|
40 | ''}; |
---|
41 | return %exit the function |
---|
42 | end |
---|
43 | |
---|
44 | %% input parameters |
---|
45 | % read the xml file for batch case |
---|
46 | if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) |
---|
47 | Param=xml2struct(Param); |
---|
48 | else % RUN case: parameters introduced as the input structure Param |
---|
49 | hseries=guidata(Param.hseries);%handles of the GUI series |
---|
50 | WaitbarPos=get(hseries.waitbar_frame,'Position'); |
---|
51 | end |
---|
52 | [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); |
---|
53 | |
---|
54 | |
---|
55 | %%%%%%%%%%%%%%%%%%%%%%%% |
---|
56 | |
---|
57 | % number of slices |
---|
58 | NbSlice=Param.NbSlice; |
---|
59 | if isempty(NbSlice),NbSlice=1; end; %default |
---|
60 | |
---|
61 | %% root input file and type |
---|
62 | RootPath=Param.InputTable(:,1); |
---|
63 | RootFile=Param.InputTable(:,3); |
---|
64 | SubDir=Param.InputTable(:,2); |
---|
65 | NomType=Param.InputTable(:,4); |
---|
66 | FileExt=Param.InputTable(:,5); |
---|
67 | % number of views |
---|
68 | count=0; |
---|
69 | nbview=numel(RootFile); |
---|
70 | |
---|
71 | for iview=1:nbview |
---|
72 | filebase=fullfile(RootPath{iview},RootFile{iview});%root file name |
---|
73 | % if testcell |
---|
74 | % num_i1=num_i1_cell{iview}; num_i2=num_i2_cell{iview}; num_j1=num_j1_cell{iview}; num_j2=num_j2_cell{iview}; |
---|
75 | % else |
---|
76 | % num_i1=num_i1_cell; num_i2=num_i2_cell; num_j1=num_j1_cell; num_j2=num_j2_cell; |
---|
77 | % end |
---|
78 | % siz=size(num_i1); |
---|
79 | nbfield=size(i1_series{iview},1); |
---|
80 | nbfield2=size(i1_series{iview},2); %nb of consecutive fields at each level(burst |
---|
81 | nbfield=numel(i1_series{iview}); |
---|
82 | nbfield=floor(nbfield/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices) |
---|
83 | if isequal(lower(FileExt{iview}),'.avi') |
---|
84 | info=aviinfo([filebase FileExt{iview}]); |
---|
85 | message{1}=info.Filename; |
---|
86 | message{2}=info.FileModDate; |
---|
87 | message{3}=[num2str(info.FramesPerSecond) ' frames/s ']; |
---|
88 | message{4}=info.ImageType; |
---|
89 | message{5}=[' compression' info.VideoCompression]; |
---|
90 | message{6}=[ 'quality ' num2str(info.Quality)]; |
---|
91 | Tabchar=message; |
---|
92 | else |
---|
93 | datnum=zeros(1,nbfield); |
---|
94 | Tabchar={}; |
---|
95 | %LOOP ON SLICES |
---|
96 | for i_slice=1:NbSlice |
---|
97 | for ifield=1:nbfield |
---|
98 | indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice |
---|
99 | end |
---|
100 | filefound={}; |
---|
101 | for index=1:nbfield*nbfield2 |
---|
102 | stopstate=get(hseries.RUN,'BusyAction'); |
---|
103 | if isequal(stopstate,'queue')% enable STOP command |
---|
104 | update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield*nbfield2)) |
---|
105 | ifile=indselect(index); |
---|
106 | % file=... |
---|
107 | % name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt{iview},NomType{iview},1,num_i2(ifile),num_j2(ifile),SubDir{iview}); |
---|
108 | file=filecell{iview,ifile}; |
---|
109 | [Path,Name,ext]=fileparts(file); |
---|
110 | detect=exist(file,'file'); % check the existence of the file |
---|
111 | if detect==0 |
---|
112 | count=count+1; |
---|
113 | lastfield='not found'; |
---|
114 | else |
---|
115 | datfile=dir(file); |
---|
116 | if isfield(datfile,'datenum') |
---|
117 | datnum(ifile)=datfile.datenum; |
---|
118 | end |
---|
119 | filefound(ifile)={datfile.name}; |
---|
120 | lastfield=''; |
---|
121 | [FileType,FileInfo,Object]=get_file_type(file); |
---|
122 | if strcmp(FileType,'civx')||strcmp(FileType,'civdata') |
---|
123 | if isfield(FileInfo,'CivStage') |
---|
124 | liststage={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
125 | lastfield=liststage{FileInfo.CivStage}; |
---|
126 | end |
---|
127 | end |
---|
128 | lastfield=[FileType ', ' lastfield]; |
---|
129 | end |
---|
130 | Tabchar(1,i_slice)={['slice #' num2str(i_slice)]}; |
---|
131 | Tabchar(index+1,i_slice)={[file '...' lastfield]}; |
---|
132 | end |
---|
133 | end |
---|
134 | end |
---|
135 | % if isempty(datnum)||isempty(filefound) |
---|
136 | if isempty(filefound) |
---|
137 | if NbSlice>1 |
---|
138 | message=['no set of ' num2str(NbSlice) ' (NbSlices) files found']; |
---|
139 | else |
---|
140 | message='no file found'; |
---|
141 | end |
---|
142 | else |
---|
143 | datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files |
---|
144 | [first,ind]=min(datnum); |
---|
145 | [last,indlast]=max(datnum); |
---|
146 | message={['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
147 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
148 | end |
---|
149 | if ~isempty(Tabchar) |
---|
150 | Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1); |
---|
151 | end |
---|
152 | end |
---|
153 | hfig=figure(iview); |
---|
154 | clf |
---|
155 | if iview>1 |
---|
156 | pos=get(iview-1,'Position'); |
---|
157 | pos(1)=pos(1)+(iview-1)*pos(1)/nbview; |
---|
158 | set(hfig,'Position',pos) |
---|
159 | end |
---|
160 | set(hfig,'name',['view= ' num2str(iview)]) |
---|
161 | |
---|
162 | h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'}); |
---|
163 | hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message); |
---|
164 | end |
---|