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