Changeset 355
- Timestamp:
- Dec 30, 2011, 7:40:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r354 r355 102 102 %% prepare the GUI with parameters from the input file if opened from uvmat 103 103 if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName) 104 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 104 105 errormsg=display_file_name(handles,fileinput); 105 106 if ~isempty(errormsg) 106 107 msgbox_uvmat('ERROR',errormsg) 107 108 end 109 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 108 110 end 109 111 … … 205 207 206 208 %% prepare the GUI with parameters from the input file 209 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 207 210 errormsg=display_file_name(handles,fileinput); 208 211 if ~isempty(errormsg) 209 212 msgbox_uvmat('ERROR',erromsg) 210 213 end 211 214 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 212 215 213 216 %------------------------------------------------------------------------ … … 215 218 function MenuFile_1_Callback(hObject, eventdata, handles) 216 219 %------------------------------------------------------------------------ 220 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 217 221 fileinput=get(handles.MenuFile_1,'Label'); 218 222 errormsg=display_file_name(handles,fileinput); 219 223 if ~isempty(errormsg) 220 msgbox_uvmat('ERROR',erromsg) 221 end 224 msgbox_uvmat('ERROR',errormsg) 225 end 226 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 222 227 223 228 % ----------------------------------------------------------------------- … … 225 230 function MenuFile_2_Callback(hObject, eventdata, handles) 226 231 %------------------------------------------------------------------------ 232 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 227 233 fileinput=get(handles.MenuFile_2,'Label'); 228 234 errormsg=display_file_name(handles,fileinput); 229 235 if ~isempty(errormsg) 230 msgbox_uvmat('ERROR',erromsg) 231 end 236 msgbox_uvmat('ERROR',errormsg) 237 end 238 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 232 239 233 240 % ----------------------------------------------------------------------- … … 235 242 function MenuFile_3_Callback(hObject, eventdata, handles) 236 243 %------------------------------------------------------------------------ 244 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 237 245 fileinput=get(handles.MenuFile_3,'Label'); 238 246 errormsg=display_file_name(handles,fileinput); 239 247 if ~isempty(errormsg) 240 msgbox_uvmat('ERROR',erromsg) 241 end 248 msgbox_uvmat('ERROR',errormsg) 249 end 250 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 242 251 243 252 % ----------------------------------------------------------------------- … … 245 254 function MenuFile_4_Callback(hObject, eventdata, handles) 246 255 %------------------------------------------------------------------------ 256 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 247 257 fileinput=get(handles.MenuFile_4,'Label'); 248 258 errormsg=display_file_name(handles,fileinput); 249 259 if ~isempty(errormsg) 250 msgbox_uvmat('ERROR',erromsg) 251 end 260 msgbox_uvmat('ERROR',errormsg) 261 end 262 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 252 263 253 264 % ----------------------------------------------------------------------- … … 255 266 function MenuFile_5_Callback(hObject, eventdata, handles) 256 267 %------------------------------------------------------------------------ 268 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 257 269 fileinput=get(handles.MenuFile_5,'Label'); 258 270 errormsg=display_file_name(handles,fileinput); 259 271 if ~isempty(errormsg) 260 msgbox_uvmat('ERROR',erro msg)261 end 262 272 msgbox_uvmat('ERROR',errormsg) 273 end 274 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 263 275 % ----------------------------------------------------------------------- 264 276 % --- Prepare the GUI for the compiled CivX program … … 308 320 function RootName_Callback(hObject, eventdata, handles) 309 321 %------------------------------------------------------------------------ 322 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 310 323 filebase=get(handles.RootName,'String'); 311 324 errormsg=display_file_name(handles,filebase); … … 313 326 msgbox_uvmat('ERROR',erromsg) 314 327 end 315 328 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 316 329 %------------------------------------------------------------------------ 317 330 % --- general function activated for an input file series … … 320 333 set(handles.ListCompareMode,'Visible','on') 321 334 errormsg='';%default empty error message 335 drawnow 322 336 323 337 %% enable RUN, BATCH button and 'status' display … … 333 347 %% determine nomenclature types and extension of the input files 334 348 ext_ima='';%default 335 nom_type_ima='';%default336 nom_type_nc='';349 NomTypeIma='';%default 350 NomTypeNc=''; 337 351 %[RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,SubDir]=name2display(fileinput); 338 [RootPath,SubDir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput); 352 [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); 353 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomTypeInput,FileType,Object]=find_file_series(fileinput); 354 if strcmp(NomTypeInput,'*')% movies will be opened at the first frame 355 i1=1; 356 i2=[]; 357 j1=[]; 358 j2=[]; 359 end 360 ind_opening=0;%default 361 switch FileType 362 case 'civdata' 363 Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','Civ1_ImageA'); 364 if isfield(Data,'Txt') 365 errormsg=Data.Txt; 366 return 367 end 368 if ~isempty(Data.CivStage)%test for civ files 369 ind_opening=Data.CivStage; 370 end 371 if ~isempty(Data.Civ1_ImageA)%test for civ files 372 imageinput=Data.Civ1_ImageA; 373 if ~exist(imageinput,'file') 374 errormsg=['the image ' imageinput ' does not exist, please enter an image']; 375 return 376 end 377 end 378 set(handles.MenuMatlab,'checked','on') 379 set(handles.MenuCivX,'checked','off') 380 NomTypeNc=NomTypeInput; 381 case 'civx' 382 Data=nc2struct(fileinput,'ListGlobalAttribute','fix','patch','civ2','fix2'); 383 if ~isempty(Data.fix2) 384 ind_opening=5; 385 elseif ~isempty(Data.civ2) 386 ind_opening=4; 387 elseif ~isempty(Data.patch) 388 ind_opening=3; 389 elseif ~isempty(Data.fix) 390 ind_opening=2; 391 end 392 % look for the input images 393 check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$'));%detect pair label by letter 394 NomTypeIma=NomTypeInput; 395 if check_letter 396 NomTypeIma=NomTypeInput(1:end-1); 397 else 398 r=regexp(NomTypeIma,'.-(?<num2>\d+$','names'); 399 if ~isempty(r) 400 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 401 end 402 end 403 imageinput=fullfile_uvmat(RootPath,'',RootFile,'.png',NomTypeIma,i1,[],j1); 404 if ~exist(imageinput,'file') 405 errormsg='no image corresponds to the input .nc file, please open an image'; 406 return 407 end 408 case {'image','multimage','video'} 409 imageinput=fileinput; 410 NomTypeIma=NomTypeInput; 411 ext_ima=ExtInput; 412 otherwise 413 errormsg='invalid input file: enter an image, a movie or .nc file'; 414 end 415 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomTypeIma,ImageType,Object]=find_file_series(imageinput); 339 416 RootName=fullfile(RootPath,RootFile); 340 417 set(handles.RootName,'String',RootName) 341 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 342 drawnow 343 % i1=str2double(i1_str); 344 % i2=str2double(i2_str); 345 % j1=str2double(j1_str); 346 % j2=str2double(j2_str); 418 MaxIndex_i=max(i1_series(i1_series>0)); 419 MaxIndex_j=max(j1_series(j1_series>0)); 420 347 421 num_ref_i=i1;%efaulmt ref index 348 422 num_ref_j=j1; 349 423 browse=get(handles.RootName,'UserData'); 424 browse.nom_type_nc=NomTypeNc; 425 browse.nom_type_ima=NomTypeInput; 350 426 browse.incr_pair=[0 0];%default 351 427 352 % form=imformats(ext_input(2:end)); 353 check_letter=0; 354 check_separator=0; 355 if ~isempty(ext_input)&&(~isempty(imformats(ext_input(2:end)))||strcmpi(ext_input,'.avi'))% if the extension corresponds to an image or movie format recognized by Matlab 356 ext_ima=ext_input; 357 nom_type_ima=nom_type_input; 358 imagename=fileinput; 359 check_letter=~isempty(regexp(nom_type_ima,'[a|A]$'));%detect pair label by letter 360 else %case of netcdf input file, look for corresponding images 361 nom_type_nc=nom_type_input; 362 imagename=fullfile_uvmat(RootPath,[],RootFile,ext_ima,nom_type_ima,1,[],1); 363 %imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima); 364 i1_str=''; 365 j1_str=''; 366 if ~isnan(i2) 367 num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file 368 browse.incr_pair(1)=i2-i1; 369 browse.incr_pair(2)=0; 370 end 371 %TODO: read the image name in the netcdf file (if documented) 372 %look for double image series '_i_j' 373 check_letter=~isempty(regexp(nom_type_nc,'[ab|AB]$'));%detect pair label by letter 374 if check_letter 375 j1_str=nom_type_nc(end-1); 376 r=regexp(nom_type_nc,'_(?<num1>\d+)','names'); 377 if ~isempty(r) 378 i1_str=r.num1; 379 end 380 else 381 NomTypeIma=regexprep(nom_type_nc,'-\d','');% 382 r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names'); 383 if ~isempty(r_end) 384 j1_str=r.num2; 385 end 386 end 387 r=regexp(NomTypeIma,'_(?<num1>\d+)','names'); 388 if ~isempty(r) 389 i1_str=r.num1; 390 end 391 dirima=dir([RootName '_' i1_str '_' j1_str '.*']); 392 if isempty(dirima) 393 % look for images series with sub marker '_' 394 dirima=dir([RootName '_*' i1_str '.*']); 395 if isempty(dirima) 396 % look for other images series 397 dirima=dir([RootName '*' i1_str '.*']); 398 if isempty(dirima) 399 % look for other images series witth letter appendix 400 appendix=char(96+j1_str); 401 dirima=dir([RootName '*' i1_str appendix '.*']); 402 end 403 end 404 end 405 for ilist=1:numel(dirima) 406 %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name); 407 [tild,tild,tild,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name); 408 form=imformats(ext_list(2:end)); 409 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 410 ext_ima=ext_list; 411 nom_type_ima=nom_type_list; 412 % i1=str2double(i1_str); 413 % j1=str2double(j1_str); 414 % i2=str2double(i2_str); 415 % j2=str2double(j2_str); 416 % set the range of fields (1:1 by default) and selected pair 417 if isempty(i2) 418 num_ref_i=i1; 419 else 420 num_ref_i=floor((i1+i2)/2); 421 browse.incr_pair(1)=i2-i1; 422 browse.incr_pair(2)=0; 423 end 424 if isempty(j2) 425 if isempty(j1) 426 num_ref_j=1; 427 else 428 num_ref_j=j1; 429 end 430 else 431 num_ref_j=floor((j1+j2)/2); 432 browse.incr_pair(2)=j2-j1; 433 end 434 break 435 end 436 end 437 end 438 [RootPath,RootFile,i1_series,tild,j1_series,tild,NomType,FileType,Object]=find_file_series(imagename); 439 MaxIndex_i=max(i1_series(i1_series>0)); 440 MaxIndex_j=max(j1_series(j1_series>0)); 428 % % form=imformats(ext_input(2:end)); 429 % check_letter=0; 430 % check_separator=0; 431 % if ~isempty(ext_input)&&(~isempty(imformats(ext_input(2:end)))||strcmpi(ext_input,'.avi'))% if the extension corresponds to an image or movie format recognized by Matlab 432 % ext_ima=ext_input; 433 % nom_type_ima=nom_type_input; 434 % imagename=fileinput; 435 % check_letter=~isempty(regexp(nom_type_ima,'[a|A]$'));%detect pair label by letter 436 % else %case of netcdf input file, look for corresponding images 437 % nom_type_nc=nom_type_input; 438 % imagename=fullfile_uvmat(RootPath,[],RootFile,ext_ima,nom_type_ima,1,[],1); 439 % %imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima); 440 % i1_str=''; 441 % j1_str=''; 442 % if ~isnan(i2) 443 % num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file 444 % browse.incr_pair(1)=i2-i1; 445 % browse.incr_pair(2)=0; 446 % end 447 % %TODO: read the image name in the netcdf file (if documented) 448 % %look for double image series '_i_j' 449 % check_letter=~isempty(regexp(nom_type_nc,'[ab|AB]$'));%detect pair label by letter 450 % if check_letter 451 % j1_str=nom_type_nc(end-1); 452 % r=regexp(nom_type_nc,'_(?<num1>\d+)','names'); 453 % if ~isempty(r) 454 % i1_str=r.num1; 455 % end 456 % else 457 % NomTypeIma=regexprep(nom_type_nc,'-\d','');% 458 % r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names'); 459 % if ~isempty(r_end) 460 % j1_str=r.num2; 461 % end 462 % end 463 % r=regexp(NomTypeIma,'_(?<num1>\d+)','names'); 464 % if ~isempty(r) 465 % i1_str=r.num1; 466 % end 467 % dirima=dir([RootName '_' i1_str '_' j1_str '.*']); 468 % if isempty(dirima) 469 % % look for images series with sub marker '_' 470 % dirima=dir([RootName '_*' i1_str '.*']); 471 % if isempty(dirima) 472 % % look for other images series 473 % dirima=dir([RootName '*' i1_str '.*']); 474 % if isempty(dirima) 475 % % look for other images series witth letter appendix 476 % appendix=char(96+j1_str); 477 % dirima=dir([RootName '*' i1_str appendix '.*']); 478 % end 479 % end 480 % end 481 % for ilist=1:numel(dirima) 482 % %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name); 483 % [tild,tild,tild,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name); 484 % form=imformats(ext_list(2:end)); 485 % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 486 % ext_ima=ext_list; 487 % nom_type_ima=nom_type_list; 488 % % i1=str2double(i1_str); 489 % % j1=str2double(j1_str); 490 % % i2=str2double(i2_str); 491 % % j2=str2double(j2_str); 492 % % set the range of fields (1:1 by default) and selected pair 493 % if isempty(i2) 494 % num_ref_i=i1; 495 % else 496 % num_ref_i=floor((i1+i2)/2); 497 % browse.incr_pair(1)=i2-i1; 498 % browse.incr_pair(2)=0; 499 % end 500 % if isempty(j2) 501 % if isempty(j1) 502 % num_ref_j=1; 503 % else 504 % num_ref_j=j1; 505 % end 506 % else 507 % num_ref_j=floor((j1+j2)/2); 508 % browse.incr_pair(2)=j2-j1; 509 % end 510 % break 511 % end 512 % end 513 % end 514 441 515 442 516 %% look for an image documentation file … … 567 641 568 642 %% set the civ options depending on the input file content 569 ind_opening=0;%default570 if isequal(ext_input,'.nc')571 browse.nom_type_nc=nom_type_input;572 ind_opening=2;% propose 'fix' as the default option573 Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2');574 if isfield(Data,'Txt')575 msgbox_uvmat('ERROR',Data.Txt)576 return577 end578 if ~isempty(Data.CivStage)%test for civ files579 ind_opening=Data.CivStage;580 set(handles.ListPairMode,'Value',3)581 end582 end643 % ind_opening=0;%default 644 % if isequal(ext_input,'.nc') 645 % browse.nom_type_nc=nom_type_input; 646 % ind_opening=2;% propose 'fix' as the default option 647 % Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); 648 % if isfield(Data,'Txt') 649 % msgbox_uvmat('ERROR',Data.Txt) 650 % return 651 % end 652 % if ~isempty(Data.CivStage)%test for civ files 653 % ind_opening=Data.CivStage; 654 % set(handles.ListPairMode,'Value',3) 655 % end 656 % end 583 657 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; 584 658 for index = 1:ind_opening … … 595 669 % TODO: determine MaxIndex_i and MaxIndex_j using find_file_series (in the absence of xml file) 596 670 % try 597 if ~check_letter|| isequal(nom_type_nc,'_1-2')|| (MaxIndex_j==1) 671 check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter 672 if ~check_letter|| isequal(NomTypeNc,'_1-2')|| (MaxIndex_j==1) 598 673 set(handles.ListPairMode,'Value',1) 599 674 set(handles.ListPairMode,'String',{'series(Di)'}) … … 653 728 654 729 %% store info 655 browse.nom_type_ima=nom_type_ima;730 % browse.nom_type_ima=nom_type_ima; 656 731 set(handles.RootName,'UserData',browse)% store the nomenclature type 657 732
Note: See TracChangeset
for help on using the changeset viewer.