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 | %======================================================================= |
---|
7 | % Copyright 2008-2019, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
8 | % http://www.legi.grenoble-inp.fr |
---|
9 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
10 | % |
---|
11 | % This file is part of the toolbox UVMAT. |
---|
12 | % |
---|
13 | % UVMAT is free software; you can redistribute it and/or modify |
---|
14 | % it under the terms of the GNU General Public License as published |
---|
15 | % by the Free Software Foundation; either version 2 of the license, |
---|
16 | % or (at your option) any later version. |
---|
17 | % |
---|
18 | % UVMAT is distributed in the hope that it will be useful, |
---|
19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
22 | %======================================================================= |
---|
23 | |
---|
24 | function varargout = browse_data(varargin) |
---|
25 | |
---|
26 | % Last Modified by GUIDE v2.5 08-Sep-2018 19:03:40 |
---|
27 | |
---|
28 | % Begin initialization code - DO NOT EDIT |
---|
29 | gui_Singleton = 1; |
---|
30 | gui_State = struct('gui_Name', mfilename, ... |
---|
31 | 'gui_Singleton', gui_Singleton, ... |
---|
32 | 'gui_OpeningFcn', @browse_data_OpeningFcn, ... |
---|
33 | 'gui_OutputFcn', @browse_data_OutputFcn, ... |
---|
34 | 'gui_LayoutFcn', [] , ... |
---|
35 | 'gui_Callback', []); |
---|
36 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
37 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
38 | end |
---|
39 | |
---|
40 | if nargout |
---|
41 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
42 | else |
---|
43 | gui_mainfcn(gui_State, varargin{:}); |
---|
44 | end |
---|
45 | % End initialization code - DO NOT EDIT |
---|
46 | |
---|
47 | %------------------------------------------------------------------------ |
---|
48 | % --- Executes just before browse_data is made visible. |
---|
49 | function browse_data_OpeningFcn(hObject, eventdata, handles, InputDir,EnableMirror,MultiDevices) |
---|
50 | %------------------------------------------------------------------------ |
---|
51 | |
---|
52 | %% Choose default command line output for browse_data |
---|
53 | handles.output =hObject;% 'Cancel'; |
---|
54 | |
---|
55 | %% Update handles structure |
---|
56 | guidata(hObject, handles); |
---|
57 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
58 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
59 | |
---|
60 | %% Determine the position of the dialog - centered on the screen |
---|
61 | FigPos=get(0,'DefaultFigurePosition'); |
---|
62 | OldUnits = get(hObject, 'Units'); |
---|
63 | set(hObject, 'Units', 'pixels'); |
---|
64 | OldPos = get(hObject,'Position'); |
---|
65 | FigWidth = OldPos(3); |
---|
66 | FigHeight = OldPos(4); |
---|
67 | ScreenUnits=get(0,'Units'); |
---|
68 | set(0,'Units','pixels'); |
---|
69 | ScreenSize=get(0,'ScreenSize'); |
---|
70 | set(0,'Units',ScreenUnits); |
---|
71 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth); |
---|
72 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight); |
---|
73 | FigPos(3:4)=[FigWidth FigHeight]; |
---|
74 | set(hObject, 'Position', FigPos); |
---|
75 | set(hObject, 'Units', OldUnits); |
---|
76 | if exist('MultiDevices','var') && strcmp(MultiDevices,'on') |
---|
77 | set(handles.ListDevices,'Max',2) |
---|
78 | else |
---|
79 | set(handles.ListDevices,'Max',1) |
---|
80 | end |
---|
81 | if exist('EnableMirror','var') && strcmp(EnableMirror,'on') |
---|
82 | set(handles.CreateMirror,'Visible','on') |
---|
83 | set(handles.mirror_txt,'Visible','on') |
---|
84 | else |
---|
85 | set(handles.CreateMirror,'Visible','off') |
---|
86 | set(handles.mirror_txt,'Visible','off') |
---|
87 | end |
---|
88 | |
---|
89 | %% initialize the GUI |
---|
90 | if isempty(regexp(InputDir,'^http:'))&& ~(exist('InputDir','var') && ischar(InputDir) && exist(InputDir,'dir')) |
---|
91 | InputDir=pwd;% current dir is the starting data series by default |
---|
92 | end |
---|
93 | % [Experiment,DataSeries,Ext]=fileparts(DataSeries); |
---|
94 | % DataSeries=[DataSeries Ext]; |
---|
95 | % [Campaign,Experiment,Ext]=fileparts(Experiment); |
---|
96 | % Experiment=[Experiment Ext]; |
---|
97 | [ExpWithPath,DataSeries]=fileparts(InputDir); |
---|
98 | [Campaign,Experiment,Ext]=fileparts(ExpWithPath); |
---|
99 | [tild,CampaignName]=fileparts(Campaign); |
---|
100 | RootXml=fullfile(Campaign,[CampaignName '.xml']); |
---|
101 | s=[]; |
---|
102 | if exist(RootXml,'file') |
---|
103 | [s,Heading]=xml2struct(RootXml);%read the xml file |
---|
104 | if isfield(s,'SourceDir') |
---|
105 | set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened |
---|
106 | set(handles.MirrorDir,'Visible','on');% mirror dir display |
---|
107 | set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir |
---|
108 | set(handles.CreateMirror,'String','update_mirror') |
---|
109 | end |
---|
110 | end |
---|
111 | if isempty(s) %a source dir has been opened |
---|
112 | set(handles.SourceDir,'String',Campaign); |
---|
113 | set(handles.MirrorDir,'Visible','off');% no mirror dir display |
---|
114 | set(handles.CreateMirror,'String','create_mirror') |
---|
115 | end |
---|
116 | errormsg=scan_campaign(handles,Campaign,Experiment,ExpWithPath); |
---|
117 | if ~isempty(errormsg) |
---|
118 | msgbox_uvmat('ERROR',errormsg) |
---|
119 | return |
---|
120 | end |
---|
121 | % set(handles.OK,'Visible','on') |
---|
122 | % set(handles.Cancel,'Visible','on') |
---|
123 | |
---|
124 | %set(handles.browse_data,'WindowStyle','modal')% Make the GUI |
---|
125 | %modal%%%%%%%%%%%%%%%%%%%%%%% |
---|
126 | set(hObject,'Visible','on') |
---|
127 | drawnow |
---|
128 | % UIWAIT makes GUI wait for user response (see UIRESUME)%%%%%%%%%%%%%%%%TO |
---|
129 | % CHECK |
---|
130 | %uiwait(handles.browse_data); |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | %------------------------------------------------------------------------ |
---|
135 | % --- Outputs from this function are returned to the command line. |
---|
136 | function varargout = browse_data_OutputFcn(hObject, eventdata, handles) |
---|
137 | %------------------------------------------------------------------------ |
---|
138 | % Get default command line output from handles structure |
---|
139 | varargout{1} = handles.output; |
---|
140 | %%%%%%%%%%%%%%%%%%delete(handles.browse_data) |
---|
141 | |
---|
142 | %------------------------------------------------------------------------ |
---|
143 | % --- Executes on button press in CreateMirror. |
---|
144 | function CreateMirror_Callback(hObject, eventdata, handles) |
---|
145 | %------------------------------------------------------------------------ |
---|
146 | set(handles.SourceDir,'BackgroundColor',[1 1 0])% indicate action of button by yellow color |
---|
147 | drawnow |
---|
148 | SourceDir=get(handles.SourceDir,'String'); |
---|
149 | [SourcePath,ProjectName]=fileparts(SourceDir); |
---|
150 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
151 | MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder |
---|
152 | else% create the mirror folder if it does not exist |
---|
153 | MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir'); |
---|
154 | if isempty(MirrorRoot) |
---|
155 | return |
---|
156 | elseif strcmp(MirrorRoot,SourcePath) |
---|
157 | msgbox_uvmat('ERROR','The mirror folder must be different from the source') |
---|
158 | return |
---|
159 | else |
---|
160 | MirrorDir=fullfile(MirrorRoot,ProjectName); |
---|
161 | end |
---|
162 | if exist(MirrorDir,'dir') |
---|
163 | msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) |
---|
164 | return |
---|
165 | else |
---|
166 | [s,errormsg]=mkdir(MirrorDir)% create the mirror dir |
---|
167 | if s~=1 |
---|
168 | msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) |
---|
169 | return |
---|
170 | end |
---|
171 | end |
---|
172 | MirrorDoc.SourceDir=SourceDir; |
---|
173 | t=struct2xml(MirrorDoc); |
---|
174 | set(t,1,'name','DataTree'); |
---|
175 | save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder |
---|
176 | set(handles.MirrorDir,'String',MirrorDir) |
---|
177 | set(handles.MirrorDir,'Visible','on') |
---|
178 | set(handles.CreateMirror,'String','update_mirror') |
---|
179 | end |
---|
180 | ExpName={''}; |
---|
181 | |
---|
182 | %% update the mirror from the source dir |
---|
183 | if exist(SourceDir,'dir') |
---|
184 | hdir=dir(SourceDir); %list files and dirs |
---|
185 | idir=0; |
---|
186 | for ilist=1:length(hdir) |
---|
187 | if hdir(ilist).isdir% scan all subfolders |
---|
188 | dirname=hdir(ilist).name;% |
---|
189 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0' |
---|
190 | idir=idir+1; |
---|
191 | mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror |
---|
192 | if ~exist(mirror,'dir') |
---|
193 | mkdir(mirror)% create the mirror folder if it does not exist |
---|
194 | end |
---|
195 | ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder |
---|
196 | end |
---|
197 | % look for the list of 'devices' |
---|
198 | else |
---|
199 | %warning for isolated files |
---|
200 | end |
---|
201 | end |
---|
202 | set(handles.ListExperiments,'String',[{'*'};ExpName']) |
---|
203 | set(handles.ListExperiments,'Value',1) |
---|
204 | update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir) |
---|
205 | % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment |
---|
206 | else |
---|
207 | msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) |
---|
208 | end |
---|
209 | set(handles.SourceDir,'BackgroundColor',[1 1 1]) |
---|
210 | |
---|
211 | %------------------------------------------------------------------------ |
---|
212 | % List the experiments in a campaign, filling the menu ListExperiments |
---|
213 | %------------------------------------------------------------------------ |
---|
214 | function errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries) |
---|
215 | %------------------------------------------------------------------------ |
---|
216 | errormsg=''; |
---|
217 | if ~isempty(regexp(Campaign,'^http'))|| exist(Campaign,'dir') |
---|
218 | ListStruct=dir_uvmat(Campaign); %list files and dirs |
---|
219 | if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders |
---|
220 | errormsg=[Campaign ' contains too many items (>1000) to be a Project folder']; |
---|
221 | return |
---|
222 | end |
---|
223 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
224 | ListFiles=ListCells(1,:);%list of dir and file names |
---|
225 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
226 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
227 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
228 | check_keep=cellfun('isempty', cell_remove); |
---|
229 | ListFiles=sort((ListFiles(check_keep))'); |
---|
230 | index=find(strcmp(['+/' Experiment],ListFiles)); |
---|
231 | if isempty(index), index=1; end |
---|
232 | set(handles.ListExperiments,'String',ListFiles) |
---|
233 | set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input |
---|
234 | ListExperiments_Callback([],[], handles) |
---|
235 | ListDevices=get(handles.ListDevices,'String'); |
---|
236 | index=find(strcmp(['+/' DataSeries],ListDevices)); |
---|
237 | if isempty(index) |
---|
238 | index=find(strcmp(['~/' DataSeries],ListDevices)); |
---|
239 | end |
---|
240 | if ~isempty(index) |
---|
241 | set(handles.ListDevices,'Value',index) |
---|
242 | end |
---|
243 | else |
---|
244 | msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) |
---|
245 | end |
---|
246 | |
---|
247 | %------------------------------------------------------------------------ |
---|
248 | % --- Executes on selection change in ListExperiments. |
---|
249 | %------------------------------------------------------------------------ |
---|
250 | function ListExperiments_Callback(hObject, eventdata, handles) |
---|
251 | |
---|
252 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
253 | MirrorPath=get(handles.MirrorDir,'String'); |
---|
254 | else |
---|
255 | MirrorPath=get(handles.SourceDir,'String'); |
---|
256 | end |
---|
257 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
258 | list_val=get(handles.ListExperiments,'Value'); |
---|
259 | % if isequal(list_val(1),1) |
---|
260 | % ListExperiments=ListExperiments(2:end); %choose all experiments if the first line '*' is selected |
---|
261 | % set(handles.ListExperiments,'Value',1) |
---|
262 | % else |
---|
263 | ListExperiments=ListExperiments(list_val);%choose selected experiments |
---|
264 | % end |
---|
265 | list_dataseries(handles,ListExperiments,MirrorPath) |
---|
266 | |
---|
267 | %------------------------------------------------------------------------ |
---|
268 | % --- List the DataSeries when a set of experiments is selected |
---|
269 | %------------------------------------------------------------------------ |
---|
270 | function list_dataseries(handles,ListExperiments,MirrorPath) |
---|
271 | |
---|
272 | ListDevices={}; |
---|
273 | for iexp=1:numel(ListExperiments) |
---|
274 | if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory |
---|
275 | ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders |
---|
276 | ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory |
---|
277 | ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray |
---|
278 | ListFiles=ListCells(1,:);%list of dir and file names |
---|
279 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
280 | cell_remove_tild=regexp(ListFiles,'~$');% detect tild the end of file nqme (do not list) |
---|
281 | check_keep=cellfun('isempty', cell_remove) & cellfun('isempty', cell_remove_tild); |
---|
282 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
283 | for ilist=1:numel(ListFiles) |
---|
284 | if check_keep(ilist)% loop on eligible DataSeries folders |
---|
285 | mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder |
---|
286 | if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link |
---|
287 | delete(mirror)% delete broken link |
---|
288 | else %update the list of dataSeries |
---|
289 | [tild,msg]=fileattrib(mirror); |
---|
290 | % msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name |
---|
291 | % if ~strcmp(msg.Name,mirror)% if it is a link |
---|
292 | % ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list |
---|
293 | % end |
---|
294 | if check_dir(ilist) |
---|
295 | ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list |
---|
296 | end |
---|
297 | if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices |
---|
298 | ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list |
---|
299 | end |
---|
300 | end |
---|
301 | end |
---|
302 | end |
---|
303 | end |
---|
304 | end |
---|
305 | set(handles.ListDevices,'Value',1) |
---|
306 | set(handles.ListDevices,'String',sort(ListDevices)) |
---|
307 | |
---|
308 | %------------------------------------------------------------------------ |
---|
309 | % --- Executes when the mirror is created or updated |
---|
310 | %------------------------------------------------------------------------ |
---|
311 | function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath) |
---|
312 | |
---|
313 | ListDevices={}; |
---|
314 | for iexp=1:numel(ListExperiments) |
---|
315 | if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory |
---|
316 | ListExperiments{iexp}(1)=[]; |
---|
317 | ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the source experiment directory |
---|
318 | ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray |
---|
319 | ListFiles=ListCells(1,:);%list of dir and file names |
---|
320 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
321 | check_keep=cellfun('isempty', cell_remove); |
---|
322 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
323 | for ilist=1:numel(ListFiles) |
---|
324 | if check_keep(ilist)% loop on eligible DataSeries folders |
---|
325 | DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});%source folder |
---|
326 | if ~isempty(MirrorPath) |
---|
327 | mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist}); |
---|
328 | if exist(mirror,'file')% if mirror already exists as a file or folder |
---|
329 | [tild,msg]=fileattrib(mirror); |
---|
330 | if strcmp(msg.Name,mirror)%if the mirror name already exists as a local file or dir |
---|
331 | if msg.directory% case of a folder |
---|
332 | answer=msgbox_uvmat('INPUT_Y-N',['replace local folder ' msg.Name ' by a link to the source dir']); |
---|
333 | if strcmp(answer,'Yes') |
---|
334 | [ss,msg]=rmdir(mirror); |
---|
335 | if ss==1 |
---|
336 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
337 | else |
---|
338 | msgbox_uvmat('ERROR',['enable to delete local folder: ' msg]); |
---|
339 | end |
---|
340 | end |
---|
341 | else % case of an existing mirror file |
---|
342 | answer=msgbox_uvmat('INPUT_Y-N',['replace local file ' msg.Name ' by a link to the source file']); |
---|
343 | if strcmp(answer,'Yes') |
---|
344 | delete(mirror); |
---|
345 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
346 | end |
---|
347 | end |
---|
348 | end |
---|
349 | else% create mirror to the data series if needed |
---|
350 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
351 | end |
---|
352 | if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices |
---|
353 | if check_dir(ilist) |
---|
354 | ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list |
---|
355 | end |
---|
356 | ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list |
---|
357 | end |
---|
358 | end |
---|
359 | end |
---|
360 | end |
---|
361 | end |
---|
362 | end |
---|
363 | set(handles.ListDevices,'String',sort(ListDevices)) |
---|
364 | |
---|
365 | %------------------------------------------------------------------------ |
---|
366 | % --- Executes on button press in CampaignDoc. |
---|
367 | function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
368 | %------------------------------------------------------------------------ |
---|
369 | 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'); |
---|
370 | if ~isequal(answer{1},'OK') |
---|
371 | return |
---|
372 | end |
---|
373 | set(handles.ListExperiments,'Value',1) |
---|
374 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
375 | DataviewData=get(handles.browse_data,'UserData'); |
---|
376 | List=DataviewData.List; |
---|
377 | Currentpath=get(handles.SourceDir,'String'); |
---|
378 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
379 | Campaign=[Campaign DirExt]; |
---|
380 | t=xmltree; |
---|
381 | t=set(t,1,'name','CampaignDoc'); |
---|
382 | t = attributes(t,'add',1,'source','directory'); |
---|
383 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
384 | root_uid=1; |
---|
385 | if SubCampaignTest |
---|
386 | %TO DO open an exoiting xml doc |
---|
387 | [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
388 | t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
389 | end |
---|
390 | for iexp=1:length(List.Experiment) |
---|
391 | set(handles.ListExperiments,'Value',iexp+1) |
---|
392 | drawnow |
---|
393 | test_mod=0; |
---|
394 | [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
395 | t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
396 | ExpName=List.Experiment{iexp}.name; |
---|
397 | t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
398 | |
---|
399 | if isfield(List.Experiment{iexp},'Device') |
---|
400 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
401 | [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
402 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
403 | t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
404 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
405 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
406 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
407 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
408 | if test |
---|
409 | disp([List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']) |
---|
410 | end |
---|
411 | if isequal(Title,'ImaDoc') |
---|
412 | [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
413 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
414 | [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
415 | end |
---|
416 | end |
---|
417 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
418 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
419 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
420 | [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
421 | t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
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 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
426 | if test |
---|
427 | disp([FileName ' , Heading updated']) |
---|
428 | end |
---|
429 | [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
430 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
431 | [t]=add(t,uid_xml,'chardata',FileName); |
---|
432 | end |
---|
433 | end |
---|
434 | end |
---|
435 | end |
---|
436 | end |
---|
437 | end |
---|
438 | end |
---|
439 | set(handles.ListExperiments,'Value',1) |
---|
440 | outputdir=get(handles.SourceDir,'String'); |
---|
441 | [path,dirname]=fileparts(outputdir); |
---|
442 | outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
443 | %campaigndoc(t); |
---|
444 | save(t,outputfile) |
---|
445 | |
---|
446 | |
---|
447 | |
---|
448 | %------------------------------------------------------------------------ |
---|
449 | % --- Executes on button press in OK. |
---|
450 | %------------------------------------------------------------------------ |
---|
451 | function OK_Callback(hObject, eventdata, handles) |
---|
452 | |
---|
453 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
454 | Campaign=get(handles.MirrorDir,'String'); |
---|
455 | else |
---|
456 | Campaign=get(handles.SourceDir,'String'); |
---|
457 | end |
---|
458 | handles.output=[]; |
---|
459 | handles.output.Campaign=Campaign; |
---|
460 | Experiment=get(handles.ListExperiments,'String'); |
---|
461 | IndicesExp=get(handles.ListExperiments,'Value'); |
---|
462 | if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected |
---|
463 | Experiment=Experiment(IndicesExp);% use the selection of the list of experiments |
---|
464 | end |
---|
465 | Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir |
---|
466 | Device=get(handles.ListDevices,'String'); |
---|
467 | Value=get(handles.ListDevices,'Value'); |
---|
468 | Device=Device(Value); |
---|
469 | Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir |
---|
470 | Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link |
---|
471 | handles.output.Experiment=Experiment; |
---|
472 | handles.output.DataSeries=Device; |
---|
473 | guidata(hObject, handles);% Update handles structure |
---|
474 | uiresume(handles.browse_data); |
---|
475 | drawnow |
---|
476 | |
---|
477 | %------------------------------------------------------------------------ |
---|
478 | % --- Executes on button press in HELP. |
---|
479 | function HELP_Callback(hObject, eventdata, handles) |
---|
480 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
481 | pathelp=fileparts(path_to_uvmat); |
---|
482 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
483 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
484 | else |
---|
485 | web([helpfile '#dataview']) |
---|
486 | end |
---|
487 | |
---|
488 | %------------------------------------------------------------------------ |
---|
489 | % --- Executes on button press in Cancel. |
---|
490 | %------------------------------------------------------------------------ |
---|
491 | % function Cancel_Callback(hObject, eventdata, handles) |
---|
492 | % % hseries=findobj(allchild(0),'Tag','series'); |
---|
493 | % % if ~isempty(hseries) |
---|
494 | % % hhh=guidata(hseries); |
---|
495 | % % set(hhh.Replicate,'Value',0) |
---|
496 | % % end |
---|
497 | % % delete(get(hObject,'parent')) |
---|
498 | |
---|
499 | % handles.output = get(hObject,'String'); |
---|
500 | % guidata(hObject, handles); % Update handles structure |
---|
501 | % % Use UIRESUME instead of delete because the OutputFcn needs |
---|
502 | % uiresume(handles.browse_data); |
---|
503 | |
---|
504 | %------------------------------------------------------------------------ |
---|
505 | % --- executes when user attempts to close geometry_calib. |
---|
506 | function browse_data_CloseRequestFcn(hObject, eventdata, handles) |
---|
507 | |
---|
508 | %------------------------------------------------------------------------ |
---|
509 | % --- Executes when user attempts to close browse_data. |
---|
510 | %------------------------------------------------------------------------ |
---|
511 | function closefcn(gcbo, eventdata) |
---|
512 | % if isequal(get(handles.browse_data, 'waitstatus'), 'waiting') |
---|
513 | % % The GUI is still in UIWAIT, us UIRESUME |
---|
514 | % handles.output = get(hObject,'String'); |
---|
515 | % guidata(hObject, handles); % Update handles structure |
---|
516 | % uiresume(handles.browse_data); |
---|
517 | % else |
---|
518 | % % The GUI is no longer waiting, just close it |
---|
519 | % delete(handles.browse_data); |
---|
520 | % end |
---|
521 | hseries=findobj(allchild(0),'Tag','series'); |
---|
522 | if ~isempty(hseries) |
---|
523 | hreplicate=findobj(hseries,'Tag','Replicate'); |
---|
524 | set(hreplicate,'Value',0) |
---|
525 | end |
---|
526 | hcalib=findobj(allchild(0),'Tag','geometry_calib'); |
---|
527 | if ~isempty(hcalib) |
---|
528 | hreplicate=findobj(hcalib,'Tag','Replicate'); |
---|
529 | set(hreplicate,'Value',0) |
---|
530 | end |
---|
531 | |
---|
532 | %------------------------------------------------------------------------ |
---|
533 | % --- Executes on key press over figure1 with no controls selected. |
---|
534 | %------------------------------------------------------------------------ |
---|
535 | function browse_data_KeyPressFcn(hObject, eventdata, handles) |
---|
536 | |
---|
537 | % Check for "enter" or "escape" |
---|
538 | if isequal(get(hObject,'CurrentKey'),'escape') |
---|
539 | % User said no by hitting escape |
---|
540 | handles.output = 'Cancel'; |
---|
541 | |
---|
542 | % Update handles structure |
---|
543 | guidata(hObject, handles); |
---|
544 | |
---|
545 | uiresume(handles.browse_data); |
---|
546 | end |
---|
547 | if isequal(get(hObject,'CurrentKey'),'return') |
---|
548 | uiresume(handles.browse_data); |
---|
549 | end |
---|
550 | |
---|
551 | |
---|
552 | % --- Executes on button press in Up. |
---|
553 | function Up_Callback(hObject, eventdata, handles) |
---|
554 | SourceDir=get(handles.SourceDir,'String'); |
---|
555 | % Device=ListDevices{get(handles.ListDevices,'Value')}; |
---|
556 | % DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir'); |
---|
557 | % uiresume(handles.browse_data); |
---|
558 | browse_data(SourceDir) |
---|
559 | |
---|
560 | |
---|
561 | % --- Executes on button press in Down. |
---|
562 | function Down_Callback(hObject, eventdata, handles) |
---|
563 | SourceDir=get(handles.SourceDir,'String'); |
---|
564 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
565 | list_val=get(handles.ListExperiments,'Value'); |
---|
566 | SourceFolder=regexprep(ListExperiments{list_val(1)},'+',''); |
---|
567 | set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder)) |
---|
568 | ListDevices=get(handles.ListDevices,'String'); |
---|
569 | ValueDevice=get(handles.ListDevices,'Value'); |
---|
570 | set(handles.ListExperiments,'String',ListDevices) |
---|
571 | set(handles.ListExperiments,'Value',ValueDevice) |
---|
572 | ListExperiments_Callback(hObject, [], handles) |
---|
573 | % Device=regexprep(ListDevices{get(handles.ListDevices,'Value')},'+',''); |
---|
574 | % Device=regexprep(Device,'~',''); |
---|
575 | % PathDevice=fullfile(SourceDir,SourceFolder,Device); |
---|
576 | % DirDevice=dir(PathDevice); |
---|
577 | % NewDevice=DirDevice(end).name; |
---|
578 | % % uiresume(handles.browse_data); |
---|
579 | % browse_data(fullfile(PathDevice,NewDevice)) |
---|