[2] | 1 | %TEST 'dataview': function for scanning directories in a campaign (TEST) |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function varargout = series(varargin) |
---|
| 4 | % associated with the GUI dataview.fig |
---|
| 5 | % |
---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % This file is part of the toolbox UVMAT. |
---|
| 10 | % |
---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published by |
---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 14 | % (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | |
---|
| 22 | function varargout = dataview(varargin) |
---|
| 23 | |
---|
| 24 | % Last Modified by GUIDE v2.5 28-Apr-2009 00:12:36 |
---|
| 25 | |
---|
| 26 | % Begin initialization code - DO NOT EDIT |
---|
| 27 | gui_Singleton = 1; |
---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @dataview_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @dataview_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
| 34 | if nargin & isstr(varargin{1}) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | % --- Executes just before dataview is made visible. |
---|
| 47 | function dataview_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
| 48 | |
---|
| 49 | % Choose default command line output for dataview |
---|
| 50 | handles.output = hObject; |
---|
| 51 | |
---|
| 52 | % Update handles structure |
---|
| 53 | guidata(hObject, handles); |
---|
| 54 | |
---|
| 55 | %---------------------------------------------------------------- |
---|
| 56 | % --- Outputs from this function are returned to the command line. |
---|
| 57 | function varargout = dataview_OutputFcn(hObject, eventdata, handles) |
---|
| 58 | |
---|
| 59 | % Get default command line output from handles structure |
---|
| 60 | varargout{1} = handles.output; |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 65 | %------------------------------------------------------ |
---|
| 66 | % --- Executes on button press in browser. |
---|
| 67 | function browser_Callback(hObject, eventdata, handles) |
---|
| 68 | %------------------------------------------------------------------------ |
---|
| 69 | |
---|
| 70 | CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String'); |
---|
| 71 | set(handles.SubCampaignTest,'Value',0) |
---|
| 72 | CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser |
---|
| 73 | set(handles.RootDirectory,'String',CampaignDir) |
---|
| 74 | RootDirectory_Callback(hObject, eventdata, handles) |
---|
| 75 | |
---|
| 76 | % --- Executes on button press in open_SubCampaign. |
---|
| 77 | function OpenSubCampaign_Callback(hObject, eventdata, handles) |
---|
| 78 | CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String'); |
---|
| 79 | set(handles.SubCampaignTest,'Value',1) |
---|
| 80 | CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser |
---|
| 81 | set(handles.RootDirectory,'String',CampaignDir) |
---|
| 82 | |
---|
| 83 | RootDirectory_Callback(hObject, eventdata, handles) |
---|
| 84 | |
---|
| 85 | %------------------------------------------------------------------------ |
---|
| 86 | |
---|
| 87 | function RootDirectory_Callback(hObject, eventdata, handles) |
---|
| 88 | CampaignDir=get(handles.RootDirectory,'String'); |
---|
| 89 | if exist(CampaignDir,'dir') |
---|
| 90 | hdir=dir(CampaignDir); %list files and dirs |
---|
| 91 | idir=0; |
---|
| 92 | for ilist=1:length(hdir) |
---|
| 93 | if hdir(ilist).isdir |
---|
| 94 | dirname=hdir(ilist).name; |
---|
| 95 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 96 | idir=idir+1; |
---|
| 97 | ExpName{idir}=hdir(ilist).name; |
---|
| 98 | end |
---|
| 99 | % look for the list of 'devices' |
---|
| 100 | else |
---|
| 101 | %warning for isolated files |
---|
| 102 | end |
---|
| 103 | end |
---|
| 104 | set(handles.ListExperiments,'String',[{'*'};ExpName']) |
---|
| 105 | set(handles.ListExperiments,'Value',1) |
---|
| 106 | ListExperiments_Callback(hObject, eventdata, handles) |
---|
| 107 | else |
---|
| 108 | warndlg_uvmat(['The input ' CampaignDir ' is not a directory'],'ERROR') |
---|
| 109 | end |
---|
| 110 | |
---|
| 111 | %------------------------------------------------------------------------ |
---|
| 112 | % --- Executes on selection change in ListExperiments. |
---|
| 113 | function ListExperiments_Callback(hObject, eventdata, handles) |
---|
| 114 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 115 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 116 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 117 | if isequal(list_val(1),1) |
---|
| 118 | ListExperiments=ListExperiments(2:end); %choose all experiments |
---|
| 119 | testList=1; |
---|
| 120 | set(handles.ListExperiments,'Value',1) |
---|
| 121 | else |
---|
| 122 | ListExperiments=ListExperiments(list_val);%choose selected experiments |
---|
| 123 | testList=0; |
---|
| 124 | end |
---|
| 125 | set(handles.ListDevices,'Value',1) |
---|
| 126 | set(handles.ListRecords,'Value',1) |
---|
| 127 | set(handles.ListXml,'Value',1) |
---|
| 128 | [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,{},{}); |
---|
| 129 | set(handles.ListRecords,'String',[{'*'};ListRecords']) |
---|
| 130 | set(handles.ListDevices,'String',[{'*'};ListDevices']) |
---|
| 131 | set(handles.ListXml,'String',[{'*'};ListXml']) |
---|
| 132 | if testList |
---|
| 133 | hh=get(handles.ListExperiments,'parent'); |
---|
| 134 | set(hh,'UserData',List) |
---|
| 135 | end |
---|
| 136 | set(handles.CampaignDoc,'Visible','on') |
---|
| 137 | set(handles.edit_xml,'Visible','on') |
---|
| 138 | |
---|
| 139 | %------------------------------------------------------------------------ |
---|
| 140 | % --- Executes on button press in update_headings. |
---|
| 141 | function ListDevices_Callback(hObject, eventdata, handles) |
---|
| 142 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 143 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 144 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 145 | if isequal(list_val,1) |
---|
| 146 | ListExperiments=ListExperiments(2:end); |
---|
| 147 | else |
---|
| 148 | ListExperiments=ListExperiments(list_val); |
---|
| 149 | end |
---|
| 150 | set(handles.ListRecords,'Value',1) |
---|
| 151 | set(handles.ListXml,'Value',1) |
---|
| 152 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 153 | list_val=get(handles.ListDevices,'Value'); |
---|
| 154 | if isequal(list_val,1) |
---|
| 155 | ListDevices=ListDevices(2:end); |
---|
| 156 | else |
---|
| 157 | ListDevices=ListDevices(list_val); |
---|
| 158 | end |
---|
| 159 | [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); |
---|
| 160 | set(handles.ListRecords,'String',[{'*'};ListRecords']) |
---|
| 161 | set(handles.ListXml,'String',[{'*'};ListXml']) |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | %------------------------------------------------------------------------ |
---|
| 169 | % --- Executes on selection change in ListRecords. |
---|
| 170 | function ListRecords_Callback(hObject, eventdata, handles) |
---|
| 171 | Value=get(handles.ListRecords,'Value'); |
---|
| 172 | if isequal(Value(1),1) |
---|
| 173 | set(handles.ListRecords,'Value',1); |
---|
| 174 | end |
---|
| 175 | |
---|
| 176 | %------------------------------------------------------------------------ |
---|
| 177 | % --- Executes on button press in CampaignDoc. |
---|
| 178 | function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
| 179 | %------------------------------------------------------------------------ |
---|
| 180 | 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') |
---|
| 181 | if ~isequal(answer{1},'OK') |
---|
| 182 | return |
---|
| 183 | end |
---|
| 184 | set(handles.ListExperiments,'Value',1) |
---|
| 185 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
| 186 | hh=get(handles.CampaignDoc,'parent'); |
---|
| 187 | List=get(hh,'UserData'); |
---|
| 188 | Currentpath=get(handles.RootDirectory,'String'); |
---|
| 189 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 190 | Campaign=[Campaign DirExt]; |
---|
| 191 | t=xmltree; |
---|
| 192 | t=set(t,1,'name','CampaignDoc'); |
---|
| 193 | t = attributes(t,'add',1,'source','directory'); |
---|
| 194 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 195 | root_uid=1; |
---|
| 196 | if SubCampaignTest |
---|
| 197 | %TO DO open an exoiting xml doc |
---|
| 198 | [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
| 199 | t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
| 200 | end |
---|
| 201 | for iexp=1:length(List.Experiment) |
---|
| 202 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 203 | drawnow |
---|
| 204 | test_mod=0; |
---|
| 205 | [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
| 206 | t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
| 207 | ExpName=List.Experiment{iexp}.name; |
---|
| 208 | t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
| 209 | |
---|
| 210 | if isfield(List.Experiment{iexp},'Device') |
---|
| 211 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 212 | [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
| 213 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 214 | t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
| 215 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 216 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 217 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 218 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
| 219 | if test |
---|
| 220 | [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] |
---|
| 221 | end |
---|
| 222 | if isequal(Title,'ImaDoc') |
---|
| 223 | [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
| 224 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 225 | [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
| 226 | end |
---|
| 227 | end |
---|
| 228 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 229 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 230 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 231 | [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
| 232 | t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
| 233 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 234 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 235 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 236 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
| 237 | if test |
---|
| 238 | [FileName ' , Heading updated'] |
---|
| 239 | end |
---|
| 240 | [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
| 241 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 242 | [t]=add(t,uid_xml,'chardata',FileName); |
---|
| 243 | end |
---|
| 244 | end |
---|
| 245 | end |
---|
| 246 | end |
---|
| 247 | end |
---|
| 248 | end |
---|
| 249 | end |
---|
| 250 | set(handles.ListExperiments,'Value',1) |
---|
| 251 | outputdir=get(handles.RootDirectory,'String'); |
---|
| 252 | [path,dirname]=fileparts(outputdir); |
---|
| 253 | outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
| 254 | %campaigndoc(t); |
---|
| 255 | save(t,outputfile) |
---|
| 256 | |
---|
| 257 | %------------------------------------------------------------------------ |
---|
| 258 | % --- Executes on button press in CampaignDoc. |
---|
| 259 | function edit_xml_Callback(hObject, eventdata, handles) |
---|
| 260 | %------------------------------------------------------------------------ |
---|
| 261 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 262 | %[CurrentPath,Name,Ext]=fileparts(CurrentDir); |
---|
| 263 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 264 | Value=get(handles.ListExperiments,'Value'); |
---|
| 265 | if ~isequal(Value,1) |
---|
| 266 | ListExperiments=ListExperiments(Value); |
---|
| 267 | end |
---|
| 268 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 269 | Value=get(handles.ListDevices,'Value'); |
---|
| 270 | if ~isequal(Value,1) |
---|
| 271 | ListDevices=ListDevices(Value); |
---|
| 272 | end |
---|
| 273 | ListRecords=get(handles.ListRecords,'String'); |
---|
| 274 | Value=get(handles.ListRecords,'Value'); |
---|
| 275 | if ~isequal(Value,1) |
---|
| 276 | ListRecords=ListRecords(Value); |
---|
| 277 | end |
---|
| 278 | [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 279 | ListXml=get(handles.ListXml,'String'); |
---|
| 280 | Value=get(handles.ListXml,'Value'); |
---|
| 281 | set(handles.ListXml,'Value',Value(1)); |
---|
| 282 | if isequal(Value(1),1) |
---|
| 283 | warndlg_uvmat('an xml file needs to be selected','ERROR') |
---|
| 284 | return |
---|
| 285 | else |
---|
| 286 | XmlName=ListXml{Value(1)}; |
---|
| 287 | end |
---|
| 288 | for iexp=1:length(List.Experiment) |
---|
| 289 | ExpName=List.Experiment{iexp}.name; |
---|
| 290 | if isfield(List.Experiment{iexp},'Device') |
---|
| 291 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 292 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 293 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 294 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 295 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} |
---|
| 296 | if isequal(FileName,XmlName) |
---|
| 297 | editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); |
---|
| 298 | return |
---|
| 299 | end |
---|
| 300 | end |
---|
| 301 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 302 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 303 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 304 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 305 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 306 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 307 | if isequal(FileName,XmlName) |
---|
| 308 | editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); |
---|
| 309 | return |
---|
| 310 | end |
---|
| 311 | end |
---|
| 312 | end |
---|
| 313 | end |
---|
| 314 | end |
---|
| 315 | end |
---|
| 316 | end |
---|
| 317 | end |
---|
| 318 | |
---|
| 319 | |
---|
| 320 | |
---|
| 321 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 322 | % CurrentPath/Campaign: root directory |
---|
| 323 | function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) |
---|
| 324 | |
---|
| 325 | %Shema for Heading: |
---|
| 326 | % Campaign |
---|
| 327 | % (SubCampaign) |
---|
| 328 | % Experiment |
---|
| 329 | % Device |
---|
| 330 | % (Record) |
---|
| 331 | % ImageName |
---|
| 332 | % DateExp |
---|
| 333 | % old: %Project: suppressed ( changed to Campaign) |
---|
| 334 | %Exp: suppressed (changed to experiment) |
---|
| 335 | %ImaNames: changed to ImageName |
---|
| 336 | if exist('Record','var') && ~isempty(Record) |
---|
| 337 | xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); |
---|
| 338 | testrecord=1; |
---|
| 339 | else |
---|
| 340 | xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); |
---|
| 341 | testrecord=0; |
---|
| 342 | end |
---|
| 343 | if ~exist('testSubCampaign','var') |
---|
| 344 | testSubCampaign=0; |
---|
| 345 | end |
---|
| 346 | if testSubCampaign |
---|
| 347 | SubCampaign=Campaign; |
---|
| 348 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 349 | Campaign=[Campaign DirExt]; |
---|
| 350 | end |
---|
| 351 | test_mod=0; %test for the modification of the xml file |
---|
| 352 | t_device=xmltree(xmlfullname); |
---|
| 353 | Title=get(t_device,1,'name'); |
---|
| 354 | uid_child=children(t_device,1); |
---|
| 355 | Heading_old=[]; |
---|
| 356 | uidheading=0; |
---|
| 357 | for ilist=1:length(uid_child) |
---|
| 358 | name=get(t_device,uid_child(ilist),'name'); |
---|
| 359 | if isequal(name,'Heading') |
---|
| 360 | uidheading=uid_child(ilist); |
---|
| 361 | end |
---|
| 362 | end |
---|
| 363 | if uidheading |
---|
| 364 | subt=branch(t_device,uidheading); |
---|
| 365 | Heading_old=convert(subt); |
---|
| 366 | else |
---|
| 367 | return % do not edit xml files without element 'Heading' |
---|
| 368 | end |
---|
| 369 | if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) |
---|
| 370 | test_mod=1; |
---|
| 371 | end |
---|
| 372 | Heading.Campaign=Campaign; |
---|
| 373 | if testSubCampaign |
---|
| 374 | if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) |
---|
| 375 | test_mod=1; |
---|
| 376 | end |
---|
| 377 | Heading.SubCampaign=SubCampaign; |
---|
| 378 | end |
---|
| 379 | if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) |
---|
| 380 | test_mod=1; |
---|
| 381 | end |
---|
| 382 | Heading.Experiment=Experiment; |
---|
| 383 | if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) |
---|
| 384 | test_mod=1; |
---|
| 385 | end |
---|
| 386 | Heading.Device=Device; |
---|
| 387 | if testrecord |
---|
| 388 | if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) |
---|
| 389 | test_mod=1; |
---|
| 390 | end |
---|
| 391 | Heading.Record=Record; |
---|
| 392 | end |
---|
| 393 | if isfield(Heading_old,'ImaNames') |
---|
| 394 | test_mod=1; |
---|
| 395 | if ~isempty(Heading_old.ImaNames) |
---|
| 396 | Heading.ImageName=Heading_old.ImaNames; |
---|
| 397 | end |
---|
| 398 | end |
---|
| 399 | if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) |
---|
| 400 | Heading.ImageName=Heading_old.ImageName; |
---|
| 401 | end |
---|
| 402 | if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) |
---|
| 403 | Heading.DateExp=Heading_old.DateExp; |
---|
| 404 | end |
---|
| 405 | if test_mod && uidheading |
---|
| 406 | uid_child=children(t_device,uidheading); |
---|
| 407 | t_device=delete(t_device,uid_child); |
---|
| 408 | t_device=struct2xml(Heading,t_device,uidheading); |
---|
| 409 | backupfile=xmlfullname; |
---|
| 410 | testexist=2; |
---|
| 411 | while testexist==2 |
---|
| 412 | backupfile=[backupfile '~']; |
---|
| 413 | testexist=exist(backupfile,'file'); |
---|
| 414 | end |
---|
| 415 | [success,message]=copyfile(xmlfullname,backupfile);%make backup |
---|
| 416 | if isequal(success,1) |
---|
| 417 | delete(xmlfullname) |
---|
| 418 | else |
---|
| 419 | return |
---|
| 420 | end |
---|
| 421 | save(t_device,xmlfullname) |
---|
| 422 | end |
---|
| 423 | |
---|
| 424 | % --- Executes on button press in HELP. |
---|
| 425 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 426 | path_to_uvmat=which ('uvmat')% check the path of uvmat |
---|
| 427 | pathelp=fileparts(path_to_uvmat); |
---|
| 428 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 429 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 430 | else |
---|
| 431 | web([helpfile '#dataview']) |
---|
| 432 | end |
---|
| 433 | |
---|
| 434 | |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | % --- Executes on button press in SubCampaignTest. |
---|
| 438 | function SubCampaignTest_Callback(hObject, eventdata, handles) |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | % --- Executes on selection change in ListXml. |
---|
| 442 | function ListXml_Callback(hObject, eventdata, handles) |
---|
| 443 | Value=get(handles.ListXml,'Value'); |
---|
| 444 | if isequal(Value(1),1) |
---|
| 445 | set(handles.ListXml,'Value',1); |
---|
| 446 | end |
---|
| 447 | |
---|
| 448 | |
---|
| 449 | % --- Executes on button press in clean_civ_cmx. |
---|
| 450 | function clean_civ_cmx_Callback(hObject, eventdata, handles) |
---|
| 451 | message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)'; |
---|
| 452 | answer=msgbox_uvmat('INPUT_Y-N',message); |
---|
| 453 | if ~isequal(answer{1},'OK') |
---|
| 454 | return |
---|
| 455 | end |
---|
| 456 | set(handles.ListExperiments,'Value',1) |
---|
| 457 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
| 458 | hh=get(handles.CampaignDoc,'parent'); |
---|
| 459 | List=get(hh,'UserData'); |
---|
| 460 | Currentpath=get(handles.RootDirectory,'String'); |
---|
| 461 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 462 | Campaign=[Campaign DirExt]; |
---|
| 463 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 464 | nbdelete_tot=0; |
---|
| 465 | for iexp=1:length(List.Experiment) |
---|
| 466 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 467 | drawnow |
---|
| 468 | test_mod=0; |
---|
| 469 | ExpName=List.Experiment{iexp}.name; |
---|
| 470 | nbdelete=0; |
---|
| 471 | if isfield(List.Experiment{iexp},'Device') |
---|
| 472 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 473 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 474 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 475 | currentdir=fullfile(Currentpath,Campaign,ExpName,DeviceName); |
---|
| 476 | hdir=dir(currentdir); %list files and dirs |
---|
| 477 | idir=0; |
---|
| 478 | for ilist=1:length(hdir) |
---|
| 479 | if hdir(ilist).isdir |
---|
| 480 | dirname=hdir(ilist).name; |
---|
| 481 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 482 | CivDir=fullfile(currentdir,dirname) |
---|
| 483 | hCivDir=dir(CivDir); |
---|
| 484 | for ilist=1:length(hCivDir) |
---|
| 485 | FileName=hCivDir(ilist).name; |
---|
| 486 | [dd,ff,Ext]=fileparts(FileName); |
---|
| 487 | if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors') |
---|
| 488 | delete(fullfile(CivDir,FileName)) |
---|
| 489 | nbdelete=nbdelete+1; |
---|
| 490 | end |
---|
| 491 | end |
---|
| 492 | end |
---|
| 493 | end |
---|
| 494 | end |
---|
| 495 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 496 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 497 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 498 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 499 | 'look at subdirectories' |
---|
| 500 | end |
---|
| 501 | end |
---|
| 502 | end |
---|
| 503 | end |
---|
| 504 | end |
---|
| 505 | display([num2str(nbdelete) ' files deleted']) |
---|
| 506 | nbdelete_tot=nbdelete_tot+nbdelete; |
---|
| 507 | end |
---|
| 508 | msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete_tot) ' files deleted by clean_civ_cmx']) |
---|
| 509 | set(handles.ListExperiments,'Value',1) |
---|
| 510 | |
---|
| 511 | |
---|
| 512 | |
---|
| 513 | |
---|