Changeset 457 for trunk/src/series/aver_stat.m
- Timestamp:
- Jun 17, 2012, 10:52:04 PM (13 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.