Changeset 1059 for trunk/src/browse_data.m
- Timestamp:
- Nov 29, 2018, 5:44:44 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r1039 r1059 24 24 function varargout = browse_data(varargin) 25 25 26 % Last Modified by GUIDE v2.5 24-Jan-2015 16:55:0426 % Last Modified by GUIDE v2.5 08-Sep-2018 19:03:40 27 27 28 28 % Begin initialization code - DO NOT EDIT … … 47 47 %------------------------------------------------------------------------ 48 48 % --- Executes just before browse_data is made visible. 49 function browse_data_OpeningFcn(hObject, eventdata, handles, DataSeries,EnableMirror,MultiDevices)49 function browse_data_OpeningFcn(hObject, eventdata, handles, InputDir,EnableMirror,MultiDevices) 50 50 %------------------------------------------------------------------------ 51 51 52 52 %% Choose default command line output for browse_data 53 handles.output = 'Cancel';53 handles.output =hObject;% 'Cancel'; 54 54 55 55 %% Update handles structure 56 56 guidata(hObject, handles); 57 57 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 58 set(hObject,'DeleteFcn',{@closefcn})% 58 59 59 60 %% Determine the position of the dialog - centered on the screen … … 87 88 88 89 %% initialize the GUI 89 if isempty(regexp(DataSeries,'^http:'))&& ~(exist('DataSeries','var') && ischar(DataSeries) && exist(DataSeries,'dir')) 90 DataSeries=pwd;% current dir is the starting data series by default 91 end 92 [Experiment,DataSeries,Ext]=fileparts(DataSeries); 93 DataSeries=[DataSeries Ext]; 94 [Campaign,Experiment,Ext]=fileparts(Experiment); 95 Experiment=[Experiment Ext]; 90 if isempty(regexp(InputDir,'^http:'))&& ~(exist('InputDir','var') && ischar(InputDir) && exist(InputDir,'dir')) 91 InputDir=pwd;% current dir is the starting data series by default 92 end 93 % [Experiment,DataSeries,Ext]=fileparts(DataSeries); 94 % DataSeries=[DataSeries Ext]; 95 % [Campaign,Experiment,Ext]=fileparts(Experiment); 96 % Experiment=[Experiment Ext]; 97 [ExpWithPath,DataSeries]=fileparts(InputDir); 98 [Campaign,Experiment,Ext]=fileparts(ExpWithPath); 96 99 [tild,CampaignName]=fileparts(Campaign); 97 100 RootXml=fullfile(Campaign,[CampaignName '.xml']); … … 111 114 set(handles.CreateMirror,'String','create_mirror') 112 115 end 113 errormsg=scan_campaign(handles,Campaign,Experiment, DataSeries);116 errormsg=scan_campaign(handles,Campaign,Experiment,ExpWithPath); 114 117 if ~isempty(errormsg) 115 118 msgbox_uvmat('ERROR',errormsg) 116 119 return 117 120 end 118 set(handles.OK,'Visible','on') 119 set(handles.Cancel,'Visible','on') 120 121 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 121 % set(handles.OK,'Visible','on') 122 % set(handles.Cancel,'Visible','on') 123 124 %set(handles.browse_data,'WindowStyle','modal')% Make the GUI 125 %modal%%%%%%%%%%%%%%%%%%%%%%% 122 126 set(hObject,'Visible','on') 123 127 drawnow 124 % UIWAIT makes GUI wait for user response (see UIRESUME) 125 uiwait(handles.browse_data); 128 % UIWAIT makes GUI wait for user response (see UIRESUME)%%%%%%%%%%%%%%%%TO 129 % CHECK 130 %uiwait(handles.browse_data); 126 131 127 132 … … 133 138 % Get default command line output from handles structure 134 139 varargout{1} = handles.output; 135 delete(handles.browse_data)140 %%%%%%%%%%%%%%%%%%delete(handles.browse_data) 136 141 137 142 %------------------------------------------------------------------------ … … 213 218 ListStruct=dir_uvmat(Campaign); %list files and dirs 214 219 if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders 215 errormsg=[Campaign ' contains too many items (>1000) to be a Campaignfolder'];220 errormsg=[Campaign ' contains too many items (>1000) to be a Project folder']; 216 221 return 217 222 end … … 224 229 ListFiles=sort((ListFiles(check_keep))'); 225 230 index=find(strcmp(['+/' Experiment],ListFiles)); 226 if isempty(index), index= 0; end227 set(handles.ListExperiments,'String', [{'*'};ListFiles])228 set(handles.ListExperiments,'Value',index +1)% initialise the menu selection with the folder defined by the input231 if isempty(index), index=1; end 232 set(handles.ListExperiments,'String',ListFiles) 233 set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input 229 234 ListExperiments_Callback([],[], handles) 230 235 ListDevices=get(handles.ListDevices,'String'); … … 252 257 ListExperiments=get(handles.ListExperiments,'String'); 253 258 list_val=get(handles.ListExperiments,'Value'); 254 if isequal(list_val(1),1)255 ListExperiments=ListExperiments(2:end); %choose all experiments if the first line '*' is selected256 set(handles.ListExperiments,'Value',1)257 else259 % if isequal(list_val(1),1) 260 % ListExperiments=ListExperiments(2:end); %choose all experiments if the first line '*' is selected 261 % set(handles.ListExperiments,'Value',1) 262 % else 258 263 ListExperiments=ListExperiments(list_val);%choose selected experiments 259 end264 % end 260 265 list_dataseries(handles,ListExperiments,MirrorPath) 261 266 … … 283 288 else %update the list of dataSeries 284 289 [tild,msg]=fileattrib(mirror); 285 msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name286 if ~strcmp(msg.Name,mirror)% if it is a link287 ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list288 end290 % msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name 291 % if ~strcmp(msg.Name,mirror)% if it is a link 292 % ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list 293 % end 289 294 if check_dir(ilist) 290 295 ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list … … 298 303 end 299 304 end 305 set(handles.ListDevices,'Value',1) 300 306 set(handles.ListDevices,'String',sort(ListDevices)) 301 307 … … 438 444 save(t,outputfile) 439 445 440 % %------------------------------------------------------------------------ 441 % % --- Executes on button press in CampaignDoc. 442 % function edit_xml_Callback(hObject, eventdata, handles) 443 % %------------------------------------------------------------------------ 444 % CurrentPath=get(handles.SourceDir,'String'); 445 % %[CurrentPath,Name,Ext]=fileparts(CurrentDir); 446 % ListExperiments=get(handles.ListExperiments,'String'); 447 % Value=get(handles.ListExperiments,'Value'); 448 % if ~isequal(Value,1) 449 % ListExperiments=ListExperiments(Value); 450 % end 451 % ListDevices=get(handles.ListDevices,'String'); 452 % Value=get(handles.ListDevices,'Value'); 453 % if ~isequal(Value,1) 454 % ListDevices=ListDevices(Value); 455 % end 456 % ListRecords=get(handles.ListRecords,'String'); 457 % Value=get(handles.ListRecords,'Value'); 458 % if ~isequal(Value,1) 459 % ListRecords=ListRecords(Value); 460 % end 461 % [ListDevices,ListRecords,ListXml,List]=dir_scan(CurrentPath,ListExperiments,ListDevices,ListRecords); 462 % ListXml=get(handles.ListXml,'String'); 463 % Value=get(handles.ListXml,'Value'); 464 % set(handles.ListXml,'Value',Value(1)); 465 % if isequal(Value(1),1) 466 % msgbox_uvmat('ERROR','an xml file needs to be selected') 467 % return 468 % else 469 % XmlName=ListXml{Value(1)}; 470 % end 471 % for iexp=1:length(List.Experiment) 472 % ExpName=List.Experiment{iexp}.name; 473 % if isfield(List.Experiment{iexp},'Device') 474 % for idevice=1:length(List.Experiment{iexp}.Device) 475 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 476 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 477 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 478 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 479 % if isequal(FileName,XmlName) 480 % editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); 481 % return 482 % end 483 % end 484 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 485 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 486 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 487 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 488 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 489 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 490 % if isequal(FileName,XmlName) 491 % editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); 492 % return 493 % end 494 % end 495 % end 496 % end 497 % end 498 % end 499 % end 500 % end 501 % 502 % 503 % 504 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 505 % % CurrentPath/Campaign: root directory 506 % function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) 507 % 508 % %Shema for Heading: 509 % % Campaign 510 % % (SubCampaign) 511 % % Experiment 512 % % Device 513 % % (Record) 514 % % ImageName 515 % % DateExp 516 % % old: %Project: suppressed ( changed to Campaign) 517 % %Exp: suppressed (changed to experiment) 518 % %ImaNames: changed to ImageName 519 % if exist('Record','var') && ~isempty(Record) 520 % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 521 % testrecord=1; 522 % else 523 % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); 524 % testrecord=0; 525 % end 526 % if ~exist('testSubCampaign','var') 527 % testSubCampaign=0; 528 % end 529 % if testSubCampaign 530 % SubCampaign=Campaign; 531 % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 532 % Campaign=[Campaign DirExt]; 533 % end 534 % test_mod=0; %test for the modification of the xml file 535 % t_device=xmltree(xmlfullname); 536 % Title=get(t_device,1,'name'); 537 % uid_child=children(t_device,1); 538 % Heading_old=[]; 539 % uidheading=0; 540 % for ilist=1:length(uid_child) 541 % name=get(t_device,uid_child(ilist),'name'); 542 % if isequal(name,'Heading') 543 % uidheading=uid_child(ilist); 544 % end 545 % end 546 % if uidheading 547 % subt=branch(t_device,uidheading); 548 % Heading_old=convert(subt); 549 % else 550 % return % do not edit xml files without element 'Heading' 551 % end 552 % if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) 553 % test_mod=1; 554 % end 555 % Heading.Campaign=Campaign; 556 % if testSubCampaign 557 % if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) 558 % test_mod=1; 559 % end 560 % Heading.SubCampaign=SubCampaign; 561 % end 562 % if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) 563 % test_mod=1; 564 % end 565 % Heading.Experiment=Experiment; 566 % if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) 567 % test_mod=1; 568 % end 569 % Heading.Device=Device; 570 % if testrecord 571 % if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) 572 % test_mod=1; 573 % end 574 % Heading.Record=Record; 575 % end 576 % if isfield(Heading_old,'ImaNames') 577 % test_mod=1; 578 % if ~isempty(Heading_old.ImaNames) 579 % Heading.ImageName=Heading_old.ImaNames; 580 % end 581 % end 582 % if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) 583 % Heading.ImageName=Heading_old.ImageName; 584 % end 585 % if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) 586 % Heading.DateExp=Heading_old.DateExp; 587 % end 588 % if test_mod && uidheading 589 % uid_child=children(t_device,uidheading); 590 % t_device=delete(t_device,uid_child); 591 % t_device=struct2xml(Heading,t_device,uidheading); 592 % backupfile=xmlfullname; 593 % testexist=2; 594 % while testexist==2 595 % backupfile=[backupfile '~']; 596 % testexist=exist(backupfile,'file'); 597 % end 598 % [success,message]=copyfile(xmlfullname,backupfile);%make backup 599 % if isequal(success,1) 600 % delete(xmlfullname) 601 % else 602 % return 603 % end 604 % save(t_device,xmlfullname) 605 % end 446 606 447 607 448 %------------------------------------------------------------------------ … … 648 489 % --- Executes on button press in Cancel. 649 490 %------------------------------------------------------------------------ 650 function Cancel_Callback(hObject, eventdata, handles) 651 652 handles.output = get(hObject,'String'); 653 guidata(hObject, handles); % Update handles structure 654 % Use UIRESUME instead of delete because the OutputFcn needs 655 uiresume(handles.browse_data); 491 % function Cancel_Callback(hObject, eventdata, handles) 492 % % hseries=findobj(allchild(0),'Tag','series'); 493 % % if ~isempty(hseries) 494 % % hhh=guidata(hseries); 495 % % set(hhh.Replicate,'Value',0) 496 % % end 497 % % delete(get(hObject,'parent')) 498 499 % handles.output = get(hObject,'String'); 500 % guidata(hObject, handles); % Update handles structure 501 % % Use UIRESUME instead of delete because the OutputFcn needs 502 % uiresume(handles.browse_data); 503 504 %------------------------------------------------------------------------ 505 % --- executes when user attempts to close geometry_calib. 506 function browse_data_CloseRequestFcn(hObject, eventdata, handles) 656 507 657 508 %------------------------------------------------------------------------ 658 509 % --- Executes when user attempts to close browse_data. 659 510 %------------------------------------------------------------------------ 660 function browse_data_CloseRequestFcn(hObject, eventdata, handles) 661 if isequal(get(handles.browse_data, 'waitstatus'), 'waiting') 662 % The GUI is still in UIWAIT, us UIRESUME 663 handles.output = get(hObject,'String'); 664 guidata(hObject, handles); % Update handles structure 665 uiresume(handles.browse_data); 666 else 667 % The GUI is no longer waiting, just close it 668 delete(handles.browse_data); 511 function closefcn(gcbo, eventdata) 512 % if isequal(get(handles.browse_data, 'waitstatus'), 'waiting') 513 % % The GUI is still in UIWAIT, us UIRESUME 514 % handles.output = get(hObject,'String'); 515 % guidata(hObject, handles); % Update handles structure 516 % uiresume(handles.browse_data); 517 % else 518 % % The GUI is no longer waiting, just close it 519 % delete(handles.browse_data); 520 % end 521 hseries=findobj(allchild(0),'Tag','series'); 522 if ~isempty(hseries) 523 hreplicate=findobj(hseries,'Tag','Replicate'); 524 set(hreplicate,'Value',0) 525 end 526 hcalib=findobj(allchild(0),'Tag','geometry_calib'); 527 if ~isempty(hcalib) 528 hreplicate=findobj(hcalib,'Tag','Replicate'); 529 set(hreplicate,'Value',0) 669 530 end 670 531 … … 689 550 690 551 691 % --- Executes on button press in Browse. 692 function Browse_Callback(hObject, eventdata, handles) 552 % --- Executes on button press in Up. 553 function Up_Callback(hObject, eventdata, handles) 554 SourceDir=get(handles.SourceDir,'String'); 555 % Device=ListDevices{get(handles.ListDevices,'Value')}; 556 % DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir'); 557 % uiresume(handles.browse_data); 558 browse_data(SourceDir) 559 560 561 % --- Executes on button press in Down. 562 function Down_Callback(hObject, eventdata, handles) 563 SourceDir=get(handles.SourceDir,'String'); 564 ListExperiments=get(handles.ListExperiments,'String'); 565 list_val=get(handles.ListExperiments,'Value'); 566 SourceFolder=regexprep(ListExperiments{list_val(1)},'+',''); 567 set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder)) 693 568 ListDevices=get(handles.ListDevices,'String'); 694 Device=ListDevices{get(handles.ListDevices,'Value')}; 695 DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir'); 696 uiresume(handles.browse_data); 697 browse_data(DataSeries) 569 ValueDevice=get(handles.ListDevices,'Value'); 570 set(handles.ListExperiments,'String',ListDevices) 571 set(handles.ListExperiments,'Value',ValueDevice) 572 ListExperiments_Callback(hObject, [], handles) 573 % Device=regexprep(ListDevices{get(handles.ListDevices,'Value')},'+',''); 574 % Device=regexprep(Device,'~',''); 575 % PathDevice=fullfile(SourceDir,SourceFolder,Device); 576 % DirDevice=dir(PathDevice); 577 % NewDevice=DirDevice(end).name; 578 % % uiresume(handles.browse_data); 579 % browse_data(fullfile(PathDevice,NewDevice))
Note: See TracChangeset
for help on using the changeset viewer.