[573] | 1 | %%'check_data_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 | |
---|
[810] | 34 | %======================================================================= |
---|
[977] | 35 | % Copyright 2008-2017, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[810] | 36 | % http://www.legi.grenoble-inp.fr |
---|
| 37 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
| 38 | % |
---|
| 39 | % This file is part of the toolbox UVMAT. |
---|
| 40 | % |
---|
| 41 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 42 | % it under the terms of the GNU General Public License as published |
---|
| 43 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 44 | % or (at your option) any later version. |
---|
| 45 | % |
---|
| 46 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 47 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 48 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 49 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 50 | %======================================================================= |
---|
| 51 | |
---|
[457] | 52 | function ParamOut=check_data_files(Param) |
---|
[447] | 53 | |
---|
[592] | 54 | %% input preparation mode (no RUN) |
---|
| 55 | if isstruct(Param) && isequal(Param.Action.RUN,0) |
---|
[594] | 56 | ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) |
---|
| 57 | ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) |
---|
| 58 | ParamOut.NbSlice='on';%nbre of slices ('off' by default) |
---|
| 59 | ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) |
---|
| 60 | ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
| 61 | ParamOut.FieldTransform = 'off';%can use a transform function |
---|
| 62 | ParamOut.ProjObject='off';%can use projection object(option 'off'/'on', |
---|
| 63 | ParamOut.Mask='off';%can use mask option (option 'off'/'on', 'off' by default) |
---|
[826] | 64 | ParamOut.OutputSubDirMode='none'; %(options 'none'/'custom'/'auto'/'first'/'last','auto' by default) |
---|
| 65 | % 'none' =no output files |
---|
[626] | 66 | return |
---|
[330] | 67 | end |
---|
[478] | 68 | %%%%%%%%%%%% STANDARD PART %%%%%%%%%%%% |
---|
[594] | 69 | |
---|
| 70 | %% read input parameters from an xml file if input is a file name (batch mode) |
---|
| 71 | checkrun=1; |
---|
[478] | 72 | if ischar(Param) |
---|
[594] | 73 | Param=xml2struct(Param);% read Param as input file (batch case) |
---|
| 74 | checkrun=0; |
---|
[374] | 75 | end |
---|
[626] | 76 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 77 | RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series |
---|
| 78 | WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series |
---|
[594] | 79 | |
---|
[447] | 80 | %% root input file(s) and type |
---|
| 81 | RootPath=Param.InputTable(:,1); |
---|
| 82 | RootFile=Param.InputTable(:,3); |
---|
| 83 | SubDir=Param.InputTable(:,2); |
---|
| 84 | NomType=Param.InputTable(:,4); |
---|
| 85 | FileExt=Param.InputTable(:,5); |
---|
[478] | 86 | [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); |
---|
[592] | 87 | if isempty(i1_series) |
---|
| 88 | return |
---|
| 89 | end |
---|
[478] | 90 | %%%%%%%%%%%% |
---|
| 91 | % The cell array filecell is the list of input file names, while |
---|
| 92 | % filecell{iview,fileindex}: |
---|
| 93 | % iview: line in the table corresponding to a given file series |
---|
[626] | 94 | % fileindex: file index within the file series, |
---|
| 95 | % 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 |
---|
[478] | 96 | % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices |
---|
| 97 | %%%%%%%%%%%% |
---|
[447] | 98 | NbSlice=1;%default |
---|
[478] | 99 | if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) |
---|
[447] | 100 | NbSlice=Param.IndexRange.NbSlice; |
---|
| 101 | end |
---|
[455] | 102 | nbview=numel(i1_series);%number of input file series (lines in InputTable) |
---|
[478] | 103 | nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) |
---|
| 104 | nbfield_i=size(i1_series{1},2); %nb of fields for the i index |
---|
| 105 | nbfield=nbfield_j*nbfield_i; %total number of fields |
---|
[626] | 106 | nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) |
---|
[478] | 107 | nbfield=nbfield_i*NbSlice; %total number of fields after adjustement |
---|
[330] | 108 | |
---|
[626] | 109 | %determine the file type on each line from the first input file |
---|
[984] | 110 | ImageTypeOptions={'image','multimage','mmreader','video','cine_phantom'}; |
---|
[447] | 111 | NcTypeOptions={'netcdf','civx','civdata'}; |
---|
| 112 | for iview=1:nbview |
---|
[784] | 113 | [FileInfo{iview},Object{iview}]=get_file_info(filecell{iview,1}); |
---|
[783] | 114 | FileType{iview}=FileInfo{iview}.FileType; |
---|
[447] | 115 | CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images |
---|
| 116 | CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files |
---|
| 117 | end |
---|
[330] | 118 | |
---|
[447] | 119 | %% MAIN LOOP ON VIEWS (INPUT LINES) |
---|
[330] | 120 | for iview=1:nbview |
---|
[455] | 121 | if isequal(FileType{iview},'mmreader')||isequal(FileType{iview},'video')||isequal(FileType{iview},'multimage') |
---|
[784] | 122 | [FileInfo]=get_file_info(filecell{iview,1}); |
---|
[470] | 123 | Tabchar{1}=filecell{iview,1};%info.Filename; |
---|
[616] | 124 | Tabchar{2}=''; |
---|
| 125 | Tabchar{3}=[num2str(FileInfo.FrameRate) ' frames/s ']; |
---|
[635] | 126 | message=''; |
---|
[330] | 127 | else |
---|
| 128 | Tabchar={}; |
---|
| 129 | %LOOP ON SLICES |
---|
| 130 | for i_slice=1:NbSlice |
---|
[447] | 131 | index_slice=i_slice:NbSlice:nbfield; |
---|
[340] | 132 | filefound={}; |
---|
[451] | 133 | datnum=zeros(1,nbfield_j); |
---|
[447] | 134 | for ifile=1:nbfield_i |
---|
[626] | 135 | update_waitbar(WaitbarHandle,ifile/nbfield_i) |
---|
| 136 | if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') |
---|
| 137 | disp('program stopped by user') |
---|
| 138 | break |
---|
| 139 | end |
---|
| 140 | file=filecell{iview,index_slice(ifile)}; |
---|
| 141 | [Path,Name,ext]=fileparts(file); |
---|
| 142 | detect=exist(file,'file'); % check the existence of the file |
---|
| 143 | if detect==0 |
---|
| 144 | lastfield='not found'; |
---|
[594] | 145 | else |
---|
[626] | 146 | datfile=dir(file); |
---|
| 147 | if isfield(datfile,'datenum') |
---|
| 148 | datnum(ifile)=datfile.datenum; |
---|
| 149 | filefound(ifile)={datfile.name}; |
---|
| 150 | end |
---|
| 151 | lastfield=''; |
---|
[784] | 152 | [FileInfo,Object]=get_file_info(file); |
---|
[783] | 153 | FileType{iview}=FileInfo.FileType; |
---|
[626] | 154 | if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata') |
---|
| 155 | if isfield(FileInfo,'CivStage') |
---|
[912] | 156 | liststage={'civ','fix','patch'}; |
---|
| 157 | stagechoice=1+mod(FileInfo.CivStage-1,3); |
---|
| 158 | iter=1+floor((FileInfo.CivStage-1)/3); |
---|
| 159 | lastfield=[liststage{stagechoice} num2str(iter)]; |
---|
| 160 | %liststage={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 161 | %lastfield=liststage{FileInfo.CivStage}; |
---|
[594] | 162 | end |
---|
[330] | 163 | end |
---|
[626] | 164 | lastfield=[FileType{iview} ', ' lastfield]; |
---|
[330] | 165 | end |
---|
[626] | 166 | Tabchar(1,i_slice)={['slice #' num2str(i_slice)]}; |
---|
| 167 | Tabchar(ifile+1,i_slice)={[file '...' lastfield]}; |
---|
[330] | 168 | end |
---|
| 169 | end |
---|
[340] | 170 | if isempty(filefound) |
---|
[330] | 171 | if NbSlice>1 |
---|
| 172 | message=['no set of ' num2str(NbSlice) ' (NbSlices) files found']; |
---|
| 173 | else |
---|
[594] | 174 | message='no file found'; |
---|
[330] | 175 | end |
---|
| 176 | else |
---|
| 177 | datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files |
---|
[451] | 178 | filefound=filefound(find(datnum)); |
---|
[330] | 179 | [first,ind]=min(datnum); |
---|
| 180 | [last,indlast]=max(datnum); |
---|
[451] | 181 | message={['oldest modification: ' filefound{ind} ' : ' datestr(first)];... |
---|
| 182 | ['latest modification: ' filefound{indlast} ' : ' datestr(last)]}; |
---|
[594] | 183 | end |
---|
[330] | 184 | if ~isempty(Tabchar) |
---|
[594] | 185 | Tabchar=reshape(Tabchar,NbSlice*(nbfield_i+1),1); |
---|
[330] | 186 | end |
---|
| 187 | end |
---|
| 188 | hfig=figure(iview); |
---|
| 189 | clf |
---|
| 190 | if iview>1 |
---|
| 191 | pos=get(iview-1,'Position'); |
---|
| 192 | pos(1)=pos(1)+(iview-1)*pos(1)/nbview; |
---|
| 193 | set(hfig,'Position',pos) |
---|
| 194 | end |
---|
[427] | 195 | set(hfig,'name',['check_data_files:view= ' num2str(iview)]) |
---|
| 196 | set(hfig,'MenuBar','none')% suppress the menu bar |
---|
| 197 | set(hfig,'NumberTitle','off')%suppress the fig number in the title |
---|
[361] | 198 | h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'}); |
---|
[330] | 199 | hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message); |
---|
| 200 | end |
---|
[649] | 201 | |
---|
| 202 | % 'open_uvmat': open with uvmat the field selected in the list of 'series/check_data_files' |
---|
| 203 | %------------------------------------------------------------------------ |
---|
| 204 | %function open_uvmat(hObject, eventdata) |
---|
| 205 | % |
---|
| 206 | % INPUT: |
---|
| 207 | % hObject: handle of uicontrol object containing the list |
---|
| 208 | % eventdata: not used |
---|
| 209 | function open_uvmat(hObject, eventdata) |
---|
| 210 | %------------------------------------------------------------------------ |
---|
| 211 | list=get(hObject,'String'); |
---|
| 212 | index=get(hObject,'Value'); |
---|
| 213 | rootroot=get(hObject,'UserData'); |
---|
| 214 | filename=list{index}; |
---|
| 215 | ind_dot=strfind(filename,'...'); |
---|
| 216 | if ~isempty(ind_dot) |
---|
| 217 | filename=filename(1:ind_dot-1); |
---|
| 218 | end |
---|
| 219 | filename=fullfile(rootroot,filename); |
---|
| 220 | if exist(filename,'file')%visualise the vel field if it exists |
---|
| 221 | uvmat(filename) |
---|
| 222 | set(gcbo,'Value',1) |
---|
| 223 | end |
---|