Changeset 374 for trunk/src/series/merge_proj.m
- Timestamp:
- Jan 16, 2012, 12:51:23 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.