[447] | 1 | %%'check_files': check the existence, type and status of the files selected by series.fig |
---|
[330] | 2 | %------------------------------------------------------------------------ |
---|
[447] | 3 | % function GUI_input=check_data_files(Param) |
---|
[330] | 4 | % |
---|
[447] | 5 | %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[330] | 6 | %OUTPUT |
---|
| 7 | % GUI_input=list of options in the GUI series.fig needed for the function |
---|
| 8 | % |
---|
| 9 | %INPUT: |
---|
[447] | 10 | % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. |
---|
| 11 | % In batch mode, Param is the name of the corresponding xml file containing the same information |
---|
| 12 | % In the absence of input (as activated when the current Action is selected |
---|
| 13 | % in series), the function ouput GUI_input set the activation of the needed GUI elements |
---|
[330] | 14 | % |
---|
[447] | 15 | % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param) |
---|
| 16 | % .InputTable: cell of input file names, (several lines for multiple input) |
---|
| 17 | % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} |
---|
| 18 | % .OutputSubDir: name of the subdirectory for data outputs |
---|
| 19 | % .OutputDir: directory for data outputs, including path |
---|
| 20 | % .Action: .ActionName: name of the current activated function |
---|
| 21 | % .ActionPath: path of the current activated function |
---|
| 22 | % .IndexRange: set the file or frame indices on which the action must be performed |
---|
| 23 | % .FieldTransform: .TransformName: name of the selected transform function |
---|
| 24 | % .TransformPath: path of the selected transform function |
---|
| 25 | % .TransformHandle: corresponding function handle |
---|
| 26 | % .InputFields: sub structure describing the input fields withfields |
---|
| 27 | % .FieldName: name of the field |
---|
| 28 | % .VelType: velocity type |
---|
| 29 | % .FieldName_1: name of the second field in case of two input series |
---|
| 30 | % .VelType_1: velocity type of the second field in case of two input series |
---|
| 31 | % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) |
---|
| 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[330] | 33 | |
---|
[457] | 34 | function ParamOut=check_data_files(Param) |
---|
[447] | 35 | |
---|
| 36 | %% set the input elements needed on the GUI series when the action is selected in the menu ActionName |
---|
| 37 | if ~exist('Param','var') % case with no input parameter |
---|
[457] | 38 | ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation) |
---|
[447] | 39 | 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) |
---|
[330] | 40 | 'NbSlice';'on'; ...%nbre of slices ('off' by default) |
---|
[447] | 41 | 'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) |
---|
| 42 | 'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
| 43 | 'FieldTransform'; 'off';...%can use a transform function |
---|
| 44 | 'ProjObject';'off';...%can use projection object(option 'off'/'on', |
---|
| 45 | 'Mask';'off';...%can use mask option (option 'off'/'on', 'off' by default) |
---|
| 46 | 'OutputDirExt';'';...%set the output dir extension |
---|
[330] | 47 | ''}; |
---|
[447] | 48 | return |
---|
[330] | 49 | end |
---|
| 50 | |
---|
[447] | 51 | %% get input parameters, file names and indices |
---|
| 52 | % BATCH case: read the xml file for batch case |
---|
[457] | 53 | ParamOut=Param; %default output |
---|
[374] | 54 | if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) |
---|
| 55 | Param=xml2struct(Param); |
---|
[447] | 56 | checkrun=0; |
---|
| 57 | % RUN case: parameters introduced as the input structure Param |
---|
| 58 | else |
---|
[374] | 59 | hseries=guidata(Param.hseries);%handles of the GUI series |
---|
[447] | 60 | WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series |
---|
| 61 | checkrun=1; % indicate the RUN option is used |
---|
[374] | 62 | end |
---|
[447] | 63 | % get the set of input file names (cell array filecell), and the lists of |
---|
| 64 | % input file or frame indices i1_series,i2_series,j1_series,j2_series |
---|
[374] | 65 | [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); |
---|
[447] | 66 | % filecell{iview,fileindex}: cell array representing the list of file names |
---|
| 67 | % iview: line in the table corresponding to a given file series |
---|
| 68 | % fileindex: file index within the file series, |
---|
| 69 | % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j |
---|
| 70 | % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices |
---|
| 71 | % set of frame indices used for movie or multimage input |
---|
| 72 | if ~isempty(j1_series) |
---|
| 73 | frame_index=j1_series; |
---|
| 74 | else |
---|
| 75 | frame_index=i1_series; |
---|
| 76 | end |
---|
[330] | 77 | |
---|
[447] | 78 | %% root input file(s) and type |
---|
| 79 | RootPath=Param.InputTable(:,1); |
---|
| 80 | RootFile=Param.InputTable(:,3); |
---|
| 81 | SubDir=Param.InputTable(:,2); |
---|
| 82 | NomType=Param.InputTable(:,4); |
---|
| 83 | FileExt=Param.InputTable(:,5); |
---|
[374] | 84 | |
---|
[447] | 85 | % numbers of slices and file indices |
---|
| 86 | NbSlice=1;%default |
---|
| 87 | if isfield(Param.IndexRange,'NbSlice') |
---|
| 88 | NbSlice=Param.IndexRange.NbSlice; |
---|
| 89 | end |
---|
[455] | 90 | nbview=numel(i1_series);%number of input file series (lines in InputTable) |
---|
| 91 | nbfield_j=size(i1_series{1},1); %nb of consecutive fields at each level(burst |
---|
| 92 | nbfield=nbfield_j*size(i1_series{1},2); %total number of files or frames |
---|
[447] | 93 | nbfield_i=floor(nbfield/NbSlice);%total number of i indexes (adjusted to an integer number of slices) |
---|
| 94 | nbfield=nbfield_i*nbfield_j; %total number of fields after adjustement |
---|
[330] | 95 | |
---|
[447] | 96 | %determine the file type on each line from the first input file |
---|
| 97 | ImageTypeOptions={'image','multimage','mmreader','video'}; |
---|
| 98 | NcTypeOptions={'netcdf','civx','civdata'}; |
---|
| 99 | for iview=1:nbview |
---|
| 100 | [FileType{iview},FileInfo{iview},Object{iview}]=get_file_type(filecell{iview,1}); |
---|
| 101 | CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images |
---|
| 102 | CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files |
---|
| 103 | end |
---|
[330] | 104 | |
---|
[447] | 105 | %% MAIN LOOP ON VIEWS (INPUT LINES) |
---|
[330] | 106 | for iview=1:nbview |
---|
[455] | 107 | if isequal(FileType{iview},'mmreader')||isequal(FileType{iview},'video')||isequal(FileType{iview},'multimage') |
---|
| 108 | [tild,FileInfo]=get_file_type(filecell{iview,1}) |
---|
| 109 | % info=aviinfo(filecell{iview,1}); |
---|
| 110 | message{1}=filecell{iview,1};%info.Filename; |
---|
| 111 | message{2}=FileInfo.FileModDate; |
---|
| 112 | message{3}=[num2str(FileInfo.FramesPerSecond) ' frames/s ']; |
---|
| 113 | message{4}=FileInfo.ImageType; |
---|
| 114 | message{5}=[' compression' FileInfo.VideoCompression]; |
---|
| 115 | message{6}=[ 'quality ' num2str(FileInfo.Quality)]; |
---|
[330] | 116 | Tabchar=message; |
---|
| 117 | else |
---|
| 118 | Tabchar={}; |
---|
| 119 | %LOOP ON SLICES |
---|
| 120 | for i_slice=1:NbSlice |
---|
[447] | 121 | index_slice=i_slice:NbSlice:nbfield; |
---|
[340] | 122 | filefound={}; |
---|
[451] | 123 | datnum=zeros(1,nbfield_j); |
---|
[447] | 124 | for ifile=1:nbfield_i |
---|
[330] | 125 | stopstate=get(hseries.RUN,'BusyAction'); |
---|
| 126 | if isequal(stopstate,'queue')% enable STOP command |
---|
[447] | 127 | update_waitbar(hseries.waitbar_frame,WaitbarPos,ifile/nbfield_i) |
---|
| 128 | file=filecell{iview,index_slice(ifile)}; |
---|
[330] | 129 | [Path,Name,ext]=fileparts(file); |
---|
| 130 | detect=exist(file,'file'); % check the existence of the file |
---|
| 131 | if detect==0 |
---|
[451] | 132 | % count=count+1; |
---|
[330] | 133 | lastfield='not found'; |
---|
| 134 | else |
---|
| 135 | datfile=dir(file); |
---|
| 136 | if isfield(datfile,'datenum') |
---|
| 137 | datnum(ifile)=datfile.datenum; |
---|
[451] | 138 | filefound(ifile)={datfile.name}; |
---|
| 139 | end |
---|
[330] | 140 | lastfield=''; |
---|
[377] | 141 | [FileType,FileInfo,Object]=get_file_type(file); |
---|
| 142 | if strcmp(FileType,'civx')||strcmp(FileType,'civdata') |
---|
| 143 | if isfield(FileInfo,'CivStage') |
---|
| 144 | liststage={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 145 | lastfield=liststage{FileInfo.CivStage}; |
---|
| 146 | end |
---|
| 147 | end |
---|
| 148 | lastfield=[FileType ', ' lastfield]; |
---|
[330] | 149 | end |
---|
| 150 | Tabchar(1,i_slice)={['slice #' num2str(i_slice)]}; |
---|
[447] | 151 | Tabchar(ifile+1,i_slice)={[file '...' lastfield]}; |
---|
[330] | 152 | end |
---|
| 153 | end |
---|
| 154 | end |
---|
[340] | 155 | if isempty(filefound) |
---|
[330] | 156 | if NbSlice>1 |
---|
| 157 | message=['no set of ' num2str(NbSlice) ' (NbSlices) files found']; |
---|
| 158 | else |
---|
| 159 | message='no file found'; |
---|
| 160 | end |
---|
| 161 | else |
---|
| 162 | datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files |
---|
[451] | 163 | filefound=filefound(find(datnum)); |
---|
[330] | 164 | [first,ind]=min(datnum); |
---|
| 165 | [last,indlast]=max(datnum); |
---|
[451] | 166 | message={['oldest modification: ' filefound{ind} ' : ' datestr(first)];... |
---|
| 167 | ['latest modification: ' filefound{indlast} ' : ' datestr(last)]}; |
---|
[330] | 168 | end |
---|
| 169 | if ~isempty(Tabchar) |
---|
[447] | 170 | Tabchar=reshape(Tabchar,NbSlice*(nbfield_i+1),1); |
---|
[330] | 171 | end |
---|
| 172 | end |
---|
| 173 | hfig=figure(iview); |
---|
| 174 | clf |
---|
| 175 | if iview>1 |
---|
| 176 | pos=get(iview-1,'Position'); |
---|
| 177 | pos(1)=pos(1)+(iview-1)*pos(1)/nbview; |
---|
| 178 | set(hfig,'Position',pos) |
---|
| 179 | end |
---|
[427] | 180 | set(hfig,'name',['check_data_files:view= ' num2str(iview)]) |
---|
| 181 | set(hfig,'MenuBar','none')% suppress the menu bar |
---|
| 182 | set(hfig,'NumberTitle','off')%suppress the fig number in the title |
---|
[361] | 183 | h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'}); |
---|
[330] | 184 | hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message); |
---|
| 185 | end |
---|