[27] | 1 | function GUI_input=check_files(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series) %(filecell,filecell_1,num_i,num_j,vel_type,field,param); |
---|
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3 | %detect the chosen series of files and check their date of modification: |
---|
| 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 5 | %INPUT: |
---|
| 6 | %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
| 7 | %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
| 8 | %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) |
---|
| 9 | %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) |
---|
| 10 | %OTHER INPUTS given by the structure Series |
---|
| 11 | |
---|
| 12 | %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) |
---|
| 13 | if ~exist('num_i1_cell','var') |
---|
| 14 | GUI_input={'RootPath';'many';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') |
---|
| 15 | 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) |
---|
| 16 | 'RootFile';'on';... %root input file name ('on' by default) |
---|
| 17 | 'FileExt';'on';... %input file extension ('on' by default) |
---|
| 18 | 'NomType';'on';...%type of file indexing ('on' by default) |
---|
| 19 | 'NbSlice';'on'; ...%nbre of slices ('off' by default) |
---|
| 20 | %'VelTypeMenu';'on';...% menu for selecting the velocity type (civ1,..) 'off' by default) |
---|
| 21 | %'FieldMenu';'on';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
| 22 | %'CoordType';'on'...%can use a transform function 'off' by default |
---|
| 23 | %'GetObject';'on'...%can use projection object ,'off' by default |
---|
| 24 | %'GetMask';'on'...%can use mask option ,'off' by default |
---|
| 25 | %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter |
---|
| 26 | ''}; |
---|
| 27 | return %exit the function |
---|
| 28 | end |
---|
| 29 | |
---|
| 30 | %standard parameters for waitbar and STOP action (do not modify) |
---|
| 31 | hseries=guidata(Series.hseries);%handles of the GUI series |
---|
| 32 | WaitbarPos=get(hseries.waitbar_frame,'Position'); |
---|
| 33 | |
---|
| 34 | %%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 35 | |
---|
| 36 | % number of slices |
---|
| 37 | NbSlice=str2num(get(hseries.NbSlice,'String')); |
---|
| 38 | if isempty(NbSlice) |
---|
| 39 | NbSlice=1; |
---|
| 40 | end |
---|
| 41 | NbSlice_name=num2str(NbSlice); |
---|
| 42 | if isequal(NbSlice,[]),NbSlice=1; end; %default |
---|
| 43 | |
---|
| 44 | % number of views |
---|
| 45 | count=0; |
---|
| 46 | testcell=iscell(Series.RootFile); |
---|
| 47 | if ~testcell |
---|
| 48 | Series.RootPath={Series.RootPath}; |
---|
| 49 | Series.RootFile={Series.RootFile}; |
---|
| 50 | Series.SubDir={Series.SubDir}; |
---|
| 51 | Series.FileExt={Series.FileExt}; |
---|
| 52 | Series.NomType={Series.NomType}; |
---|
| 53 | end |
---|
| 54 | nbview=length(Series.RootFile); |
---|
| 55 | for iview=1:nbview |
---|
| 56 | filebase=fullfile(Series.RootPath{iview},Series.RootFile{iview});%root file name |
---|
| 57 | if testcell |
---|
| 58 | num_i1=num_i1_cell{iview}; num_i2=num_i2_cell{iview}; num_j1=num_j1_cell{iview}; num_j2=num_j2_cell{iview}; |
---|
| 59 | else |
---|
| 60 | num_i1=num_i1_cell; num_i2=num_i2_cell; num_j1=num_j1_cell; num_j2=num_j2_cell; |
---|
| 61 | end |
---|
| 62 | siz=size(num_i1); |
---|
| 63 | nbfield2=siz(1); %nb of consecutive fields at each level(burst |
---|
| 64 | nbfield=siz(1)*siz(2); |
---|
| 65 | nbfield=floor(nbfield/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices) |
---|
| 66 | if isequal(lower(Series.FileExt{iview}),'.avi') |
---|
| 67 | info=aviinfo([filebase Series.FileExt{iview}]); |
---|
| 68 | message{1}=info.Filename; |
---|
| 69 | message{2}=info.FileModDate; |
---|
| 70 | message{3}=[num2str(info.FramesPerSecond) ' frames/s ']; |
---|
| 71 | message{4}=info.ImageType; |
---|
| 72 | message{5}=[' compression' info.VideoCompression]; |
---|
| 73 | message{6}=[ 'quality ' num2str(info.Quality)]; |
---|
| 74 | Tabchar=message; |
---|
| 75 | else |
---|
| 76 | datnum=[]; |
---|
| 77 | Tabchar={}; |
---|
| 78 | %LOOP ON SLICES |
---|
| 79 | for i_slice=1:NbSlice |
---|
| 80 | for ifield=1:nbfield |
---|
| 81 | indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice |
---|
| 82 | end |
---|
| 83 | for index=1:nbfield*nbfield2 |
---|
| 84 | stopstate=get(hseries.RUN,'BusyAction'); |
---|
| 85 | if isequal(stopstate,'queue')% enable STOP command |
---|
| 86 | update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2)) |
---|
| 87 | ifile=indselect(index); |
---|
| 88 | file=... |
---|
| 89 | name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2(ifile),num_j2(ifile),Series.SubDir{iview}); |
---|
| 90 | [Path,Name,ext]=fileparts(file); |
---|
| 91 | detect=exist(file,'file'); % check the existence of the file |
---|
| 92 | if detect==0 |
---|
| 93 | count=count+1; |
---|
| 94 | lastfield='not found'; |
---|
| 95 | else |
---|
| 96 | datfile=dir(file); |
---|
| 97 | datnum(ifile)=datenum(datfile.date); |
---|
| 98 | filefound(ifile)={datfile.name}; |
---|
| 99 | lastfield=''; |
---|
| 100 | if isequal(Series.FileExt{iview},'.nc') || isequal(Series.FileExt{iview},'.cdf') |
---|
| 101 | % check the content netcdf file |
---|
| 102 | Data=nc2struct(file,'ListGlobalAttribute','patch2','fix2','civ2','patch','fix','absolut_time_T0','hart'); |
---|
| 103 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
| 104 | lastfield='patch2'; |
---|
| 105 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
| 106 | lastfield='fix2'; |
---|
| 107 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
| 108 | lastfield='civ2'; |
---|
| 109 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
| 110 | lastfield='patch1'; |
---|
| 111 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
| 112 | lastfield='fix1'; |
---|
| 113 | elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart) |
---|
| 114 | lastfield='civ1'; |
---|
| 115 | end |
---|
| 116 | end |
---|
| 117 | end |
---|
| 118 | Tabchar(1,i_slice)={['slice #' num2str(i_slice)]}; |
---|
| 119 | Tabchar(index+1,i_slice)={[file ' ' lastfield]}; |
---|
| 120 | end |
---|
| 121 | end |
---|
| 122 | end |
---|
| 123 | if isempty(datnum) |
---|
| 124 | if NbSlice>1 |
---|
| 125 | message=['no set of ' num2str(NbSlice) ' (NbSlices) files found']; |
---|
| 126 | else |
---|
| 127 | message='no file found'; |
---|
| 128 | end |
---|
| 129 | else |
---|
| 130 | datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files |
---|
| 131 | [first,ind]=min(datnum); |
---|
| 132 | [last,indlast]=max(datnum); |
---|
| 133 | message={['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 134 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
| 135 | end |
---|
| 136 | if ~isempty(Tabchar) |
---|
| 137 | Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1); |
---|
| 138 | end |
---|
| 139 | end |
---|
| 140 | hfig=figure(iview); |
---|
| 141 | clf |
---|
| 142 | if iview>1 |
---|
| 143 | pos=get(iview-1,'Position'); |
---|
| 144 | pos(1)=pos(1)+(iview-1)*pos(1)/nbview; |
---|
| 145 | set(hfig,'Position',pos) |
---|
| 146 | end |
---|
| 147 | set(hfig,'name',['view= ' num2str(iview)]) |
---|
| 148 | |
---|
| 149 | h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', @ncbrowser_uvmat); |
---|
| 150 | hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message); |
---|
| 151 | end |
---|
| 152 | %---------------------------------------------------- |
---|
| 153 | % determine the list of index pairs of processing file |
---|
| 154 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 155 | function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode) |
---|
| 156 | num_i1=num_i;% set of first image numbers by default |
---|
| 157 | num_i2=num_i; |
---|
| 158 | num_j1=num_j; |
---|
| 159 | num_j2=num_j; |
---|
| 160 | num_i_out=num_i; |
---|
| 161 | num_j_out=num_j; |
---|
| 162 | if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2') |
---|
| 163 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
| 164 | num_i2_line=num_i+ind_shift(4); |
---|
| 165 | % adjust the first and last field number |
---|
| 166 | indsel=find(num_i1_line >= 1); |
---|
| 167 | num_i_out=num_i(indsel); |
---|
| 168 | num_i1_line=num_i1_line(indsel); |
---|
| 169 | num_i2_line=num_i2_line(indsel); |
---|
| 170 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 171 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 172 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
| 173 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
| 174 | elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab') |
---|
| 175 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
| 176 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
| 177 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
| 178 | else |
---|
| 179 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
| 180 | num_j2_col=num_j+ind_shift(2); |
---|
| 181 | % adjust the first field number |
---|
| 182 | indsel=find((num_j1_col >= 1)); |
---|
| 183 | num_j_out=num_j(indsel); |
---|
| 184 | num_j1_col=num_j1_col(indsel); |
---|
| 185 | num_j2_col=num_j2_col(indsel); |
---|
| 186 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
| 187 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
| 188 | end |
---|
| 189 | end |
---|