- Timestamp:
- Jun 17, 2012, 10:52:04 PM (13 years ago)
- Location:
- trunk/src/series
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r454 r457 1 1 %'aver_stat': calculate field average, used with series.fig 2 % this function can be used as a template for applying a global operation (here averaging) on a series of input fields 2 3 %------------------------------------------------------------------------ 3 % function GUI_input=aver_stat(Param)4 % function ParamOut=aver_stat(Param) 4 5 % 5 6 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 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 configuration 10 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 11 % 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 configuration 16 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 17 % 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 % 6 20 %OUTPUT 7 21 % GUI_input=list of options in the GUI series.fig needed for the function … … 32 46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 47 34 function GUI_input=aver_stat(Param)48 function ParamOut=aver_stat(Param) 35 49 36 50 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 37 51 if ~exist('Param','var') % case with no input parameter 38 GUI_input={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation)52 ParamOut={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation) 39 53 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 54 'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 40 55 'NbSlice';'on'; ...%nbre of slices ('off' by default) 41 56 'VelType';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) … … 50 65 51 66 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 52 %% get input parameters, file names and indices67 %% select different modes, RUN, parameter input, BATCH 53 68 % BATCH case: read the xml file for batch case 54 if ischar(Param) && ~isempty(find(regexp(Param,'.xml$'))) 55 Param=xml2struct(Param); 56 checkrun=0; 57 % RUN case: parameters introduced as the input structure Param 58 else 69 ParamOut=Param; %default output 70 if ischar(Param) 71 if strcmp(Param,'input?') 72 checkrun=1;% will inly search input parameters (preparation of BATCH mode) 73 else 74 Param=xml2struct(Param); 75 checkrun=0; 76 end 77 % RUN case: parameters introduced as the input structure Param 78 else 59 79 hseries=guidata(Param.hseries);%handles of the GUI series 60 80 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 61 checkrun=1; % indicate the RUN option is used 62 end 81 checkrun=2; % indicate the RUN option is used 82 end 83 84 %% root input file(s) and type 85 RootPath=Param.InputTable(:,1); 86 RootFile=Param.InputTable(:,3); 87 SubDir=Param.InputTable(:,2); 88 NomType=Param.InputTable(:,4); 89 FileExt=Param.InputTable(:,5); 90 63 91 % get the set of input file names (cell array filecell), and the lists of 64 92 % input file or frame indices i1_series,i2_series,j1_series,j2_series 65 66 93 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 67 68 94 % filecell{iview,fileindex}: cell array representing the list of file names 69 95 % iview: line in the table corresponding to a given file series … … 72 98 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 73 99 % set of frame indices used for movie or multimage input 74 75 76 %% root input file(s) and type77 RootPath=Param.InputTable(:,1);78 RootFile=Param.InputTable(:,3);79 SubDir=Param.InputTable(:,2);80 NomType=Param.InputTable(:,4);81 FileExt=Param.InputTable(:,5);82 83 100 % numbers of slices and file indices 101 84 102 NbSlice=1;%default 85 if isfield(Param.IndexRange,'NbSlice') 103 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) 86 104 NbSlice=Param.IndexRange.NbSlice; 87 105 end 88 106 nbview=numel(i1_series);%number of input file series (lines in InputTable) 89 nbfield_j=size(i1_series{1},1); %nb of consecutivefields for the j index (bursts or volume slices)90 nbfield_i=size(i1_series{1},2); %nb of consecutivefields for the i index91 nbfield=nbfield_j*nbfield_i; %total number of fi les or frames107 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 108 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 109 nbfield=nbfield_j*nbfield_i; %total number of fields 92 110 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 93 111 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement … … 96 114 ImageTypeOptions={'image','multimage','mmreader','video'}; 97 115 NcTypeOptions={'netcdf','civx','civdata'}; 98 99 116 for iview=1:nbview 100 117 if ~exist(filecell{iview,1}','file') … … 117 134 itime=0; 118 135 NbSlice_calib={}; 136 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) 119 137 for iview=1:nbview%Loop on views 120 XmlData{iview}=[];%default 121 filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); 122 if exist([filebase{iview} '.xml'],'file') 123 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); 124 if isfield(XmlData{iview},'Time') 125 itime=itime+1; 126 timecell{itime}=XmlData{iview}.Time; 127 end 128 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 129 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 130 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 131 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 132 end 133 end 134 elseif exist([filebase{iview} '.civ'],'file') 135 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); 138 SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.' 139 filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder 140 if ~exist(filexml,'file') 141 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder 142 if ~exist(filexml,'file') 143 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file 144 if ~exist(filexml,'file') 145 filexml=''; 146 end 147 end 148 end 149 if ~isempty(filexml) 150 [XmlData{iview},error]=imadoc2struct(filexml); 151 end 152 if isfield(XmlData{iview},'Time') 136 153 itime=itime+1; 137 timecell{itime}=time; 138 XmlData{iview}.Time=time; 139 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; 140 GeometryCalib.Tx=0; 141 GeometryCalib.Ty=0; 142 GeometryCalib.Tz=1; 143 GeometryCalib.dpx=1; 144 GeometryCalib.dpy=1; 145 GeometryCalib.sx=1; 146 GeometryCalib.Cx=0; 147 GeometryCalib.Cy=0; 148 GeometryCalib.f=1; 149 GeometryCalib.kappa1=0; 150 GeometryCalib.CoordUnit='cm'; 151 XmlData{iview}.GeometryCalib=GeometryCalib; 152 if error==1 153 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 154 timecell{itime}=XmlData{iview}.Time; 155 end 156 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 157 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 158 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 159 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 154 160 end 155 161 end … … 182 188 end 183 189 end 184 if size(time,2) < i2_series{1}(end) || size(time,3) < j2_series{1}(end)% time array absent or too short in ImaDoc xml file'190 if size(time,2) < i2_series{1}(end) ||( ~isempty(j2_series{1}) && size(time,3) < j2_series{1}(end))% time array absent or too short in ImaDoc xml file' 185 191 time=[]; 186 192 end … … 283 289 284 290 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 285 index286 291 for iview=1:nbview 287 292 % reading input file(s) … … 369 374 msgbox_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted']) 370 375 end 371 if isempty(time) % time read from files prevails376 if isempty(time) % time is read from files 372 377 if isfield(Field,'Time') 373 378 time_end=Field.Time(1);%last time read … … 377 382 end 378 383 end 379 else % time from ImaDoc prevails 380 DataOut.Time=time(1,i1_series{1}(1),j1_series{1}(1)); 384 else % time from ImaDoc prevails if it exists 385 j1=1;%default 386 if ~isempty(j1_series{1}) 387 j1=j1_series{1}; 388 end 389 DataOut.Time=time(1,i1_series{1}(1),j1filexml); 381 390 DataOut.Time_end=time(end,i1_series{end}(end),j1_series{end}(end)); 382 391 end -
trunk/src/series/check_data_files.m
r455 r457 32 32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 33 34 function GUI_input=check_data_files(Param)34 function ParamOut=check_data_files(Param) 35 35 36 36 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 37 37 if ~exist('Param','var') % case with no input parameter 38 GUI_input={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation)38 ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation) 39 39 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 40 40 'NbSlice';'on'; ...%nbre of slices ('off' by default) … … 51 51 %% get input parameters, file names and indices 52 52 % BATCH case: read the xml file for batch case 53 ParamOut=Param; %default output 53 54 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 54 55 Param=xml2struct(Param); -
trunk/src/series/ima_levels.m
r454 r457 1 1 %'ima_levels': rescale the image intensity to reduce strong luminosity peaks (their blinking effects often perturbs PIV)) 2 % this function can be used as a template for applying a transform (here 'levels.m') oneach image of a series2 % this function can be used as a template for applying a transform (here 'levels.m') to each image of a series 3 3 %------------------------------------------------------------------------ 4 4 % function GUI_input=ima_levels(Param) 5 5 % 6 6 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 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 configuration 10 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 11 % 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 % 7 14 %OUTPUT 8 15 % GUI_input=list of options in the GUI series.fig needed for the function … … 50 57 end 51 58 52 %% get input parameters, file names and indices 59 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 60 %% select different modes, RUN, parameter input, BATCH 53 61 % BATCH case: read the xml file for batch case 54 if ischar(Param) && ~isempty(find(regexp(Param,'.xml$'))) 55 Param=xml2struct(Param); 56 checkrun=0; 57 % RUN case: parameters introduced as the input structure Param 58 else 62 if ischar(Param) 63 if strcmp(Param,'input?') 64 checkrun=1;% will inly search input parameters (preparation of BATCH mode) 65 else 66 Param=xml2struct(Param); 67 checkrun=0; 68 end 69 % RUN case: parameters introduced as the input structure Param 70 else 59 71 hseries=guidata(Param.hseries);%handles of the GUI series 60 72 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 61 checkrun=1; % indicate the RUN option is used 62 end 63 64 % get the set of input file names (cell array filecell), and the lists of 65 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 73 checkrun=2; % indicate the RUN option is used 74 end 66 75 67 76 %% root input file(s) and type … … 72 81 FileExt=Param.InputTable(:,5); 73 82 83 % get the set of input file names (cell array filecell), and the lists of 84 % input file or frame indices i1_series,i2_series,j1_series,j2_series 85 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 86 % filecell{iview,fileindex}: cell array representing the list of file names 87 % iview: line in the table corresponding to a given file series 88 % fileindex: file index within the file series, 89 % 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 90 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 91 % set of frame indices used for movie or multimage input 74 92 % numbers of slices and file indices 93 75 94 NbSlice=1;%default 76 95 if isfield(Param.IndexRange,'NbSlice') … … 78 97 end 79 98 nbview=numel(i1_series);%number of input file series (lines in InputTable) 80 nbfield_j=size(i1_series{1},1); %nb of consecutivefields for the j index (bursts or volume slices)81 nbfield_i=size(i1_series{1},2); %nb of consecutivefields for the i index82 nbfield=nbfield_j*nbfield_i; %total number of fi les or frames99 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 100 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 101 nbfield=nbfield_j*nbfield_i; %total number of fields 83 102 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 84 103 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement … … 86 105 %determine the file type on each line from the first input file 87 106 ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images) 107 88 108 [FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1}); 89 109 CheckImage{1}=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images -
trunk/src/series/merge_proj.m
r447 r457 1 2 3 4 5 6 %'merge_proj': project and concatene fields, used with series.fig 1 %'merge_proj': project and concatene fieldsmerge_proj 2 % can be used as a template for applying an operation (here projection and concateantion) on each field of an input series 7 3 %------------------------------------------------------------------------ 8 % function GUI_input=merge_proj(Param) 4 % function GUI_config=merge_proj(Param) 5 %------------------------------------------------------------------------ 6 7 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 9 8 % 9 % This function is used in four modes by the GUI series: 10 % 1) config GUI: with no input argument, the function determine the suitable GUI configuration 11 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 12 % 3) RUN: the function itself runs, when an appropriate input structure Param has been introduced. 13 % 4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input. 14 % 15 % This function is used in four modes by the GUI series: 16 % 1) config GUI: with no input argument, the function determine the suitable GUI configuration 17 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 18 % 3) RUN: the function itself runs, when an appropriate input structure Param has been introduced. 19 % 4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input. 20 % 21 %OUTPUT 22 % GUI_input=list of options in the GUI series.fig needed for the function 23 % 24 %INPUT: 25 % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. 26 % In batch mode, Param is the name of the corresponding xml file containing the same information 27 % In the absence of input (as activated when the current Action is selected 28 % in series), the function ouput GUI_input set the activation of the needed GUI elements 29 % 30 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param) 31 % .InputTable: cell of input file names, (several lines for multiple input) 32 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 33 % .OutputSubDir: name of the subdirectory for data outputs 34 % .OutputDir: directory for data outputs, including path 35 % .Action: .ActionName: name of the current activated function 36 % .ActionPath: path of the current activated function 37 % .IndexRange: set the file or frame indices on which the action must be performed 38 % .FieldTransform: .TransformName: name of the selected transform function 39 % .TransformPath: path of the selected transform function 40 % .TransformHandle: corresponding function handle 41 % .InputFields: sub structure describing the input fields withfields 42 % .FieldName: name of the field 43 % .VelType: velocity type 44 % .FieldName_1: name of the second field in case of two input series 45 % .VelType_1: velocity type of the second field in case of two input series 46 % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) 47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48 49 function GUI_input=merge_proj(Param) 50 51 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 52 if ~exist('Param','var') % case with no input parameter 53 GUI_input={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation) 54 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 55 'NbSlice';'on'; ...%nbre of slices ('off' by default) 56 'VelType';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 57 'FieldName';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 58 'FieldTransform'; 'on';...%can use a transform function 59 'ProjObject';'on';...%can use projection object(option 'off'/'on', 60 'Mask';'on';...%can use mask option (option 'off'/'on', 'off' by default) 61 'OutputDirExt';'.proj';...%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 69 if ischar(Param) 70 if strcmp(Param,'input?') 71 checkrun=1;% will inly search input parameters (preparation of BATCH mode) 72 else 73 Param=xml2struct(Param); 74 checkrun=0; 75 end 76 % RUN case: parameters introduced as the input structure Param 77 else 78 hseries=guidata(Param.hseries);%handles of the GUI series 79 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 80 checkrun=2; % indicate the RUN option is used 81 end 82 83 %% root input file(s) and type 84 RootPath=Param.InputTable(:,1); 85 RootFile=Param.InputTable(:,3); 86 SubDir=Param.InputTable(:,2); 87 NomType=Param.InputTable(:,4); 88 FileExt=Param.InputTable(:,5); 89 90 % get the set of input file names (cell array filecell), and the lists of 91 % input file or frame indices i1_series,i2_series,j1_series,j2_series 92 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 93 % filecell{iview,fileindex}: cell array representing the list of file names 94 % iview: line in the table corresponding to a given file series 95 % fileindex: file index within the file series, 96 % 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 97 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 98 % set of frame indices used for movie or multimage input 99 % numbers of slices and file indices 100 101 NbSlice=1;%default 102 if isfield(Param.IndexRange,'NbSlice') 103 NbSlice=Param.IndexRange.NbSlice; 104 end 105 nbview=numel(i1_series);%number of input file series (lines in InputTable) 106 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 107 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 108 nbfield=nbfield_j*nbfield_i; %total number of fields 109 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 110 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement 111 112 %determine the file type on each line from the first input file 113 ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images) 114 115 [FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1}); 116 CheckImage{1}=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images 117 if ~isempty(j1_series{1}) 118 frame_index{1}=j1_series{1}; 119 else 120 frame_index{1}=i1_series{1}; 121 end 122 123 %% calibration data and timing: read the ImaDoc files 124 mode=''; %default 125 timecell={}; 126 itime=0; 127 NbSlice_calib={}; 128 for iview=1:nbview%Loop on views 129 XmlData{iview}=[];%default 130 filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); 131 if exist([filebase{iview} '.xml'],'file') 132 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); 133 if isfield(XmlData{iview},'Time') 134 itime=itime+1; 135 timecell{itime}=XmlData{iview}.Time; 136 end 137 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 138 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 139 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 140 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 141 end 142 end 143 elseif exist([filebase{iview} '.civ'],'file') 144 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); 145 itime=itime+1; 146 timecell{itime}=time; 147 XmlData{iview}.Time=time; 148 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; 149 GeometryCalib.Tx=0; 150 GeometryCalib.Ty=0; 151 GeometryCalib.Tz=1; 152 GeometryCalib.dpx=1; 153 GeometryCalib.dpy=1; 154 GeometryCalib.sx=1; 155 GeometryCalib.Cx=0; 156 GeometryCalib.Cy=0; 157 GeometryCalib.f=1; 158 GeometryCalib.kappa1=0; 159 GeometryCalib.CoordUnit='cm'; 160 XmlData{iview}.GeometryCalib=GeometryCalib; 161 if error==1 162 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 163 end 164 end 165 end 166 167 %% check coincidence in time for several input file series 168 multitime=0; 169 if isempty(timecell) 170 time=[]; 171 elseif length(timecell)==1 172 time=timecell{1}; 173 elseif length(timecell)>1 174 multitime=1; 175 for icell=1:length(timecell) 176 if ~isequal(size(timecell{icell}),size(timecell{1})) 177 msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') 178 time=timecell{1}; 179 multitime=0; 180 break 181 end 182 end 183 end 184 if multitime 185 for icell=1:length(timecell) 186 time(icell,:,:)=timecell{icell}; 187 end 188 diff_time=max(max(diff(time))); 189 if diff_time>0 190 msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)]) 191 end 192 end 193 if size(time,2) < i2_series{1}(end) || size(time,3) < j2_series{1}(end)% time array absent or too short in ImaDoc xml file' 194 time=[]; 195 end 196 197 %% coordinate transform or other user defined transform 198 transform_fct='';%default 199 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle') 200 transform_fct=Param.FieldTransform.TransformHandle; 201 end 202 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 203 % EDIT FROM HERE 204 205 %% check the validity of input file types 206 if CheckImage{1} 207 FileExtOut='.png'; % write result as .png images for image inputs 208 elseif CheckNc{1} 209 FileExtOut='.nc';% write result as .nc files for netcdf inputs 210 else 211 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}]) 212 return 213 end 214 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 215 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') 216 return 217 end 218 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 219 if NbSlice~=nbfield_j 220 answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); 221 if ~strcmp(answer,'Yes') 222 return 223 end 224 end 225 226 %% Set field names and velocity types 227 InputFields{1}=[];%default (case of images) 228 if isfield(Param,'InputFields') 229 InputFields{1}=Param.InputFields; 230 end 231 if nbview==2 232 InputFields{2}=[];%default (case of images) 233 if isfield(Param,'InputFields') 234 InputFields{2}=Param.InputFields{1};%default 235 if isfield(Param.InputFields,'FieldName_1') 236 InputFields{2}.FieldName=Param.InputFields.FieldName_1; 237 if isfield(Param.InputFields,'VelType_1') 238 InputFields{2}.VelType=Param.InputFields.VelType_1; 239 end 240 end 241 end 242 end 243 244 %% Initiate output fields 245 %initiate the output structure as a copy of the first input one (reproduce fields) 246 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1); 247 if ~isempty(errormsg) 248 msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg]) 249 return 250 end 251 time_1=[]; 252 if isfield(DataOut,'Time') 253 time_1=DataOut.Time(1); 254 end 255 if CheckNc{iview} 256 if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute)) 257 DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute]; 258 end 259 DataOut.Conventions='uvmat'; 260 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}]; 261 ActionKey='Action'; 262 while isfield(DataOut,ActionKey) 263 ActionKey=[ActionKey '_1']; 264 end 265 DataOut.(ActionKey)=Param.Action; 266 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}]; 267 if isfield(DataOut,'Time') 268 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}]; 269 end 270 end 271 272 %% MAIN LOOP ON SLICES 273 %%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 274 for i_slice=1:NbSlice 275 index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice 276 nbfiles=0; 277 nbmissing=0; 278 279 %initiate result fields 280 for ivar=1:length(DataOut.ListVarName) 281 DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero 282 end 283 284 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 285 for index=index_slice 286 if checkrun 287 update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield)) 288 stopstate=get(hseries.RUN,'BusyAction'); 289 else 290 stopstate='queue'; 291 end 10 292 %OUTPUT 11 293 % GUI_input=list of options in the GUI series.fig needed for the function … … 15 297 % or name of the xml file containing these parameters (BATCH case) 16 298 % 17 function GUI_input=merge_proj(Param) 18 19 %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 20 if ~exist('Param','var') 21 GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') 22 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) 23 'RootFile';'on';... %root input file name ('on' by default) 24 'FileExt';'on';... %input file extension ('on' by default) 25 'NomType';'on';...%type of file indexing ('on' by default) 26 'NbSlice';'on'; ...%nbre of slices ('off' by default) 27 'VelTypeMenu';'one';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default) 28 'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 29 'CoordType';'on';...%can use a transform function 'off' by default 30 'GetObject';'on';...%can use projection object ,'off' by default 31 'OutputDirExt';'.proj';... 32 %'GetMask';'on'...%can use mask option ,'off' by default 33 %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter 34 ''}; 35 return %exit the function 36 end 37 38 %% input parameters: 39 % read the xml file for batch case 40 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 41 Param=xml2struct(Param); 42 else % RUN case : parameters introduced as the input structure Param 43 hseries=guidata(Param.hseries);%handles of the GUI series 44 WaitbarPos=get(hseries.waitbar_frame,'Position');% info for the waitbar 45 end 46 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 47 48 %% coordinate transform or other user defined transform 49 transform_fct='';%default 50 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'fct_handle') 51 transform_fct=Param.FieldTransform.fct_handle; 52 end 299 53 300 54 301 %% projection object -
trunk/src/series/relabel_i_j.m
r249 r457 1 1 %'relabel_i_j': relabel an image series with two indices, and correct errors from the RDvision transfer program 2 %---------------------------------------------------------------------- 3 function GUI_input=relabel_i_j(num_i1,num_i2,num_j1,num_j2,Series) 4 %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 5 6 GUI_input={}; 7 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%enable waitbar 9 hGUI=findobj(allchild(0),'name','series'); 10 hseries=guidata(hGUI);%handles of the GUI series 11 WaitbarPos=get(hseries.waitbar_frame,'Position'); 12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 14 %% PARAMETERS (for RDvision system) 2 %------------------------------------------------------------------------ 3 % function GUI_config=relabel_i_j(Param) 4 %------------------------------------------------------------------------ 5 6 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 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 configuration 10 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 11 % 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 configuration 16 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 17 % 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 %OUTPUT 21 % GUI_input=list of options in the GUI series.fig needed for the function 22 % 23 %INPUT: 24 % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. 25 % 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 selected 27 % in series), the function ouput GUI_input set the activation of the needed GUI elements 28 % 29 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param) 30 % .InputTable: cell of input file names, (several lines for multiple input) 31 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 32 % .OutputSubDir: name of the subdirectory for data outputs 33 % .OutputDir: directory for data outputs, including path 34 % .Action: .ActionName: name of the current activated function 35 % .ActionPath: path of the current activated function 36 % .IndexRange: set the file or frame indices on which the action must be performed 37 % .FieldTransform: .TransformName: name of the selected transform function 38 % .TransformPath: path of the selected transform function 39 % .TransformHandle: corresponding function handle 40 % .InputFields: sub structure describing the input fields withfields 41 % .FieldName: name of the field 42 % .VelType: velocity type 43 % .FieldName_1: name of the second field in case of two input series 44 % .VelType_1: velocity type of the second field in case of two input series 45 % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) 46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 48 function GUI_config=relabel_i_j(Param) 49 50 %% 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 GUI_config={'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 69 GUI_config=Param;%reproduce the input parameters, no interactive input 70 if ischar(Param) 71 if strcmp(Param,'input?') 72 checkrun=1;% will inly search input parameters (preparation of BATCH mode) 73 else 74 Param=xml2struct(Param); 75 checkrun=0; 76 end 77 % RUN case: parameters introduced as the input structure Param 78 else 79 hseries=guidata(Param.hseries);%handles of the GUI series 80 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 81 checkrun=2; % indicate the RUN option is used 82 end 83 84 %% root input file(s) and type 85 RootPath=Param.InputTable(:,1); 86 RootFile=Param.InputTable(:,3); 87 SubDir=Param.InputTable(:,2); 88 NomType=Param.InputTable(:,4); 89 FileExt=Param.InputTable(:,5); 90 91 % get the set of input file names (cell array filecell), and the lists of 92 % input file or frame indices i1_series,i2_series,j1_series,j2_series 93 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 94 % filecell{iview,fileindex}: cell array representing the list of file names 95 % iview: line in the table corresponding to a given file series 96 % fileindex: file index within the file series, 97 % 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 98 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 99 % set of frame indices used for movie or multimage input 100 % numbers of slices and file indices 101 102 NbSlice=1;%default 103 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) 104 NbSlice=Param.IndexRange.NbSlice; 105 end 106 nbview=numel(i1_series);%number of input file series (lines in InputTable) 107 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 108 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 109 nbfield=nbfield_j*nbfield_i; %total number of fields 110 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 111 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement 112 113 %determine the file type on each line from the first input file 114 ImageTypeOptions={'image','multimage','mmreader','video'}; 115 NcTypeOptions={'netcdf','civx','civdata'}; 116 for iview=1:nbview 117 if ~exist(filecell{iview,1}','file') 118 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist']) 119 return 120 end 121 [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1}); 122 CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images 123 CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files 124 if ~isempty(j1_series{iview}) 125 frame_index{iview}=j1_series{iview}; 126 else 127 frame_index{iview}=i1_series{iview}; 128 end 129 end 130 131 %% calibration data and timing: read the ImaDoc files 132 mode=''; %default 133 timecell={}; 134 itime=0; 135 NbSlice_calib={}; 136 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) 137 for iview=1:nbview%Loop on views 138 SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.' 139 filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder 140 if ~exist(filexml,'file') 141 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder 142 if ~exist(filexml,'file') 143 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file 144 if ~exist(filexml,'file') 145 filexml=''; 146 end 147 end 148 end 149 if ~isempty(filexml) 150 [XmlData{iview},error]=imadoc2struct_special(filexml); 151 end 152 if isfield(XmlData{iview},'Time') 153 itime=itime+1; 154 timecell{itime}=XmlData{iview}.Time; 155 end 156 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 157 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 158 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 159 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 160 end 161 end 162 end 163 164 %% check coincidence in time for several input file series 165 % not relevant 166 167 %% coordinate transform or other user defined transform 168 %not relevant 169 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 170 % EDIT FROM HERE 171 172 %% check the validity of input file types 173 if CheckImage{1} 174 FileExtOut='.png'; % write result as .png images for image inputs 175 elseif CheckNc{1} 176 FileExtOut='.nc';% write result as .nc files for netcdf inputs 177 else 178 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}]) 179 return 180 end 181 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 182 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') 183 return 184 end 185 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 186 if NbSlice~=nbfield_j 187 answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); 188 if ~strcmp(answer,'Yes') 189 return 190 end 191 end 192 193 %% Set field names and velocity types 194 % not relevant here 195 196 %% Initiate output fields 197 % not relevant here 198 199 %% interactive input of specific parameters (for RDvision system) 15 200 display('RDvision system') 16 201 first_label=0; %image numbers start from 0 17 %errorfactor=1 %correct a factor of 2 in NbDk+1 18 19 %% read imadoc 20 RootPath=get(hseries.RootPath,'String'); 21 RootFile=get(hseries.RootFile,'String'); 22 if ~iscell(RootFile) 23 msgbox_uvmat('ERROR','please enter an input image series from RDVision system')%error message for xml file reading 24 return 25 end 26 basename=fullfile(RootPath{1},RootFile{1}); 27 [XmlData,warntext]=imadoc2struct([basename '.xml']);% read the xml file appended to the present function (containing bug corrections) 28 if ~isempty(warntext) 29 msgbox_uvmat('ERROR',warntext)%error message for xml file reading 30 end 31 nbfield1=size(XmlData.Time,1); 32 nbfield2=size(XmlData.Time,2); 33 set(hseries.first_i,'String',num2str(first_label))% display the first image in the process 34 set(hseries.last_i,'String',num2str(nbfield1*nbfield2-1+first_label))% display the last image in the process 35 set(hseries.nb_field,'String',{num2str(nbfield1*nbfield2-1+first_label)})% display the total nbre of images 36 SeriesData=get(hGUI,'UserData'); 37 if ~strcmp(SeriesData.NomType,'_000001') 202 if ~strcmp(NomType{1},'_000001') 38 203 msgbox_uvmat('WARNING','the input is not a file from RDvision: this function relabel_i_j has no action');%error message for directory creation 39 204 return 40 205 else 41 answer=msgbox_uvmat('','this function will relabel the file series from RDvision and correct the xml file');%error message for directory creation206 answer=msgbox_uvmat('','this function will relabel the file series from RDvision from and correct the xml file');%error message for directory creation 42 207 if ~strcmp(answer,'Yes') 43 208 return … … 45 210 end 46 211 47 %% stop program ther when it is selected in the menu (no run action) 48 if ~exist('num_i1','var') 49 return 50 end 51 if nbfield2>=2 52 answer=msgbox_uvmat('',[num2str(nbfield1) ' bursts containing ' num2str(nbfield2) ' images each']);%error message for directory creation 53 nomtype='_i_j'; 54 else 55 answer=msgbox_uvmat('',['image series with ' num2str(nbfield1) ' images']);%error message for directory creation 56 nomtype='_i'; 57 end 58 if ~strcmp(answer,'Yes') 59 return 60 end 212 %% read imadoc 213 % RootPath=get(hseries.RootPath,'String'); 214 % RootFile=get(hseries.RootFile,'String'); 215 % if ~iscell(RootFile) 216 % msgbox_uvmat('ERROR','please enter an input image series from RDVision system')%error message for xml file reading 217 % return 218 % end 219 % basename=fullfile(RootPath{1},RootFile{1}); 220 % [XmlData,warntext]=imadoc2struct_special([basename '.xml']);% read the xml file appended to the present function (containing bug corrections) 221 % if ~isempty(warntext) 222 % msgbox_uvmat('ERROR',warntext)%error message for xml file reading 223 % end 224 % nbfield1=size(XmlData.Time,1); 225 % nbfield2=size(XmlData.Time,2); 226 % set(hseries.first_i,'String',num2str(first_label))% display the first image in the process 227 % set(hseries.last_i,'String',num2str(nbfield1*nbfield2-1+first_label))% display the last image in the process 228 % set(hseries.nb_field,'String',{num2str(nbfield1*nbfield2-1+first_label)})% display the total nbre of images 229 % SeriesData=get(hGUI,'UserData'); 230 231 232 %% stop program there when it is selected in the menu (no run action) 233 % if ~exist('num_i1','var') 234 % return 235 % end 236 % if nbfield2>=2 237 % answer=msgbox_uvmat('',[num2str(nbfield1) ' bursts containing ' num2str(nbfield2) ' images each']);%error message for directory creation 238 % nomtype='_i_j'; 239 % else 240 % answer=msgbox_uvmat('',['image series with ' num2str(nbfield1) ' images']);%error message for directory creation 241 % nomtype='_i'; 242 % end 243 % if ~strcmp(answer,'Yes') 244 % return 245 % end 61 246 62 247 %% copy and adapt the xml file 63 if exist([basename '.xml'],'file') 64 try 65 copyfile([basename '.xml'],[basename '.xml~']);% backup the xml file 66 catch ME 67 msgbox_uvmat('ERROR',ME.message); 68 return 69 end 70 t=xmltree([basename '.xml']); 71 72 %update information on the first image name in the series 73 uid_Heading=find(t,'ImaDoc/Heading'); 74 if isempty(uid_Heading) 75 [t,uid_Heading]=add(t,1,'element','Heading'); 76 end 77 uid_ImageName=find(t,'ImaDoc/Heading/ImageName'); 78 ImageName=name_generator(basename,1,1,'.png','_i_j'); 79 [pth,ImageName]=fileparts(ImageName); 80 ImageName=[ImageName '.png']; 81 if isempty(uid_ImageName) 82 [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName'); 83 end 84 uid_value=children(t,uid_ImageName); 85 if isempty(uid_value) 86 t=add(t,uid_ImageName,'chardata',ImageName);%indicate name of the first image, with ;png extension 248 if ~isempty(XmlData{1}) 249 250 % if exist([basename '.xml'],'file') 251 % try 252 % copyfile([basename '.xml'],[basename '.xml~']);% backup the xml file 253 % catch ME 254 % msgbox_uvmat('ERROR',ME.message); 255 % return 256 % end 257 % filexml=[filebase{1} '.xml'] 258 t=xmltree(filexml); 259 260 %update information on the first image name in the series 261 uid_Heading=find(t,'ImaDoc/Heading'); 262 if isempty(uid_Heading) 263 [t,uid_Heading]=add(t,1,'element','Heading'); 264 end 265 uid_ImageName=find(t,'ImaDoc/Heading/ImageName'); 266 j1=[]; 267 if ~isempty(j1_series{1}) 268 j1=j1_series{1}; 269 end 270 ImageName=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},'_1_1',i1_series{1}(1),[],j); 271 % ImageName=name_generator(basename,1,1,'.png','_i_j'); 272 [pth,ImageName]=fileparts(ImageName); 273 ImageName=[ImageName '.png']; 274 if isempty(uid_ImageName) 275 [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName'); 276 end 277 uid_value=children(t,uid_ImageName); 278 if isempty(uid_value) 279 t=add(t,uid_ImageName,'chardata',ImageName);%indicate name of the first image, with ;png extension 280 else 281 t=set(t,uid_value(1),'value',ImageName);%indicate name of the first image, with ;png extension 282 end 283 284 %%%% correction RDvision %%%% 285 if isfield(XmlData,'NbDtj') 286 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 287 uid_value=children(t,uid_NbDtj); 288 if ~isempty(uid_value) 289 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtj)); 290 end 291 end 292 if isfield(XmlData,'NbDtk') 293 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 294 uid_value=children(t,uid_NbDtk); 295 if ~isempty(uid_value) 296 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtk)); 297 end 298 end 299 if isempty(j1_series{1}) && isfield(XmlData,'NbDti') 300 uid_Dti=find(t,'ImaDoc/Camera/BurstTiming/Dti'); 301 t=add(t,uid_Dti,'chardata',num2str(XmlData.Dti)); 302 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti'); 303 t=add(t,uid_NbDti,'chardata',num2str(XmlData.NbDti)); 304 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 305 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 306 t=delete(t,uid_NbDtj); 307 t=delete(t,uid_NbDtk); 308 uid_Dtj=find(t,'ImaDoc/Camera/BurstTiming/Dtj'); 309 uid_Dtk=find(t,'ImaDoc/Camera/BurstTiming/Dtk'); 310 t=delete(t,uid_Dtj); 311 t=delete(t,uid_Dtk); 312 end 313 SubDirBase=regexprep(SubDir{1},'\..*','');%take the root part of SubDir, before the first dot '.' 314 filexml_new=[fullfile(RootPath{1},SubDirBase) '.xml']; 315 save(t,filexml_new) 316 % end 317 end 318 319 %% main loop on images 320 %j1=[];%default 321 nbfield2=size(XmlData{1}.Time,2); 322 for ifile=1:nbfield 323 if checkrun 324 update_waitbar(hseries.waitbar_frame,WaitbarPos,ifile/nbfield) 325 stopstate=get(hseries.RUN,'BusyAction'); 87 326 else 88 t=set(t,uid_value(1),'value',ImageName);%indicate name of the first image, with ;png extension 89 end 90 91 %%%% correction RDvision %%%% 92 if isfield(XmlData,'NbDtj') 93 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 94 uid_value=children(t,uid_NbDtj); 95 if ~isempty(uid_value) 96 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtj)); 97 end 98 end 99 if isfield(XmlData,'NbDtk') 100 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 101 uid_value=children(t,uid_NbDtk); 102 if ~isempty(uid_value) 103 t=set(t,uid_value(1),'value',num2str(XmlData.NbDtk)); 104 end 105 end 106 if strcmp(nomtype,'_i') && isfield(XmlData,'NbDti') 107 uid_Dti=find(t,'ImaDoc/Camera/BurstTiming/Dti'); 108 t=add(t,uid_Dti,'chardata',num2str(XmlData.Dti)); 109 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti'); 110 t=add(t,uid_NbDti,'chardata',num2str(XmlData.NbDti)); 111 % uid_value=children(t,uid_NbDti); 112 % if ~isempty(uid_value) 113 % t=set(t,uid_value(1),'value',num2str(XmlData.NbDti)); 114 % end 115 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj'); 116 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk'); 117 t=delete(t,uid_NbDtj); 118 t=delete(t,uid_NbDtk); 119 uid_Dtj=find(t,'ImaDoc/Camera/BurstTiming/Dtj'); 120 uid_Dtk=find(t,'ImaDoc/Camera/BurstTiming/Dtk'); 121 t=delete(t,uid_Dtj); 122 t=delete(t,uid_Dtk); 123 end 124 %%% 125 126 save(t,[basename '.xml']) 127 end 128 129 %% main loop 130 131 for ifile=1:nbfield1*nbfield2 132 update_waitbar(hseries.waitbar,WaitbarPos,ifile/(nbfield1*nbfield2)) 133 filename=name_generator(basename,ifile-1,1,Series.FileExt,Series.NomType); 134 num_j=mod(ifile-1+first_label,nbfield2)+1; 135 num_i=floor((ifile-1+first_label)/nbfield2)+1; 136 filename_new=name_generator(basename,num_i,num_j,'.png',nomtype); 137 try 138 movefile(filename,filename_new); 139 [s,errormsg] = fileattrib(filename_new,'-w','a'); %set images to read only '-w' for all users ('a') 140 if ~s 141 msgbox_uvmat('ERROR',errormsg); 327 stopstate='queue'; 328 end 329 if isequal(stopstate,'queue') % enable STOP command 330 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile)); 331 j1=mod(ifile-1+first_label,nbfield2)+1; 332 i1=floor((ifile-1+first_label)/nbfield2)+1; 333 % filename_new=name_generator(basename,num_i,num_j,'.png',nomtype); 334 filename_new=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},'_1_1',i1,[],j1); 335 try 336 movefile(filename,filename_new); 337 [s,errormsg] = fileattrib(filename_new,'-w','a'); %set images to read only '-w' for all users ('a') 338 if ~s 339 msgbox_uvmat('ERROR',errormsg); 340 return 341 end 342 catch ME 343 msgbox_uvmat('ERROR',ME.message); 142 344 return 143 345 end 144 catch ME 145 msgbox_uvmat('ERROR',ME.message); 146 return 147 end 148 end 149 150 151 %'imadoc2struct': reads the xml file for image documentation 346 end 347 end 348 349 %'imadoc2struct_special': reads the xml file for image documentation 152 350 %------------------------------------------------------------------------ 153 % function [s,errormsg]=imadoc2struct (ImaDoc,option)351 % function [s,errormsg]=imadoc2struct_special(ImaDoc,option) 154 352 % 155 353 % OUTPUT: … … 165 363 % option: ='GeometryCalib': read the data of GeometryCalib, including source point coordinates 166 364 167 function [s,errormsg]=imadoc2struct (ImaDoc,option)365 function [s,errormsg]=imadoc2struct_special(ImaDoc,option) 168 366 169 367 %% default input and output … … 247 445 s.Dti=Dti; 248 446 else 249 NbDtj=NbDtj/numel(Dtj);%bursts447 % NbDtj=NbDtj/numel(Dtj);%bursts 250 448 s.NbDtj=NbDtj; 251 449 end -
trunk/src/series/sub_background.m
r455 r457 1 %'sub_background': substract background to an image series, used with series.fig 1 %'sub_background': substract a sliding background to an image series 2 % This is an example of action on a series of input images 2 3 %------------------------------------------------------------------------ 3 4 % Method: … … 14 15 % Else nbfield2=nbfield_j =nbre of images in a burst (j index) 15 16 16 % function GUI_ series_config=sub_background(Param)17 % function GUI_config=sub_background(Param) 17 18 % 18 19 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 20 % 21 % This function is used in four modes by the GUI series: 22 % 1) config GUI: with no input argument, the function determine the suitable GUI configuration 23 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 24 % 3) RUN: the function itself runs, when an appropriate input structure Param has been introduced. 25 % 4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input. 26 % 19 27 %OUTPUT 20 28 % GUI_series_config=list of options in the GUI series.fig needed for the function … … 52 60 GUI_config={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation) 53 61 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 62 'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 54 63 'NbSlice';'on'; ...%nbre of slices ('off' by default) 55 64 'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) … … 64 73 65 74 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 66 %% get input parameters, file names and indices75 %% select different modes, RUN, parameter input, BATCH 67 76 % BATCH case: read the xml file for batch case 68 if ischar(Param) && ~isempty(find(regexp(Param,'.xml$'))) %batch mode 77 if ischar(Param) 78 if strcmp(Param,'input?') 79 checkrun=1;% will inly search input parameters (preparation of BATCH mode) 80 else 69 81 Param=xml2struct(Param); 70 82 checkrun=0; 71 % RUN case: parameters introduced as the input structure Param 83 end 84 % RUN case: parameters introduced as the input structure Param 72 85 else 73 86 hseries=guidata(Param.hseries);%handles of the GUI series 74 87 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 75 checkrun=1; % indicate the RUN option is used 76 end 88 checkrun=2; % indicate the RUN option is used 89 end 90 91 %% root input file(s) and type 92 RootPath=Param.InputTable(:,1); 93 RootFile=Param.InputTable(:,3); 94 SubDir=Param.InputTable(:,2); 95 NomType=Param.InputTable(:,4); 96 FileExt=Param.InputTable(:,5); 97 77 98 % get the set of input file names (cell array filecell), and the lists of 78 99 % input file or frame indices i1_series,i2_series,j1_series,j2_series … … 84 105 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 85 106 % set of frame indices used for movie or multimage input 86 87 88 %% root input file(s) and type89 RootPath=Param.InputTable(:,1);90 RootFile=Param.InputTable(:,3);91 SubDir=Param.InputTable(:,2);92 NomType=Param.InputTable(:,4);93 FileExt=Param.InputTable(:,5);94 95 107 % numbers of slices and file indices 108 96 109 NbSlice=1;%default 97 if isfield(Param.IndexRange,'NbSlice') 110 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) 98 111 NbSlice=Param.IndexRange.NbSlice; 99 112 end … … 162 175 end 163 176 164 %% set processingparameters165 if ~isfield(Param,'Specific')177 %% input of specific parameters 178 if checkrun %get specific parameters interactively 166 179 prompt = {'volume scan mode (Yes/No)';'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';... 167 180 'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'}; … … 200 213 answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background'); 201 214 GUI_config.CheckLevelTransform=strcmp(answer,'Yes'); 202 203 % % return to BATCH mode 204 % if checkrun==-1 205 return %transfer to BATCH mode 206 % end 215 if checkrun==2 216 return 217 end 218 %%%%%%%%%%%%%%%%%%%%%% STOP HERE FOR PAMETER INPUT MODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 207 219 else 208 220 GUI_config=Param.Specific; -
trunk/src/series/time_series.m
r447 r457 1 1 %'time_series': extract a time series, used with series.fig 2 % this function can be used as a template for applying a global operation on a series of input fields 2 3 %------------------------------------------------------------------------ 3 4 % function GUI_input=time_series(Param) 5 % 6 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 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 configuration 10 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 11 % 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 configuration 16 % 2) interactive input: the function is used to interactively introduce input parameters, and then stops 17 % 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. 4 19 % 5 20 %OUTPUT … … 7 22 % 8 23 %INPUT: 9 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 10 %i2_series: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 11 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) 12 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) 13 %Series: Matlab structure containing information set by the series interface 24 % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. 25 % 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 selected 27 % in series), the function ouput GUI_input set the activation of the needed GUI elements 14 28 % 15 function GUI_input=time_series(Param) 29 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param) 30 % .InputTable: cell of input file names, (several lines for multiple input) 31 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 32 % .OutputSubDir: name of the subdirectory for data outputs 33 % .OutputDir: directory for data outputs, including path 34 % .Action: .ActionName: name of the current activated function 35 % .ActionPath: path of the current activated function 36 % .IndexRange: set the file or frame indices on which the action must be performed 37 % .FieldTransform: .TransformName: name of the selected transform function 38 % .TransformPath: path of the selected transform function 39 % .TransformHandle: corresponding function handle 40 % .InputFields: sub structure describing the input fields withfields 41 % .FieldName: name of the field 42 % .VelType: velocity type 43 % .FieldName_1: name of the second field in case of two input series 44 % .VelType_1: velocity type of the second field in case of two input series 45 % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) 46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 % 48 function ParamOut=time_series(Param) 16 49 17 50 %% requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 18 51 if ~exist('Param','var') 19 GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')52 ParamOut={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') 20 53 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) 21 54 'RootFile';'on';... %root input file name ('on' by default) … … 34 67 end 35 68 36 %% input parameters 37 % read the xml file for batch case 38 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 39 Param=xml2struct(Param); 40 checkrun=0; 41 else % RUN case: parameters introduced as the input structure Param 69 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 70 %% select different modes, RUN, parameter input, BATCH 71 % BATCH case: read the xml file for batch case 72 ParamOut=Param; %default output 73 if ischar(Param) 74 if strcmp(Param,'input?') 75 checkrun=1;% will inly search input parameters (preparation of BATCH mode) 76 else 77 Param=xml2struct(Param); 78 checkrun=0; 79 end 80 % RUN case: parameters introduced as the input structure Param 81 else 42 82 hseries=guidata(Param.hseries);%handles of the GUI series 43 WaitbarPos=get(hseries.waitbar_frame,'Position'); 44 checkrun=1; 45 end 83 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 84 checkrun=2; % indicate the RUN option is used 85 end 86 87 %% root input file(s) and type 88 RootPath=Param.InputTable(:,1); 89 RootFile=Param.InputTable(:,3); 90 SubDir=Param.InputTable(:,2); 91 NomType=Param.InputTable(:,4); 92 FileExt=Param.InputTable(:,5); 93 94 % get the set of input file names (cell array filecell), and the lists of 95 % input file or frame indices i1_series,i2_series,j1_series,j2_series 46 96 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 97 % filecell{iview,fileindex}: cell array representing the list of file names 98 % iview: line in the table corresponding to a given file series 99 % fileindex: file index within the file series, 100 % 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 101 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 102 % set of frame indices used for movie or multimage input 103 % numbers of slices and file indices 104 105 NbSlice=1;%default 106 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) 107 NbSlice=Param.IndexRange.NbSlice; 108 end 109 nbview=numel(i1_series);%number of input file series (lines in InputTable) 110 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 111 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 112 nbfield=nbfield_j*nbfield_i; %total number of fields 113 nbfield_i=floor(nbfield/NbSlice);%total number of indexes in a slice (adjusted to an integer number of slices) 114 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement 115 116 %determine the file type on each line from the first input file 117 ImageTypeOptions={'image','multimage','mmreader','video'}; 118 NcTypeOptions={'netcdf','civx','civdata'}; 119 for iview=1:nbview 120 if ~exist(filecell{iview,1}','file') 121 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist']) 122 return 123 end 124 [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1}); 125 CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images 126 CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files 127 if ~isempty(j1_series{iview}) 128 frame_index{iview}=j1_series{iview}; 129 else 130 frame_index{iview}=i1_series{iview}; 131 end 132 end 133 134 %% calibration data and timing: read the ImaDoc files 135 mode=''; %default 136 timecell={}; 137 itime=0; 138 NbSlice_calib={}; 139 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) 140 for iview=1:nbview%Loop on views 141 SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.' 142 filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder 143 if ~exist(filexml,'file') 144 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder 145 if ~exist(filexml,'file') 146 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file 147 if ~exist(filexml,'file') 148 filexml=''; 149 end 150 end 151 end 152 if ~isempty(filexml) 153 [XmlData{iview},error]=imadoc2struct(filexml); 154 end 155 if isfield(XmlData{iview},'Time') 156 itime=itime+1; 157 timecell{itime}=XmlData{iview}.Time; 158 end 159 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 160 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 161 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 162 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 163 end 164 end 165 end 166 167 %% check coincidence in time for several input file series 168 multitime=0; 169 if isempty(timecell) 170 time=[]; 171 elseif length(timecell)==1 172 time=timecell{1}; 173 elseif length(timecell)>1 174 multitime=1; 175 for icell=1:length(timecell) 176 if ~isequal(size(timecell{icell}),size(timecell{1})) 177 msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') 178 time=timecell{1}; 179 multitime=0; 180 break 181 end 182 end 183 end 184 if multitime 185 for icell=1:length(timecell) 186 time(icell,:,:)=timecell{icell}; 187 end 188 diff_time=max(max(diff(time))); 189 if diff_time>0 190 msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)]) 191 end 192 end 193 if size(time,2) < i2_series{1}(end) ||( ~isempty(j2_series{1}) && size(time,3) < j2_series{1}(end))% time array absent or too short in ImaDoc xml file' 194 time=[]; 195 end 47 196 48 197 %% coordinate transform or other user defined transform 49 198 transform_fct='';%default 50 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'fct_handle') 51 transform_fct=Param.FieldTransform.fct_handle; 52 end 53 54 %% projection object 55 test_object=get(hseries.GetObject,'Value'); 56 if test_object 57 hset_object=findobj(allchild(0),'tag','set_object'); 58 ProjObject=read_GUI(hset_object); 59 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Type]); 60 if ~isequal(answeryes,'Yes') 199 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle') 200 transform_fct=Param.FieldTransform.TransformHandle; 201 end 202 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 203 % EDIT FROM HERE 204 205 %% check the validity of input file types 206 if CheckImage{1} 207 FileExtOut='.png'; % write result as .png images for image inputs 208 elseif CheckNc{1} 209 FileExtOut='.nc';% write result as .nc files for netcdf inputs 210 else 211 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}]) 212 return 213 end 214 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 215 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') 216 return 217 end 218 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 219 if NbSlice~=nbfield_j 220 answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); 221 if ~strcmp(answer,'Yes') 61 222 return 62 223 end 63 else 64 msgbox_uvmat('ERROR','a projection object is needed'); 65 return 66 end 67 68 %% features of the input fields 69 RootPath=Param.InputTable(:,1); 70 RootFile=Param.InputTable(:,3); 71 % SubDir=Param.InputTable(:,2); 72 NomType=Param.InputTable(:,4); 73 FileExt=Param.InputTable(:,5); 74 % ext=FileExt{1}; 75 % form=imformats(ext(2:end));%test valid Matlab image formats 76 nbfield=size(i1_series{1},1)*size(i1_series{1},2); %number of fields in the time series 77 78 %% determine image type 79 hhh=which('mmreader'); 80 testnetcdf=0; 81 nbview=length(RootPath);%Number of input series: this function accepts only one or two input file series (sub_field is used in the latter case) 82 for iview=1:nbview 83 if isequal(FileExt{iview},'.nc')||isequal(FileExt{iview},'.cdf') 84 FileType{iview}='netcdf'; 85 testnetcdf=1; 86 elseif isequal(lower(FileExt{iview}),'.avi') 87 if ~isequal(hhh,'')%&& mmreader.isPlatformSupported() 88 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); 89 FileType{iview}='movie'; 90 else 91 FileType{iview}='avi'; 92 end 93 elseif isequal(lower(FileExt{iview}),'.vol') 94 FileType{iview}='vol'; 95 else 96 form=imformats(FileExt{iview}(2:end)); 97 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 98 if isequal(NomType{iview},'*'); 99 FileType{iview}='multimage'; 100 else 101 FileType{iview}='image'; 102 end 103 end 104 end 105 end 106 filebase{1}=fullfile(RootPath{1},RootFile{1}); 107 108 %% number of slices 109 NbSlice=Param.NbSlice; 110 111 %% Field and velocity type (the same for the two views) 112 FieldName={''}; 113 114 if isfield(Param,'InputFields')&&isfield(Param.InputFields,'FieldMenu') 115 FieldName=Param.InputFields.FieldMenu;%the same set of fields for all views 116 VelType{1}=Param.InputFields.VelTypeMenu; 117 end 118 if isempty(FieldName) && testnetcdf 119 msgbox_uvmat('ERROR','A field must be defined as input') 120 return 121 end 224 end 225 226 %% Set field names and velocity types 227 InputFields{1}=[];%default (case of images) 228 if isfield(Param,'InputFields') 229 InputFields{1}=Param.InputFields; 230 end 231 if nbview==2 232 InputFields{2}=[];%default (case of images) 233 if isfield(Param,'InputFields') 234 InputFields{2}=Param.InputFields{1};%default 235 if isfield(Param.InputFields,'FieldName_1') 236 InputFields{2}.FieldName=Param.InputFields.FieldName_1; 237 if isfield(Param.InputFields,'VelType_1') 238 InputFields{2}.VelType=Param.InputFields.VelType_1; 239 end 240 end 241 end 242 end 243 %%% TO UPDATE 122 244 if isequal(FieldName,'get_field...') 123 245 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI … … 140 262 end 141 263 end 264 %%%%%%% 265 266 %% Initiate output fields 267 %initiate the output structure as a copy of the first input one (reproduce fields) 268 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1); 269 if ~isempty(errormsg) 270 msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg]) 271 return 272 end 273 time_1=[]; 274 if isfield(DataOut,'Time') 275 time_1=DataOut.Time(1); 276 end 277 if CheckNc{iview} 278 if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute)) 279 DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute]; 280 end 281 DataOut.Conventions='uvmat'; 282 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}]; 283 ActionKey='Action'; 284 while isfield(DataOut,ActionKey) 285 ActionKey=[ActionKey '_1']; 286 end 287 DataOut.(ActionKey)=Param.Action; 288 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}]; 289 if isfield(DataOut,'Time') 290 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}]; 291 end 292 end 293 294 295 142 296 143 297 %% detect whether the two files are 'images' or 'netcdf' … … 155 309 % VelType{2}=VelType_str{VelType_val}; 156 310 % end 157 158 %% Calibration data and timing: read the ImaDoc files159 % mode=''; %default160 timecell={};161 XmlData={};162 itime=0;163 NbSlice_calib={};164 for iview=1:nbview%Loop on views165 XmlData{iview}=[];%default166 filebase{iview}=fullfile(RootPath{iview},RootFile{iview});167 if exist([filebase{iview} '.xml'],'file')168 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']);169 if isfield(XmlData{iview},'Time')170 itime=itime+1;171 timecell{itime}=XmlData{iview}.Time;172 end173 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')174 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform175 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})176 msgbox_uvmat('WARNING','inconsistent number of Z indices for the field series');177 end178 end179 elseif exist([filebase{iview} '.civ'],'file')%old convention .civ text file180 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']);181 itime=itime+1;182 timecell{itime}=time;183 XmlData{iview}.Time=time;184 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];185 GeometryCalib.Tx=0;186 GeometryCalib.Ty=0;187 GeometryCalib.Tz=1;188 GeometryCalib.dpx=1;189 GeometryCalib.dpy=1;190 GeometryCalib.sx=1;191 GeometryCalib.Cx=0;192 GeometryCalib.Cy=0;193 GeometryCalib.f=1;194 GeometryCalib.kappa1=0;195 GeometryCalib.CoordUnit='cm';196 XmlData{iview}.GeometryCalib=GeometryCalib;197 if error==1198 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');199 end200 end201 end202 time=[];%default203 if ~isempty(timecell)204 if numel(timecell{1})<nbfield205 msgbox_uvmat('WARNING','time array from ImaDoc to short')206 else207 time=timecell{1}; %time defined from ImaDoc file (image series)208 end209 end210 211 %% check coincidence in time212 if length(timecell)>1213 for icell=2:length(timecell)214 if isequal(size(timecell{icell}),size(time))215 diff_time=max(abs(timecell{icell}-time));216 if diff_time>0217 msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)])218 break219 end220 else221 msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')222 break223 end224 end225 end226 if ~isempty(time)227 display(['time is read from ' filebase{iview} '.xml'])228 end229 230 %% Root name of output files (TO GENERALISE FOR TWO INPUT SERIES)231 subdir_result='time_series';232 pathdir=fullfile(RootPath{1},subdir_result);233 while exist(pathdir,'dir')234 subdir_result=[subdir_result '.0'];235 pathdir=fullfile(RootPath{1},subdir_result);236 end237 [m1,m2,m3]=mkdir(pathdir);238 if ~isequal(m2,'')239 msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation240 end241 [xx,msg2] = fileattrib(pathdir,'+w','g'); %yield writing access (+w) to user group (g)242 if ~strcmp(msg2,'')243 msgbox_uvmat('ERROR',['pb of permission for ' pathdir ': ' msg2])%error message for directory creation244 return245 end246 filebase_out=filebase{1};247 i21=i1_series{end}(end);248 if ~isempty(i2_series{end})249 i21=i2_series{end}(end)-i1_series{1}(1);250 end251 j21=1;252 if ~isempty(j1_series{1})253 j21=j1_series{end}(end);254 if ~isempty(j2_series{end})255 j21=j2_series{end}(end)-j21;256 end257 end258 NomTypeOut=nomtype2pair(NomType{1},i21,j21);259 260 261 %% velocity type262 VelType_str=get(hseries.VelTypeMenu,'String');263 VelType_val=get(hseries.VelTypeMenu,'Value');264 VelType{1}=VelType_str{VelType_val};265 if nbview==2266 VelType_str=get(hseries.VelTypeMenu_1,'String');267 VelType_val=get(hseries.VelTypeMenu_1,'Value');268 VelType{2}=VelType_str{VelType_val};269 end270 311 271 312 %% LOOP ON SLICES
Note: See TracChangeset
for help on using the changeset viewer.