Changeset 374 for trunk/src/series/aver_stat.m
- Timestamp:
- Jan 16, 2012, 12:51:23 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r361 r374 1 1 %'aver_stat': calculate field average, used with series.fig 2 2 %------------------------------------------------------------------------ 3 % function GUI_input=aver_stat( num_i1,num_i2,num_j1,num_j2,Series)3 % function GUI_input=aver_stat(Param) 4 4 % 5 5 %OUTPUT … … 7 7 % 8 8 %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 %num_i2: 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 9 % Param: structure containing all the parameters read on the GUI series 10 % or name of the xml file containing these parameters (BATCH case) 14 11 % 15 12 function GUI_input=aver_stat(Param) … … 18 15 %---------------------------------------------------------------------- 19 16 %INPUT: 20 % num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)17 %i1_series: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 21 18 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 22 % num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )19 %j1_series: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) 23 20 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) 24 21 %OTHER INPUTS given by the structure Series … … 44 41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45 42 46 %% Input parameters: read the xml file fior batch case 43 %% input parameters 44 % read the xml file for batch case 47 45 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 48 46 Param=xml2struct(Param); 49 else 50 47 else % RUN case: parameters introduced as the input structure Param 48 hseries=guidata(Param.hseries);%handles of the GUI series 51 49 WaitbarPos=get(hseries.waitbar_frame,'Position'); 52 50 end 53 Param 54 Param.IndexRange 51 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 52 53 %% coordinate transform or other user defined transform (TODO: case BATCH ?) 54 transform_fct='';%default 55 if isfield(Param,'transform_fct') % transform function handle 56 transform_fct=Param.transform_fct; 57 end 55 58 56 59 %% projection object … … 67 70 68 71 %% root input file and type 69 % if ~iscell(Series.RootPath)% case of a single input field series70 % num_i1={num_i1};num_j1={num_j1};num_i2={num_i2};num_j2={num_j2};71 % RootPath={Series.RootPath};72 % RootFile={Series.RootFile};73 % SubDir={Series.SubDir};74 % FileExt={Series.FileExt};75 % NomType={Series.NomType};76 % else77 % RootPath=Series.RootPath;78 % RootFile=Series.RootFile;79 % SubDir=Series.SubDir;80 % NomType=Series.NomType;81 % FileExt=Series.FileExt;82 % end83 72 RootPath=Param.InputTable(:,1); 84 73 RootFile=Param.InputTable(:,3); … … 103 92 end 104 93 end 94 105 95 106 96 %% Number of input series: this function accepts two input file series at most (then it operates on the difference of fields) … … 162 152 elseif isempty(hget_field) 163 153 filename=... 164 name_generator(fullfile(RootPath{1},RootFile{1}), num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1});154 name_generator(fullfile(RootPath{1},RootFile{1}),i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),num_j2{1}(1),SubDir{1}); 165 155 get_field(filename); 166 156 return … … 258 248 end 259 249 end 260 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file'250 if size(time,2) < i2_series{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file' 261 251 time=[]; 262 252 end … … 276 266 pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path 277 267 if NbSlice==1% keep track of the first and lsat indices of the input files 278 NomTypeOut=nomtype2pair(NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1)); 279 fileresult{1}=name_generator(filebase_out,num_i1{1}(1),num_j1{1}(1),ext_out,NomTypeOut,1,num_i2{end}(end),num_j2{end}(end),subdir_result); 268 %NomTypeOut=nomtype2pair(Param.InputTable{1,4},i2_series{end}(end)-i1_series{1}(1),j2_series{end}(end)-j1_series{1}(1)); 269 NomTypeOut='_1-2'; 270 % RootPath,SubDir,RootFile,FileExt,NomType,i1,i2,j1,j2) 271 fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),[],[],[]); 272 % fileresult{1}=name_generator(filebase_out,i1_series{1}(1),j1_series{1}(1),ext_out,NomTypeOut,1,i2_series{end}(end),j2_series{end}(end),subdir_result); 280 273 testexist=exist(fileresult{1},'file'); 281 274 else % simplified indexing with i_slice for multiple slices 282 275 testexist=0; 283 276 for i_slice=1:NbSlice 284 fileresult{i_slice}=name_generator(filebase_out,i_slice,[],ext_out,'_1',1,i_slice,[],subdir_result); 277 fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i_slice,[],[],[]); 278 %fileresult{i_slice}=name_generator(filebase_out,i_slice,[],ext_out,'_1',1,i_slice,[],subdir_result); 285 279 if exist(fileresult{i_slice},'file') 286 280 testexist=1; … … 307 301 308 302 %% coordinate transform or other user defined transform 309 transform_fct= [];%default310 if isfield( Series,'transform_fct')311 transform_fct=Param. transform_fct;303 transform_fct='';%default 304 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'transform_fct') 305 transform_fct=Param.FieldTransform.transform_fct; 312 306 end 313 307 314 308 %% main loop 315 siz=size( num_i1{1});309 siz=size(i1_series{1}); 316 310 nbfield2=siz(1); %nb of consecutive fields at each level(burst 317 311 nbfield=siz(1)*siz(2); … … 328 322 % averaging loop 329 323 for index=1:nbfield*nbfield2 330 stopstate=get(hseries.RUN,'BusyAction');331 if isequal(stopstate,'queue') % enable STOP command332 update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))324 % stopstate=get(hseries.RUN,'BusyAction'); 325 % if isequal(stopstate,'queue') % enable STOP command 326 % update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2)) 333 327 ifile=indselect(index); 334 328 % reading input file(s) 335 329 for iview=1:nbview 336 [filename]=... 337 name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview}); 338 if ~isequal(FileType{iview},'netcdf') 330 % [filename]=... 331 % name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),j2_series{iview}(ifile),SubDir{iview}); 332 filename=filecell{iview,index}; 333 if ~isequal(FileType{iview},'netcdf') 339 334 Data{iview}.ListVarName={'A'}; 340 335 Data{iview}.AName='image'; 341 336 switch FileType{iview} 342 337 case 'movie' 343 A=read(MovieObject{iview}, num_i1{iview}(ifile));338 A=read(MovieObject{iview},i1_series{iview}(ifile)); 344 339 case 'avi' 345 mov=aviread(filename, num_i1{iview}(ifile));340 mov=aviread(filename,i1_series{iview}(ifile)); 346 341 A=frame2im(mov(1)); 347 342 case 'vol' 348 343 A=imread(filename); 349 344 case 'multimage' 350 A=imread(filename, num_i1{iview}(ifile));345 A=imread(filename,i1_series{iview}(ifile)); 351 346 case 'image' 352 347 A=imread(filename); … … 381 376 if ~isempty(transform_fct) 382 377 if ~isempty(NbSlice_calib) 383 Data{iview}.ZIndex=mod( num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;%Zindex for phys transform378 Data{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1;%Zindex for phys transform 384 379 end 385 380 if nbview==2 … … 435 430 end 436 431 end 437 end432 % end 438 433 end 439 434 %end averaging loop … … 455 450 end 456 451 else % time from ImaDoc prevails 457 DataMean.Time=time(1, num_i1{1}(1),num_j1{1}(1));458 DataMean.Time_end=time(end, num_i1{end}(end),num_j1{end}(end));452 DataMean.Time=time(1,i1_series{1}(1),j1_series{1}(1)); 453 DataMean.Time_end=time(end,i1_series{end}(end),j1_series{end}(end)); 459 454 end 460 455 … … 468 463 display([fileresult{i_slice} ' written']); 469 464 else %case of netcdf input file , determine global attributes 465 if isempty(strcmp('Conventions',DataMean.ListGlobalAttribute)) 466 DataMean.ListGlobalAttribute=['Conventions' DataMean.ListGlobalAttribute]; 467 end 468 DataMean.Conventions='uvmat'; 470 469 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {Param.Action}]; 471 470 ActionKey='Action'; … … 473 472 ActionKey=[ActionKey '_1']; 474 473 end 475 eval(['DataMean.' ActionKey '=Param.Action;'])474 DataMean.(ActionKey)=Param.Action; 476 475 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {ActionKey}]; 477 476 if isfield(DataMean,'Time')
Note: See TracChangeset
for help on using the changeset viewer.