Changeset 651 for trunk/src/browse_data.m
- Timestamp:
- Jun 25, 2013, 12:48:10 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r630 r651 121 121 MirrorDir=get(handles.MirrorDir,'String'); 122 122 else 123 MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser 124 if ~ischar(MirrorRoot) 123 MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir'); 124 % MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser 125 if isempty(MirrorRoot) 125 126 return 126 127 else … … 148 149 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') 149 150 idir=idir+1; 150 ExpName{idir}=hdir(ilist).name; 151 152 mirror=fullfile(MirrorDir,ExpName{idir}); 151 mirror=fullfile(MirrorDir,hdir(ilist).name); 153 152 if ~exist(mirror,'dir') 154 153 mkdir(mirror) 155 154 end 155 ExpName{idir}=['+/' hdir(ilist).name]; 156 156 end 157 157 % look for the list of 'devices' … … 186 186 %SourceDir=get(handles.SourceDir,'String'); 187 187 %MirrorDir=get(handles.MirrorDir,'String'); 188 ExpName={''};188 % ExpName={''}; 189 189 if exist(Campaign,'dir') 190 hdir=dir(Campaign); %list files and dirs 191 idir=0; 192 for ilist=1:length(hdir) 193 if hdir(ilist).isdir 194 dirname=hdir(ilist).name; 195 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') 196 idir=idir+1; 197 ExpName{idir}=hdir(ilist).name; 198 end 199 end 200 end 201 set(handles.ListExperiments,'String',[{'*'};ExpName']) 190 ListStruct=dir(Campaign); %list files and dirs 191 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 192 ListFiles=ListCells(1,:);%list of dir and file names 193 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 194 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 195 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 196 check_keep=cellfun('isempty', cell_remove); 197 ListFiles=sort((ListFiles(check_keep))'); 198 set(handles.ListExperiments,'String',[{'*'};ListFiles]) 202 199 set(handles.ListExperiments,'Value',1) 203 200 ListExperiments_Callback([],[], handles) … … 210 207 %------------------------------------------------------------------------ 211 208 % --- Executes on selection change in ListExperiments. 209 %------------------------------------------------------------------------ 212 210 function ListExperiments_Callback(hObject, eventdata, handles) 213 %------------------------------------------------------------------------ 211 214 212 MirrorPath=''; 215 213 CampaignPath=get(handles.SourceDir,'String'); 216 214 if strcmp(get(handles.MirrorDir,'Visible'),'on') 217 % CampaignPath=get(handles.MirrorDir,'String');218 215 MirrorPath=get(handles.MirrorDir,'String'); 219 else 220 % CampaignPath=get(handles.SourceDir,'String'); 221 end 222 % MirrorPath=get(handles.MirrorDir,'String'); 216 end 223 217 ListExperiments=get(handles.ListExperiments,'String'); 224 218 list_val=get(handles.ListExperiments,'Value'); 225 219 if isequal(list_val(1),1) 226 220 ListExperiments=ListExperiments(2:end); %choose all experiments 227 testList=1;228 221 set(handles.ListExperiments,'Value',1) 229 222 else 230 223 ListExperiments=ListExperiments(list_val);%choose selected experiments 231 testList=0;232 224 end 233 225 scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath) … … 236 228 %------------------------------------------------------------------------ 237 229 % --- Executes on selection change in ListExperiments. 230 %------------------------------------------------------------------------ 238 231 function scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath) 239 %------------------------------------------------------------------------ 232 240 233 ListDevices={}; 241 234 for iexp=1:numel(ListExperiments) 242 hdir=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory 243 idir=0; 244 for ilist=1:length(hdir) 245 if ~isequal(hdir(ilist).name(1),'.') 246 DataSeries=fullfile(CampaignPath,ListExperiments{iexp},hdir(ilist).name); 247 if ~isempty(MirrorPath) 248 mirror=fullfile(MirrorPath,ListExperiments{iexp},hdir(ilist).name); 249 if ~exist(mirror)% create mirror if needed 250 system(['ln -s ' DataSeries ' ' mirror]) 251 end 252 end 253 check_list=strcmp(hdir(ilist).name,ListDevices); 254 if isempty(find(check_list, 1)) 255 ListDevices=[ListDevices;hdir(ilist).name]; 235 if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory 236 ListExperiments{iexp}(1)=[]; 237 ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory 238 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 239 ListFiles=ListCells(1,:);%list of dir and file names 240 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 241 check_keep=cellfun('isempty', cell_remove); 242 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 243 for ilist=1:numel(ListFiles) 244 if check_keep(ilist) 245 DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist}); 246 if ~isempty(MirrorPath) 247 mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist}); 248 if ~exist(mirror)% create mirror if needed 249 system(['ln -s ' DataSeries ' ' mirror]) 250 end 251 end 252 if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices 253 if check_dir(ilist) 254 ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list 255 end 256 ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list 257 end 256 258 end 257 259 end 258 260 end 259 261 end 260 set(handles.ListDevices,'String',ListDevices) 261 262 %------------------------------------------------------------------------ 263 % --- Executes on button press in update_headings. 264 function ListDevices_Callback(hObject, eventdata, handles) 265 % CurrentPath=get(handles.SourceDir,'String'); 266 % ListExperiments=get(handles.ListExperiments,'String'); 267 % list_val=get(handles.ListExperiments,'Value'); 268 % if isequal(list_val,1) 269 % ListExperiments=ListExperiments(2:end); 270 % else 271 % ListExperiments=ListExperiments(list_val); 272 % end 273 % set(handles.ListRecords,'Value',1) 274 % set(handles.ListXml,'Value',1) 275 % ListDevices=get(handles.ListDevices,'String'); 276 % list_val=get(handles.ListDevices,'Value'); 277 % if isequal(list_val,1) 278 % ListDevices=ListDevices(2:end); 279 % else 280 % ListDevices=ListDevices(list_val); 281 % end 282 % [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); 283 % set(handles.ListRecords,'String',[{'*'};ListRecords']) 284 % set(handles.ListXml,'String',[{'*'};ListXml']) 285 % 286 % 287 % if strcmp(get(handles.MirrorDir,'Visible'),'on') 288 % CurrentPath=get(handles.MirrorDir,'String'); 289 % else 290 % CurrentPath=get(handles.SourceDir,'String'); 291 % end 292 % ListDevices=get(handles.ListDevices,'String'); 293 % Device=ListDevices(get(handles.ListDevices,'Value')); 294 % % else 295 % hdir=dir(fullfile(SourcePath,Device)); %list files and dirs 296 297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 298 299 300 301 %------------------------------------------------------------------------ 302 % --- Executes on selection change in ListRecords. 303 function ListRecords_Callback(hObject, eventdata, handles) 304 Value=get(handles.ListRecords,'Value'); 305 if isequal(Value(1),1) 306 set(handles.ListRecords,'Value',1); 307 end 262 set(handles.ListDevices,'String',sort(ListDevices)) 308 263 309 264 %------------------------------------------------------------------------ … … 311 266 function CampaignDoc_Callback(hObject, eventdata, handles) 312 267 %------------------------------------------------------------------------ 313 answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file') 268 answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file'); 314 269 if ~isequal(answer{1},'OK') 315 270 return … … 351 306 [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); 352 307 if test 353 [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']308 disp([List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']) 354 309 end 355 310 if isequal(Title,'ImaDoc') … … 369 324 [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); 370 325 if test 371 [FileName ' , Heading updated']326 disp([FileName ' , Heading updated']) 372 327 end 373 328 [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); … … 426 381 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 427 382 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 428 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} 383 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 429 384 if isequal(FileName,XmlName) 430 385 editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); … … 556 511 557 512 %------------------------------------------------------------------------ 558 % --- Executes on button press in HELP.559 function HELP_Callback(hObject, eventdata, handles)560 path_to_uvmat=which ('uvmat')% check the path of uvmat561 pathelp=fileparts(path_to_uvmat);562 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');563 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')564 else565 web([helpfile '#dataview'])566 end567 568 569 570 % --- Executes on selection change in ListXml.571 function ListXml_Callback(hObject, eventdata, handles)572 Value=get(handles.ListXml,'Value');573 if isequal(Value(1),1)574 set(handles.ListXml,'Value',1);575 end576 577 578 % --- Executes on button press in clean_civ_cmx.579 function clean_civ_cmx_Callback(hObject, eventdata, handles)580 message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)';581 answer=msgbox_uvmat('INPUT_Y-N',message);582 if ~isequal(answer,'Yes')583 return584 end585 set(handles.ListExperiments,'Value',1)586 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories587 DataviewData=get(handles.browse_data,'UserData')588 List=DataviewData.List;589 Currentpath=get(handles.SourceDir,'String');590 [Currentpath,Campaign,DirExt]=fileparts(Currentpath);591 Campaign=[Campaign DirExt];592 SubCampaignTest=get(handles.SubCampaignTest,'Value');593 nbdelete_tot=0;594 for iexp=1:length(List.Experiment)595 set(handles.ListExperiments,'Value',iexp+1)596 drawnow597 test_mod=0;598 ExpName=List.Experiment{iexp}.name;599 nbdelete=0;600 if isfield(List.Experiment{iexp},'Device')601 for idevice=1:length(List.Experiment{iexp}.Device)602 DeviceName=List.Experiment{iexp}.Device{idevice}.name;603 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')604 currentdir=fullfile(Currentpath,Campaign,ExpName,DeviceName);605 hdir=dir(currentdir); %list files and dirs606 idir=0;607 for ilist=1:length(hdir)608 if hdir(ilist).isdir609 dirname=hdir(ilist).name;610 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')611 CivDir=fullfile(currentdir,dirname)612 hCivDir=dir(CivDir);613 for ilist=1:length(hCivDir)614 FileName=hCivDir(ilist).name;615 [dd,ff,Ext]=fileparts(FileName);616 if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors')617 delete(fullfile(CivDir,FileName))618 nbdelete=nbdelete+1;619 end620 end621 end622 end623 end624 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')625 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)626 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;627 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')628 'look at subdirectories'629 end630 end631 end632 end633 end634 display([num2str(nbdelete) ' files deleted'])635 nbdelete_tot=nbdelete_tot+nbdelete;636 end637 msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete_tot) ' files deleted by clean_civ_cmx'])638 set(handles.ListExperiments,'Value',1)639 640 641 513 % --- Executes on button press in OK. 514 %------------------------------------------------------------------------ 642 515 function OK_Callback(hObject, eventdata, handles) 643 %------------------------------------------------------------------------ 516 644 517 if strcmp(get(handles.MirrorDir,'Visible'),'on') 645 518 Campaign=get(handles.MirrorDir,'String'); … … 653 526 Experiment=Experiment(IndicesExp);% use the selection of the list of experiments 654 527 end 528 Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir 655 529 Device=get(handles.ListDevices,'String'); 656 530 Value=get(handles.ListDevices,'Value'); 657 531 Device=Device(Value); 532 Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir 658 533 handles.output.Experiment=Experiment; 659 handles.output.D evice=Device;534 handles.output.DataSeries=Device; 660 535 guidata(hObject, handles);% Update handles structure 661 536 uiresume(handles.browse_data); 662 537 drawnow 663 return 664 665 666 % ListRecords=get(handles.ListRecords,'String'); 667 % Value=get(handles.ListRecords,'Value'); 668 % if ~isequal(Value,1) 669 % ListRecords=ListRecords(Value); 670 % end 671 672 %[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices); 673 ListXml=get(handles.ListXml,'String'); 674 Value=get(handles.ListXml,'Value'); 675 if isequal(Value,1) 676 msgbox_uvmat('ERROR','you need to select in the GUI browse_data the xml files to edit') 677 return 678 else 679 ListXml=ListXml(Value); 680 end 681 682 %update all the selected xml files 683 DataviewData=get(handles.browse_data,'UserData'); 684 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... 685 % DataviewData.GeometryCalib.CalibrationType ' calibration data']) 686 % if ~isequal(answer,'Yes') 687 % return 688 % end 689 %List.Experiment{1}.Device{1} 690 %List.Experiment{2}.Device{1} 691 for iexp=1:length(List.Experiment) 692 ExpName=List.Experiment{iexp}.name; 693 set(handles.ListExperiments,'Value',IndicesExp(iexp)); 694 if isfield(List.Experiment{iexp},'Device') 695 for idevice=1:length(List.Experiment{iexp}.Device) 696 DeviceName=List.Experiment{iexp}.Device{idevice}.name; 697 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 698 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 699 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 700 for ilistxml=1:length(ListXml) 701 if isequal(FileName,ListXml{ilistxml}) 702 set(handles.ListXml,'Value',Value(ilistxml)) 703 drawnow 704 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); 705 update_imadoc(DataviewData.GeometryCalib,xmlfullname,'GeometryCalib') 706 display([xmlfullname ' updated']) 707 break 708 end 709 end 710 end 711 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 712 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 713 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 714 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 715 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 716 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 717 for ilistxml=1:length(ListXml) 718 if isequal(FileName,ListXml{ilistxml}) 719 set(handles.ListXml,'Value',Value(ilistxml)) 720 drawnow 721 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); 722 update_imadoc(DataviewData.GeometryCalib,xmlfullname,'GeometryCalib') 723 display([xmlfullname ' updated']) 724 break 725 end 726 end 727 end 728 end 729 end 730 end 731 end 732 end 733 end 734 set(handles.ListXml,'Value',Value) 735 % 736 % 737 % 738 % 739 % 740 % 741 % 742 % CurrentPath=get(handles.SourceDir,'String');%= get(hObject,'String'); 743 % ListExperiments=get(handles.ListExperiments,'String'); 744 % Value=get(handles.ListExperiments,'Value'); 745 % if ~isequal(Value,1) 746 % ListExperiments=ListExperiments(Value); 747 % end 748 % ListDevices=get(handles.ListDevices,'String'); 749 % Value=get(handles.ListDevices,'Value'); 750 % if isequal(Value,1) 751 % msgbox_uvmat('ERROR','manually select in the GUI browse_data the device being calibrated') 752 % return 753 % else 754 % ListDevices=ListDevices(Value); 755 % end 756 % ListRecords=get(handles.ListRecords,'String'); 757 % Value=get(handles.ListRecords,'Value'); 758 % if ~isequal(Value,1) 759 % ListRecords=ListRecords(Value); 760 % end 761 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 762 % ListXml=get(handles.ListXml,'String'); 763 % Value=get(handles.ListXml,'Value'); 764 % if isequal(Value,1) 765 % msgbox_uvmat('ERROR','you need to select in the GUI browse_data the xml files to edit') 766 % return 767 % else 768 % ListXml=ListXml(Value); 769 % end 770 % handles.output.CurrentPath=CurrentPath; 771 % handles.output.ListExperiments=ListExperiments; 772 % handles.output.ListDevices=ListDevices; 773 % handles.output.ListRecords=ListRecords; 774 % handles.output.ListXml=ListXml; 775 % handles.output.List=List; 776 % handles.output ='OK, Calibration replicated'; 777 % guidata(hObject, handles);% Update handles structure 778 % uiresume(handles.browse_data); 779 538 539 %------------------------------------------------------------------------ 540 % --- Executes on button press in HELP. 541 function HELP_Callback(hObject, eventdata, handles) 542 path_to_uvmat=which ('uvmat');% check the path of uvmat 543 pathelp=fileparts(path_to_uvmat); 544 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); 545 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') 546 else 547 web([helpfile '#dataview']) 548 end 549 550 %------------------------------------------------------------------------ 780 551 % --- Executes on button press in Cancel. 552 %------------------------------------------------------------------------ 781 553 function Cancel_Callback(hObject, eventdata, handles) 554 782 555 handles.output = get(hObject,'String'); 783 556 guidata(hObject, handles); % Update handles structure … … 785 558 uiresume(handles.browse_data); 786 559 560 %------------------------------------------------------------------------ 787 561 % --- Executes when user attempts to close browse_data. 562 %------------------------------------------------------------------------ 788 563 function browse_data_CloseRequestFcn(hObject, eventdata, handles) 564 789 565 if isequal(get(handles.browse_data, 'waitstatus'), 'waiting') 790 566 % The GUI is still in UIWAIT, us UIRESUME … … 795 571 end 796 572 573 %------------------------------------------------------------------------ 797 574 % --- Executes on key press over figure1 with no controls selected. 575 %------------------------------------------------------------------------ 798 576 function browse_data_KeyPressFcn(hObject, eventdata, handles) 577 799 578 % Check for "enter" or "escape" 800 579 if isequal(get(hObject,'CurrentKey'),'escape')
Note: See TracChangeset
for help on using the changeset viewer.