Changeset 374
- Timestamp:
- Jan 16, 2012, 12:51:23 AM (13 years ago)
- Location:
- trunk/src/series
- Files:
-
- 5 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') -
trunk/src/series/check_data_files.m
r361 r374 1 1 %'check_files': check the existence and status of the files selected by series.fig 2 2 %------------------------------------------------------------------------ 3 % function GUI_input=check_ files(num_i1,num_i2,num_j1,num_j2,Series)3 % function GUI_input=check_data_files(num_i1,num_i2,num_j1,num_j2,Series) 4 4 % 5 5 %OUTPUT … … 13 13 %Series: Matlab structure containing information set by the series interface 14 14 % 15 function GUI_input=check_ files(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series) %(filecell,filecell_1,num_i,num_j,vel_type,field,param);15 function GUI_input=check_data_files(Param) %(filecell,filecell_1,num_i,num_j,vel_type,field,param); 16 16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 17 %detect the chosen series of files and check their date of modification: … … 42 42 end 43 43 44 %standard parameters for waitbar and STOP action (do not modify) 45 hseries=guidata(Series.hseries);%handles of the GUI series 46 WaitbarPos=get(hseries.waitbar_frame,'Position'); 44 %% input parameters 45 % read the xml file for batch case 46 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 47 Param=xml2struct(Param); 48 else % RUN case: parameters introduced as the input structure Param 49 hseries=guidata(Param.hseries);%handles of the GUI series 50 WaitbarPos=get(hseries.waitbar_frame,'Position'); 51 end 52 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 53 47 54 48 55 %%%%%%%%%%%%%%%%%%%%%%%% 49 56 50 57 % number of slices 51 % NbSlice=str2num(get(hseries.NbSlice,'String')); 52 % if isempty(NbSlice) 53 % NbSlice=1; 54 NbSlice=Series.IndexRange.NbSlice 55 NbSlice_name=num2str(Series.IndexRange.NbSlice); 56 if isequal(NbSlice,[]),NbSlice=1; end; %default 58 NbSlice=Param.NbSlice; 59 if isempty(NbSlice),NbSlice=1; end; %default 57 60 61 %% root input file and type 62 RootPath=Param.InputTable(:,1); 63 RootFile=Param.InputTable(:,3); 64 SubDir=Param.InputTable(:,2); 65 NomType=Param.InputTable(:,4); 66 FileExt=Param.InputTable(:,5); 58 67 % number of views 59 count=0; 60 testcell=iscell(Series.RootFile); 61 if ~testcell 62 Series.RootPath={Series.RootPath}; 63 Series.RootFile={Series.RootFile}; 64 Series.SubDir={Series.SubDir}; 65 Series.FileExt={Series.FileExt}; 66 Series.NomType={Series.NomType}; 67 end 68 nbview=length(Series.RootFile); 68 count=0; 69 nbview=length(RootFile); 70 69 71 for iview=1:nbview 70 72 filebase=fullfile(Series.RootPath{iview},Series.RootFile{iview});%root file name -
trunk/src/series/merge_proj.m
r335 r374 1 2 1 3 2 4 %'merge_proj': project and concatene fields, used with series.fig 3 5 %------------------------------------------------------------------------ 4 % function GUI_input=merge_proj( num_i1,num_i2,num_j1,num_j2,Series)6 % function GUI_input=merge_proj(Param) 5 7 % 6 8 %OUTPUT … … 8 10 % 9 11 %INPUT: 10 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 11 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) 12 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) 13 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) 14 %Series: Matlab structure containing information set by the series interface 12 % Param: structure containing all the parameters read on the GUI series 13 % or name of the xml file containing these parameters (BATCH case) 15 14 % 16 function GUI_input=merge_proj( num_i1,num_i2,num_j1,num_j2,Series)15 function GUI_input=merge_proj(Param) 17 16 18 17 %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 19 if ~exist(' num_i1','var')18 if ~exist('Param','var') 20 19 GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') 21 20 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) … … 34 33 end 35 34 36 %------------------------------------------------- 37 hseries=guidata(Series.hseries);%handles of the GUI series 38 WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame 39 %------------------------------------------------- 40 35 %% input parameters: 36 % read the xml file for batch case 37 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 38 Param=xml2struct(Param); 39 else % RUN case : parameters introduced as the input structure Param 40 hseries=guidata(Param.hseries);%handles of the GUI series 41 WaitbarPos=get(hseries.waitbar_frame,'Position');% info for the waitbar 42 end 43 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 44 45 %% coordinate transform or other user defined transform (TODO: case BATCH ?) 46 transform_fct='';%default 47 if isfield(Param,'transform_fct') % transform function handle 48 transform_fct=Param.transform_fct; 49 end 41 50 42 51 %% projection object … … 59 68 end 60 69 61 %% numbers of view fields (nbre of inputs in RootPath) 62 testcell=iscell(Series.RootFile); 63 if ~testcell 64 Series.RootPath={Series.RootPath}; 65 Series.RootFile={Series.RootFile}; 66 Series.SubDir={Series.SubDir}; 67 Series.FileExt={Series.FileExt}; 68 Series.NomType={Series.NomType}; 69 num_i1={num_i1}; 70 num_i2={num_i2}; 71 num_j1={num_j1}; 72 num_j2={num_j2}; 73 end 74 nbview=length(Series.RootFile);%number of views (file series to merge) 75 nbfield=size(num_i1{1},1)*size(num_i1{1},2);%number of fields in the time series 70 %% features of the input fields 71 RootPath=Param.InputTable(:,1); 72 RootFile=Param.InputTable(:,3); 73 SubDir=Param.InputTable(:,2); 74 NomType=Param.InputTable(:,4); 75 FileExt=Param.InputTable(:,5); 76 77 nbview=length(RootFile);%number of views (file series to merge) 78 nbfield=size(i1_series{1},1)*size(i1_series{1},2);%number of fields in the time series 76 79 hhh=which('mmreader'); 77 80 for iview=1:nbview 78 81 test_movie(iview)=0; 79 82 if ~isequal(hhh,'')&& mmreader.isPlatformSupported() 80 if isequal(lower( Series.FileExt{iview}),'.avi')81 MovieObject{iview}=mmreader(fullfile( Series.RootPath{iview},[Series.RootFile{iview} Series.FileExt{iview}]));83 if isequal(lower(FileExt{iview}),'.avi') 84 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); 82 85 test_movie(iview)=1; 83 86 end 84 end 87 end 85 88 end 86 89 … … 91 94 for iview=1:nbview%Loop on views 92 95 XmlData{iview}=[];%default 93 filebase{iview}=fullfile( Series.RootPath{iview},Series.RootFile{iview});96 filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); 94 97 if exist([filebase{iview} '.xml'],'file') 95 98 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); … … 154 157 end 155 158 end 156 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' 157 time=[]; 158 end 159 160 %% coordinate transform or other user defined transform 161 transform_fct=[];%default 162 if isfield(Series,'transform_fct') 163 transform_fct=Series.transform_fct; 164 end 159 % if size(time,2) < i2_series{1}(end) || size(time,3) < j2_series{1}(end)% ime array absent or too short in ImaDoc xml file' 160 % time=[]; 161 % end 165 162 166 163 %% Field and velocity type (the same for all views) 167 164 FieldName=''; 168 if strcmp(get(hseries.FieldMenu,'Visible'),'on') 169 Field_str=get(hseries.FieldMenu,'String'); 170 val=get(hseries.FieldMenu,'Value'); 171 FieldName=Field_str(val);%the same set of fields for all views 172 VelType_str=get(hseries.VelTypeMenu,'String'); 173 VelType_val=get(hseries.VelTypeMenu,'Value'); 174 VelType=VelType_str{VelType_val}; %the same for all views 175 if strcmp(FieldName,'') 176 msgbox_uvmat('ERROR','no input field defined in FieldMenu') 177 elseif strcmp(FieldName,'get_field...') 178 hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI 179 SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI 180 end 181 end 165 if isfield(Param,'InputFields')&&isfield(Param.InputFields,'FieldMenu') 166 FieldName=Param.InputFields.FieldMenu;%the same set of fields for all views 167 VelType=Param.InputFields.VelTypeMenu; 168 end 169 % if strcmp(get(hseries.FieldMenu,'Visible'),'on') 170 % Field_str=get(hseries.FieldMenu,'String'); 171 % val=get(hseries.FieldMenu,'Value'); 172 % FieldName=Field_str(val);%the same set of fields for all views 173 % VelType_str=get(hseries.VelTypeMenu,'String'); 174 % VelType_val=get(hseries.VelTypeMenu,'Value'); 175 % VelType=VelType_str{VelType_val}; %the same for all views 176 if strcmp(FieldName,'') 177 msgbox_uvmat('ERROR','no input field defined in FieldMenu') 178 elseif strcmp(FieldName,'get_field...') 179 hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI 180 SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI 181 end 182 % end 182 183 %detect whether all the files are 'images' or 'netcdf' 183 184 testima=0; … … 185 186 testcivx=0; 186 187 testnc=0; 187 FileExt=get(hseries.FileExt,'String');188 188 for iview=1:nbview 189 189 ext=FileExt{iview}; … … 210 210 211 211 %% name of output files and directory: 212 ProjectDir=fileparts(fileparts( Series.RootPath{1}));% preoject directory (GERK)212 ProjectDir=fileparts(fileparts(RootPath{1}));% preoject directory (GERK) 213 213 prompt={['result directory (in' ProjectDir ')']}; 214 RootPath=get(hseries.RootPath,'String');215 SubDir=get(hseries.SubDir,'String');214 % RootPath=get(hseries.RootPath,'String'); 215 % SubDir=get(hseries.SubDir,'String'); 216 216 if isequal(length(RootPath),1) 217 217 fulldir=RootPath{1}; … … 225 225 fulldir=answer{1}; 226 226 subdir=[]; 227 dirlist=sort( Series.RootFile);227 dirlist=sort(RootFile); 228 228 for iview=1:nbview 229 229 if ~isempty(subdir) … … 256 256 end 257 257 end 258 filebasesub=fullfile(res_subdir, Series.RootFile{1});259 filebase_merge=fullfile(res_subdir,'merged');%root name for the merged files258 filebasesub=fullfile(res_subdir,RootFile{1}); 259 %filebase_merge=fullfile(res_subdir,'merged');%root name for the merged files 260 260 261 261 %% MAIN LOOP … … 269 269 for iview=1:nbview 270 270 %name of the current file 271 filename=name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview}); 271 filename=filecell{iview,ifile}; 272 % filename=name_generator(filebase{iview},i1_series{iview}(ifile),j1_series{iview}(ifile),FileExt{iview},NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile),SubDir{iview}); 272 273 if ~exist(filename,'file') 273 274 msgbox_uvmat('ERROR',['missing input file' filename]) 274 275 break 275 276 end 277 timeread(iview)=0; 276 278 %reading the current file 277 279 if testima 278 280 if test_movie(iview) 279 Field{iview}.A=read(MovieObject{iview}, num_i1{iview}(ifile));281 Field{iview}.A=read(MovieObject{iview},i1_series{iview}(ifile)); 280 282 else 281 283 Field{iview}.A=imread(filename); … … 288 290 Field{iview}.CoordUnit='pixel'; 289 291 Field{iview}.AName='image'; 290 timeread(iview)=0;291 292 else 292 293 if testcivx … … 306 307 end 307 308 if ~isempty(NbSlice_calib) 308 Field{iview}.ZIndex=mod( num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;309 Field{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1; 309 310 end 310 311 %transform the input field (e.g; phys) if requested … … 332 333 ResultExt='.png'; 333 334 else 334 ResultExt= Series.FileExt{iview};335 ResultExt=FileExt{iview}; 335 336 end 336 mergename=name_generator(filebase_merge,num_i1{iview}(ifile),num_j1{iview}(ifile),ResultExt,Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile)); 337 i1=i1_series{iview}(ifile); 338 if ~isempty(i2_series{iview}) 339 i2=i2_series{iview}(ifile); 340 else 341 i2=i1; 342 end 343 j1=1; 344 j2=1; 345 if ~isempty(j1_series{iview}) 346 j1=j1_series{iview}(ifile); 347 if ~isempty(j2_series{iview}) 348 j2=j2_series{iview}(ifile); 349 else 350 j2=j1; 351 end 352 end 353 mergename=fullfile_uvmat(res_subdir,'','merged',ResultExt,NomType{iview},i1,i2,j1,j2); 354 % mergename=name_generator(filebase_merge,i1,j1_series{iview}(ifile),ResultExt,NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile)); 337 355 338 356 % time of the merged field: … … 341 359 time_i=sum(timeread)/nbtime; 342 360 else 343 time_i=(time(iview,num_i1{iview}(ifile),num_j1{iview}(ifile))+time(iview,num_i2{iview}(ifile),num_j2{iview}(ifile)))/2; 361 time_i=i1; 362 %time_i=(time(iview,i1,j1)+time(iview,i2,j2))/2; TODO: upgrade 344 363 end 345 364 -
trunk/src/series/sub_background.m
r240 r374 1 1 %'sub_background': substract background to an image series, 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=sub_background(Param) 4 4 % 5 5 %OUTPUT … … 32 32 % In the mode 'volume', nbfield2=1 (1 image at each level) 33 33 % 34 function GUI_input=sub_background ( num_i1,num_i2,num_j1,num_j2,Series)34 function GUI_input=sub_background (Param) 35 35 36 36 %------------------------------------------------------------------------ 37 37 %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 38 if ~exist(' num_i1','var')38 if ~exist('Param','var') 39 39 GUI_input={'RootPath';'on';... 40 40 'SubDir';'off';... % subdirectory of derived files (PIV fields), ('on' by default) … … 57 57 end 58 58 59 %---------------------------------------------------------------- 60 %% initiate the waitbar 61 hseries=guidata(Series.hseries);%handles of the GUI series 62 WaitbarPos=get(hseries.waitbar_frame,'Position'); 63 %----------------------------------------------------------------- 64 if iscell(Series.RootPath) 59 %% input parameters 60 % read the xml file for batch case 61 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 62 Param=xml2struct(Param); 63 else % RUN case: parameters introduced as the input structure Param 64 hseries=guidata(Param.hseries);%handles of the GUI series 65 WaitbarPos=get(hseries.waitbar_frame,'Position'); 66 end 67 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 68 if size(filecell,1)>1 65 69 msgbox_uvmat('ERROR','This function use only one input image series') 66 70 return 67 71 end 68 72 %%% TODO: update with the new conventions%%%%%%%%%%%%%%%%% 69 73 %% determine input image type 70 74 FileType=[];%default -
trunk/src/series/time_series.m
r340 r374 1 1 %'time_series': extract a time series, used with series.fig 2 2 %------------------------------------------------------------------------ 3 % function GUI_input=time_series( num_i1,num_i2,num_j1,num_j2,Series)3 % function GUI_input=time_series(Param) 4 4 % 5 5 %OUTPUT … … 8 8 %INPUT: 9 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)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 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 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 13 %Series: Matlab structure containing information set by the series interface 14 14 % 15 function GUI_input=time_series( num_i1,num_i2,num_j1,num_j2,Series)15 function GUI_input=time_series(Param) 16 16 17 17 %% requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 18 if ~exist(' num_i1','var')18 if ~exist('Param','var') 19 19 GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') 20 20 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) … … 33 33 end 34 34 35 %------------------------------------------------------ 36 hseries=guidata(Series.hseries);%handles in the GUI series 37 WaitbarPos=get(hseries.waitbar_frame,'Position'); %position of the waitbar frame 35 %% input parameters 36 % read the xml file for batch case 37 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 38 Param=xml2struct(Param); 39 else % RUN case: parameters introduced as the input structure Param 40 hseries=guidata(Param.hseries);%handles of the GUI series 41 WaitbarPos=get(hseries.waitbar_frame,'Position'); 42 end 43 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 44 45 46 %% coordinate transform or other user defined transform (TODO: case BATCH ?) 47 transform_fct='';%default 48 if isfield(Param,'transform_fct') % transform function handle 49 transform_fct=Param.transform_fct; 50 end 38 51 39 52 %% projection object … … 51 64 end 52 65 53 %% root names: transform input to cell in case of a single input series 54 if ischar(Series.RootPath) 55 Series.RootPath={Series.RootPath}; 56 Series.RootFile={Series.RootFile}; 57 Series.SubDir={Series.SubDir}; 58 Series.FileExt={Series.FileExt}; 59 Series.NomType={Series.NomType}; 60 num_i1={num_i1}; 61 num_i2={num_i2}; 62 num_j1={num_j1}; 63 num_j2={num_j2}; 64 end 65 ext=Series.FileExt{1}; 66 %% features of the input fields 67 RootPath=Param.InputTable(:,1); 68 RootFile=Param.InputTable(:,3); 69 SubDir=Param.InputTable(:,2); 70 NomType=Param.InputTable(:,4); 71 FileExt=Param.InputTable(:,5); 72 ext=FileExt{1}; 66 73 form=imformats(ext(2:end));%test valid Matlab image formats 67 nbfield=size( num_i1{1},1)*size(num_i1{1},2); %number of fields in the time series74 nbfield=size(i1_series{1},1)*size(i1_series{1},2); %number of fields in the time series 68 75 69 76 %% determine image type 70 77 hhh=which('mmreader'); 71 78 testnetcdf=0; 72 nbview=length( Series.RootPath);%Number of input series: this function accepts only one or two input file series (sub_field is used in the latter case)79 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) 73 80 for iview=1:nbview 74 if isequal( Series.FileExt{iview},'.nc')||isequal(Series.FileExt{iview},'.cdf')81 if isequal(FileExt{iview},'.nc')||isequal(FileExt{iview},'.cdf') 75 82 FileType{iview}='netcdf'; 76 83 testnetcdf=1; 77 elseif isequal(lower( Series.FileExt{iview}),'.avi')84 elseif isequal(lower(FileExt{iview}),'.avi') 78 85 if ~isequal(hhh,'')%&& mmreader.isPlatformSupported() 79 MovieObject{iview}=mmreader(fullfile( Series.RootPath{iview},[Series.RootFile{iview} Series.FileExt{iview}]));86 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); 80 87 FileType{iview}='movie'; 81 88 else 82 89 FileType{iview}='avi'; 83 90 end 84 elseif isequal(lower( Series.FileExt{iview}),'.vol')91 elseif isequal(lower(FileExt{iview}),'.vol') 85 92 FileType{iview}='vol'; 86 93 else 87 form=imformats( Series.FileExt{iview}(2:end));94 form=imformats(FileExt{iview}(2:end)); 88 95 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 89 if isequal( Series.NomType{iview},'*');96 if isequal(NomType{iview},'*'); 90 97 FileType{iview}='multimage'; 91 98 else … … 95 102 end 96 103 end 97 filebase{1}=fullfile( Series.RootPath{1},Series.RootFile{1});104 filebase{1}=fullfile(RootPath{1},RootFile{1}); 98 105 99 106 %% number of slices 100 NbSlice= Series.NbSlice;107 NbSlice=Param.NbSlice; 101 108 102 109 %% Field and velocity type (the same for the two views) 103 if isfield(Series,'Field') 104 FieldName=Series.Field;%the same set of fields for all views 105 else 106 FieldName={''}; 107 end 108 if isequal(FieldName,{''}) && testnetcdf 110 FieldName={''}; 111 112 if isfield(Param,'InputFields')&&isfield(Param.InputFields,'FieldMenu') 113 FieldName=Param.InputFields.FieldMenu;%the same set of fields for all views 114 VelType{1}=Param.InputFields.VelTypeMenu; 115 end 116 if isempty(FieldName) && testnetcdf 109 117 msgbox_uvmat('ERROR','A field must be defined as input') 110 118 return 111 119 end 112 if isequal(FieldName, {'get_field...'})120 if isequal(FieldName,'get_field...') 113 121 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI 114 122 if numel(hget_field)>1 115 123 delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld 116 124 elseif isempty(hget_field) 117 filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),Series.FileExt{1},Series.NomType{1},1,num_i2{1}(1),num_j2{1}(1),Series.SubDir{1}); 125 filename=filecell{1,1}; 126 % filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),num_j2{1}(1),SubDir{1}); 118 127 idetect(iview)=exist(filename,'file'); 119 128 hget_field=get_field(filename); … … 123 132 if isempty(SubField) 124 133 delete(hget_field) 125 filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),Series.FileExt{1},Series.NomType{1},1,num_i2{1}(1),num_j2{1}(1),Series.SubDir{1}); 134 filename=filecell{1,1}; 135 %filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),j2_series{1}(1),SubDir{1}); 126 136 hget_field=get_field(filename); 127 137 SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI … … 135 145 testcivx=isequal(FileType{1},'netcdf'); 136 146 end 137 VelType_str=get(hseries.VelTypeMenu,'String');138 VelType_val=get(hseries.VelTypeMenu,'Value');139 VelType{1}=VelType_str{VelType_val};140 if nbview==2141 VelType_str=get(hseries.VelTypeMenu_1,'String');142 VelType_val=get(hseries.VelTypeMenu_1,'Value');143 VelType{2}=VelType_str{VelType_val};144 end147 % VelType_str=get(hseries.VelTypeMenu,'String'); 148 % VelType_val=get(hseries.VelTypeMenu,'Value'); 149 % VelType{1}=VelType_str{VelType_val}; 150 % if nbview==2 151 % VelType_str=get(hseries.VelTypeMenu_1,'String'); 152 % VelType_val=get(hseries.VelTypeMenu_1,'Value'); 153 % VelType{2}=VelType_str{VelType_val}; 154 % end 145 155 146 156 %% Calibration data and timing: read the ImaDoc files … … 152 162 for iview=1:nbview%Loop on views 153 163 XmlData{iview}=[];%default 154 filebase{iview}=fullfile( Series.RootPath{iview},Series.RootFile{iview});164 filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); 155 165 if exist([filebase{iview} '.xml'],'file') 156 166 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); … … 218 228 %% Root name of output files (TO GENERALISE FOR TWO INPUT SERIES) 219 229 subdir_result='time_series'; 220 pathdir=fullfile( Series.RootPath{1},subdir_result);230 pathdir=fullfile(RootPath{1},subdir_result); 221 231 while exist(pathdir,'dir') 222 232 subdir_result=[subdir_result '.0']; 223 pathdir=fullfile( Series.RootPath{1},subdir_result);233 pathdir=fullfile(RootPath{1},subdir_result); 224 234 end 225 235 [m1,m2,m3]=mkdir(pathdir); … … 233 243 end 234 244 filebase_out=filebase{1}; 235 NomTypeOut=nomtype2pair(Series.NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1)); 236 237 %% coordinate transform or other user defined transform 238 transform_fct=[];%default 239 if isfield(Series,'transform_fct') 240 transform_fct=Series.transform_fct; 241 end 245 i21=i1_series{end}(end); 246 if ~isempty(i2_series{end}) 247 i21=i2_series{end}(end)-i1_series{1}(1); 248 end 249 j21=1; 250 if ~isempty(j1_series{1}) 251 j21=j1_series{end}(end); 252 if ~isempty(j2_series{end}) 253 j21=j2_series{end}(end)-j21; 254 end 255 end 256 NomTypeOut=nomtype2pair(NomType{1},i21,j21); 257 242 258 243 259 %% velocity type … … 264 280 % loop on views (in case of multiple input series) 265 281 for iview=1:nbview 266 filename=name_generator(filebase{iview},... 267 num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),Series.SubDir{iview}); 282 filename=filecell{iview,ifile}; 283 % filename=name_generator(filebase{iview},... 284 % i1_series{iview}(ifile),j1_series{iview}(ifile),FileExt{iview},NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile),SubDir{iview}); 268 285 if exist(filename,'file') 269 286 try … … 274 291 switch FileType{iview} 275 292 case 'movie' 276 A=read(MovieObject{iview}, num_i1{iview}(ifile));293 A=read(MovieObject{iview},i1_series{iview}(ifile)); 277 294 case 'avi' 278 mov=aviread(filename, num_i1{iview}(ifile));295 mov=aviread(filename,i1_series{iview}(ifile)); 279 296 A=frame2im(mov(1)); 280 297 case 'vol' 281 298 A=imread(filename); 282 299 case 'multimage' 283 A=imread(filename, num_i1{iview}(ifile));300 A=imread(filename,i1_series{iview}(ifile)); 284 301 case 'image' 285 302 A=imread(filename); … … 308 325 end 309 326 if ~isempty(NbSlice_calib) % z index 310 Data{iview}.ZIndex=mod( num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;327 Data{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1; 311 328 end 312 329 catch ME … … 397 414 if isequal(ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 398 415 if isempty(VarVal) 399 msgbox_uvmat('ERROR',['empty result at frame index ' num2str( num_i1{iview}(ifile))])416 msgbox_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))]) 400 417 return 401 418 end … … 423 440 RecordData.Time(filecounter,1)=ifile;%default 424 441 end 425 else % time from ImaDoc prevails 426 RecordData.Time(filecounter,1)=(time(1,num_i1{1}(ifile),num_j1{1}(ifile))+time(end,num_i2{end}(ifile),num_j2{end}(ifile)))/2; 442 else % time from ImaDoc prevails TODO: correct 443 % RecordData.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2; 444 RecordData.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise 427 445 end 428 446 … … 472 490 end 473 491 RecordData.VarDimName=[{'Time'} RecordData.VarDimName]; 474 RecordData.Action= Series.Action;%name of the processing programme492 RecordData.Action=Param.Action;%name of the processing programme 475 493 test_time=diff(RecordData.Time)>0;% test that the readed time is increasing (not constant) 476 494 if ~test_time … … 484 502 485 503 %name of result file 486 [filemean]=... 487 name_generator(filebase_out,num_i1{1}(i_slice),num_j1{1}(i_slice),'.nc','_i1-i2_j1-j2',1,num_i2{end}(ifile),num_j2{end}(ifile),subdir_result); 504 % [filemean]=... 505 % name_generator(filebase_out,i1_series{1}(i_slice),j1_series{1}(i_slice),'.nc','_i1-i2_j1-j2',1,i2_series{end}(ifile),j2_series{end}(ifile),subdir_result); 506 filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice)); 488 507 errormsg=struct2nc(filemean,RecordData); %save result file 489 508 if isempty(errormsg)
Note: See TracChangeset
for help on using the changeset viewer.