[503] | 1 | %'datatree_browser': function for scanning directories in a campaign |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function varargout = series(varargin) |
---|
| 4 | % associated with the GUI datatree_browser.fig |
---|
| 5 | |
---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 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 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | |
---|
| 22 | function varargout = datatree_browser(varargin) |
---|
| 23 | |
---|
[507] | 24 | % Last Modified by GUIDE v2.5 29-Jul-2012 08:49:20 |
---|
[503] | 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', @datatree_browser_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @datatree_browser_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
| 34 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 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 datatree_browser is made visible. |
---|
[507] | 47 | function datatree_browser_OpeningFcn(hObject, eventdata, handles, InputName) |
---|
[503] | 48 | %------------------------------------------------------------------------ |
---|
| 49 | % Choose default command line output for datatree_browser |
---|
| 50 | handles.output = 'Cancel'; |
---|
| 51 | |
---|
| 52 | % Update handles structure |
---|
| 53 | guidata(hObject, handles); |
---|
| 54 | testCancel=1; |
---|
| 55 | testinputstring=0; |
---|
| 56 | icontype='quest';%default question icon (text input asked) |
---|
| 57 | |
---|
| 58 | % Determine the position of the dialog - centered on the screen |
---|
| 59 | FigPos=get(0,'DefaultFigurePosition'); |
---|
| 60 | OldUnits = get(hObject, 'Units'); |
---|
| 61 | set(hObject, 'Units', 'pixels'); |
---|
| 62 | OldPos = get(hObject,'Position'); |
---|
| 63 | FigWidth = OldPos(3); |
---|
| 64 | FigHeight = OldPos(4); |
---|
| 65 | ScreenUnits=get(0,'Units'); |
---|
| 66 | set(0,'Units','pixels'); |
---|
| 67 | ScreenSize=get(0,'ScreenSize'); |
---|
| 68 | set(0,'Units',ScreenUnits); |
---|
| 69 | |
---|
| 70 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth); |
---|
| 71 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight); |
---|
| 72 | FigPos(3:4)=[FigWidth FigHeight]; |
---|
| 73 | set(hObject, 'Position', FigPos); |
---|
| 74 | set(hObject, 'Units', OldUnits); |
---|
| 75 | |
---|
[507] | 76 | if exist('InputName','var') |
---|
| 77 | if isdir(InputName)% opening by uvmat/MenuSetProject |
---|
| 78 | set(handles.SourceDir,'String',InputName)% the input directory is considered as a project |
---|
| 79 | set(handles.LinkDir,'Visible','off') |
---|
| 80 | set(handles.UpdateLink,'String','create_link') |
---|
| 81 | set(handles.MarkupDir,'Visible','on') |
---|
[503] | 82 | |
---|
[507] | 83 | else% opening by uvmat/Open |
---|
| 84 | InputDir=regexprep(InputName,'.xml$',''); |
---|
| 85 | if exist(InputDir,'dir') |
---|
| 86 | s=xml2struct(InputName); |
---|
| 87 | if isfield(s,'SourceDir') |
---|
| 88 | set(handles.SourceDir,'String',s.SourceDir) |
---|
| 89 | set(handles.LinkDir,'String',InputDir) |
---|
| 90 | set(handles.LinkDir,'Visible','on') |
---|
| 91 | else |
---|
| 92 | set(handles.SourceDir,'String',InputDir) |
---|
[503] | 93 | set(handles.LinkDir,'Visible','off') |
---|
[507] | 94 | set(handles.MarkupDir,'String','CreateLink') |
---|
| 95 | end |
---|
[503] | 96 | end |
---|
[507] | 97 | FillExperiments(handles) |
---|
| 98 | set(handles.OK,'Visible','on') |
---|
| 99 | drawnow |
---|
| 100 | |
---|
| 101 | end |
---|
[503] | 102 | end |
---|
| 103 | |
---|
[507] | 104 | |
---|
[503] | 105 | %------------------------------------------------------------------------ |
---|
| 106 | % --- Outputs from this function are returned to the command line. |
---|
| 107 | function varargout = datatree_browser_OutputFcn(hObject, eventdata, handles) |
---|
| 108 | %------------------------------------------------------------------------ |
---|
| 109 | % Get default command line output from handles structure |
---|
| 110 | varargout{1} = handles.output; |
---|
[507] | 111 | %delete(handles.datatree_browser) |
---|
[503] | 112 | |
---|
| 113 | %------------------------------------------------------------------------ |
---|
[507] | 114 | % --- Executes on button press in MarkupDir: create a xml file to mark SourceDir as project source |
---|
| 115 | function MarkupDir_Callback(hObject, eventdata, handles) |
---|
[503] | 116 | %------------------------------------------------------------------------ |
---|
[507] | 117 | SourceDir=get(handles.SourceDir,'String'); |
---|
| 118 | t=xmltree; |
---|
| 119 | t=set(t,1,'name','Project'); |
---|
| 120 | try |
---|
| 121 | save(t,[SourceDir '.xml']) |
---|
| 122 | catch ME |
---|
| 123 | msgbox_uvmat('ERROR',ME.message) |
---|
[503] | 124 | end |
---|
| 125 | |
---|
| 126 | %------------------------------------------------------------------------ |
---|
[507] | 127 | % --- Executes on button press in UpdateLink: create a link dir or update it if it exists |
---|
| 128 | function UpdateLink_Callback(hObject, eventdata, handles) |
---|
[503] | 129 | %------------------------------------------------------------------------ |
---|
[507] | 130 | [SourcePath,ProjectName]=fileparts(get(handles.SourceDir,'String')); |
---|
| 131 | LinkDir=get(handles.LinkDir,'String'); |
---|
| 132 | if isempty(LinkDir)||strcmp(get(handles.LinkDir,'Visible'),'off') |
---|
| 133 | LinkRoot=uigetdir(LinkDir,'pick up the path to the link directory'); %file browser |
---|
| 134 | if isempty(LinkRoot),return,end |
---|
| 135 | LinkDir=fullfile(LinkRoot,[ProjectName '.link']); |
---|
| 136 | set(handles.LinkDir,'Visible','on') |
---|
| 137 | set(handles.LinkDir,'String',LinkDir) |
---|
| 138 | end |
---|
[503] | 139 | |
---|
[507] | 140 | if ~exist(LinkDir,'dir') |
---|
| 141 | try |
---|
| 142 | mkdir(LinkDir) |
---|
| 143 | catch ME |
---|
| 144 | msgbox_uvmat('ERROR',ME.message) |
---|
| 145 | end |
---|
| 146 | end |
---|
| 147 | LinkDirXml=fullfile(fileparts(LinkDir),[ProjectName '.link.xml']); |
---|
| 148 | if ~exist(LinkDirXml,'file') |
---|
| 149 | LinkDoc.SourceDir=get(handles.SourceDir,'String'); |
---|
| 150 | t=struct2xml(LinkDoc); |
---|
| 151 | t=set(t,1,'name','Project'); |
---|
| 152 | save(t,LinkDirXml) |
---|
| 153 | set(handles.UpdateLink,'String','update_link') |
---|
| 154 | end |
---|
[503] | 155 | |
---|
[507] | 156 | FillExperiments(handles) |
---|
[503] | 157 | |
---|
| 158 | %------------------------------------------------------------------------ |
---|
[507] | 159 | % --- Fill the column 'Experiments' with the list of detected directries |
---|
| 160 | function FillExperiments(handles) |
---|
| 161 | %------------------------------------------------------------------------ |
---|
[503] | 162 | SourceDir=get(handles.SourceDir,'String'); |
---|
[507] | 163 | LinkDir=''; |
---|
| 164 | if strcmp(get(handles.LinkDir,'Visible'),'on') |
---|
| 165 | LinkDir=get(handles.LinkDir,'String'); |
---|
| 166 | end |
---|
| 167 | |
---|
| 168 | hdir=dir(SourceDir); %list files and dirs |
---|
| 169 | idir=0; |
---|
| 170 | ExpName=cell(length(hdir),1); |
---|
| 171 | for ilist=1:length(hdir) |
---|
| 172 | if hdir(ilist).isdir |
---|
| 173 | dirname=hdir(ilist).name; |
---|
| 174 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')% do not list directories beginning by '0' |
---|
| 175 | idir=idir+1; |
---|
| 176 | ExpName{idir}=hdir(ilist).name; |
---|
| 177 | if ~isempty(LinkDir) |
---|
| 178 | link=fullfile(LinkDir,ExpName{idir}); |
---|
[503] | 179 | if ~exist(link,'dir') |
---|
[507] | 180 | mkdir(link)% create the directory containing links |
---|
[503] | 181 | end |
---|
| 182 | end |
---|
| 183 | end |
---|
| 184 | end |
---|
| 185 | end |
---|
[507] | 186 | set(handles.ListExperiments,'String',[{'*'};ExpName(1:idir)]) |
---|
| 187 | set(handles.ListExperiments,'Value',1) |
---|
| 188 | ListExperiments_Callback([],[], handles) |
---|
[503] | 189 | |
---|
| 190 | |
---|
| 191 | %------------------------------------------------------------------------ |
---|
| 192 | % --- Executes on selection change in ListExperiments. |
---|
[507] | 193 | function ListExperiments_Callback(hObject,eventdata,handles) |
---|
[503] | 194 | %------------------------------------------------------------------------ |
---|
| 195 | SourcePath=get(handles.SourceDir,'String'); |
---|
[507] | 196 | MirrorPath=''; |
---|
| 197 | if strcmp(get(handles.LinkDir,'Visible'),'on') |
---|
[503] | 198 | MirrorPath=get(handles.LinkDir,'String'); |
---|
[507] | 199 | end |
---|
[503] | 200 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
[507] | 201 | if isequal(get(handles.ListExperiments,'Value'),1) |
---|
[503] | 202 | ListExperiments=ListExperiments(2:end); %choose all experiments |
---|
| 203 | else |
---|
[507] | 204 | ListExperiments=ListExperiments(get(handles.ListExperiments,'Value')); |
---|
[503] | 205 | end |
---|
[507] | 206 | ListDevices={}; |
---|
| 207 | |
---|
[503] | 208 | for iexp=1:numel(ListExperiments) |
---|
| 209 | hdir=dir(fullfile(SourcePath,ListExperiments{iexp})); %list files and dirs |
---|
| 210 | for ilist=1:length(hdir) |
---|
[507] | 211 | Device=hdir(ilist).name; |
---|
| 212 | if ~isequal(Device(1),'.') |
---|
| 213 | if ~isempty(MirrorPath)% we list the links to the data directories of files |
---|
| 214 | link=fullfile(MirrorPath,ListExperiments{iexp},Device); |
---|
| 215 | if ~exist(link) |
---|
| 216 | source=fullfile(SourcePath,ListExperiments{iexp},Device); |
---|
| 217 | system(['ln -s ' source ' ' link])%TODO translate for DOS |
---|
| 218 | end |
---|
| 219 | Device=['@' Device]; |
---|
| 220 | end |
---|
| 221 | if hdir(ilist).isdir |
---|
| 222 | Device=[Device '/']; |
---|
| 223 | end |
---|
| 224 | check_list=strcmp(Device,ListDevices); |
---|
| 225 | if isempty(find(check_list)) |
---|
| 226 | ListDevices=[ListDevices;Device]; |
---|
| 227 | end |
---|
[503] | 228 | end |
---|
| 229 | end |
---|
| 230 | end |
---|
| 231 | set(handles.ListDevices,'String',ListDevices) |
---|
| 232 | |
---|
[507] | 233 | |
---|
[503] | 234 | %------------------------------------------------------------------------ |
---|
[507] | 235 | % --- Executes on selection in column ListDevices |
---|
[503] | 236 | function ListDevices_Callback(hObject, eventdata, handles) |
---|
[507] | 237 | %------------------------------------------------------------------------ |
---|
[503] | 238 | list_val=get(handles.ListExperiments,'Value'); |
---|
[507] | 239 | if numel(list_val)~=1 |
---|
| 240 | msgbox_uvmat('ERROR','select a single experiment') |
---|
| 241 | return |
---|
[503] | 242 | end |
---|
[507] | 243 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 244 | Experiment=ListExperiments{list_val}; |
---|
| 245 | RootPath=''; |
---|
| 246 | if strcmp(get(handles.LinkDir,'Visible'),'on') |
---|
| 247 | RootPath=get(handles.LinkDir,'String'); |
---|
| 248 | end |
---|
| 249 | if isempty(RootPath) |
---|
| 250 | RootPath=get(handles.SourceDir,'String'); |
---|
| 251 | end |
---|
[503] | 252 | ListDevices=get(handles.ListDevices,'String'); |
---|
[507] | 253 | Device=ListDevices{get(handles.ListDevices,'Value')}; |
---|
| 254 | Device=regexprep(Device,'^@',''); |
---|
| 255 | if strcmp(Device(end),'/') |
---|
| 256 | DataDir=fullfile(RootPath,Experiment,Device(1:end-1)); |
---|
| 257 | DirList=dir(DataDir); |
---|
| 258 | for ilist=1:numel(DirList) |
---|
| 259 | [tild,tild,FileExt]=fileparts(DirList(ilist).name); |
---|
| 260 | FileExt=regexprep(FileExt,'^.',''); |
---|
| 261 | if ~isempty(FileExt) && (~isempty(imformats(FileExt))||strcmp(lower(FileExt),'avi')||strcmp(lower(FileExt),'nc')) |
---|
| 262 | uvmat(fullfile(DataDir,DirList(ilist).name)) |
---|
| 263 | return |
---|
| 264 | end |
---|
| 265 | end |
---|
[503] | 266 | end |
---|
[507] | 267 | % |
---|
| 268 | % set(handles.ListRecords,'Value',1) |
---|
| 269 | % set(handles.ListXml,'Value',1) |
---|
| 270 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 271 | % list_val=get(handles.ListDevices,'Value'); |
---|
| 272 | % if isequal(list_val,1) |
---|
| 273 | % ListDevices=ListDevices(2:end); |
---|
| 274 | % else |
---|
| 275 | % ListDevices=ListDevices(list_val); |
---|
| 276 | % end |
---|
| 277 | % [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); |
---|
| 278 | % set(handles.ListRecords,'String',[{'*'};ListRecords']) |
---|
| 279 | % set(handles.ListXml,'String',[{'*'};ListXml']) |
---|
[503] | 280 | |
---|
| 281 | |
---|
| 282 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | |
---|
[507] | 286 | % %------------------------------------------------------------------------ |
---|
| 287 | % % --- Executes on selection change in ListRecords. |
---|
| 288 | % function ListRecords_Callback(hObject, eventdata, handles) |
---|
| 289 | % Value=get(handles.ListRecords,'Value'); |
---|
| 290 | % if isequal(Value(1),1) |
---|
| 291 | % set(handles.ListRecords,'Value',1); |
---|
| 292 | % end |
---|
[503] | 293 | |
---|
[507] | 294 | % %------------------------------------------------------------------------ |
---|
| 295 | % % --- Executes on button press in CampaignDoc. |
---|
| 296 | % function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
| 297 | % %------------------------------------------------------------------------ |
---|
| 298 | % 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') |
---|
| 299 | % if ~isequal(answer{1},'OK') |
---|
| 300 | % return |
---|
| 301 | % end |
---|
| 302 | % set(handles.ListExperiments,'Value',1) |
---|
| 303 | % ListExperiments_Callback(handles)%update the overview of the experiment directories |
---|
| 304 | % DataviewData=get(handles.datatree_browser,'UserData'); |
---|
| 305 | % List=DataviewData.List; |
---|
| 306 | % Currentpath=get(handles.SourceDir,'String'); |
---|
| 307 | % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 308 | % Campaign=[Campaign DirExt]; |
---|
| 309 | % t=xmltree; |
---|
| 310 | % t=set(t,1,'name','CampaignDoc'); |
---|
| 311 | % t = attributes(t,'add',1,'source','directory'); |
---|
| 312 | % SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 313 | % root_uid=1; |
---|
| 314 | % if SubCampaignTest |
---|
| 315 | % %TO DO open an exoiting xml doc |
---|
| 316 | % [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
| 317 | % t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
| 318 | % end |
---|
| 319 | % for iexp=1:length(List.Experiment) |
---|
| 320 | % set(handles.ListExperiments,'Value',iexp+1) |
---|
| 321 | % drawnow |
---|
| 322 | % test_mod=0; |
---|
| 323 | % [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
| 324 | % t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
| 325 | % ExpName=List.Experiment{iexp}.name; |
---|
| 326 | % t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
| 327 | % |
---|
| 328 | % if isfield(List.Experiment{iexp},'Device') |
---|
| 329 | % for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 330 | % [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
| 331 | % DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 332 | % t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
| 333 | % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 334 | % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 335 | % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 336 | % [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
| 337 | % if test |
---|
| 338 | % [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] |
---|
| 339 | % end |
---|
| 340 | % if isequal(Title,'ImaDoc') |
---|
| 341 | % [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
| 342 | % t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 343 | % [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
| 344 | % end |
---|
| 345 | % end |
---|
| 346 | % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 347 | % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 348 | % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 349 | % [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
| 350 | % t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
| 351 | % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 352 | % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 353 | % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 354 | % [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
| 355 | % if test |
---|
| 356 | % [FileName ' , Heading updated'] |
---|
| 357 | % end |
---|
| 358 | % [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
| 359 | % t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 360 | % [t]=add(t,uid_xml,'chardata',FileName); |
---|
| 361 | % end |
---|
| 362 | % end |
---|
| 363 | % end |
---|
| 364 | % end |
---|
| 365 | % end |
---|
| 366 | % end |
---|
| 367 | % end |
---|
| 368 | % set(handles.ListExperiments,'Value',1) |
---|
| 369 | % outputdir=get(handles.SourceDir,'String'); |
---|
| 370 | % [path,dirname]=fileparts(outputdir); |
---|
| 371 | % outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
| 372 | % %campaigndoc(t); |
---|
| 373 | % save(t,outputfile) |
---|
| 374 | % |
---|
| 375 | % %------------------------------------------------------------------------ |
---|
| 376 | % % --- Executes on button press in CampaignDoc. |
---|
| 377 | % function edit_xml_Callback(hObject, eventdata, handles) |
---|
| 378 | % %------------------------------------------------------------------------ |
---|
| 379 | % CurrentPath=get(handles.SourceDir,'String'); |
---|
| 380 | % %[CurrentPath,Name,Ext]=fileparts(CurrentDir); |
---|
| 381 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 382 | % Value=get(handles.ListExperiments,'Value'); |
---|
| 383 | % if ~isequal(Value,1) |
---|
| 384 | % ListExperiments=ListExperiments(Value); |
---|
| 385 | % end |
---|
| 386 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 387 | % Value=get(handles.ListDevices,'Value'); |
---|
| 388 | % if ~isequal(Value,1) |
---|
| 389 | % ListDevices=ListDevices(Value); |
---|
| 390 | % end |
---|
| 391 | % ListRecords=get(handles.ListRecords,'String'); |
---|
| 392 | % Value=get(handles.ListRecords,'Value'); |
---|
| 393 | % if ~isequal(Value,1) |
---|
| 394 | % ListRecords=ListRecords(Value); |
---|
| 395 | % end |
---|
| 396 | % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 397 | % ListXml=get(handles.ListXml,'String'); |
---|
| 398 | % Value=get(handles.ListXml,'Value'); |
---|
| 399 | % set(handles.ListXml,'Value',Value(1)); |
---|
| 400 | % if isequal(Value(1),1) |
---|
| 401 | % msgbox_uvmat('ERROR','an xml file needs to be selected') |
---|
| 402 | % return |
---|
| 403 | % else |
---|
| 404 | % XmlName=ListXml{Value(1)}; |
---|
| 405 | % end |
---|
| 406 | % for iexp=1:length(List.Experiment) |
---|
| 407 | % ExpName=List.Experiment{iexp}.name; |
---|
| 408 | % if isfield(List.Experiment{iexp},'Device') |
---|
| 409 | % for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 410 | % DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 411 | % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 412 | % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 413 | % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} |
---|
| 414 | % if isequal(FileName,XmlName) |
---|
| 415 | % editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); |
---|
| 416 | % return |
---|
| 417 | % end |
---|
| 418 | % end |
---|
| 419 | % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 420 | % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 421 | % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 422 | % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 423 | % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 424 | % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 425 | % if isequal(FileName,XmlName) |
---|
| 426 | % editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); |
---|
| 427 | % return |
---|
| 428 | % end |
---|
| 429 | % end |
---|
| 430 | % end |
---|
| 431 | % end |
---|
| 432 | % end |
---|
| 433 | % end |
---|
| 434 | % end |
---|
| 435 | % end |
---|
[503] | 436 | |
---|
| 437 | |
---|
[507] | 438 | % |
---|
| 439 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 440 | % % CurrentPath/Campaign: root directory |
---|
| 441 | % function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) |
---|
| 442 | % |
---|
| 443 | % %Shema for Heading: |
---|
| 444 | % % Campaign |
---|
| 445 | % % (SubCampaign) |
---|
| 446 | % % Experiment |
---|
| 447 | % % Device |
---|
| 448 | % % (Record) |
---|
| 449 | % % ImageName |
---|
| 450 | % % DateExp |
---|
| 451 | % % old: %Project: suppressed ( changed to Campaign) |
---|
| 452 | % %Exp: suppressed (changed to experiment) |
---|
| 453 | % %ImaNames: changed to ImageName |
---|
| 454 | % if exist('Record','var') && ~isempty(Record) |
---|
| 455 | % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); |
---|
| 456 | % testrecord=1; |
---|
| 457 | % else |
---|
| 458 | % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); |
---|
| 459 | % testrecord=0; |
---|
| 460 | % end |
---|
| 461 | % if ~exist('testSubCampaign','var') |
---|
| 462 | % testSubCampaign=0; |
---|
| 463 | % end |
---|
| 464 | % if testSubCampaign |
---|
| 465 | % SubCampaign=Campaign; |
---|
| 466 | % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 467 | % Campaign=[Campaign DirExt]; |
---|
| 468 | % end |
---|
| 469 | % test_mod=0; %test for the modification of the xml file |
---|
| 470 | % t_device=xmltree(xmlfullname); |
---|
| 471 | % Title=get(t_device,1,'name'); |
---|
| 472 | % uid_child=children(t_device,1); |
---|
| 473 | % Heading_old=[]; |
---|
| 474 | % uidheading=0; |
---|
| 475 | % for ilist=1:length(uid_child) |
---|
| 476 | % name=get(t_device,uid_child(ilist),'name'); |
---|
| 477 | % if isequal(name,'Heading') |
---|
| 478 | % uidheading=uid_child(ilist); |
---|
| 479 | % end |
---|
| 480 | % end |
---|
| 481 | % if uidheading |
---|
| 482 | % subt=branch(t_device,uidheading); |
---|
| 483 | % Heading_old=convert(subt); |
---|
| 484 | % else |
---|
| 485 | % return % do not edit xml files without element 'Heading' |
---|
| 486 | % end |
---|
| 487 | % if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) |
---|
| 488 | % test_mod=1; |
---|
| 489 | % end |
---|
| 490 | % Heading.Campaign=Campaign; |
---|
| 491 | % if testSubCampaign |
---|
| 492 | % if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) |
---|
| 493 | % test_mod=1; |
---|
| 494 | % end |
---|
| 495 | % Heading.SubCampaign=SubCampaign; |
---|
| 496 | % end |
---|
| 497 | % if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) |
---|
| 498 | % test_mod=1; |
---|
| 499 | % end |
---|
| 500 | % Heading.Experiment=Experiment; |
---|
| 501 | % if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) |
---|
| 502 | % test_mod=1; |
---|
| 503 | % end |
---|
| 504 | % Heading.Device=Device; |
---|
| 505 | % if testrecord |
---|
| 506 | % if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) |
---|
| 507 | % test_mod=1; |
---|
| 508 | % end |
---|
| 509 | % Heading.Record=Record; |
---|
| 510 | % end |
---|
| 511 | % if isfield(Heading_old,'ImaNames') |
---|
| 512 | % test_mod=1; |
---|
| 513 | % if ~isempty(Heading_old.ImaNames) |
---|
| 514 | % Heading.ImageName=Heading_old.ImaNames; |
---|
| 515 | % end |
---|
| 516 | % end |
---|
| 517 | % if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) |
---|
| 518 | % Heading.ImageName=Heading_old.ImageName; |
---|
| 519 | % end |
---|
| 520 | % if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) |
---|
| 521 | % Heading.DateExp=Heading_old.DateExp; |
---|
| 522 | % end |
---|
| 523 | % if test_mod && uidheading |
---|
| 524 | % uid_child=children(t_device,uidheading); |
---|
| 525 | % t_device=delete(t_device,uid_child); |
---|
| 526 | % t_device=struct2xml(Heading,t_device,uidheading); |
---|
| 527 | % backupfile=xmlfullname; |
---|
| 528 | % testexist=2; |
---|
| 529 | % while testexist==2 |
---|
| 530 | % backupfile=[backupfile '~']; |
---|
| 531 | % testexist=exist(backupfile,'file'); |
---|
| 532 | % end |
---|
| 533 | % [success,message]=copyfile(xmlfullname,backupfile);%make backup |
---|
| 534 | % if isequal(success,1) |
---|
| 535 | % delete(xmlfullname) |
---|
| 536 | % else |
---|
| 537 | % return |
---|
| 538 | % end |
---|
| 539 | % save(t_device,xmlfullname) |
---|
| 540 | % end |
---|
[503] | 541 | |
---|
| 542 | %------------------------------------------------------------------------ |
---|
| 543 | % --- Executes on button press in HELP. |
---|
| 544 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 545 | path_to_uvmat=which ('uvmat')% check the path of uvmat |
---|
| 546 | pathelp=fileparts(path_to_uvmat); |
---|
| 547 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 548 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 549 | else |
---|
| 550 | web([helpfile '#dataview']) |
---|
| 551 | end |
---|
| 552 | |
---|
[507] | 553 | % |
---|
| 554 | % |
---|
| 555 | % % --- Executes on selection change in ListXml. |
---|
| 556 | % function ListXml_Callback(hObject, eventdata, handles) |
---|
| 557 | % Value=get(handles.ListXml,'Value'); |
---|
| 558 | % if isequal(Value(1),1) |
---|
| 559 | % set(handles.ListXml,'Value',1); |
---|
| 560 | % end |
---|
[503] | 561 | |
---|
| 562 | |
---|
| 563 | % --- Executes on button press in clean_civ_cmx. |
---|
| 564 | function clean_civ_cmx_Callback(hObject, eventdata, handles) |
---|
| 565 | message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)'; |
---|
| 566 | answer=msgbox_uvmat('INPUT_Y-N',message); |
---|
| 567 | if ~isequal(answer,'Yes') |
---|
| 568 | return |
---|
| 569 | end |
---|
| 570 | set(handles.ListExperiments,'Value',1) |
---|
[507] | 571 | ListDataDir(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
| 572 | DataviewData=get(handles.datatree_browser,'UserData') |
---|
[503] | 573 | List=DataviewData.List; |
---|
| 574 | Currentpath=get(handles.SourceDir,'String'); |
---|
| 575 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 576 | Campaign=[Campaign DirExt]; |
---|
| 577 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 578 | nbdelete_tot=0; |
---|
| 579 | for iexp=1:length(List.Experiment) |
---|
| 580 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 581 | drawnow |
---|
| 582 | test_mod=0; |
---|
| 583 | ExpName=List.Experiment{iexp}.name; |
---|
| 584 | nbdelete=0; |
---|
| 585 | if isfield(List.Experiment{iexp},'Device') |
---|
| 586 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 587 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 588 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 589 | currentdir=fullfile(Currentpath,Campaign,ExpName,DeviceName); |
---|
| 590 | hdir=dir(currentdir); %list files and dirs |
---|
| 591 | idir=0; |
---|
| 592 | for ilist=1:length(hdir) |
---|
| 593 | if hdir(ilist).isdir |
---|
| 594 | dirname=hdir(ilist).name; |
---|
| 595 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 596 | CivDir=fullfile(currentdir,dirname) |
---|
| 597 | hCivDir=dir(CivDir); |
---|
| 598 | for ilist=1:length(hCivDir) |
---|
| 599 | FileName=hCivDir(ilist).name; |
---|
| 600 | [dd,ff,Ext]=fileparts(FileName); |
---|
| 601 | if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors') |
---|
| 602 | delete(fullfile(CivDir,FileName)) |
---|
| 603 | nbdelete=nbdelete+1; |
---|
| 604 | end |
---|
| 605 | end |
---|
| 606 | end |
---|
| 607 | end |
---|
| 608 | end |
---|
| 609 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 610 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 611 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 612 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 613 | 'look at subdirectories' |
---|
| 614 | end |
---|
| 615 | end |
---|
| 616 | end |
---|
| 617 | end |
---|
| 618 | end |
---|
| 619 | display([num2str(nbdelete) ' files deleted']) |
---|
| 620 | nbdelete_tot=nbdelete_tot+nbdelete; |
---|
| 621 | end |
---|
| 622 | msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete_tot) ' files deleted by clean_civ_cmx']) |
---|
| 623 | set(handles.ListExperiments,'Value',1) |
---|
| 624 | |
---|
[507] | 625 | % |
---|
| 626 | % % --- Executes on button press in OK. |
---|
| 627 | % function OK_Callback(hObject, eventdata, handles) |
---|
| 628 | % %------------------------------------------------------------------------ |
---|
| 629 | % CurrentPath=get(handles.SourceDir,'String'); |
---|
| 630 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 631 | % IndicesExp=get(handles.ListExperiments,'Value'); |
---|
| 632 | % if ~isequal(IndicesExp,1) |
---|
| 633 | % ListExperiments=ListExperiments(IndicesExp); |
---|
| 634 | % end |
---|
| 635 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 636 | % Value=get(handles.ListDevices,'Value'); |
---|
| 637 | % if isequal(Value,1) |
---|
| 638 | % msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') |
---|
[503] | 639 | % return |
---|
[507] | 640 | % else |
---|
| 641 | % ListDevices=ListDevices(Value); |
---|
[503] | 642 | % end |
---|
[507] | 643 | % ListRecords=get(handles.ListRecords,'String'); |
---|
| 644 | % Value=get(handles.ListRecords,'Value'); |
---|
| 645 | % if ~isequal(Value,1) |
---|
| 646 | % ListRecords=ListRecords(Value); |
---|
| 647 | % end |
---|
| 648 | % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 649 | % ListXml=get(handles.ListXml,'String'); |
---|
| 650 | % Value=get(handles.ListXml,'Value'); |
---|
| 651 | % if isequal(Value,1) |
---|
| 652 | % msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') |
---|
| 653 | % return |
---|
| 654 | % else |
---|
| 655 | % ListXml=ListXml(Value); |
---|
| 656 | % end |
---|
| 657 | % |
---|
| 658 | % %update all the selected xml files |
---|
| 659 | % DataviewData=get(handles.datatree_browser,'UserData'); |
---|
| 660 | % % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... |
---|
| 661 | % % DataviewData.GeometryCalib.CalibrationType ' calibration data']) |
---|
| 662 | % % if ~isequal(answer,'Yes') |
---|
| 663 | % % return |
---|
| 664 | % % end |
---|
| 665 | % %List.Experiment{1}.Device{1} |
---|
| 666 | % %List.Experiment{2}.Device{1} |
---|
| 667 | % for iexp=1:length(List.Experiment) |
---|
| 668 | % ExpName=List.Experiment{iexp}.name; |
---|
| 669 | % set(handles.ListExperiments,'Value',IndicesExp(iexp)); |
---|
| 670 | % if isfield(List.Experiment{iexp},'Device') |
---|
| 671 | % for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 672 | % DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 673 | % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 674 | % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 675 | % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 676 | % for ilistxml=1:length(ListXml) |
---|
| 677 | % if isequal(FileName,ListXml{ilistxml}) |
---|
| 678 | % set(handles.ListXml,'Value',Value(ilistxml)) |
---|
| 679 | % drawnow |
---|
| 680 | % xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); |
---|
| 681 | % update_imadoc(DataviewData.GeometryCalib,xmlfullname) |
---|
| 682 | % display([xmlfullname ' updated']) |
---|
| 683 | % break |
---|
| 684 | % end |
---|
| 685 | % end |
---|
| 686 | % end |
---|
| 687 | % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 688 | % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 689 | % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 690 | % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 691 | % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 692 | % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 693 | % for ilistxml=1:length(ListXml) |
---|
| 694 | % if isequal(FileName,ListXml{ilistxml}) |
---|
| 695 | % set(handles.ListXml,'Value',Value(ilistxml)) |
---|
| 696 | % drawnow |
---|
| 697 | % xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); |
---|
| 698 | % update_imadoc(DataviewData.GeometryCalib,xmlfullname) |
---|
| 699 | % display([xmlfullname ' updated']) |
---|
| 700 | % break |
---|
| 701 | % end |
---|
| 702 | % end |
---|
| 703 | % end |
---|
| 704 | % end |
---|
| 705 | % end |
---|
| 706 | % end |
---|
| 707 | % end |
---|
| 708 | % end |
---|
| 709 | % end |
---|
| 710 | % set(handles.ListXml,'Value',Value) |
---|
[503] | 711 | % |
---|
| 712 | % |
---|
| 713 | % |
---|
| 714 | % |
---|
| 715 | % |
---|
| 716 | % |
---|
| 717 | % |
---|
| 718 | % CurrentPath=get(handles.SourceDir,'String');%= get(hObject,'String'); |
---|
| 719 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 720 | % Value=get(handles.ListExperiments,'Value'); |
---|
| 721 | % if ~isequal(Value,1) |
---|
| 722 | % ListExperiments=ListExperiments(Value); |
---|
| 723 | % end |
---|
| 724 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 725 | % Value=get(handles.ListDevices,'Value'); |
---|
| 726 | % if isequal(Value,1) |
---|
| 727 | % msgbox_uvmat('ERROR','manually select in the GUI datatree_browser the device being calibrated') |
---|
| 728 | % return |
---|
| 729 | % else |
---|
| 730 | % ListDevices=ListDevices(Value); |
---|
| 731 | % end |
---|
| 732 | % ListRecords=get(handles.ListRecords,'String'); |
---|
| 733 | % Value=get(handles.ListRecords,'Value'); |
---|
| 734 | % if ~isequal(Value,1) |
---|
| 735 | % ListRecords=ListRecords(Value); |
---|
| 736 | % end |
---|
| 737 | % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 738 | % ListXml=get(handles.ListXml,'String'); |
---|
| 739 | % Value=get(handles.ListXml,'Value'); |
---|
| 740 | % if isequal(Value,1) |
---|
| 741 | % msgbox_uvmat('ERROR','you need to select in the GUI datatree_browser the xml files to edit') |
---|
| 742 | % return |
---|
| 743 | % else |
---|
| 744 | % ListXml=ListXml(Value); |
---|
| 745 | % end |
---|
| 746 | % handles.output.CurrentPath=CurrentPath; |
---|
| 747 | % handles.output.ListExperiments=ListExperiments; |
---|
| 748 | % handles.output.ListDevices=ListDevices; |
---|
| 749 | % handles.output.ListRecords=ListRecords; |
---|
| 750 | % handles.output.ListXml=ListXml; |
---|
| 751 | % handles.output.List=List; |
---|
| 752 | handles.output ='OK, Calibration replicated'; |
---|
| 753 | guidata(hObject, handles);% Update handles structure |
---|
[507] | 754 | uiresume(handles.datatree_browser); |
---|
| 755 | % |
---|
| 756 | % % --- Executes on button press in Cancel. |
---|
| 757 | % function Cancel_Callback(hObject, eventdata, handles) |
---|
| 758 | % handles.output = get(hObject,'String'); |
---|
| 759 | % guidata(hObject, handles); % Update handles structure |
---|
| 760 | % % Use UIRESUME instead of delete because the OutputFcn needs |
---|
| 761 | % uiresume(handles.datatree_browser); |
---|
[503] | 762 | |
---|
[507] | 763 | % --- Executes when user attempts to close datatree_browser. |
---|
| 764 | function datatree_browser_CloseRequestFcn(hObject, eventdata, handles) |
---|
| 765 | % if isequal(get(handles.datatree_browser, 'waitstatus'), 'waiting') |
---|
[503] | 766 | % % The GUI is still in UIWAIT, us UIRESUME |
---|
[507] | 767 | % uiresume(handles.datatree_browser); |
---|
[503] | 768 | % else |
---|
| 769 | % % The GUI is no longer waiting, just close it |
---|
[507] | 770 | % delete(handles.datatree_browser); |
---|
[503] | 771 | % end |
---|
[507] | 772 | delete(hObject) |
---|