Changeset 599
- Timestamp:
- Apr 3, 2013, 10:21:53 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r596 r599 433 433 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 434 434 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 435 [RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType, MovieObject]=find_file_series(FilePath,[FileName ImaExt]);435 [RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,FileInfo,MovieObject]=find_file_series(FilePath,[FileName ImaExt]); 436 436 switch FileType 437 437 case {'image','multimage','video','mmreader'} … … 2562 2562 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 2563 2563 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 2564 [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType, Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]);2564 [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,FileInfo,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]); 2565 2565 2566 2566 %check image nom type -
trunk/src/find_file_series.m
r562 r599 37 37 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 38 38 39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType, MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput) 40 40 %------------------------------------------------------------------------ 41 41 … … 230 230 %% update the file type if the input file does not exist (pb of 0001) 231 231 if isempty(FileType) 232 [FileType, tild,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name));232 [FileType,FileInfo,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name)); 233 233 end 234 234 end -
trunk/src/get_file_series.m
r591 r599 57 57 FilePath=fullfile(InputTable{iview,1},InputTable{iview,2}); 58 58 fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]; 59 [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType, MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput);59 [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput); 60 60 i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %first pair index 61 61 check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i; -
trunk/src/msgbox_uvmat.m
r581 r599 196 196 function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles) 197 197 %------------------------------------------------------------------------ 198 198 varargout{1}='Cancel';%deg 199 199 % Get default command line output from handles structure 200 200 if isfield(handles,'output') … … 214 214 end 215 215 % The figure can be deleted now 216 end 217 delete(handles.figure1); 216 delete(handles.figure1); 217 end 218 % delete(handles.figure1); 218 219 219 220 %------------------------------------------------------------------------ -
trunk/src/series.m
r598 r599 282 282 oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); 283 283 end 284 [FileName, PathName , filterindex] = uigetfile( ...284 [FileName, PathName] = uigetfile( ... 285 285 {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; 286 286 '*.xml', '.xml files '; ... … … 304 304 set_object(Param.ProjObject) 305 305 end 306 set(handles.REFRESH,'UserData', [1:size(Param.InputTable,1)])306 set(handles.REFRESH,'UserData',1:size(Param.InputTable,1)) 307 307 REFRESH_Callback([],[], handles) 308 308 return … … 456 456 RootPath=fileparts(RootPath); %will try the upped forldr 457 457 else 458 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType, MovieObject]=...458 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=... 459 459 find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); 460 460 end … … 475 475 display_file_name(handles,fileinput,iview) 476 476 else 477 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType, MovieObject,iview)477 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,iview) 478 478 end 479 479 end … … 514 514 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 515 515 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 516 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType, MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);516 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); 517 517 if isempty(RootFile)&&isempty(i1_series) 518 518 errormsg='no input file in the series'; … … 581 581 582 582 %% initiate input file series and refresh the current field view: 583 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType, MovieObject,iview);583 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,iview); 584 584 585 585 %------------------------------------------------------------------------ 586 586 % --- Update information about a new field series (indices to scan, timing, 587 587 % calibration from an xml file 588 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType, VideoObject,iview)588 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,VideoObject,iview) 589 589 %------------------------------------------------------------------------ 590 590 %% update the output dir … … 708 708 NbSlice_calib={}; 709 709 XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5}); 710 TimeUnit=''; 710 711 if ~isempty(XmlFileName) 711 712 [XmlData,warntext]=imadoc2struct(XmlFileName); … … 769 770 %% number of slices 770 771 NbSlice=1;%default 771 if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') 772 heck_calib=0; 773 if isfield(XmlData,'GeometryCalib') 774 check_calib=1; 775 if isfield(XmlData.GeometryCalib,'SliceCoord') 772 776 siz=size(XmlData.GeometryCalib.SliceCoord); 773 777 if siz(1)>1 774 778 NbSlice=siz(1); 779 end 775 780 end 776 781 end … … 793 798 SeriesData.j2_series{iview}=j2_series; 794 799 SeriesData.FileType{iview}=FileType; 800 SeriesData.FileInfo{iview}=FileInfo; 795 801 SeriesData.Time{iview}=time; 802 if ~isempty(TimeUnit) 803 SeriesData.TimeUnit=TimeUnit; 804 end 805 if check_calib 806 SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib; 807 end 796 808 set(handles.series,'UserData',SeriesData) 797 809 … … 1313 1325 [Series,OutputDir,errormsg]=prepare_jobs(handles);% get parameters form the GUI series 1314 1326 if ~isempty(errormsg) 1327 if ~strcmp(errormsg,'Cancel') 1315 1328 msgbox_uvmat('ERROR',errormsg) 1329 end 1330 STOP_Callback([],[], handles) 1316 1331 return 1317 1332 end … … 1681 1696 while detect 1682 1697 answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); 1683 if isequal(answer,'Yes') 1698 if strcmp(answer,'Cancel') 1699 errormsg='Cancel'; 1700 return 1701 elseif strcmp(answer,'Yes') 1684 1702 detect=0; 1685 1703 check_create=0; … … 1849 1867 [Series,tild,errormsg]=prepare_jobs(handles);% read the parameters from the GUI series 1850 1868 if ~isempty(errormsg) 1869 if ~strcmp(errormsg,'Cancel') 1851 1870 msgbox_uvmat('ERROR',errormsg) 1871 end 1852 1872 return 1853 1873 end … … 2386 2406 Param=read_GUI(handles.series); 2387 2407 RootPath=Param.InputTable{1,1}; 2408 if ~isfield(Param,'OutputSubDir') 2409 msgbox_uvmat('ERROR','no directory defined for output files') 2410 return 2411 end 2388 2412 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files 2389 2413 OutputDir=fullfile(RootPath,OutputSubDir); -
trunk/src/series/civ_input.m
r598 r599 57 57 guidata(hObject, handles); % Update handles structure 58 58 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 59 60 %% set visibility options 59 SeriesData.ParentHandle=gcbf; 60 SeriesData=get(gcbf,'UserData'); 61 % relevant data in gcbf:.FileType,.FileInfo,.Time,.TimeUnit,.GeometryCalib{1}; 62 63 %% set visibility options: case civ_matlab 64 if strcmp(Param.Action.ActionName,'civ_series') 61 65 set(handles.num_MaxDiff,'Visible','on') 62 66 set(handles.num_MaxVel,'Visible','on') … … 73 77 set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) 74 78 set(handles.CheckDecimal,'Value',0)% desactivate (work in progress) 79 end 80 81 %% input file info 82 RootPath=Param.InputTable{1,1}; 83 RootFile=Param.InputTable{1,3}; 84 SubDir=Param.InputTable{1,2}; 85 NomTypeInput=Param.InputTable{1,4}; 86 FileExt=Param.InputTable{1,5}; 87 FileType=SeriesData.FileType{1}; 88 FileInfo=SeriesData.FileInfo{1}; 89 90 %% case of netcdf file as input, get the processing stage and look for corresponding images 91 % imageinput=fileinput;%default 92 % TODO: insert image input in the GUI series 93 ind_opening=0;%default 94 NomTypeNc=''; 95 switch FileType 96 case 'civdata' 97 NomTypeNc=NomTypeInput; 98 ind_opening=FileInfo.CivStage; 99 if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) 100 set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs 101 set(handles.RootFile_1,'Visible','On'); 102 else 103 set(handles.ListCompareMode,'Value',1) 104 set(handles.RootFile_1,'Visible','Off'); 105 end 106 imageinput=''; 107 set(handles.Program,'Value',1) %select civ/Matlab by default 108 % if ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file 109 % imageinput=Data.Civ2_ImageB; 110 % [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA); 111 % set(handles.RootFile_1,'String',[ImaName ImaExt]) 112 % elseif ~isempty(Data.Civ1_ImageB) 113 % imageinput=Data.Civ1_ImageB; 114 % [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA); 115 % set(handles.RootFile_1,'String',[ImaName ImaExt]) 116 % end 117 % settings for civx data, 118 % look for the corresponding input images 119 check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter 120 NomTypeIma=NomTypeInput; 121 if check_letter 122 NomTypeIma=NomTypeInput(1:end-1); 123 else 124 r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names'); 125 if ~isempty(r) 126 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 127 end 128 r=regexp(NomTypeIma,'.-(?<num2>\d+)','names'); 129 if ~isempty(r) 130 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 131 end 132 end 133 if ~exist(imageinput,'file') 134 imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1); 135 end 136 case 'civxdata'% case of civx data, 137 NomTypeNc=NomTypeInput; 138 ind_opening=FileInfo.CivStage; 139 set(handles.Program,'Value',3) %select Cix by default 140 msgbox_uvmat('ERROR','old civX convention, use the GUI civ') 141 return 142 case {'image','multimage','video','mmreader'} 143 NomTypeIma=NomTypeInput; 144 end 145 146 %% TODO: get corresponding image in nc case 147 148 %% reinitialise menus 149 set(handles.ListPairMode,'Value',1) 150 set(handles.ListPairMode,'String',{''}) 151 set(handles.ListPairCiv1,'Value',1) 152 set(handles.ListPairCiv1,'String',{''}) 153 set(handles.ListPairCiv2,'Value',1) 154 set(handles.ListPairCiv2,'String',{''}) 155 fill_GUI(Param,hObject);%fill the GUI with the parameters retrieved from the input Param 156 75 157 76 158 %% prepare the GUI with input parameters 77 % from the GUI series 78 79 %from the input file 80 filecell=get_file_series(Param); 81 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 82 errormsg=display_file_name(handles,filecell{1}); 83 if ~isempty(errormsg) 84 msgbox_uvmat('ERROR',errormsg) 85 end 86 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 87 if isfield(Param,'ActionInput')&&isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'civ_series') 88 fill_GUI(Param.ActionInput,handles.civ_input) 89 end 159 set(handles.ListCompareMode,'Visible','on') 160 161 %display the parameters stored on the GUI series 162 set(handles.first_i,'String',num2str(Param.IndexRange.first_i)) 163 set(handles.incr_i,'String',num2str(Param.IndexRange.incr_i)) 164 set(handles.last_i,'String',num2str(Param.IndexRange.last_i)) 165 set(handles.ref_i,'String',num2str(Param.IndexRange.first_i)) 166 if isfield(Param.IndexRange,'first_j') 167 set(handles.first_j,'String',num2str(Param.IndexRange.first_j)) 168 set(handles.incr_j,'String',num2str(Param.IndexRange.incr_j)) 169 set(handles.last_j,'String',num2str(Param.IndexRange.last_j)) 170 set(handles.ref_i,'String',num2str(Param.IndexRange.first_j)) 171 end 172 173 %% set the civ_input options depending on the input file content when a nc file has been opened 174 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; 175 checkbox=zeros(size(ListOptions));%default 176 if ind_opening==0%case of image opening, start with Civ1 177 for index=1:numel(ListOptions) 178 checkbox(index)=get(handles.(ListOptions{index}),'Value'); 179 end 180 index_max=find(checkbox, 1, 'last' ); 181 if isempty(index_max),index_max=1;end 182 for index=1:index_max 183 set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 184 end 185 else 186 for index = 1:min(ind_opening,5) 187 set(handles.(ListOptions{index}),'value',0) 188 end 189 set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) 190 for index = ind_opening+2:6 191 set(handles.(ListOptions{index}),'value',0) 192 end 193 end 194 %list_operation={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2'}; 195 196 %set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) 197 update_CivOptions(handles,ind_opening) 198 199 %% set the menus of image pairs and default selection for civ_input %%%%%%%%%%%%%%%%%%% 200 %check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter 201 %if isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1) 202 MaxIndex_i=Param.IndexRange.MaxIndex{1}; 203 MaxIndex_j=Param.IndexRange.MaxIndex{1,2}; 204 MinIndex_i=Param.IndexRange.MinIndex{1}; 205 MinIndex_j=Param.IndexRange.MinIndex{1,2}; 206 if ~isfield(Param.IndexRange,'first_j') 207 set(handles.ListPairMode,'Value',1) 208 set(handles.ListPairMode,'String',{'series(Di)'}) 209 elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j 210 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) 211 if MaxIndex_j <= 10 212 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 213 end 214 elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 215 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice 216 if strcmp(NomTypeNc,'_1-2_1') 217 set(handles.ListPairMode,'Value',3)% advise 'series(Di)' 218 elseif MaxIndex_j <= 10 219 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 220 end 221 end 222 223 %% transfer the time from the GUI series, or use file index by default 224 time=[]; 225 TimeUnit='frame'; %default 226 CoordUnit='';%default 227 pxcm_search=1; 228 if isfield(SeriesData,'Time') && ~isempty(SeriesData.Time{1}) 229 time=SeriesData.Time{1}; 230 %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml 231 if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector 232 if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) 233 time=time'; 234 MaxIndex_i=MaxIndex_j; 235 MaxIndex_j=1; 236 end 237 end 238 end 239 if isfield(SeriesData,'TimeUnit') 240 TimeUnit=SeriesData.TimeUnit; 241 end 242 if isfield(SeriesData,'GeometryCalib') 243 tsai=SeriesData.GeometryCalib; 244 if isfield(tsai,'fx_fy') 245 pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range 246 end 247 if isfield(tsai,'CoordUnit') 248 CoordUnit=tsai.CoordUnit; 249 end 250 end 251 % timing set by video input 252 if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 253 set(handles.ListPairMode,'Value',1); 254 dt=1/get(MovieObject,'FrameRate');%time interval between successive frames 255 if strcmp(NomTypeIma,'*') 256 set(handles.ListPairMode,'String',{'series(Di)'}) 257 time=(dt*(0:MaxIndex_i-1))';%list of image times 258 else 259 set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}]) 260 time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times 261 enable_j(handles,'on') 262 end 263 TimeUnit='s'; 264 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter 265 end 266 267 %% timing display 268 %show the reference image edit box if relevant (not needed for movies or in the absence of time information 269 if numel(time)>=2 % if there are at least two time values to define dt 270 if size(time,1)<MaxIndex_i; 271 msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file'); 272 elseif size(time,2)<MaxIndex_j 273 msgbox_uvmat('WARNING','maximum j index restricted by the timing of the xml file'); 274 end 275 MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data 276 MaxIndex_j=min(size(time,2),MaxIndex_j); 277 else 278 set(handles.ImaDoc,'String',''); %xml file not used for timing 279 % time=(i1_series(:,1)+0:size(i1_series,3)-1);% time=index i 280 % time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices 281 TimeUnit='frame'; 282 time=ones(MaxIndex_j-MinIndex_j+1,1)*(MinIndex_i:MaxIndex_i); 283 time=time+0.001*(MinIndex_j:MaxIndex_j)'*ones(1,MaxIndex_i-MinIndex_i+1); 284 end 285 time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) 286 time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros 287 CivInputData.Time=time; 288 set(handles.civ_input,'UserData',CivInputData) 289 %set(handles.ImaDoc,'UserData',time); %store the matrix of times 290 set(handles.NomType,'String',NomTypeIma) 291 set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) 292 set(handles.TimeUnit,'String',TimeUnit); 293 set(handles.nb_field,'String',num2str(MaxIndex_i)); 294 set(handles.nb_field2,'String',num2str(MaxIndex_j)); 295 set(handles.CoordUnit,'String',CoordUnit) 296 set(handles.SearchRange,'UserData', pxcm_search); 297 298 % set(handles.ImaExt,'String',ImaExt) 299 % set(handles.NomType,'String',NomTypeIma) 300 301 %% set the reference indices from the input file indices 302 num_ref_i=str2num(get(handles.ref_i,'String')); 303 num_ref_j=str2num(get(handles.ref_j,'String')); 304 305 306 %% list the possible index pairs, depending on the option set in ListPairMode 307 ListPairMode_Callback([], [], handles) 308 309 % for movies don't modify except if the current ref is outside index bounds 310 %if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j) 311 % if ~isempty(i1)% if i1 has been selected by the input 312 % num_ref_i=i1;%default ref index 313 % if ~isempty(i2) 314 % num_ref_i=floor((num_ref_i+i2)/2); 315 % end 316 % if ~isempty(j1) 317 % num_ref_j=j1; 318 % if ~isempty(j2) 319 % num_ref_j=floor((num_ref_j+j2)/2); 320 % end 321 % end 322 % end 323 % if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i 324 % num_ref_i=round((MinIndex_i+MaxIndex_i)/2); 325 % end 326 % if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j) 327 % if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j) 328 % num_ref_j=round((MinIndex_j+MaxIndex_j)/2); 329 % end 330 % end 331 % if isempty(num_ref_j) 332 % num_ref_j=1; 333 % end 334 % 335 %% set the GUI to modal: wait for OK to close 90 336 set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal 91 337 drawnow 92 338 uiwait(handles.civ_input); 339 340 93 341 94 342 %Program_Callback([],[], handles) … … 111 359 delete(handles.civ_input); 112 360 end 113 %------------------------------------------------------------------------ 114 % --- Function activated by the Open/Browse... option in the upper menu bar. 115 function MenuBrowse_Callback(hObject, eventdata, handles) 116 %------------------------------------------------------------------------ 117 %% get the current input root file name to initiate the browser 118 filebase=get(handles.RootPath,'String'); 119 oldfile=''; %default 120 if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name 121 dir_perso=prefdir; 122 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 123 if exist(profil_perso,'file') 124 h=load (profil_perso); 125 if isfield(h,'filebase')&& ischar(h.filebase) 126 oldfile=h.filebase; 127 end 128 if isfield(h,'RootPath') && ischar(h.RootPath) 129 oldfile=h.RootPath; 130 end 131 end 132 else 133 oldfile=filebase; 134 end 135 136 %% get the new input file with the browser 137 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 138 '*.xml', '.xml files '; ... 139 '*.civ', '.civ files '; ... 140 '*.png','.png image files'; ... 141 '*.jpg',' jpeg image files'; ... 142 '*.tif','.tif image files'; ... 143 '*.avi;*.AVI','.avi movie files'; ... 144 '*.nc','.netcdf files'; ... 145 '*.*', 'All Files (*.*)'}; 146 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); 147 fileinput=[PathName FileName];%complete file name 148 sizf=size(fileinput); 149 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string 150 151 %% case of the xml file opened as input (TODO: check and see whether it is useful) 152 [path,name,ext]=fileparts(fileinput); 153 testeditxml=0; 154 % if isequal(ext,'.xml') 155 % testeditxml=1; 156 % t_browse=xmltree(fileinput); 157 % head_element=get(t_browse,1); 158 % if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') 159 % testeditxml=0; 160 % end 161 % end 162 % if testeditxml==1 || isequal(ext,'.xls') 163 % heditxml=editxml({fileinput}); 164 % set(heditxml,'Tag','browser') 165 % waitfor(heditxml,'Tag','idle') 166 % if ~ishandle(heditxml) 167 % return 168 % end 169 % attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); 170 % set(handles.browse,'UserData',fileinput)% store for future opening with browser 171 % fileinput=get(attr,'UserData'); 172 % if ~exist(fileinput,'file') 173 % return 174 % end 175 % end 176 [tild,tild,tild,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); 177 178 %% prepare the GUI with parameters from the input file 179 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 180 errormsg=display_file_name(handles,fileinput); 181 if ~isempty(errormsg) 182 msgbox_uvmat('ERROR',erromsg) 183 end 184 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 185 186 %------------------------------------------------------------------------ 187 % --- Open again the file whose name has been recorded in MenuFile_1 188 function MenuFile_1_Callback(hObject, eventdata, handles) 189 %------------------------------------------------------------------------ 190 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 191 fileinput=get(handles.MenuFile_1,'Label'); 192 errormsg=display_file_name(handles,fileinput); 193 if ~isempty(errormsg) 194 msgbox_uvmat('ERROR',errormsg) 195 end 196 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 197 198 % ----------------------------------------------------------------------- 199 % --- Open again the file whose name has been recorded in MenuFile_2 200 function MenuFile_2_Callback(hObject, eventdata, handles) 201 %------------------------------------------------------------------------ 202 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 203 fileinput=get(handles.MenuFile_2,'Label'); 204 errormsg=display_file_name(handles,fileinput); 205 if ~isempty(errormsg) 206 msgbox_uvmat('ERROR',errormsg) 207 end 208 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 209 210 % ----------------------------------------------------------------------- 211 % --- Open again the file whose name has been recorded in MenuFile_3 212 function MenuFile_3_Callback(hObject, eventdata, handles) 213 %------------------------------------------------------------------------ 214 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 215 fileinput=get(handles.MenuFile_3,'Label'); 216 errormsg=display_file_name(handles,fileinput); 217 if ~isempty(errormsg) 218 msgbox_uvmat('ERROR',errormsg) 219 end 220 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 221 222 % ----------------------------------------------------------------------- 223 % --- Open again the file whose name has been recorded in MenuFile_4 224 function MenuFile_4_Callback(hObject, eventdata, handles) 225 %------------------------------------------------------------------------ 226 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 227 fileinput=get(handles.MenuFile_4,'Label'); 228 errormsg=display_file_name(handles,fileinput); 229 if ~isempty(errormsg) 230 msgbox_uvmat('ERROR',errormsg) 231 end 232 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 233 234 % ----------------------------------------------------------------------- 235 % --- Open again the file whose name has been recorded in MenuFile_5 236 function MenuFile_5_Callback(hObject, eventdata, handles) 237 %------------------------------------------------------------------------ 238 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 239 fileinput=get(handles.MenuFile_5,'Label'); 240 errormsg=display_file_name(handles,fileinput); 241 if ~isempty(errormsg) 242 msgbox_uvmat('ERROR',errormsg) 243 end 244 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 361 362 245 363 246 364 % ----------------------------------------------------------------------- … … 258 376 end 259 377 260 %------------------------------------------------------------------------261 % --- Function activated when a new filebase (image series) is introduced262 function RootPath_Callback(hObject, eventdata, handles)263 %------------------------------------------------------------------------264 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding265 RootPath=get(handles.RootPath,'String');266 SubDirImages=get(handles.SubDirImages,'String');267 RootFile=get(handles.RootFile,'String');268 ref_i=str2num(get(handles.ref_i,'String'));269 ref_j=str2num(get(handles.ref_j,'String'));270 NomType=get(handles.NomType,'String');271 ImaExt=get(handles.ImaExt,'String');272 fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);273 errormsg=display_file_name(handles,fileinput);274 if ~isempty(errormsg)275 msgbox_uvmat('ERROR',errormsg)276 end277 set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished278 378 279 379 %------------------------------------------------------------------------ … … 281 381 function errormsg=display_file_name(handles,fileinput) 282 382 %------------------------------------------------------------------------ 283 set(handles.ListCompareMode,'Visible','on') 284 errormsg='';%default empty error message 285 drawnow 383 286 384 287 385 %% enable OK, BATCH button and 'status' display … … 294 392 295 393 %% determine nomenclature types and extension of the input files 296 [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); 297 NomTypeNc='';%default 298 299 %% case of xml file as input, read the civ_input parameters 300 ind_opening=0;%default 301 if strcmp(ExtInput,'.xml') 302 %reinitialise menus 303 set(handles.ListPairMode,'Value',1) 304 set(handles.ListPairMode,'String',{''}) 305 set(handles.ListPairCiv1,'Value',1) 306 set(handles.ListPairCiv1,'String',{''}) 307 set(handles.ListPairCiv2,'Value',1) 308 set(handles.ListPairCiv2,'String',{''}) 309 Param=xml2struct(fileinput); %read parameters from the xml input file 310 fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file 311 return 312 end 313 314 %% case of netcdf file as input, get the civ_input processing stage and look for a coresponding image 315 imageinput=fileinput;%default 316 if strcmp(ExtInput,'.nc') 317 NomTypeNc=NomTypeInput; 318 if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) 319 set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs 320 set(handles.RootFile_1,'Visible','On'); 321 else 322 set(handles.ListCompareMode,'Value',1) 323 set(handles.RootFile_1,'Visible','Off'); 324 end 325 imageinput=''; 326 Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2'); 327 if isfield(Data,'Txt') 328 errormsg=Data.Txt; 329 return 330 end 331 % settings for new civ_input data, 332 if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, 333 set(handles.Program,'Value',1) %select civ/Matlab by default 334 Program_Callback([],[], handles) 335 if ~isempty(Data.CivStage)%test for civ files 336 ind_opening=Data.CivStage; 337 end 338 if ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file 339 imageinput=Data.Civ2_ImageB; 340 [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA); 341 set(handles.RootFile_1,'String',[ImaName ImaExt]) 342 elseif ~isempty(Data.Civ1_ImageB) 343 imageinput=Data.Civ1_ImageB; 344 [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA); 345 set(handles.RootFile_1,'String',[ImaName ImaExt]) 346 end 347 % settings for civx data, 348 elseif ~isempty(Data.absolut_time_T0')% case of civx data, 349 set(handles.Program,'Value',3) %select Cix by default 350 Program_Callback([],[], handles) 351 if ~isempty(Data.fix2) 352 ind_opening=5; 353 elseif ~isempty(Data.civ2) 354 ind_opening=4; 355 elseif ~isempty(Data.patch) 356 ind_opening=3; 357 elseif ~isempty(Data.fix) 358 ind_opening=2; 359 end 360 else 361 errormsg='the input netcdf file is not civ data'; 362 return 363 end 364 % look for the corresponding input images 365 check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter 366 NomTypeIma=NomTypeInput; 367 if check_letter 368 NomTypeIma=NomTypeInput(1:end-1); 369 else 370 r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names'); 371 if ~isempty(r) 372 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 373 end 374 r=regexp(NomTypeIma,'.-(?<num2>\d+)','names'); 375 if ~isempty(r) 376 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 377 end 378 end 379 if ~exist(imageinput,'file') 380 imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1); 381 end 382 end 383 384 %% no corresponding image found, select manually with the browser 385 ImaExt=ExtInput; 386 if ~isempty(NomTypeNc) 387 %no corresponding image found, select manually with the browser 388 if ~exist(imageinput,'file') 389 menu={'*.png;*.jpg;*.tif;*.avi;*.AVI', '(*.png,*.jpg ,*.tif, *.avi,*.AVI)'; 390 '*.png','.png image files'; ... 391 '*.jpg',' jpeg image files'; ... 392 '*.tif','.tif image files'; ... 393 '*.avi;*.AVI','.avi movie files'; ... 394 '*.*', 'All Files (*.*)'}; 395 [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput))); 396 imageinput=[PathName FileName];%complete file name 397 if ~exist(imageinput,'file') 398 return %abandon of the browser is cancelled 399 end 400 end 401 %fileinput=imageinput; 402 end 403 404 %% scan the image file series 394 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); 395 % NomTypeNc='';%default 396 397 398 399 %% scan the image file series 405 400 [FilePath,FileName,ImaExt]=fileparts(imageinput); 406 401 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 407 402 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 408 [RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);409 switch FileType403 %[RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]); 404 switch Param.FileType{1} 410 405 case {'image','multimage','video','mmreader'} 411 406 otherwise … … 445 440 set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used 446 441 447 %% read the time in the image documentation file 448 time=[]; 449 TimeUnit=''; %default 450 CoordUnit='';%default 451 pxcm_search=1; 452 if ~isempty(XmlFileName) 453 set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning 454 drawnow 455 [XmlData,warntext]=imadoc2struct(XmlFileName); 456 nom_type_read=[]; 457 if isfield(XmlData,'Time') && ~isempty(XmlData.Time) 458 time=XmlData.Time; 459 %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml 460 if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector 461 if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) 462 time=time'; 463 MaxIndex_i=MaxIndex_j; 464 MaxIndex_j=1; 465 end 466 end 467 end 468 if isfield(XmlData,'Camera') && isfield(XmlData.Camera,'TimeUnit') 469 TimeUnit=XmlData.Camera.TimeUnit; 470 end 471 if isfield(XmlData,'GeometryCalib') 472 tsai=XmlData.GeometryCalib; 473 if isfield(tsai,'fx_fy') 474 pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range 475 end 476 if isfield(tsai,'CoordUnit') 477 CoordUnit=tsai.CoordUnit; 478 end 479 end 480 end 481 if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 482 set(handles.ListPairMode,'Value',1); 483 dt=1/get(MovieObject,'FrameRate');%time interval between successive frames 484 if strcmp(NomTypeIma,'*') 485 set(handles.ListPairMode,'String',{'series(Di)'}) 486 MaxIndex_i=get(MovieObject,'NumberOfFrames'); 487 time=(dt*(0:MaxIndex_i-1))';%list of image times 488 else 489 set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}]) 490 MaxIndex_i=max(i1_series(i1_series>0)); 491 MaxIndex_j=get(MovieObject,'NumberOfFrames'); 492 time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times 493 enable_j(handles,'on') 494 end 495 TimeUnit='s'; 496 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter 497 end 498 499 %% timing display 500 %show the reference image edit box if relevant (not needed for movies or in the absence of time information 501 if numel(time)>=2 % if there are at least two time values to define dt 502 if size(time,1)<MaxIndex_i; 503 msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file'); 504 elseif size(time,2)<MaxIndex_j 505 msgbox_uvmat('WARNING','maximum j index restricted by the timing of the xml file'); 506 end 507 MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data 508 MaxIndex_j=min(size(time,2),MaxIndex_j); 509 time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) 510 time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros 511 else 512 set(handles.ImaDoc,'String',''); %xml file not used for timing 513 time=(i1_series(:,1)+0:size(i1_series,3)-1);% time=index i 514 time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices 515 TimeUnit='frame'; 516 end 517 set(handles.ImaDoc,'UserData',time); %store the matrix of times 518 set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) 519 set(handles.TimeUnit,'String',TimeUnit); 520 set(handles.nb_field,'String',num2str(MaxIndex_i)); 521 set(handles.nb_field2,'String',num2str(MaxIndex_j)); 522 set(handles.CoordUnit,'String',CoordUnit) 523 set(handles.SearchRange,'UserData', pxcm_search); 524 set(handles.ImaExt,'String',ImaExt) 525 set(handles.NomType,'String',NomTypeIma) 526 527 %% set the reference indices from the input file indices 528 num_ref_i=str2num(get(handles.ref_i,'String')); 529 num_ref_j=str2num(get(handles.ref_j,'String')); 530 % for movies don't modify except if the current ref is outside index bounds 531 %if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j) 532 if ~isempty(i1)% if i1 has been selected by the input 533 num_ref_i=i1;%default ref index 534 if ~isempty(i2) 535 num_ref_i=floor((num_ref_i+i2)/2); 536 end 537 if ~isempty(j1) 538 num_ref_j=j1; 539 if ~isempty(j2) 540 num_ref_j=floor((num_ref_j+j2)/2); 541 end 542 end 543 end 544 if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i 545 num_ref_i=round((MinIndex_i+MaxIndex_i)/2); 546 end 547 if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j) 548 if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j) 549 num_ref_j=round((MinIndex_j+MaxIndex_j)/2); 550 end 551 end 552 if isempty(num_ref_j) 553 num_ref_j=1; 554 end 555 556 %% update i and j index range if a nc file has been opened or pb withmin max image indices: 442 443 444 %% update i and j index range if a nc file has been opened or pb withmin max image indices: 557 445 % then set first and last to the inputfile index by default 558 446 first_i=str2num(get(handles.first_i,'String')); 559 447 last_i=str2num(get(handles.last_i,'String')); 560 448 if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)||ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i 561 first_i=num_ref_i;562 last_i=num_ref_i;449 first_i=num_ref_i; 450 last_i=num_ref_i; 563 451 set(handles.first_i,'String',num2str(first_i)); 564 452 set(handles.last_i,'String',num2str(last_i));% 565 453 end 566 454 567 %j index range 455 %j index range 568 456 first_j=str2num(get(handles.first_j,'String')); 569 457 last_j=str2num(get(handles.last_j,'String')); 570 458 if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)||ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j 571 572 last_j=num_ref_j;459 first_j=num_ref_j; 460 last_j=num_ref_j; 573 461 set(handles.first_j,'String',num2str(first_j)); 574 462 set(handles.last_j,'String',num2str(last_j));% 575 463 end 576 if num_ref_i>last_i || num_ref_i<first_i 464 if num_ref_i>last_i || num_ref_i<first_i 577 465 num_ref_i=round((first_i+last_i)/2); 578 466 end … … 583 471 set(handles.ref_j,'String',num2str(num_ref_j)) 584 472 585 %% set the civ_input options depending on the input file content when a nc file has been opened 586 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; 587 checkbox=zeros(size(ListOptions));%default 588 if ind_opening==0%case of image opening, start with Civ1 589 for index=1:numel(ListOptions) 590 checkbox(index)=get(handles.(ListOptions{index}),'Value'); 591 end 592 index_max=find(checkbox, 1, 'last' ); 593 if isempty(index_max),index_max=1;end 594 for index=1:index_max 595 set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 596 end 597 else 598 for index = 1:min(ind_opening,5) 599 set(handles.(ListOptions{index}),'value',0) 600 end 601 set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) 602 for index = ind_opening+2:6 603 set(handles.(ListOptions{index}),'value',0) 604 end 605 end 606 %list_operation={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2'}; 607 608 %set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) 609 update_CivOptions(handles,ind_opening) 610 611 %% set the menus of image pairs and default selection for civ_input %%%%%%%%%%%%%%%%%%% 612 %check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter 613 if isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1) 614 set(handles.ListPairMode,'Value',1) 615 set(handles.ListPairMode,'String',{'series(Di)'}) 616 elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j 617 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) 618 if MaxIndex_j <= 10 619 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 620 end 621 elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 622 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice 623 if strcmp(NomTypeNc,'_1-2_1') 624 set(handles.ListPairMode,'Value',3)% advise 'series(Di)' 625 elseif MaxIndex_j <= 10 626 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 627 end 628 end 473 629 474 630 475 %% scan files to update the subdirectory list display … … 644 489 645 490 %% store info 646 set(handles.RootPath,'UserData',browse)% store the nomenclature type491 %set(handles.RootPath,'UserData',browse)% store the nomenclature type 647 492 648 493 %% list the possible index pairs, depending on the option set in ListPairMode 649 494 ListPairMode_Callback([], [], handles) 650 651 %% store the root input filename for future opening652 profil_perso=fullfile(prefdir,'uvmat_perso.mat');653 if exist(profil_perso,'file')654 save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat655 else656 txt=ver('MATLAB');657 Release=txt.Release;658 relnumb=str2double(Release(3:4));659 if relnumb >= 14660 save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat661 else662 save (profil_perso,'RootPath'); %store the root name for future opening of uvmat663 end664 end665 set(handles.RootPath,'BackgroundColor',[1 1 1])666 495 667 496 %------------------------------------------------------------------------ … … 757 586 checkbox(6)=get(handles.CheckPatch2,'Value'); 758 587 ind_selected=find(checkbox,1); 759 if ~isempty(ind_selected)760 RootPath=get(handles.RootPath,'String');761 if isempty(RootPath)762 msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')763 return764 end765 end588 % if ~isempty(ind_selected) 589 % RootPath=get(handles.RootPath,'String'); 590 % if isempty(RootPath) 591 % msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...') 592 % return 593 % end 594 % end 766 595 set(handles.PairIndices,'Visible','on') 767 596 set(handles.SubdirCiv1,'Visible','on') … … 829 658 end 830 659 831 % %------------------------------------------------------------------- 832 % % --- Executes on button press in status. 833 % function status_Callback(hObject, eventdata, handles) 834 % %------------------------------------------------------------------- 835 % val=get(handles.status,'Value'); 836 % if val==0 837 % set(handles.status,'BackgroundColor',[0 1 0]) 838 % hfig=findobj(allchild(0),'name','civ_status'); 839 % if ~isempty(hfig) 840 % delete(hfig) 841 % end 842 % return 843 % end 844 % set(handles.status,'BackgroundColor',[1 1 0]) 845 % drawnow 846 % listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; 847 % Param.CheckCiv1=get(handles.CheckCiv1,'Value'); 848 % Param.CheckFix1=get(handles.CheckFix1,'Value'); 849 % Param.CheckPatch1=get(handles.CheckPatch1,'Value'); 850 % Param.CheckCiv2=get(handles.CheckCiv2,'Value'); 851 % Param.CheckFix2=get(handles.CheckFix2,'Value'); 852 % Param.CheckPatch2=get(handles.CheckPatch2,'Value'); 853 % box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; 854 % 855 % option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) 856 % filecell=get(handles.civ_input,'UserData');%retrieve the list of output files expected for PIV 857 % test_new=0; 858 % if ~isfield(filecell,'nc') 859 % test_new=1; 860 % [ref_i,ref_j,errormsg]=find_ref_indices(handles); 861 % if ~isempty(errormsg) 862 % msgbox_uvmat('ERROR',errormsg) 863 % return 864 % end 865 % filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status 866 % end 867 % if ~isequal(box_test(4:6),[0 0 0]) 868 % civ_files=filecell.nc.civ2;%case of civ2 operations 869 % else 870 % civ_files=filecell.nc.civ1; 871 % end 872 % [root,filename,ext]=fileparts(civ_files{1}); 873 % [rootroot,SubDir,extdir]=fileparts(root); 874 % hfig=findobj(allchild(0),'name','civ_status'); 875 % if isempty(hfig) 876 % hfig=figure('DeleteFcn',@stop_status); 877 % set(hfig,'MenuBar','none')% suppress the menu bar 878 % set(hfig,'NumberTitle','off')%suppress the fig number in the title 879 % set(hfig,'name','civ_status') 880 % set(hfig,'tag','civ_status') 881 % set(hfig,'UserData',civ_files) 882 % hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list'); 883 % uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); 884 % uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 885 % %uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); 886 % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@stop_status); 887 % hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI); 888 % BarPosition=[0.05 0.81 0.01 0.05]; 889 % uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); 890 % drawnow 891 % end 892 % StatusData.time_ref=get(handles.OK,'UserData');% get the time of launch 893 % StatusData.option_civ=option_civ; 894 % set(hrefresh,'UserData',StatusData) 895 % filepath=fileparts(civ_files{1}); 896 % set(hlist,'UserData',fileparts(filepath)) 897 % refresh_GUI(hrefresh,[]) 898 899 % %------------------------------------------------------------------------ 900 % % launched by refreshing the status figure 901 % function refresh_GUI(hObject, eventdata) 902 % %------------------------------------------------------------------------ 903 % Tabchar={}; 904 % BarPosition=[0.05 0.81 0.01 0.05]; 905 % hfig=get(hObject,'parent'); 906 % StatusData=get(hObject,'UserData'); 907 % civ_files=get(hfig,'UserData'); 908 % [filepath,filename,ext]=fileparts(civ_files{1}); 909 % [tild,SubDir,extdir]=fileparts(filepath); 910 % SubDir=[SubDir extdir]; 911 % option_civ=StatusData.option_civ; 912 % nbfiles=numel(civ_files); 913 % testrecent=0; 914 % count=0; 915 % datnum=zeros(1,nbfiles); 916 % filefound=cell(1,nbfiles); 917 % for ifile=1:nbfiles 918 % detect=exist(civ_files{ifile},'file'); % check the existence of the file 919 % option=0; 920 % if detect==0 921 % option_str='not created'; 922 % else 923 % datfile=dir(civ_files{ifile}); 924 % if isfield(datfile,'datenum') 925 % datnum(ifile)=datfile.datenum;%only available in recent matlab versions 926 % testrecent=1; 927 % end 928 % filefound(ifile)={datfile.name}; 929 % 930 % % check the content netcdf file 931 % Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); 932 % option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; 933 % if ~isempty(Data.CivStage) 934 % option=Data.CivStage;%case of Matlab civ 935 % else 936 % if ~isempty(Data.patch2) && isequal(Data.patch2,1) 937 % option=6; 938 % elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 939 % option=5; 940 % elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 941 % option=4; 942 % elseif ~isempty(Data.patch) && isequal(Data.patch,1); 943 % option=3; 944 % elseif ~isempty(Data.fix) && isequal(Data.fix,1); 945 % option=2; 946 % else 947 % option=1; 948 % end 949 % end 950 % option_str=option_list{option}; 951 % if datnum(ifile)<StatusData.time_ref 952 % option_str=[option_str ' --OLD--']; 953 % end 954 % end 955 % if option >= option_civ 956 % count=count+1; 957 % end 958 % [filepath,filename,ext]=fileparts(civ_files{ifile}); 959 % Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; 960 % end 961 % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 962 % if isempty(datnum) 963 % if testrecent 964 % message='no civ result created yet'; 965 % else 966 % message=''; 967 % end 968 % else 969 % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 970 % [first,ind]=min(datnum); 971 % [last,indlast]=max(datnum); 972 % message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 973 % ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 974 % end 975 % hlist=findobj(hfig,'tag','list'); 976 % hmsgbox=findobj(hfig,'tag','msgbox'); 977 % hwaitbar=findobj(hfig,'tag','waitbar'); 978 % set(hlist,'String',Tabchar) 979 % set(hmsgbox,'String', message) 980 % if count>0 %&& ~test_new 981 % BarPosition(3)=0.9*count/nbfiles; 982 % set(hwaitbar,'Position',BarPosition) 983 % end 984 % 985 % 986 % %------------------------------------------------------------------------ 987 % % launched by deleting the status figure 988 % function stop_status(hObject, eventdata) 989 % %------------------------------------------------------------------------ 990 % hciv=findobj(allchild(0),'tag','civ'); 991 % hhciv=guidata(hciv); 992 % set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ 993 % set(hhciv.status,'BackgroundColor',[0 1 0]) 994 % 995 % % %------------------------------------------------------------------------ 996 % % % launched by pressing OK on the status figure 997 % % function close_GUI(hObject, eventdata) 998 % % %------------------------------------------------------------------------ 999 % % delete(gcbf) 1000 % 1001 1002 % %------------------------------------------------------------------------ 1003 % % --- Main lauch command, called by OK and BATCH 1004 % function errormsg=launch_jobs(hObject, eventdata, handles) 1005 % %------------------------------------------------------------------------ 1006 % errormsg='';%default 1007 % 1008 % %% read the input parameters from the GUI civ_input 1009 % Param=read_GUI(handles.civ_input); 1010 % 1011 % %% check the selected list of operations: 1012 % operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; 1013 % box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; 1014 % index_first=find(box_test==1,1); 1015 % if isempty(index_first) 1016 % errormsg='no selected operation'; 1017 % return 1018 % end 1019 % index_last=find(box_test==1,1,'last'); 1020 % box_used=box_test(index_first : index_last); 1021 % [box_missing,ind_missing]=min(box_used); 1022 % if isequal(box_missing,0); %there is a missing step in the sequence of operations 1023 % errormsg=['missing' cell2mat(operations(ind_missing))]; 1024 % return 1025 % end 1026 % 1027 % %% check mask if selecetd 1028 % %could be included in get_mask callback ? 1029 % if isequal(get(handles.CheckMask,'Value'),1) 1030 % maskname=get(handles.Mask,'String'); 1031 % if ~exist(maskname,'file') 1032 % get_mask_civ1_Callback(hObject, eventdata, handles); 1033 % end 1034 % end 1035 % if isequal(get(handles.CheckMask,'Value'),1) 1036 % maskname=get(handles.Mask,'String'); 1037 % if ~exist(maskname,'file') 1038 % get_mask_fix1_Callback(hObject, eventdata, handles); 1039 % end 1040 % end 1041 % if isequal(get(handles.CheckMask,'Value'),1) 1042 % maskname=get(handles.Mask,'String'); 1043 % if ~exist(maskname,'file') 1044 % get_mask_civ2_Callback(hObject, eventdata, handles); 1045 % end 1046 % end 1047 % if isequal(get(handles.CheckMask,'Value'),1) 1048 % maskname=get(handles.Mask,'String'); 1049 % if ~exist(maskname,'file') 1050 % get_mask_fix2_Callback(hObject, eventdata, handles); 1051 % end 1052 % end 1053 % 1054 % %% reinitialise status callback 1055 % if isfield(handles,'status') 1056 % set(handles.status,'Value',0);%suppress status display 1057 % status_Callback([], [], handles) 1058 % end 1059 % 1060 % %% read the PARAM.xml file to get the binaries (and batch_mode if batch) 1061 % % path_civ=fileparts(which('civ')); %path to the source directory of uvmat 1062 % % xmlfile=fullfile(path_civ,'PARAM.xml'); 1063 % % s=[]; 1064 % % if exist(xmlfile,'file')% search parameter xml file in the whole matlab path 1065 % % t=xmltree(xmlfile); 1066 % % s=convert(t); 1067 % % end% default configuration 1068 % % if ~isfield(s,'RunParam') 1069 % % Param.xml.Civ1Bin=fullfile('bin','civ1'); 1070 % % Param.xml.Civ2Bin=fullfile('bin','civ2'); 1071 % % Param.xml.FixBin=fullfile('bin','fix_flag'); 1072 % % Param.xml.PatchBin=fullfile('bin','patch_up'); 1073 % % end 1074 % % if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster 1075 % % if isfield(s,'BatchParam') 1076 % % Param.xml=s.BatchParam; 1077 % % if isfield(Param.xml,'BatchMode') 1078 % % batch_mode=Param.xml.BatchMode; 1079 % % if ~ismember(batch_mode,{'sge','oar'}) 1080 % % errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; 1081 % % return 1082 % % end 1083 % % end 1084 % % else 1085 % % %default configuration 1086 % % Param.xml.Civ1Bin=fullfile('bin','civ1'); 1087 % % Param.xml.Civ2Bin=fullfile('bin','civ2'); 1088 % % Param.xml.FixBin=fullfile('bin','fix_flag'); 1089 % % Param.xml.PatchBin=fullfile('bin','patch_up'); 1090 % % % Param.xml.CivmBin=fullfile('bin','civ_matlab'); 1091 % % Param.xml.BatchMode='oar';% TODO : allow choice for sge 1092 % % end 1093 % % else % run 1094 % % if isfield(s,'RunParam') 1095 % % Param.xml=s.RunParam; 1096 % % else %default configuration 1097 % % Param.xml.Civ1Bin=fullfile('bin','civ1'); 1098 % % Param.xml.Civ2Bin=fullfile('bin','civ2'); 1099 % % Param.xml.FixBin=fullfile('bin','fix_flag'); 1100 % % Param.xml.PatchBin=fullfile('bin','patch_up'); 1101 % % end 1102 % % end 1103 % % %Param.xml.CivmBin=fullfile('bin','civ_matlab'); 1104 % % 1105 % % %% check if the binaries exist : to move in civ_opening 1106 % % binary_list={}; 1107 % % switch Param.Program 1108 % % case 'CivX' 1109 % % binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; 1110 % % case 'CivAll'% desactivated option 1111 % % binary_list={'Civ'}; 1112 % % % case 'civ_matlab.sh'% compiled version of civ_matlab 1113 % % % binary_list={'CivmBin'}; 1114 % % end 1115 % % for bin_name=binary_list %loop on the list of binaries 1116 % % if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list 1117 % % if ~isunix 1118 % % Param.xml.(bin_name{1})=[regexprep(Param.xml.(bin_name{1}),'/','\') '.exe']; 1119 % % end 1120 % % if exist(Param.xml.(bin_name{1}),'file') 1121 % % [path,name,ext]=fileparts(Param.xml.(bin_name{1})); 1122 % % currentdir=pwd; 1123 % % if isempty(path) 1124 % % path=fileparts(which('civ.m')); 1125 % % end 1126 % % if exist(path,'dir') 1127 % % cd(path); 1128 % % binpath=pwd;%path of the binary 1129 % % Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); 1130 % % cd(currentdir); 1131 % % else 1132 % % errormsg=['path ' path ' for binaries specified in PARAM.xml does not exist']; 1133 % % return 1134 % % end 1135 % % else %look for the full path if the file name has been defined with a relative path in PARAM.xm 1136 % % fullname=fullfile(path_civ,Param.xml.(bin_name{1})); 1137 % % if exist(fullname,'file') 1138 % % Param.xml.(bin_name{1})=fullname; 1139 % % else 1140 % % errormsg=['Binary ' Param.xml.(bin_name{1}) ' specified in PARAM.xml does not exist']; 1141 % % return 1142 % % end 1143 % % end 1144 % % end 1145 % % end 1146 % % if strcmp(Param.Program,'civ_matlab.sh') 1147 % % if ~exist(fullfile(path_civ,'civ_matlab.sh'),'file') 1148 % % errormsg=[{'no file civ_matlab.sh found'}; {'run compile_functions.m to create it by compiling civ_matlab.m'}]; 1149 % % return 1150 % % end 1151 % % end 1152 % % 1153 % % %% set the list of files and check them 1154 % % display('checking the files...') 1155 % % [ref_i,ref_j,errormsg]=find_ref_indices(handles); 1156 % % if ~isempty(errormsg) 1157 % % return 1158 % % end 1159 % % [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,tild,tild,compare,errormsg]=... 1160 % % set_civ_filenames(handles,ref_i,ref_j,box_test); 1161 % % if ~isempty(errormsg) 1162 % % return 1163 % % end 1164 % % set(handles.civ_input,'UserData',filecell);%store for futur use of status callback 1165 % % display('files OK, processing...') 1166 % % 1167 % % %% create subfolders for log, cmx, nml, xml, bat 1168 % % RootBat=fileparts(filecell.nc.civ1{1,1}); 1169 % % switch(Param.Program) 1170 % % case {'CivX','CivAll'} 1171 % % dir_list={'0_BAT','0_CMX','0_LOG'}; 1172 % % case {'civ_matlab','civ_matlab.sh'} 1173 % % dir_list={'0_BAT','0_XML'}; 1174 % % end 1175 % % for k=1:length(dir_list) 1176 % % if ~exist(fullfile(RootBat,dir_list{k}),'dir') 1177 % % mkdir(fullfile(RootBat,dir_list{k})); 1178 % % end 1179 % % end 1180 % 1181 % %% get information on input images or movies 1182 % nbfield=numel(i1_civ1); 1183 % nbslice=numel(j1_civ1); 1184 % % if strcmp(Param.Program,'civ_matlab') 1185 % if Param.CheckCiv1 1186 % [Param.Civ1.FileTypeA,ImageInfoA_civ1,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1}); 1187 % [Param.Civ1.FileTypeB,ImageInfoB_civ1,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1}); 1188 % end 1189 % if Param.CheckCiv2 1190 % [Param.Civ2.FileTypeA,ImageInfoA_civ2,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1}); 1191 % [Param.Civ2.FileTypeB,ImageInfoB_civ2,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1}); 1192 % end 1193 % % end 1194 % 1195 % %% MAIN LOOP 1196 % time=get(handles.ImaDoc,'UserData'); %get the set of times 1197 % TimeUnit=get(handles.TimeUnit,'String'); 1198 % checkframe=strcmp(TimeUnit,'frame'); 1199 % batch_file_list=[];%should be renamed file_list, can be used for xml or bash files 1200 % NomTypeIma=get(handles.NomType,'String'); 1201 % for ifile=1:nbfield 1202 % for j=1:nbslice 1203 % 1204 % % define output file name 1205 % if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 1206 % Param.OutputFile=filecell.nc.civ2{ifile,j}; 1207 % else 1208 % Param.OutputFile=filecell.nc.civ1{ifile,j}; 1209 % end 1210 % Param.OutputFile=regexprep(Param.OutputFile,'.nc',''); 1211 % 1212 % if Param.CheckCiv1 1213 % % read image-dependent parameters 1214 % if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) 1215 % Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1)); 1216 % else 1217 % Param.Civ1.Dt=1; 1218 % end 1219 % Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); 1220 % if strcmp(Param.Program,'CivX') 1221 % Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? 1222 % Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% 1223 % end 1224 % Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; 1225 % Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; 1226 % Param.Civ1.ImageBitDepth=ImageInfoA_civ1.BitDepth; 1227 % Param.Civ1.ImageWidth=ImageInfoA_civ1.Width; 1228 % Param.Civ1.ImageHeight=ImageInfoA_civ1.Height; 1229 % if strcmp(NomTypeIma,'*') 1230 % Param.Civ1.FrameIndexA=i1_civ1(ifile); 1231 % Param.Civ1.FrameIndexB=i2_civ1(ifile); 1232 % else% case of movies indexed with i, the frame index is then in j 1233 % Param.Civ1.FrameIndexA=j1_civ1(j); 1234 % Param.Civ1.FrameIndexB=j2_civ1(j); 1235 % end 1236 % % read mask )parameters 1237 % if Param.Civ1.CheckMask % the lines below should be changed with the new gui 1238 % if ~exist(Param.Civ1.Mask,'file') 1239 % maskbase=[filecell.filebase '_' Param.Civ1.Mask]; % 1240 % nbslice_mask=str2double(Param.Civ1.Mask(1:end-4)); % 1241 % i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1; 1242 % [RootPathMask,RootFileMask]=fileparts(maskbase); 1243 % Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); 1244 % end 1245 % end 1246 % % read grid parameters 1247 % if Param.Civ1.CheckGrid 1248 % if numel(Param.Civ1.Grid)>=4 && isequal(Param.Civ1.Grid(end-3:end),'grid') 1249 % nbslice_grid=str2double(Param.Civ1.Grid(1:end-4)); % 1250 % if ~isnan(nbslice_grid) 1251 % i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; 1252 % Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)]; 1253 % if ~exist(Param.Civ1.GridName,'file') 1254 % errormsg='grid file absent for civ1'; 1255 % return 1256 % end 1257 % elseif ~exist(Param.Civ1.Grid,'file') 1258 % errormsg='grid file absent for civ1'; 1259 % return 1260 % end 1261 % end 1262 % end 1263 % 1264 % end 1265 % 1266 % if Param.CheckCiv2==1 1267 % Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; 1268 % Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; 1269 % if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) 1270 % Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1); 1271 % else 1272 % Param.Civ2.Dt=1; 1273 % end 1274 % Param.Civ2.Time=(time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2; 1275 % if strcmp(Param.Program,'CivX') 1276 % Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc); 1277 % Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc); 1278 % end 1279 % Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; 1280 % Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' 1281 % 1282 % % mask 1283 % if Param.Civ2.CheckMask 1284 % if ~exist(Param.Civ2.Mask,'file') 1285 % maskbase=[filecell.filebase '_' Param.Civ2.Mask]; % 1286 % nbslice_mask=str2double(Param.Civ2.Mask(1:end-4)); % 1287 % i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1; 1288 % [RootPathMask,RootFileMask]=fileparts(maskbase); 1289 % Param.Civ2.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); 1290 % % Param.Civ2.Mask=name_generator(maskbase,i1_mask,1,'.png','_i'); 1291 % end 1292 % end 1293 % %grid 1294 % if Param.Civ2.CheckGrid 1295 % if numel(Param.Civ2.Grid)>=4 && isequal(Param.Civ2.Grid(end-3:end),'grid') 1296 % nbslice_grid=str2double(Param.Civ2.Grid(1:end-4)); % 1297 % if ~isnan(nbslice_grid) 1298 % i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; 1299 % Param.Civ2.Grid=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; 1300 % % Param.Civ2.Grid=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; 1301 % end 1302 % end 1303 % end 1304 % 1305 % Param.Civ2.ImageBitDepth=ImageInfoA_civ2.BitDepth; 1306 % Param.Civ2.ImageWidth=ImageInfoA_civ2.Width; 1307 % Param.Civ2.ImageHeight=ImageInfoA_civ2.Height; 1308 % if strcmp(NomTypeIma,'*') 1309 % Param.Civ2.FrameIndexA=i1_civ2(ifile); 1310 % Param.Civ2.FrameIndexB=i2_civ2(ifile); 1311 % else% case of movies indexed with i, the frame index is then in j 1312 % Param.Civ2.FrameIndexA=j1_civ2(j); 1313 % Param.Civ2.FrameIndexB=j2_civ2(j); 1314 % end 1315 % end 1316 % 1317 % % write the command and eventually the cmx, xml or nml files 1318 % cmd=write_cmd(Param); 1319 % write_param(Param); 1320 % 1321 % % create the command file name .m, .bat or .sh depending on the ok option 1322 % switch Param.Program 1323 % case {'civ_matlab'} 1324 % filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.m'); 1325 % [BatRoot,BatFile]=fileparts(filename_bat); 1326 % BatFile=regexprep(BatFile,'-','__');%transform name to suppress'-' (not valid for .m files) 1327 % filename_bat=[fullfile(BatRoot,BatFile) '.m']; 1328 % case {'CivX','CivAll','civ_matlab.sh'} 1329 % switch computer 1330 % case {'PCWIN','PCWIN64'} 1331 % filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.bat'); 1332 % case {'GLNX86','GLNXA64','MACI64'} 1333 % filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.sh'); 1334 % end 1335 % end 1336 % 1337 % % print the command in the bat file 1338 % [fid,message]=fopen(filename_bat,'w'); 1339 % if isequal(fid,-1) 1340 % errormsg=['creation of .bat file: ' message]; 1341 % return 1342 % end 1343 % fprintf(fid,cmd); 1344 % fclose(fid); 1345 % 1346 % % special case for civ_matlab on cluster 1347 % if strcmp(Param.Program,'civ_matlab') && strcmp(Param.RunMode,'cluster') 1348 % filename_bat2=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.sh'); 1349 % [fid,message]=fopen(filename_bat2,'w'); 1350 % if isequal(fid,-1) 1351 % errormsg=['creation of .bat file: ' message]; 1352 % return 1353 % end 1354 % fprintf(fid,['#!/bin/bash \n' ... 1355 % '/etc/sysprofile \n'... 1356 % 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'... 1357 % 'addpath(''' path_civ ''');\n']); 1358 % % for p=1:length(batch_file_list) 1359 % fprintf(fid,['run ' filename_bat '\n']); 1360 % % end 1361 % fprintf(fid, 'exit\nEND_MATLAB\n'); 1362 % fclose(fid); 1363 % filename_bat=filename_bat2; 1364 % end 1365 % 1366 % switch computer 1367 % case {'GLNX86','GLNXA64','MACI64'} 1368 % system(['chmod +x ' filename_bat]); 1369 % end 1370 % batch_file_list{length(batch_file_list)+1}=filename_bat; 1371 % end 1372 % end 1373 % 1374 % %% start calculation 1375 % %computation on cluster 1376 % %if batch ==3 1377 % switch Param.RunMode, 1378 % case 'cluster' 1379 % switch batch_mode 1380 % case 'sge' %at the moment only psmn ENS Lyon uses it 1381 % for p=1:length(batch_file_list) 1382 % %cmd=['!qsub -p ' pvalue ' -q civ_input.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; 1383 % cmd=['!qsub -q piv1,piv2,piv3 '... 1384 % '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')... 1385 % ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}]; 1386 % display(cmd);eval(cmd); 1387 % end 1388 % case 'oar_old' % to remove 1389 % for p=1:length(batch_file_list) 1390 % oar_command=['!oarsub -n CIVX -q nicejob '... 1391 % '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... 1392 % '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; 1393 % display(oar_command);eval(oar_command); 1394 % end 1395 % case 'oar' 1396 % max_walltime=3600*12; % 12h max 1397 % oar_modes={'oar-parexec','oar-dispatch','mpilauncher'}; 1398 % text={'Batch processing on servcalcul3 LEGI';... 1399 % 'Please choose one of the followint modes';... 1400 % '* oar-parexec : default and best choice';... 1401 % '* oar-dispatch : jobs in a container of several cores';... 1402 % '* mpilauncher : one single parallel mpi job using several cores';... 1403 % '**********************************'... 1404 % }; 1405 % [S,v]=listdlg('PromptString',text,'ListString',oar_modes,... 1406 % 'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode'); 1407 % switch oar_modes{S} 1408 % case 'oar-parexec' %oar-dispatch.pl 1409 % if strcmp(Param.Program,'civ_matlab') 1410 % ncores=1; 1411 % msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing'); 1412 % else 1413 % answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); 1414 % ncores=str2double(answer{1}); 1415 % end 1416 % 1417 % extra_oar=answer{2}; 1418 % walltime_onejob=600;%seconds 1419 % filename_joblist=fullfile(RootBat,'job_list.txt'); 1420 % fid=fopen(filename_joblist,'w'); 1421 % for p=1:length(batch_file_list) 1422 % fprintf(fid,[batch_file_list{p} '\n']); 1423 % end 1424 % fclose(fid); 1425 % oar_command=['oarsub -n CIVX '... 1426 % '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... 1427 % '-l /core=' num2str(ncores) ','... 1428 % 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '... 1429 % '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... 1430 % '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... 1431 % extra_oar ' '... 1432 % '"oar-parexec -s -f ' filename_joblist ' '... 1433 % '-l ' filename_joblist '.log"\n']; 1434 % filename_oarcommand=fullfile(RootBat,'oar_command'); 1435 % fid=fopen(filename_oarcommand,'w'); 1436 % fprintf(fid,oar_command); 1437 % fclose(fid); 1438 % fprintf(oar_command);% display in command line 1439 % system(oar_command); 1440 % % eval(['! . ' filename 1441 % % _oarcommand]) 1442 % case 'oar-dispatch' %oar-dispatch.pl 1443 % ncores=str2double(... 1444 % inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})... 1445 % ); 1446 % walltime_onejob=600;%seconds 1447 % filename_joblist=fullfile(RootBat,'job_list.txt'); 1448 % fid=fopen(filename_joblist,'w'); 1449 % for p=1:length(batch_file_list) 1450 % oar_command=['oarsub -n CIVX '... 1451 % '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')... 1452 % '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '" ' batch_file_list{p}]; 1453 % fprintf(fid,[oar_command '\n']); 1454 % end 1455 % fclose(fid); 1456 % oar_command=['oarsub -t container -n civx-container '... 1457 % '-l /core=' num2str(ncores)... 1458 % ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '... 1459 % '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... 1460 % '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... 1461 % '"oar-dispatch -f ' filename_joblist '"']; 1462 % filename_oarcommand=fullfile(RootBat,'oar_command'); 1463 % fid=fopen(filename_oarcommand,'w'); 1464 % fprintf(fid,[oar_command '\n']); 1465 % fclose(fid); 1466 % display(oar_command); 1467 % eval(['! . ' filename_oarcommand]) 1468 % case 'mpilauncher' 1469 % filename_joblist=fullfile(RootBat,'job_list.txt'); 1470 % fid=fopen(filename_joblist,'w'); 1471 % 1472 % for p=1:length(batch_file_list) 1473 % fprintf(fid,[batch_file_list{p} '\n']); 1474 % end 1475 % fclose(fid) 1476 % text_oarscript=[... 1477 % '#!/bin/bash \n'... 1478 % '#OAR -n Mylauncher \n'... 1479 % '#OAR -l node=4/core=5,walltime=0:15:00 \n'... 1480 % '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'... 1481 % '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'... 1482 % '# ========================================================= \n'... 1483 % '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'... 1484 % '# application for coriolis PIV post-processing. \n'... 1485 % '# OAR uses oarshmost wrapper to propagate the user environement. \n'... 1486 % '# This wrapper assert that the user has the same environment on all the \n'... 1487 % '# allocated nodes (basic behavior needed by most MPI applications). \n'... 1488 % '# \n'... 1489 % '# REQUIREMENT: \n'... 1490 % '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'... 1491 % '# If a different location is used, change the line following the comment "Bidouille" \n'... 1492 % '# ========================================================= \n'... 1493 % '# USER should only modify these 2 lines \n'... 1494 % 'WORKDIR=' pwd ' \n'... 1495 % 'COMMANDE="mpilauncher -f ' filename_joblist '" \n'... 1496 % '# ========================================================= \n'... 1497 % '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'... 1498 % 'echo "job starting on: "`hostname` \n'... 1499 % 'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'... 1500 % 'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'... 1501 % '#========== Bidouille ============== \n'... 1502 % 'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...% 'cd $WORKDIR \n'... 1503 % 'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'... 1504 % 'echo "I run: $CMD" \n'... 1505 % '$CMD \n'... 1506 % 'echo "job ending" \n'... 1507 % ]; 1508 % % oarsub -S ./oar.sub 1509 % filename_oarscript=fullfile(RootBat,'oar_command'); 1510 % fid=fopen(filename_oarscript,'w'); 1511 % fprintf(fid,[text_oarscript]); 1512 % fclose(fid); 1513 % eval(['!chmod +x ' filename_oarscript]); 1514 % eval(['!oarsub -S ' filename_oarscript]); 1515 % end 1516 % end 1517 % case {'background','local'} 1518 % switch Param.Program 1519 % case {'civ_matlab'} 1520 % switch Param.RunMode 1521 % case 'background' 1522 % switch computer 1523 % case {'PCWIN','PCWIN64'} 1524 % filename_superbat=fullfile(RootBat,'job_list.bat'); 1525 % fid=fopen(filename_superbat,'w'); 1526 % if fid==-1 1527 % msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) 1528 % return 1529 % end 1530 % fprintf(fid,['matlab -automation '... 1531 % '-r "addpath(''' regexprep(path_civ,'\\','\\\\') ''');']); 1532 % for p=1:length(batch_file_list) 1533 % fprintf(fid,['run ' regexprep(batch_file_list{p},'\\','\\\\') ';']); 1534 % end 1535 % fprintf(fid, 'exit"'); 1536 % fclose(fid); 1537 % dos([filename_superbat ' &']); 1538 % case {'GLNX86','GLNXA64','MACI64'} 1539 % filename_superbat=fullfile(RootBat,'job_list.sh'); 1540 % fid=fopen(filename_superbat,'w'); 1541 % if fid==-1 1542 % msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) 1543 % return 1544 % end 1545 % fprintf(fid,['#!/bin/bash \n' ... 1546 % '/etc/sysprofile \n'... 1547 % 'matlab -nodisplay -nosplash -nojvm -logfile <<END_MATLAB \n'... 1548 % 'addpath(''' path_civ ''');\n']); 1549 % for p=1:length(batch_file_list) 1550 % fprintf(fid,['run ' batch_file_list{p} '\n']); 1551 % end 1552 % fprintf(fid, 'exit\nEND_MATLAB\n'); 1553 % fclose(fid); 1554 % system(['chmod +x ' filename_superbat]); 1555 % system([filename_superbat ' &']); 1556 % end 1557 % case 'local' 1558 % for p=1:length(batch_file_list) 1559 % fid=fopen(batch_file_list{p}); 1560 % eval(fscanf(fid,'%s')); 1561 % fclose(fid); 1562 % end 1563 % end 1564 % case {'CivX','CivAll','civ_matlab.sh'} 1565 % switch computer 1566 % case {'PCWIN','PCWIN64'} 1567 % filename_superbat=fullfile(RootBat,'job_list.bat'); 1568 % fid=fopen(filename_superbat,'w'); 1569 % if fid==-1 1570 % msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) 1571 % return 1572 % end 1573 % for p=1:length(batch_file_list) 1574 % fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']); 1575 % end 1576 % fclose(fid); 1577 % system(['chmod +x ' filename_superbat]); 1578 % case {'GLNX86','GLNXA64','MACI64'} 1579 % filename_superbat=fullfile(RootBat,'job_list.bat'); 1580 % fid=fopen(filename_superbat,'w'); 1581 % if fid==-1 1582 % msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) 1583 % return 1584 % end 1585 % for p=1:length(batch_file_list) 1586 % fprintf(fid,['sh ' batch_file_list{p} '\n']); 1587 % end 1588 % fclose(fid); 1589 % system(['chmod +x ' filename_superbat]); 1590 % end 1591 % switch Param.RunMode 1592 % case 'background' 1593 % system([filename_superbat ' &']);% execute main commmand see what it does in dos ? 1594 % case 'local' 1595 % system(filename_superbat); 1596 % end 1597 % end 1598 % end 1599 % 1600 % 1601 % %% save interface state 1602 % if isfield(filecell,'nc') 1603 % if isfield(filecell.nc,'civ2') 1604 % fileresu=filecell.nc.civ2{1,1}; 1605 % else 1606 % fileresu=filecell.nc.civ1{1,1}; 1607 % end 1608 % end 1609 % [RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu); 1610 % namedoc=fullfile(RootPath,SubDir,RootFile); 1611 % detect=1; 1612 % while detect==1 1613 % namefigfull=[namedoc '.fig']; 1614 % hh=dir(namefigfull); 1615 % if ~isempty(hh) 1616 % detect=1; 1617 % namedoc=[namedoc '.0']; 1618 % else 1619 % detect=0; 1620 % end 1621 % end 1622 % Param=rmfield(Param,'status'); 1623 % Param=rmfield(Param,'xml'); 1624 % t=struct2xml(Param); 1625 % t=set(t,1,'name','Civ');% set the head label 1626 % save(t,[namedoc '.civ.xml']); %save GUI parameters as xml file 1627 % % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) 1628 % 1629 % %Save info in personal profile (initiate browser next time) TODO 1630 % MenuFile={}; 1631 % dir_perso=prefdir; 1632 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 1633 % if exist(profil_perso,'file') 1634 % hh=load (profil_perso); 1635 % if isfield(hh,'MenuFile') 1636 % MenuFile=hh.MenuFile; 1637 % end 1638 % if isfield(filecell.nc,'civ2') 1639 % MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; 1640 % else 1641 % MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; 1642 % end 1643 % save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat 1644 % else 1645 % MenuFile=filecell.ima1.civ1(1,1); 1646 % save (profil_perso,'MenuFile') 1647 % end 1648 1649 % %------------------------------------------------------------------------ 1650 % % --- determine the list of reference indices of processing file 1651 % function [ref_i,ref_j,errormsg]=find_ref_indices(handles) 1652 % %------------------------------------------------------------------------ 1653 % errormsg=''; %default error message 1654 % first_i=str2double(get(handles.first_i,'String'));%first index i 1655 % last_i=str2double(get(handles.last_i,'String'));%last index i 1656 % incr_i=str2double(get(handles.incr_i,'String'));% increment 1657 % if isequal(get(handles.first_j,'Visible'),'on') 1658 % first_j=str2double(get(handles.first_j,'String'));%first index j 1659 % last_j=str2double(get(handles.last_j,'String'));%last index j 1660 % incr_j=str2double(get(handles.incr_j,'String'));% increment 1661 % else 1662 % first_j=1; 1663 % last_j=1; 1664 % incr_j=1; 1665 % end 1666 % ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) 1667 % ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) 1668 % if isnan(first_i)||isnan(first_j) 1669 % errormsg='first field number not defined'; 1670 % elseif isnan(last_i)||isnan(last_j) 1671 % errormsg='last field number not defined'; 1672 % elseif isnan(incr_i)||isnan(incr_j) 1673 % errormsg='increment in field number not defined'; 1674 % elseif last_i < first_i || last_j < first_j 1675 % errormsg='last field number must be larger than the first one'; 1676 % end 1677 1678 %------------------------------------------------------------------------ 1679 % --- determine the list of filenames and indices needed for launch_job 1680 %------------------------------------------------------------------------ 1681 % OUTPUT: 1682 % filecell: structure of cell arrays {ref_i,ref_j} containing all the filenames involved in the civ_input process 1683 % the indices ref_i and ref_j correspond to the list of reference indices 1684 % .filebase=fullfile(RootPath,RootFile) used to construct mask names, grid names, CivDoc xml file 1685 % .ima1.civ1,.ima1.civ2: first image for civ1 and civ2 respectively (possibly different) 1686 % .ima2.civ1,.ima2.civ2: second image for civ1 and civ2 respectively (possibly different) 1687 % .nc.civ1,.nc.civ2: netcdf files containing civ1 and civ2 data respectively (possibly different) 1688 % i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2: arrays of files indices, needed for timing records 1689 function [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,NomType_nc,file_ref_fix1,file_ref_fix2,compare,errormsg]=... 1690 set_civ_filenames(handles,ref_i,ref_j,checkbox) 1691 %------------------------------------------------------------------------ 1692 filecell=[];%default 1693 errormsg=''; 1694 ListProgram=get(handles.Program,'String'); 1695 CivMode=ListProgram{get(handles.Program,'Value')};%Program to use , CivX or Matlab 1696 1697 %% get the root name and check dir 1698 RootPath=get(handles.RootPath,'String'); 1699 SubDirImages=get(handles.SubDirImages,'String'); 1700 RootFile=get(handles.RootFile,'String'); 1701 filecell.filebase=fullfile(RootPath,SubDirImages,RootFile); 1702 if isempty(filecell.filebase) 1703 errormsg='please open an image with the upper menu option Open/Browse...'; 1704 return 1705 end 1706 if ~exist(RootPath,'dir') 1707 errormsg=['path to images ' RootPath ' not found']; 1708 return 1709 end 1710 [tild,message]=fileattrib(RootPath); 1711 if ~isempty(message) && ~isequal(message.UserWrite,1) 1712 errormsg=['No writting access to ' RootPath]; 1713 return 1714 end 1715 %check result directory 1716 subdir_civ1=regexprep(get(handles.SubdirCiv1,'String'),'^.','');%subdirectory subdir_civ1 for the netcdf output data 1717 subdir_civ2=regexprep(get(handles.SubdirCiv2,'String'),'^.',''); 1718 if isequal(subdir_civ1,''),subdir_civ1='civ'; end% put default subdir 1719 % subdir_civ1=[ '.' subdir_civ1]; 1720 % subdir_civ2=[ '.' subdir_civ2]; 1721 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir 1722 subdir_civ1=[SubDirImages '.' subdir_civ1]; 1723 subdir_civ2=[SubDirImages '.' subdir_civ2]; 1724 1725 %% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV 1726 ListCompareMode=get(handles.ListCompareMode,'String'); 1727 compare=ListCompareMode{get(handles.ListCompareMode,'Value')}; 1728 1729 % set the nomenclature type of the nc files depending on the pair mode 1730 if strcmp(compare,'displacement')||strcmp(compare,'shift') 1731 mode='displacement'; 1732 else 1733 mode_list=get(handles.ListPairMode,'String'); 1734 mode_value=get(handles.ListPairMode,'Value'); 1735 mode=mode_list{mode_value}; 1736 end 1737 NomType_ima2=get(handles.NomType,'String'); 1738 NomType_nc=nomtype2pair(NomType_ima2,mode); 1739 1740 % set the rootfile and image indexing 1741 RootFile_ima2=get(handles.RootFile,'String');%root file for the second image series 1742 ext_ima=get(handles.ImaExt,'String'); % image extension (the same for all images) 1743 switch compare 1744 case {'PIV','PIV volume'} 1745 RootFile_ima1=RootFile_ima2;% root name of the two image series is the same 1746 NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one 1747 RootFile_nc=RootFile_ima2; 1748 case 'displacement' 1749 RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 1750 NomType_ima1='';% no indexing of the first image, a fixed reference for the whole series 1751 RootFile_nc=RootFile_ima2; 1752 case 'shift' 1753 RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 1754 NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one 1755 RootFile_nc=[RootFile_ima1 '-' RootFile_ima2]; 1756 end 1757 1758 %determine the list of file indices involved 1759 [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... 1760 find_pair_indices(handles,ref_i,ref_j,mode); 1761 1762 %determine the new filebase for 'displacement' ListPairMode (comparison of two series) 1763 %filebase_B=filebase;% root name of the second field series for stereo 1764 % filebase_A=filebase;%default 1765 % if strcmp(compare,'PIV') 1766 % filebase_AB=filebase; 1767 % else 1768 % [Path2,Name2]=fileparts(filebase_B); 1769 % Name1=RootFile_ima1; 1770 % filebase_AB=fullfile(Path2,[Name2 '-' Name1]); 1771 % end 1772 % [RootPath_AB,RootFile_AB]=fileparts(filebase_AB); 1773 % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); 1774 % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); 1775 % [RootPath_nc,RootFile_nc]=fileparts(filebase_B);%default 1776 % if strcmp(compare,'displacement') 1777 % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); 1778 % % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); 1779 % [RootPath_nc,RootFile_nc]=fileparts(filebase_B); 1780 % elseif strcmp(compare,'shift') 1781 % RootPath_nc=RootPath_AB; 1782 % RootFile_nc=RootFile_AB; 1783 % end 1784 % else 1785 % filebase_ima1=filebase_B; 1786 % filebase_ima2=filebase_B; 1787 % filebase_nc=filebase_B; 1788 % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1); 1789 % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2); 1790 % [RootPath_nc,RootFile_nc]=fileparts(filebase_nc); 1791 % [RootPath_A,RootFile_A]=fileparts(filebase_A); 1792 1793 1794 %% determine reference files for fix: 1795 file_ref_fix1={};%default 1796 file_ref_fix2={}; 1797 nbfield=length(i1_civ1); 1798 nbslice=length(j1_civ1); 1799 if checkbox(2)==1% fix1 performed 1800 ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback 1801 if ~isempty(ref) 1802 first_i=str2double(get(handles.first_i,'String')); 1803 last_i=str2double(get(handles.last_i,'String')); 1804 incr_i=str2double(get(handles.incr_i,'String')); 1805 first_j=str2double(get(handles.first_j,'String')); 1806 last_j=str2double(get(handles.last_j,'String')); 1807 incr_j=str2double(get(handles.incr_j,'String')); 1808 num_i_ref=first_i:incr_i:last_i; 1809 num_j_ref=first_j:incr_j:last_j; 1810 if isequal(mode,'displacement') 1811 num_i1=num_i_ref; 1812 num_i2=num_i_ref; 1813 num_j1=num_j_ref; 1814 num_j2=num_j_ref; 1815 elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') 1816 num_i1=num_i_ref; 1817 num_i2=num_i1; 1818 num_j1=ref.num_a*ones(size(num_i_ref)); 1819 num_j2=ref.num_b*ones(size(num_i_ref)); 1820 elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') 1821 delta1=floor((ref.num2-ref.num1)/2); 1822 delta2=ceil((ref.num2-ref.num1)/2); 1823 num_i1=num_i_ref-delta1*ones(size(num_i_ref)); 1824 num_i2=num_i_ref+delta2*ones(size(num_i_ref)); 1825 if isempty(ref.num_a) 1826 ref.num_a=1; 1827 end 1828 num_j1=ref.num_a*ones(size(num_i1)); 1829 num_j2=num_j1; 1830 elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') 1831 delta1=floor((ref.num_b-ref.num_a)/2); 1832 delta2=ceil((ref.num_b-ref.num_a)/2); 1833 num_i1=ref.num1*ones(size(num_i_ref)); 1834 num_i2=num_i1; 1835 num_j1=num_j_ref-delta1*ones(size(num_j_ref)); 1836 num_j2=num_j_ref+delta2*ones(size(num_j_ref)); 1837 end 1838 for ifile=1:nbfield 1839 for j=1:nbslice 1840 [RootPathRef,RootFile]=fileparts(ref.filebase); 1841 file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); 1842 file_ref_fix1(ifile,j)={file_ref}; 1843 if ~exist(file_ref,'file') 1844 errormsg=['reference file ' file_ref ' not found for fix1']; 1845 return 1846 end 1847 end 1848 end 1849 end 1850 end 1851 1852 %% determine reference files for fix2: 1853 if checkbox(5)==1% fix2 performed 1854 ref=get(handles.ref_fix2,'UserData'); 1855 if ~isempty(ref) 1856 first_i=str2double(get(handles.first_i,'String')); 1857 last_i=str2double(get(handles.last_i,'String')); 1858 incr_i=str2double(get(handles.incr_i,'String')); 1859 first_j=str2double(get(handles.first_j,'String')); 1860 last_j=str2double(get(handles.last_j,'String')); 1861 incr_j=str2double(get(handles.incr_j,'String')); 1862 num_i_ref=first_i:incr_i:last_i; 1863 num_j_ref=first_j:incr_j:last_j; 1864 if isequal(mode,'displacement') 1865 num_i1=num_i_ref; 1866 num_i2=num_i_ref; 1867 num_j1=num_j_ref; 1868 num_j2=num_j_ref; 1869 elseif isequal(mode,'pair j1-j2') 1870 num_i1=num_i_ref; 1871 num_i2=num_i1; 1872 num_j1=ref.num_a; 1873 num_j2=ref.num_b; 1874 elseif isequal(mode,'series(Di)') 1875 delta1=floor((ref.num2-ref.num1)/2); 1876 delta2=ceil((ref.num2-ref.num1)/2); 1877 num_i1=num_i_ref-delta1*ones(size(num_i_ref)); 1878 num_i2=num_i_ref+delta2*ones(size(num_i_ref)); 1879 num_j1=ref.num_a*ones(size(num_i1)); 1880 num_j2=num_j1; 1881 elseif isequal(mode,'series(Dj)') 1882 delta1=floor((ref.num_b-ref.num_a)/2); 1883 delta2=ceil((ref.num_b-ref.num_a)/2); 1884 num_i1=ref.num1*ones(size(num_i_ref)); 1885 num_i2=num_i1; 1886 num_j1=num_j_ref-delta1*ones(size(num_j_ref)); 1887 num_j2=num_j_ref+delta2*ones(size(num_j_ref)); 1888 end 1889 for ifile=1:nbfield 1890 for j=1:nbslice 1891 [RootPathRef,RootFile]=fileparts(ref.filebase); 1892 file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); 1893 file_ref_fix2(ifile,j)={file_ref}; 1894 if ~exist(file_ref,'file') 1895 errormsg=['reference file ' file_ref ' not found for fix2']; 1896 return 1897 end 1898 end 1899 end 1900 end 1901 end 1902 1903 %% check the existence of the netcdf and image files involved 1904 % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% 1905 if checkbox(1)==1; 1906 detect=1; 1907 vers=0; 1908 subdir_civ1_new=subdir_civ1; 1909 answer='No'; 1910 while detect==1 %create a new subdir if the netcdf files already exist 1911 for ifile=1:nbfield 1912 for j=1:nbslice 1913 filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); 1914 detect=exist(filename,'file')==2; 1915 if detect% if a netcdf file already exists 1916 if strcmp(answer,'No') 1917 answer=msgbox_uvmat('INPUT_Y-N',['overwrite existing civ files in ' subdir_civ1_new]); 1918 end 1919 if strcmp(answer,'Yes') 1920 detect=0; 1921 filecell.nc.civ1(ifile,j)={filename}; 1922 else 1923 r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number 1924 if isempty(r) 1925 r(1).root=[subdir_civ1_new '_']; 1926 r(1).num1='0'; 1927 end 1928 subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 1929 subdir_civ2=subdir_civ1_new; 1930 end 1931 break 1932 end 1933 filecell.nc.civ1(ifile,j)={filename}; 1934 end 1935 if detect% if a netcdf file already exists 1936 break 1937 end 1938 end 1939 1940 %create the new SubdirCiv1 1941 if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') 1942 [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); 1943 if ~strcmp(msg1,'') 1944 errormsg=['cannot create ' subdir_civ1_new ': ' msg1];%error message for directory creation 1945 return 1946 elseif isunix 1947 [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) 1948 if ~strcmp(msg2,'') 1949 errormsg=['pb of permission for ' fullfile(RootPath,subdir_civ1_new) ': ' msg2];%error message for directory creation 1950 return 1951 end 1952 end 1953 end 1954 if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series 1955 for ifile=1:nbfield 1956 for j=1:nbslice 1957 filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); 1958 detect=exist(filename,'file')==2; 1959 if detect% if a netcdf file already exists 1960 indstr=regexp(subdir_civ1_new,'\D'); 1961 if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number 1962 vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; 1963 subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; 1964 else 1965 vers=vers+1; 1966 subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; 1967 end 1968 subdir_civ2=subdir_civ1; 1969 break 1970 end 1971 filecell.ncA.civ1(ifile,j)={filename}; 1972 end 1973 if detect% if a netcdf file already exists 1974 break 1975 end 1976 end 1977 %create the new SubdirCiv1 1978 if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') 1979 [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); 1980 if ~strcmp(msg1,'') 1981 errormsg=['cannot create ' subdir_civ1_new ': ' msg1]; 1982 return 1983 else 1984 [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) 1985 if ~strcmp(msg2,'') 1986 errormsg=['pb of permission for ' subdir_civ1_new ': ' msg2];%error message for directory creation 1987 return 1988 end 1989 end 1990 end 1991 end 1992 end 1993 subdir_civ1=subdir_civ1_new; 1994 % get image names 1995 for ifile=1:nbfield 1996 for j=1:nbslice 1997 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); 1998 idetect(j)=exist(filename,'file')==2; 1999 filecell.ima1.civ1(ifile,j)={filename}; %first image 2000 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); 2001 idetect_1(j)=exist(filename,'file')==2; 2002 filecell.ima2.civ1(ifile,j)={filename};%second image 2003 end 2004 [idetectmin,indexj]=min(idetect); 2005 if idetectmin==0, 2006 errormsg=[filecell.ima1.civ1{ifile,indexj} ' not found']; 2007 return 2008 end 2009 [idetectmin,indexj]=min(idetect_1); 2010 if idetectmin==0, 2011 errormsg=[filecell.ima2.civ1{ifile,indexj} ' not found']; 2012 return 2013 end 2014 end 2015 if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) 2016 for ifile=1:nbfield 2017 for j=1:nbslice 2018 filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); 2019 idetect(j)=exist(filename,'file')==2; 2020 filecell.imaA1.civ1(ifile,j)={filename} ;%first image 2021 filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); 2022 idetect_1(j)=exist(filename,'file')==2; 2023 filecell.imaA2.civ1(ifile,j)={filename};%second image 2024 end 2025 [idetectmin,indexj]=min(idetect); 2026 if idetectmin==0, 2027 errormsg=[filecell.imaA1.civ1{ifile,indexj} ' not found']; 2028 return 2029 end 2030 [idetectmin,indexj]=min(idetect_1); 2031 if idetectmin==0, 2032 errormsg=[filecell.imaA2.civ1{ifile,indexj} ' not found']; 2033 return 2034 end 2035 end 2036 end 2037 2038 %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% 2039 elseif (checkbox(2)==1 || checkbox(3)==1); 2040 for ifile=1:nbfield 2041 for j=1:nbslice 2042 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); 2043 detect=exist(filename,'file')==2; 2044 if detect==0 2045 errormsg=[filename ' not found']; 2046 return 2047 end 2048 filecell.nc.civ1(ifile,j)={filename}; 2049 end 2050 end 2051 if strcmp(compare,'stereo PIV') 2052 for ifile=1:nbfield 2053 for j=1:nbslice 2054 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); 2055 filecell.ncA.civ1(ifile,j)={filename}; 2056 if ~exist(filename,'file') 2057 errormsg=['input file ' filename ' not found']; 2058 return 2059 end 2060 end 2061 end 2062 end 2063 end 2064 2065 %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% 2066 testdiff=0; 2067 if (checkbox(4)==1)&&... 2068 ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) 2069 testdiff=1; 2070 detect=1; 2071 vers=0; 2072 subdir_civ2_new=subdir_civ2; 2073 while detect==1 %create a new subdir if the netcdf files already exist 2074 for ifile=1:nbfield 2075 for j=1:nbslice 2076 filename=fullfile_uvmat(RootPath,subdir_civ2_new,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); 2077 detect=exist(filename,'file')==2; 2078 if detect% if a netcdf file already exists 2079 indstr=regexp(subdir_civ2,'\D'); 2080 if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number 2081 vers=str2double(subdir_civ2(indstr(end)+1:end))+1; 2082 subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; 2083 else 2084 vers=vers+1; 2085 subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; 2086 end 2087 break 2088 end 2089 filecell.nc.civ2(ifile,j)={filename}; 2090 end 2091 if detect% if a netcdf file already exists 2092 break 2093 end 2094 end 2095 %create the new subdir_civ2_new 2096 if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') 2097 [xx,m2]=mkdir(fullfile(RootPath,subdir_civ2_new)); 2098 [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) 2099 if ~isequal(m2,'') 2100 errormsg=['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2]; 2101 return 2102 end 2103 end 2104 if strcmp(compare,'stereo PIV')%check second nc series 2105 for ifile=1:nbfield 2106 for j=1:nbslice 2107 filename=fullfile_uvmat(RootPath,subdir_civ2_new,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); 2108 detect=exist(filename,'file')==2; 2109 if detect% if a netcdf file already exists 2110 indstr=regexp(subdir_civ2,'\D'); 2111 if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number 2112 vers=str2double(subdir_civ2(indstr(end)+1:end))+1; 2113 subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; 2114 else 2115 vers=vers+1; 2116 subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; 2117 end 2118 break 2119 end 2120 filecell.ncA.civ2(ifile,j)={filename}; 2121 end 2122 if detect% if a netcdf file already exists 2123 break 2124 end 2125 end 2126 subdir_civ2=subdir_civ2_new; 2127 %create the new SubdirCiv1 2128 if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') 2129 [xx,m2]=mkdir(subdir_civ2_new); 2130 [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) 2131 if ~isequal(m2,'') 2132 errormsg= ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2];%error message for directory creation 2133 return 2134 end 2135 end 2136 end 2137 end 2138 subdir_civ2=subdir_civ2_new; 2139 end 2140 2141 %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% 2142 if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 2143 %check source netcdf file of checkciv1 estimates 2144 if checkbox(1)==0; %no civ1 performed 2145 for ifile=1:nbfield 2146 for j=1:nbslice 2147 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));% 2148 filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file 2149 if ~exist(filename,'file') 2150 errormsg=['input file ' filename ' not found']; 2151 return 2152 end 2153 if ~testdiff % civ2 or patch2 are written in the same file as civ1 2154 if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated 2155 Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); 2156 if isfield(Data,'Txt') 2157 errormsg=Data.Txt; 2158 return 2159 elseif ~isempty(Data.CivStage)% case of new civ files 2160 if Data.CivStage<4 %test for civ files 2161 errormsg=['no civ2 data in ' filename]; 2162 return 2163 end 2164 elseif isempty(Data.civ2)||isequal(Data.civ2,0) 2165 errormsg=['no civ2 data in ' filename]; 2166 return 2167 end 2168 elseif checkbox(3)==0; %check the existence of patch if it is not calculated 2169 Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); 2170 if isfield(Data,'Txt') 2171 errormsg=Data.Txt; 2172 return 2173 elseif ~isempty(Data.CivStage) 2174 if Data.CivStage<3 %test for civ files 2175 errormsg=['no patch data in ' filename]; 2176 return 2177 end 2178 elseif isempty(Data.patch)||isequal(Data.patch,0) 2179 errormsg=['no patch data in ' filename]; 2180 return 2181 end 2182 end 2183 end 2184 end 2185 end 2186 if strcmp(compare,'stereo PIV') 2187 for ifile=1:nbfield 2188 for j=1:nbslice 2189 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); 2190 filecell.ncA.civ2(ifile,j)={filename}; 2191 if ~exist(filename,'file') 2192 errormsg=['input file ' filename ' not found']; 2193 return 2194 end 2195 end 2196 end 2197 end 2198 end 2199 2200 detect=1; 2201 % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data 2202 for ifile=1:nbfield 2203 for j=1:nbslice 2204 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); 2205 detect=exist(filename,'file')==2; 2206 filecell.nc.civ2(ifile,j)={filename}; 2207 end 2208 end 2209 %get first image names for checkciv2 2210 if checkbox(1)==1 && isequal(i1_civ1,i1_civ2) && isequal(j1_civ1,j1_civ2) 2211 filecell.ima1.civ2=filecell.ima1.civ1; 2212 elseif checkbox(4)==1 2213 for ifile=1:nbfield 2214 for j=1:nbslice 2215 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j)); 2216 idetect_2(j)=exist(filename,'file')==2; 2217 filecell.ima1.civ2(ifile,j)={filename};%first image 2218 end 2219 [idetectmin,indexj]=min(idetect_2); 2220 if idetectmin==0, 2221 errormsg=['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']; 2222 return 2223 end 2224 end 2225 end 2226 2227 %get second image names for checkciv2 2228 if checkbox(1)==1 && isequal(i2_civ1,i2_civ2) && isequal(j2_civ1,j2_civ2) 2229 filecell.ima2.civ2=filecell.ima2.civ1; 2230 elseif checkbox(4)==1 2231 for ifile=1:nbfield 2232 for j=1:nbslice 2233 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j)); 2234 idetect_3(j)=exist(filename,'file')==2; 2235 filecell.ima2.civ2(ifile,j)={filename};%first image 2236 end 2237 [idetectmin,indexj]=min(idetect_3); 2238 if idetectmin==0, 2239 errormsg=['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']; 2240 return 2241 end 2242 end 2243 end 2244 end 2245 if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file 2246 if ~testdiff 2247 filecell.nc.civ2=filecell.nc.civ1;% file already checked 2248 else % check the civ2 files 2249 for ifile=1:nbfield 2250 for j=1:nbslice 2251 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); 2252 filecell.nc.civ2(ifile,j)={filename}; 2253 if ~exist(filename,'file') 2254 errormsg=['input file ' filename ' not found']; 2255 return 2256 else 2257 Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); 2258 if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files 2259 errormsg=['no civ2 data in ' filename]; 2260 return 2261 elseif isempty(Data.civ2)||isequal(Data.civ2,0) 2262 errormsg=['no civ2 data in ' filename]; 2263 return 2264 end 2265 end 2266 end 2267 end 2268 end 2269 end 2270 2271 %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% 2272 if strcmp(compare,'stereo PIV') 2273 if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) 2274 for ifile=1:nbfield 2275 for j=1:nbslice 2276 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_AB,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); 2277 filecell.st(ifile,j)={filename}; 2278 end 2279 end 2280 end 2281 if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) 2282 for ifile=1:nbfield 2283 for j=1:nbslice 2284 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_AB,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); 2285 filecell.st(ifile,j)={filename}; 2286 end 2287 end 2288 end 2289 end 2290 set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubDirImages],''));%suppress the root SuddirImages;);%update the edit box 2291 set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubDirImages],''));%update the edit box 2292 2293 % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED 2294 if strcmp(CivMode,'CivX') 2295 NomType_imanew1=NomType_ima1; 2296 NomType_imanew2=NomType_ima2; 2297 if ~isequal(ext_ima,'.png') 2298 if checkbox(1) %if civ1 is performed 2299 [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ1{1}); 2300 check_j=0; 2301 if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') 2302 if max(j1_civ1)>1 2303 check_j=1; 2304 NomType_imanew1='_1_1'; 2305 else 2306 NomType_imanew1='_1'; 2307 end 2308 end 2309 h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar 2310 for ifile=1:nbfield 2311 waitbar(ifile/nbfield); 2312 for j=1:nbslice 2313 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); 2314 if ~exist(filename,'file') 2315 if check_j 2316 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ1(j)); 2317 else 2318 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ1(ifile)); 2319 end 2320 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2321 end 2322 filecell.ima1.civ1(ifile,j)={filename}; 2323 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew1,i2_civ1(ifile),[],j2_civ1(j)); 2324 if ~exist(filename,'file') 2325 if check_j 2326 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j2_civ1(j)); 2327 else 2328 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i2_civ1(ifile)); 2329 end 2330 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2331 end 2332 filecell.ima2.civ1(ifile,j)={filename}; 2333 end 2334 end 2335 close(h) 2336 end 2337 if checkbox(4) %if civ2 is performed 2338 [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ2{1}); 2339 check_j=0; 2340 if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') 2341 if max(j1_civ2)>1 2342 check_j=1; 2343 NomType_imanew1='_1_1'; 2344 else 2345 NomType_imanew1='_1'; 2346 end 2347 end 2348 h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar 2349 for ifile=1:nbfield 2350 waitbar(ifile/nbfield); 2351 for j=1:nbslice 2352 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); 2353 if ~exist(filename,'file') 2354 if check_j 2355 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); 2356 else 2357 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); 2358 end 2359 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2360 end 2361 filecell.ima1.civ2(ifile,j)={filename}; 2362 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); 2363 if ~exist(filename,'file') 2364 if check_j 2365 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); 2366 else 2367 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); 2368 end 2369 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2370 end 2371 filecell.ima2.civ2(ifile,j)={filename}; 2372 end 2373 end 2374 close(h); 2375 end 2376 end 2377 end 660 2378 661 2379 662 %------------------------------------------------------------------------ … … 2407 690 i2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); 2408 691 j1_civ2=ref_j; 2409 j2_civ2=ref_j; 692 j2_civ2=ref_j; 2410 693 2411 694 % adjust the first and last field number … … 2545 828 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 2546 829 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 2547 [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType, Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]);830 [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,FileInfo,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]); 2548 831 2549 832 %check image nom type … … 2587 870 ref_i=str2double(get(handles.ref_i,'String')); 2588 871 % last_i=str2num(get(handles.last_i,'String')); 2589 time=get(handles.ImaDoc,'UserData'); %get the set of times 872 CivInputData=get(handles.civ_input,'UserData'); 2590 873 TimeUnit=get(handles.TimeUnit,'String'); 2591 874 checkframe=strcmp(TimeUnit,'frame'); 2592 siztime=size(time); 2593 nbfield=siztime(1)-1; 2594 nbfield2=siztime(2)-1; 875 time=CivInputData.Time; 876 siztime=size(CivInputData.Time); 877 nbfield=siztime(2)-1; 878 nbfield2=siztime(1)-1; 2595 879 indchosen=1; %%first pair selected by default 2596 880 %displ_num used to define the indices of the civ_input pairs … … 2612 896 numlist_b(index)=numod_b; 2613 897 if size(time,2)>1 && ~checkframe 2614 dt(numod_a,numod_b)= time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt898 dt(numod_a,numod_b)=CivInputData.Time(ref_i+1,numod_b+1)-CivInputData.Time(ref_i+1,numod_a+1);%first time interval dt 2615 899 displ_dt(index)=dt(numod_a,numod_b); 2616 900 else … … 2810 1094 %% initialisation 2811 1095 errormsg=''; 2812 browse=get(handles.RootPath,'UserData');1096 %browse=get(handles.RootPath,'UserData'); 2813 1097 compare_list=get(handles.ListCompareMode,'String'); 2814 1098 val=get(handles.ListCompareMode,'Value'); -
trunk/src/series/civ_series.m
r598 r599 55 55 Data.Mask='off';...%can use mask option (option 'off'/'on', 'off' by default) 56 56 Data.OutputDirExt='.civ';%set the output dir extension 57 57 58 return 58 59 end -
trunk/src/series/relabel_i_j.m
r563 r599 3 3 % function ParamOut=relabel_i_j(Param) 4 4 %------------------------------------------------------------------------ 5 5 % 6 6 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 7 7 % 8 % This function is used in four modes by the GUI series:9 % 1) config GUI: with no input argument, the function determine the suitable GUI configuration10 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops11 % 3) RUN: the function itself runs, when an appropriate input structure Param has been introduced.12 % 4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input.13 %14 % This function is used in four modes by the GUI series:15 % 1) config GUI: with no input argument, the function determine the suitable GUI configuration16 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops17 % 3) RUN: the function itself runs, when an appropriate input structure Param has been introduced.18 % 4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input.19 %20 8 %OUTPUT 21 % GUI_input=list ofoptions in the GUI series.fig needed for the function9 % ParamOut: sets options in the GUI series.fig needed for the function 22 10 % 23 11 %INPUT: 24 12 % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. 25 13 % In batch mode, Param is the name of the corresponding xml file containing the same information 26 % In the absence of input(as activated when the current Action is selected27 % in series), the function ouput GUI_input set the activation of the needed GUI elements14 % when Param.Action.RUN=0 (as activated when the current Action is selected 15 % in series), the function ouput paramOut set the activation of the needed GUI elements 28 16 % 29 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param) 17 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to 18 % see the current structure Param) 30 19 % .InputTable: cell of input file names, (several lines for multiple input) 31 20 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 32 21 % .OutputSubDir: name of the subdirectory for data outputs 33 % .OutputDir : directory for data outputs, including path22 % .OutputDirExt: directory extension for data outputs 34 23 % .Action: .ActionName: name of the current activated function 35 24 % .ActionPath: path of the current activated function 25 % .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled Matlab fct 26 % .RUN =0 for GUI input, =1 for function activation 27 % .RunMode='local','background', 'cluster': type of function use 28 % 36 29 % .IndexRange: set the file or frame indices on which the action must be performed 37 30 % .FieldTransform: .TransformName: name of the selected transform function 38 31 % .TransformPath: path of the selected transform function 39 % .TransformHandle: corresponding function handle40 32 % .InputFields: sub structure describing the input fields withfields 41 % .FieldName: name of the field33 % .FieldName: name(s) of the field 42 34 % .VelType: velocity type 43 35 % .FieldName_1: name of the second field in case of two input series 44 36 % .VelType_1: velocity type of the second field in case of two input series 37 % .Coord_y: name of y coordinate variable 38 % .Coord_x: name of x coordinate variable 45 39 % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) 46 40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 49 43 50 44 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 51 if ~exist('Param','var') % case with no input parameter 52 ParamOut={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation) 53 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 54 'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 55 'NbSlice';'off'; ...%nbre of slices ('off' by default) 56 'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 57 'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 58 'FieldTransform'; 'off';...%can use a transform function 59 'ProjObject';'off';...%can use projection object(option 'off'/'on', 60 'Mask';'off';...%can use mask option (option 'off'/'on', 'off' by default) 61 'OutputDirExt';'';...%set the output dir extension 62 ''}; 63 return 64 end 65 66 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 67 %% select different modes, RUN, parameter input, BATCH 68 % BATCH case: read the xml file for batch case 45 if isstruct(Param) && isequal(Param.Action.RUN,0) 46 ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 47 ParamOut.WholeIndexRange='on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 48 ParamOut.NbSlice='one'; ...%nbre of slices, 'one' prevents splitting in several processes, ('off' by default) 49 ParamOut.VelType='off';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 50 ParamOut.FieldName='off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 51 ParamOut.FieldTransform = 'off';...%can use a transform function 52 ParamOut.ProjObject='off';...%can use projection object(option 'off'/'on', 53 ParamOut.Mask='off';...%can use mask option (option 'off'/'on', 'off' by default) 54 ParamOut.OutputDirExt='';%set the output dir extension 55 if size(Param.InputTable,1)>1 56 msgbox_uvmat('WARNING', 'this function acts only on the first input file line') 57 end 58 return 59 end 60 61 ParamOut=[]; 62 %%%%%%%%%%%% STANDARD PART %%%%%%%%%%%% 63 %% read input parameters from an xml file if input is a file name (batch mode) 64 checkrun=1; 69 65 if ischar(Param) 70 Param=xml2struct(Param); 71 checkrun=0; 72 % RUN case: parameters introduced as the input structure Param 73 else 74 hseries=guidata(Param.hseries);%handles of the GUI series 75 if isfield(Param,'Specific')&& strcmp(Param.Specific,'?') 76 checkrun=1;% will only search interactive input parameters (preparation of BATCH mode) 77 else 78 checkrun=2; % indicate the RUN option is used 79 end 80 end 81 ParamOut=Param; %default output 66 Param=xml2struct(Param);% read Param as input file (batch case) 67 checkrun=0; 68 end 82 69 83 70 %% root input file(s) and type … … 94 81 % numbers of slices and file indices 95 82 96 NbSlice=1;%default97 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)98 NbSlice=Param.IndexRange.NbSlice;99 end100 nbview=numel(i1_series);%number of input file series (lines in InputTable)101 83 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 102 84 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 103 85 nbfield=nbfield_j*nbfield_i; %total number of fields 104 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices)105 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement106 86 107 87 %determine the file type on each line from the first input file 108 88 ImageTypeOptions={'image','multimage','mmreader','video'}; 109 NcTypeOptions={'netcdf','civx','civdata'}; 110 for iview=1:nbview 111 if ~exist(filecell{iview,1}','file') 112 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist']) 113 return 114 end 115 [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1}); 116 CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images 117 CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files 118 if ~isempty(j1_series{iview}) 119 frame_index{iview}=j1_series{iview}; 120 else 121 frame_index{iview}=i1_series{iview}; 122 end 123 end 89 90 if ~exist(filecell{1,1}','file') 91 msgbox_uvmat('ERROR',['the first input file ' filecell{1,1} ' does not exist']) 92 return 93 end 94 [FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1}); 95 CheckImage=~isempty(find(strcmp(FileType{1},ImageTypeOptions)));% =1 for images 96 124 97 125 98 %% calibration data and timing: read the ImaDoc files … … 128 101 itime=0; 129 102 NbSlice_calib={}; 130 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) 131 for iview=1:nbview%Loop on views 132 SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.' 133 filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder 103 104 SubDirBase=regexprep(SubDir{1},'\..*','');%take the root part of SubDir, before the first dot '.' 105 filexml=[fullfile(RootPath{1},SubDirBase) '.xml'];%new convention: xml at the level of the image folder 106 if ~exist(filexml,'file') 107 filexml=[fullfile(RootPath{1},SubDir{1},RootFile{1}) '.xml']; % old convention: xml inside the image folder 134 108 if ~exist(filexml,'file') 135 filexml=[fullfile(RootPath{ iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder109 filexml=[fullfile(RootPath{1},SubDir{1},RootFile{1}) '.civ']; % very old convention: .civ file 136 110 if ~exist(filexml,'file') 137 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file 138 if ~exist(filexml,'file') 139 filexml=''; 140 end 141 end 142 end 143 if ~isempty(filexml) 144 [XmlData{iview},error]=imadoc2struct_special(filexml); 145 end 146 if isfield(XmlData{iview},'Time') 147 itime=itime+1; 148 timecell{itime}=XmlData{iview}.Time; 149 end 150 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 151 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 152 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 153 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 154 end 111 filexml=''; 112 end 113 end 114 end 115 if ~isempty(filexml) 116 [XmlData,error]=imadoc2struct_special(filexml); 117 end 118 if isfield(XmlData,'Time') 119 itime=itime+1; 120 timecell{itime}=XmlData.Time; 121 end 122 if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') 123 NbSlice_calib{1}=size(XmlData.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 124 if ~isequal(NbSlice_calib{1},NbSlice_calib{1}) 125 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 155 126 end 156 127 end … … 164 135 % EDIT FROM HERE 165 136 166 %% check the validity of input file types167 if CheckImage{1}168 FileExtOut='.png'; % write result as .png images for image inputs169 elseif CheckNc{1}170 FileExtOut='.nc';% write result as .nc files for netcdf inputs171 else172 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])173 return174 end175 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2})176 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')177 return178 end179 % NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series180 % if NbSlice~=nbfield_j181 % answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);182 % if ~strcmp(answer,'Yes')183 % return184 % end185 % end186 137 187 138 %% Set field names and velocity types … … 194 145 display('RDvision system') 195 146 first_label=0; %image numbers start from 0 196 if ~ strcmp(NomType{1},'_000001')147 if ~CheckImage || ~strcmp(NomType{1},'_000001') 197 148 msgbox_uvmat('WARNING','the input is not a file from RDvision: this function relabel_i_j has no action');%error message for directory creation 198 149 return … … 206 157 %% copy and adapt the xml file 207 158 NomTypeNew='_1_1'; 208 if ~isempty(XmlData {1})159 if ~isempty(XmlData) 209 160 t=xmltree(filexml); 210 161 … … 233 184 234 185 %%%% correction RDvision %%%% 235 if isfield(XmlData {1},'NbDtj')186 if isfield(XmlData,'NbDtj') 236 187 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 237 188 uid_value=children(t,uid_NbDtj); 238 189 if ~isempty(uid_value) 239 t=set(t,uid_value(1),'value',num2str(XmlData {1}.NbDtj));240 end 241 end 242 if isfield(XmlData {1},'NbDtk')190 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtj)); 191 end 192 end 193 if isfield(XmlData,'NbDtk') 243 194 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 244 195 uid_value=children(t,uid_NbDtk); 245 196 if ~isempty(uid_value) 246 t=set(t,uid_value(1),'value',num2str(XmlData {1}.NbDtk));247 end 248 end 249 if isempty(j1_series{1}) && isfield(XmlData {1},'NbDti')197 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtk)); 198 end 199 end 200 if isempty(j1_series{1}) && isfield(XmlData,'NbDti') 250 201 uid_Dti=find(t,'ImaDoc/Camera/BurstTiming/Dti'); 251 t=add(t,uid_Dti,'chardata',num2str(XmlData {1}.Dti));202 t=add(t,uid_Dti,'chardata',num2str(XmlData.Dti)); 252 203 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti'); 253 t=add(t,uid_NbDti,'chardata',num2str(XmlData {1}.NbDti));204 t=add(t,uid_NbDti,'chardata',num2str(XmlData.NbDti)); 254 205 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 255 206 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); … … 264 215 SubDirBase=regexprep(SubDir{1},'\..*','');%take the root part of SubDir, before the first dot '.' 265 216 filexml_new=[fullfile(RootPath{1},SubDirBase) '.xml']; 266 save(t,filexml_new)217 % save(t,filexml_new) 267 218 end 268 219 269 220 %% main loop on images 270 221 %j1=[];%default 271 nbfield2=size(XmlData {1}.Time,2);222 nbfield2=size(XmlData.Time,2) 272 223 for ifile=1:nbfield 273 224 if checkrun 274 update_waitbar(hseries.Waitbar,ifile/nbfield) 275 drawnow 276 stopstate=get(hseries.RUN,'BusyAction'); 225 stopstate=get(Param.RUNHandle,'BusyAction'); 226 update_waitbar(Param.WaitbarHandle,ifile/nbfield) 277 227 else 278 228 stopstate='queue'; 279 229 end 280 if isequal(stopstate,'queue') % enable STOP command 281 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile)); 282 j1=mod(ifile-1+first_label,nbfield2)+1; 283 i1=floor((ifile-1+first_label)/nbfield2)+1; 284 filename_new=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomTypeNew,i1,[],j1); 285 try 286 movefile(filename,filename_new); 287 [s,errormsg] = fileattrib(filename_new,'-w','a'); %set images to read only '-w' for all users ('a') 288 if ~s 289 msgbox_uvmat('ERROR',errormsg); 290 return 291 end 292 catch ME 293 msgbox_uvmat('ERROR',ME.message); 230 if ~isequal(stopstate,'queue')% enable STOP command 231 break 232 end 233 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile)); 234 j1=mod(ifile-1+first_label,nbfield2)+1; 235 i1=floor((ifile-1+first_label)/nbfield2)+1; 236 filename_new=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomTypeNew,i1,[],j1); 237 try 238 movefile(filename,filename_new); 239 [s,errormsg] = fileattrib(filename_new,'-w','a'); %set images to read only '-w' for all users ('a') 240 if ~s 241 msgbox_uvmat('ERROR',errormsg); 294 242 return 295 243 end 296 end 244 catch ME 245 msgbox_uvmat('ERROR',ME.message); 246 return 247 end 248 297 249 end 298 250 -
trunk/src/series/sub_background.m
r596 r599 171 171 nbaver_ima=nbaver*step; 172 172 end 173 ParamOut. InputGUI.CheckVolume=strcmp(answer{1},'Yes');174 ParamOut. InputGUI.SlidingSequenceLength=nbaver_ima;175 ParamOut. InputGUI.BrightnessRankThreshold=str2num(answer{3});173 ParamOut.ActionInput.CheckVolume=strcmp(answer{1},'Yes'); 174 ParamOut.ActionInput.SlidingSequenceLength=nbaver_ima; 175 ParamOut.ActionInput.BrightnessRankThreshold=str2num(answer{3}); 176 176 177 177 % apply the image rescaling function 'level' (avoid the blinking effects of bright particles) 178 178 answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background'); 179 ParamOut. InputGUI.CheckLevelTransform=strcmp(answer,'Yes');179 ParamOut.ActionInput.CheckLevelTransform=strcmp(answer,'Yes'); 180 180 return 181 181 end … … 190 190 191 191 %% Input preparation 192 nbaver_ima=Param. InputGUI.SlidingSequenceLength;192 nbaver_ima=Param.ActionInput.SlidingSequenceLength; 193 193 NbSlice=Param.IndexRange.NbSlice; 194 194 if ~isequal(NbSlice,1) … … 225 225 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 226 226 227 if isequal(Param. InputGUI.CheckVolume,1)227 if isequal(Param.ActionInput.CheckVolume,1) 228 228 step=1; 229 229 else 230 230 step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst 231 231 end 232 nbaver_ima=Param. InputGUI.SlidingSequenceLength;%number of images for the sliding background232 nbaver_ima=Param.ActionInput.SlidingSequenceLength;%number of images for the sliding background 233 233 nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background 234 234 if isequal(floor(nbaver/2),nbaver) … … 242 242 243 243 % calculate absolute brightness rank 244 rank=floor(Param. InputGUI.BrightnessRankThreshold*nbaver_ima);244 rank=floor(Param.ActionInput.BrightnessRankThreshold*nbaver_ima); 245 245 if rank==0 246 246 rank=1;%rank selected in the sorted image series … … 346 346 347 347 %write result file 348 if Param. InputGUI.CheckLevelTransform348 if Param.ActionInput.CheckLevelTransform 349 349 C=levels(Acor); 350 350 imwrite(C,newname,'BitDepth',8); % save the new image … … 395 395 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 396 396 %write result file 397 if Param. InputGUI.CheckLevelTransform397 if Param.ActionInput.CheckLevelTransform 398 398 C=levels(Acor); 399 399 imwrite(C,newname,'BitDepth',8); % save the new image … … 430 430 431 431 %write result file 432 if Param. InputGUI.CheckLevelTransform432 if Param.ActionInput.CheckLevelTransform 433 433 C=levels(Acor); 434 434 imwrite(C,newname,'BitDepth',8); % save the new image -
trunk/src/series/time_series.m
r596 r599 45 45 if isstruct(Param) && isequal(Param.Action.RUN,0) 46 46 ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 47 ParamOut.WholeIndexRange='off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)48 ParamOut.NbSlice='on'; ...%nbre of slices ('off' by default)49 ParamOut.VelType='two';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default)50 ParamOut.FieldName='two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)51 ParamOut.FieldTransform = 'on';...%can use a transform function52 ParamOut.ProjObject='on';...%can use projection object(option 'off'/'on',53 ParamOut.Mask='off';...%can use mask option (option 'off'/'on', 'off' by default)54 ParamOut.OutputDirExt='.tseries';%set the output dir extension55 return47 ParamOut.WholeIndexRange='off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 48 ParamOut.NbSlice='on'; ...%nbre of slices ('off' by default) 49 ParamOut.VelType='two';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 50 ParamOut.FieldName='two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 51 ParamOut.FieldTransform = 'on';...%can use a transform function 52 ParamOut.ProjObject='on';...%can use projection object(option 'off'/'on', 53 ParamOut.Mask='off';...%can use mask option (option 'off'/'on', 'off' by default) 54 ParamOut.OutputDirExt='.tseries';%set the output dir extension 55 return 56 56 end 57 57 … … 78 78 % filecell{iview,fileindex}: 79 79 % iview: line in the table corresponding to a given file series 80 % fileindex: file index within the file series, 81 % 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 80 % fileindex: file index within the file series, 81 % 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 82 82 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 83 83 %%%%%%%%%%%% … … 90 90 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 91 91 nbfield=nbfield_j*nbfield_i; %total number of fields 92 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 92 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 93 93 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement 94 94 95 %determine the file type on each line from the first input file 95 %determine the file type on each line from the first input file 96 96 ImageTypeOptions={'image','multimage','mmreader','video'}; 97 97 NcTypeOptions={'netcdf','civx','civdata'}; … … 117 117 if diff_time>0 118 118 displ_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun) 119 end 119 end 120 120 time=time(1,:);% choose the time data from the first sequence 121 121 end … … 130 130 131 131 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 132 132 % EDIT FROM HERE 133 133 134 134 %% check the validity of ctinput file types … … 137 137 elseif CheckNc{1} 138 138 FileExtOut='.nc';% write result as .nc files for netcdf inputs 139 else 139 else 140 140 displ_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun) 141 141 return 142 142 end 143 143 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 144 144 displ_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun) 145 145 return 146 146 end … … 196 196 end 197 197 198 %% LOOP ON SLICES199 198 nbmissing=0; %number of undetected files 200 for i_slice=1:NbSlice 201 index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice 202 nbfile=0; 203 nbmissing=0; 204 205 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 206 for index=index_slice 207 if checkrun 208 stopstate=get(Param.RUNHandle,'BusyAction'); 209 update_waitbar(Param.WaitbarHandle,index/nbfield) 210 else 211 stopstate='queue'; 212 end 213 if isequal(stopstate,'queue')% enable STOP command 214 Data=cell(1,nbview);%initiate the set Data; 215 nbtime=0; 216 dt=[]; 217 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 218 for iview=1:nbview 219 % reading input file(s) 220 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index)); 221 if ~isempty(errormsg) 222 errormsg=['time_series / read_field / ' errormsg]; 223 display(errormsg) 224 break 199 % for i_slice=1:NbSlice 200 %index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice 201 nbfile=0; 202 nbmissing=0; 203 204 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 205 for index=1:nbfield 206 if checkrun 207 stopstate=get(Param.RUNHandle,'BusyAction'); 208 update_waitbar(Param.WaitbarHandle,index/nbfield) 209 else 210 stopstate='queue'; 211 end 212 if ~isequal(stopstate,'queue')% enable STOP command 213 break 214 end 215 Data=cell(1,nbview);%initiate the set Data; 216 nbtime=0; 217 dt=[]; 218 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 219 for iview=1:nbview 220 % reading input file(s) 221 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index)); 222 if ~isempty(errormsg) 223 errormsg=['time_series / read_field / ' errormsg]; 224 display(errormsg) 225 break 226 end 227 if ~isempty(NbSlice_calib) 228 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform 229 end 230 end 231 if isempty(errormsg) 232 Field=Data{1}; % default input field structure 233 % coordinate transform (or other user defined transform) 234 if ~isempty(transform_fct) 235 switch nargin(transform_fct) 236 case 4 237 if length(Data)==2 238 Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 239 else 240 Field=transform_fct(Data{1},XmlData{1}); 241 end 242 case 3 243 if length(Data)==2 244 Field=transform_fct(Data{1},XmlData{1},Data{2}); 245 else 246 Field=transform_fct(Data{1},XmlData{1}); 247 end 248 case 2 249 Field=transform_fct(Data{1},XmlData{1}); 250 case 1 251 Field=transform_fct(Data{1}); 252 end 253 end 254 255 % calculate tps coefficients if needed 256 if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps') 257 Field=tps_coeff_field(Field,check_proj_tps); 258 end 259 260 %field projection on an object 261 if Param.CheckObject 262 [Field,errormsg]=proj_field(Field,Param.ProjObject); 263 if ~isempty(errormsg) 264 msgbox_uvmat('ERROR',['time_series / proj_field / ' errormsg]) 265 return 266 end 267 end 268 nbfile=nbfile+1; 269 270 % initiate the time series at the first iteration 271 if nbfile==1 272 % stop program if the first field reading is in error 273 if ~isempty(errormsg) 274 displ_uvmat('ERROR',['time_series / sub_field / ' errormsg],checkrun) 275 return 276 end 277 DataOut=Field;%default 278 DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots 279 nbvar=length(Field.ListVarName); 280 if nbvar==0 281 displ_uvmat('ERROR','no input variable selected',checkrun) 282 return 283 end 284 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 285 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 286 for ivar=1:nbvar 287 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 288 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 289 if isequal(var_role,'errorflag') 290 displ_uvmat('ERROR','do not handle error flags in time series',checkrun) 291 return 292 end 293 if isequal(var_role,'warnflag') 294 testsum(ivar)=0; % not recorded variable 295 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 296 end 297 if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|... 298 isequal(var_role,'coord_z')|isequal(var_role,'coord') 299 testsum(ivar)=1; %constant coordinates, record without time evolution 300 end 301 end 302 % check whether the variable ivar is a dimension variable 303 DimCell=Field.VarDimName{ivar}; 304 if ischar(DimCell) 305 DimCell={DimCell}; 306 end 307 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables 308 testsum(ivar)=1; 309 end 225 310 end 226 if ~isempty(NbSlice_calib) 227 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform 311 end 312 for ivar=1:nbvar 313 if testsum(ivar)==2 314 eval(['DataOut.' Field.ListVarName{ivar} '=[];']) 228 315 end 229 316 end 230 if isempty(errormsg) 231 Field=Data{1}; % default input field structure 232 % coordinate transform (or other user defined transform) 233 if ~isempty(transform_fct) 234 switch nargin(transform_fct) 235 case 4 236 if length(Data)==2 237 Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 238 else 239 Field=transform_fct(Data{1},XmlData{1}); 317 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 318 end 319 320 % add data to the current field 321 for ivar=1:length(Field.ListVarName) 322 VarName=Field.ListVarName{ivar}; 323 VarVal=Field.(VarName); 324 if testsum(ivar)==2% test for recorded variable 325 if isempty(errormsg) 326 if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 327 if isempty(VarVal) 328 displ_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(index))],checkrun) 329 return 240 330 end 241 case 3 242 if length(Data)==2 243 Field=transform_fct(Data{1},XmlData{1},Data{2}); 244 else 245 Field=transform_fct(Data{1},XmlData{1}); 246 end 247 case 2 248 Field=transform_fct(Data{1},XmlData{1}); 249 case 1 250 Field=transform_fct(Data{1}); 331 VarVal=mean(VarVal,1); 332 end 333 VarVal=shiftdim(VarVal,-1); %shift dimension 334 DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series 335 else 336 DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error 251 337 end 252 end 253 254 % calculate tps coefficients if needed 255 if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps') 256 Field=tps_coeff_field(Field,check_proj_tps); 257 end 258 259 %field projection on an object 260 if Param.CheckObject 261 [Field,errormsg]=proj_field(Field,Param.ProjObject); 262 if ~isempty(errormsg) 263 msgbox_uvmat('ERROR',['time_series / proj_field / ' errormsg]) 338 elseif testsum(ivar)==1% variable representing fixed coordinates 339 VarInit=DataOut.(VarName); 340 if isempty(errormsg) && ~isequal(VarVal,VarInit) 341 displ_uvmat('ERROR',['time series requires constant coordinates ' VarName],checkrun) 264 342 return 265 343 end 266 344 end 267 nbfile=nbfile+1; 268 269 % initiate the time series at the first iteration 270 if nbfile==1 271 % stop program if the first field reading is in error 272 if ~isempty(errormsg) 273 displ_uvmat('ERROR',['time_series / sub_field / ' errormsg],checkrun) 274 return 275 end 276 DataOut=Field;%default 277 DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots 278 nbvar=length(Field.ListVarName); 279 if nbvar==0 280 displ_uvmat('ERROR','no input variable selected',checkrun) 281 return 282 end 283 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 284 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 285 for ivar=1:nbvar 286 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 287 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 288 if isequal(var_role,'errorflag') 289 displ_uvmat('ERROR','do not handle error flags in time series',checkrun) 290 return 291 end 292 if isequal(var_role,'warnflag') 293 testsum(ivar)=0; % not recorded variable 294 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 295 end 296 if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|... 297 isequal(var_role,'coord_z')|isequal(var_role,'coord') 298 testsum(ivar)=1; %constant coordinates, record without time evolution 299 end 300 end 301 % check whether the variable ivar is a dimension variable 302 DimCell=Field.VarDimName{ivar}; 303 if ischar(DimCell) 304 DimCell={DimCell}; 305 end 306 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables 307 testsum(ivar)=1; 308 end 309 end 310 end 311 for ivar=1:nbvar 312 if testsum(ivar)==2 313 eval(['DataOut.' Field.ListVarName{ivar} '=[];']) 314 end 315 end 316 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 317 end 318 319 % add data to the current field 320 for ivar=1:length(Field.ListVarName) 321 VarName=Field.ListVarName{ivar}; 322 VarVal=Field.(VarName); 323 if testsum(ivar)==2% test for recorded variable 324 if isempty(errormsg) 325 if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 326 if isempty(VarVal) 327 displ_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(index))],checkrun) 328 return 329 end 330 VarVal=mean(VarVal,1); 331 end 332 VarVal=shiftdim(VarVal,-1); %shift dimension 333 DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series 334 else 335 DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error 336 end 337 elseif testsum(ivar)==1% variable representing fixed coordinates 338 VarInit=DataOut.(VarName); 339 if isempty(errormsg) && ~isequal(VarVal,VarInit) 340 displ_uvmat('ERROR',['time series requires constant coordinates ' VarName],checkrun) 341 return 342 end 343 end 344 end 345 346 % record the time: 347 if isempty(time)% time not set by xml filer(s) 348 if isfield(Data{1},'Time') 349 DataOut.Time(nbfile,1)=Field.Time; 350 else 351 DataOut.Time(nbfile,1)=index;%default 352 end 353 else % time from ImaDoc prevails TODO: correct 354 DataOut.Time(nbfile,1)=time(index);% 355 end 356 357 % record the number of missing input fields 358 if ~isempty(errormsg) 359 nbmissing=nbmissing+1; 360 display(['index=' num2str(index) ':' errormsg]) 361 end 362 end 363 end 364 end 365 %%%%%%% END OF LOOP WITHIN A SLICE 345 end 346 347 % record the time: 348 if isempty(time)% time not set by xml filer(s) 349 if isfield(Data{1},'Time') 350 DataOut.Time(nbfile,1)=Field.Time; 351 else 352 DataOut.Time(nbfile,1)=index;%default 353 end 354 else % time from ImaDoc prevails TODO: correct 355 DataOut.Time(nbfile,1)=time(index);% 356 end 357 358 % record the number of missing input fields 359 if ~isempty(errormsg) 360 nbmissing=nbmissing+1; 361 display(['index=' num2str(index) ':' errormsg]) 362 end 363 end 366 364 367 %remove time for global attributes if exists 368 Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute)); 369 if ~isempty(Time_index) 370 DataOut.ListGlobalAttribute(Time_index)=[]; 371 end 372 DataOut.Conventions='uvmat'; 373 for ivar=1:numel(DataOut.ListVarName) 374 VarName=DataOut.ListVarName{ivar}; 375 eval(['DataOut.' VarName '=squeeze(DataOut.' VarName ');']) %remove singletons 376 end 377 378 % add time dimension 379 for ivar=1:length(Field.ListVarName) 380 DimCell=Field.VarDimName(ivar); 381 if testsum(ivar)==2%variable used as time series 382 DataOut.VarDimName{ivar}=[{'Time'} DimCell]; 383 elseif testsum(ivar)==1 384 DataOut.VarDimName{ivar}=DimCell; 385 end 386 end 387 indexremove=find(~testsum); 388 if ~isempty(indexremove) 389 DataOut.ListVarName(1+indexremove)=[]; 390 DataOut.VarDimName(indexremove)=[]; 391 if isfield(DataOut,'Role') && ~isempty(DataOut.Role{1})%generaliser aus autres attributs 392 DataOut.Role(1+indexremove)=[]; 393 end 394 end 395 396 %shift variable attributes 397 if isfield(DataOut,'VarAttribute') 398 DataOut.VarAttribute=[{[]} DataOut.VarAttribute]; 399 end 400 DataOut.VarDimName=[{'Time'} DataOut.VarDimName]; 401 DataOut.Action=Param.Action;%name of the processing programme 402 test_time=diff(DataOut.Time)>0;% test that the readed time is increasing (not constant) 403 if ~test_time 404 DataOut.Time=1:filecounter; 405 end 406 407 % display nbmissing 408 if ~isequal(nbmissing,0) 409 displ_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'],checkrun) 410 end 411 412 %name of result file 413 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]); 414 errormsg=struct2nc(OutputFile,DataOut); %save result file 415 if isempty(errormsg) 416 display([OutputFile ' written']) 417 else 418 displ_uvmat('ERROR',['error in Series/struct2nc: ' errormsg],checkrun) 419 end 420 end 365 end 366 %%%%%%% END OF LOOP WITHIN A SLICE 367 368 %remove time for global attributes if exists 369 Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute)); 370 if ~isempty(Time_index) 371 DataOut.ListGlobalAttribute(Time_index)=[]; 372 end 373 DataOut.Conventions='uvmat'; 374 for ivar=1:numel(DataOut.ListVarName) 375 VarName=DataOut.ListVarName{ivar}; 376 eval(['DataOut.' VarName '=squeeze(DataOut.' VarName ');']) %remove singletons 377 end 378 379 % add time dimension 380 for ivar=1:length(Field.ListVarName) 381 DimCell=Field.VarDimName(ivar); 382 if testsum(ivar)==2%variable used as time series 383 DataOut.VarDimName{ivar}=[{'Time'} DimCell]; 384 elseif testsum(ivar)==1 385 DataOut.VarDimName{ivar}=DimCell; 386 end 387 end 388 indexremove=find(~testsum); 389 if ~isempty(indexremove) 390 DataOut.ListVarName(1+indexremove)=[]; 391 DataOut.VarDimName(indexremove)=[]; 392 if isfield(DataOut,'Role') && ~isempty(DataOut.Role{1})%generaliser aus autres attributs 393 DataOut.Role(1+indexremove)=[]; 394 end 395 end 396 397 %shift variable attributes 398 if isfield(DataOut,'VarAttribute') 399 DataOut.VarAttribute=[{[]} DataOut.VarAttribute]; 400 end 401 DataOut.VarDimName=[{'Time'} DataOut.VarDimName]; 402 DataOut.Action=Param.Action;%name of the processing programme 403 test_time=diff(DataOut.Time)>0;% test that the readed time is increasing (not constant) 404 if ~test_time 405 DataOut.Time=1:filecounter; 406 end 407 408 % display nbmissing 409 if ~isequal(nbmissing,0) 410 displ_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'],checkrun) 411 end 412 413 %name of result file 414 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]); 415 errormsg=struct2nc(OutputFile,DataOut); %save result file 416 if isempty(errormsg) 417 display([OutputFile ' written']) 418 else 419 displ_uvmat('ERROR',['error in Series/struct2nc: ' errormsg],checkrun) 420 end 421 421 422 422 423 %% plot the time series (the last one in case of multislices) … … 425 426 haxes=axes; 426 427 plot_field(DataOut,haxes) 427 428 428 429 %% display the result file using the GUI get_field 429 430 hget_field=findobj(allchild(0),'name','get_field'); -
trunk/src/uvmat.m
r598 r599 542 542 end 543 543 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 544 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType, MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);544 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 545 545 % initiate the input file series and refresh the current field view: 546 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType, MovieObject,1);546 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,1); 547 547 548 548 %----------------------------------------------------------------------- … … 672 672 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 673 673 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 674 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType, MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);674 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); 675 675 676 676 %% open the file or fill the GUI uvmat according to the detected file type … … 2663 2663 plot_handles{2}=guidata(view_field_handle); 2664 2664 haxes(2)=plot_handles{2}.PlotAxes; 2665 PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface 2665 PlotParam{2}=read_GUI(view_field_handle); 2666 % PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface 2666 2667 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2667 2668 end -
trunk/src/view_field.m
r591 r599 82 82 if isfield(PlotParamOut,'Vectors') 83 83 set(handles.Vectors,'Visible','on') 84 else 85 set(handles.Vectors,'Visible','off') 86 end 87 if isfield(PlotParamOut,'Scalar') 88 set(handles.Scalar,'Visible','on') 89 else 90 set(handles.Scalar,'Visible','off') 84 91 end 85 92 errormsg=fill_GUI(PlotParamOut,hObject);
Note: See TracChangeset
for help on using the changeset viewer.