source: trunk/src/browse_data.m @ 1063

Last change on this file since 1063 was 1063, checked in by sommeria, 6 years ago

geometric calibration corrected

File size: 26.8 KB
Line 
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
24function varargout = browse_data(varargin)
25
26% Last Modified by GUIDE v2.5 17-Apr-2019 18:15:24
27
28% Begin initialization code - DO NOT EDIT
29gui_Singleton = 1;
30gui_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',   []);
36if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))             
37    gui_State.gui_Callback = str2func(varargin{1});
38end
39
40if nargout
41    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
42else
43    gui_mainfcn(gui_State, varargin{:});
44end
45% End initialization code - DO NOT EDIT
46
47%------------------------------------------------------------------------
48% --- Executes just before browse_data is made visible.
49function browse_data_OpeningFcn(hObject, eventdata, handles, InputDir,EnableMirror,MultiDevices)
50%------------------------------------------------------------------------
51
52%% Choose default command line output for browse_data
53handles.output =hObject;% 'Cancel';
54
55%% Update handles structure
56guidata(hObject, handles);
57set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
58set(hObject,'DeleteFcn',{@closefcn})%
59
60%% Determine the position of the dialog - centered on the screen
61FigPos=get(0,'DefaultFigurePosition');
62OldUnits = get(hObject, 'Units');
63set(hObject, 'Units', 'pixels');
64OldPos = get(hObject,'Position');
65FigWidth = OldPos(3);
66FigHeight = OldPos(4);
67ScreenUnits=get(0,'Units');
68set(0,'Units','pixels');
69ScreenSize=get(0,'ScreenSize');
70set(0,'Units',ScreenUnits);
71FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
72FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
73FigPos(3:4)=[FigWidth FigHeight];
74set(hObject, 'Position', FigPos);
75set(hObject, 'Units', OldUnits);
76if exist('MultiDevices','var') && strcmp(MultiDevices,'on')
77    set(handles.DataSeries,'Max',2)
78else
79    set(handles.DataSeries,'Max',1)
80end
81if exist('EnableMirror','var') && strcmp(EnableMirror,'on')
82    set(handles.CreateMirror,'Visible','on')
83    set(handles.mirror_txt,'Visible','on')
84else
85    set(handles.CreateMirror,'Visible','off')
86    set(handles.mirror_txt,'Visible','off')
87end
88
89%% initialize the GUI
90if isempty(regexp(InputDir,'^http:'))&& ~(exist('InputDir','var') && ischar(InputDir) && exist(InputDir,'dir'))
91    InputDir=pwd;% current dir is the starting data series by default
92end
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);
100RootXml=fullfile(Campaign,[CampaignName '.xml']);
101s=[];
102if 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
110end
111if 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')
115end
116errormsg=scan_campaign(handles,Campaign,Experiment,ExpWithPath);
117if ~isempty(errormsg)
118    msgbox_uvmat('ERROR',errormsg)
119    return
120end
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%%%%%%%%%%%%%%%%%%%%%%%
126set(hObject,'Visible','on')
127drawnow
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.
136function varargout = browse_data_OutputFcn(hObject, eventdata, handles)
137%------------------------------------------------------------------------
138% Get default command line output from handles structure
139varargout{1} = handles.output;
140%%%%%%%%%%%%%%%%%%delete(handles.browse_data)
141
142%------------------------------------------------------------------------
143% --- Executes on button press in CreateMirror.
144function CreateMirror_Callback(hObject, eventdata, handles)
145%------------------------------------------------------------------------
146set(handles.SourceDir,'BackgroundColor',[1 1 0])% indicate action of button by yellow color
147drawnow
148SourceDir=get(handles.SourceDir,'String');
149[SourcePath,ProjectName]=fileparts(SourceDir);
150if strcmp(get(handles.MirrorDir,'Visible'),'on')
151    MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder
152else% 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')
179end
180ExpName={''};
181
182%% update the mirror from the source dir
183if 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
206else
207    msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory'])
208end
209set(handles.SourceDir,'BackgroundColor',[1 1 1])
210
211%------------------------------------------------------------------------
212% List the experiments in a campaign, filling the menu ListExperiments
213%------------------------------------------------------------------------
214function errormsg=scan_campaign(handles,Campaign,Experiment,DataInput)
215%------------------------------------------------------------------------
216errormsg='';
217if ~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    DataSeries=get(handles.DataSeries,'String');
236    index=find(strcmp(['+/' DataInput],DataSeries));
237    if isempty(index)
238        index=find(strcmp(['~/' DataInput],DataSeries));
239    end
240    if ~isempty(index)
241          set(handles.DataSeries,'Value',index)
242    end
243else
244    msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])
245end
246
247%------------------------------------------------------------------------
248% --- Executes on selection change in ListExperiments.
249%------------------------------------------------------------------------
250 function ListExperiments_Callback(hObject, eventdata, handles)
251
252if strcmp(get(handles.MirrorDir,'Visible'),'on')
253    MirrorPath=get(handles.MirrorDir,'String');
254else
255    MirrorPath=get(handles.SourceDir,'String');
256end
257ListExperiments=get(handles.ListExperiments,'String');
258list_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
265list_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
272DataSeries={};
273for 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},DataSeries), 1))% if the item is not already in DataSeries
298                        DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list
299                    end                   
300                end
301            end
302        end
303    end
304end
305set(handles.DataSeries,'Value',1)
306set(handles.DataSeries,'String',sort(DataSeries))
307
308%------------------------------------------------------------------------
309% --- Executes when the mirror is created or updated
310%------------------------------------------------------------------------
311 function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
312
313DataSeries={};
314for 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},DataSeries), 1))% if the item is not already in DataSeries
353                        if check_dir(ilist)
354                            ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
355                        end
356                        DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list
357                    end
358                end
359            end
360        end
361    end
362end
363set(handles.DataSeries,'String',sort(DataSeries))
364
365%------------------------------------------------------------------------
366% --- Executes on button press in CampaignDoc.
367function CampaignDoc_Callback(hObject, eventdata, handles)
368%------------------------------------------------------------------------   
369answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file');
370if ~isequal(answer{1},'OK')
371    return
372end
373set(handles.ListExperiments,'Value',1)
374ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
375DataviewData=get(handles.browse_data,'UserData');
376List=DataviewData.List;
377Currentpath=get(handles.SourceDir,'String');
378[Currentpath,Campaign,DirExt]=fileparts(Currentpath);
379Campaign=[Campaign DirExt];
380t=xmltree;
381t=set(t,1,'name','CampaignDoc');
382t = attributes(t,'add',1,'source','directory');
383SubCampaignTest=get(handles.SubCampaignTest,'Value');
384root_uid=1;
385if 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);
389end
390for 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
438end
439set(handles.ListExperiments,'Value',1)
440outputdir=get(handles.SourceDir,'String');
441[path,dirname]=fileparts(outputdir);
442outputfile=fullfile(outputdir,[dirname '.xml']);
443%campaigndoc(t);
444save(t,outputfile)
445
446
447
448%------------------------------------------------------------------------
449% --- Executes on button press in OK.
450%------------------------------------------------------------------------
451function OK_Callback(hObject, eventdata, handles)
452
453if strcmp(get(handles.MirrorDir,'Visible'),'on')
454    Campaign=get(handles.MirrorDir,'String');
455else
456    Campaign=get(handles.SourceDir,'String');
457end
458handles.output=[];
459handles.output.Campaign=Campaign;
460Experiment=get(handles.ListExperiments,'String');
461IndicesExp=get(handles.ListExperiments,'Value');
462if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected
463    Experiment=Experiment(IndicesExp);% use the selection of the list of experiments
464end
465Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
466Device=get(handles.DataSeries,'String');
467Value=get(handles.DataSeries,'Value');
468Device=Device(Value);
469Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir
470Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link
471handles.output.Experiment=Experiment;
472handles.output.DataSeries=Device;
473guidata(hObject, handles);% Update handles structure
474uiresume(handles.browse_data);
475drawnow
476
477%------------------------------------------------------------------------
478% --- Executes on button press in HELP.
479function HELP_Callback(hObject, eventdata, handles)
480path_to_uvmat=which ('uvmat');% check the path of uvmat
481pathelp=fileparts(path_to_uvmat);
482helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
483if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
484else
485web([helpfile '#dataview'])   
486end
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.
506function browse_data_CloseRequestFcn(hObject, eventdata, handles)
507
508%------------------------------------------------------------------------
509% --- Executes when user attempts to close browse_data.
510%------------------------------------------------------------------------
511function 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
521hseries=findobj(allchild(0),'Tag','series');
522if ~isempty(hseries)
523    hreplicate=findobj(hseries,'Tag','Replicate');
524    set(hreplicate,'Value',0)
525end
526hcalib=findobj(allchild(0),'Tag','geometry_calib');
527if ~isempty(hcalib)
528    hreplicate=findobj(hcalib,'Tag','Replicate');
529    set(hreplicate,'Value',0)
530end
531
532%------------------------------------------------------------------------
533% --- Executes on key press over figure1 with no controls selected.
534%------------------------------------------------------------------------
535function browse_data_KeyPressFcn(hObject, eventdata, handles)
536   
537% Check for "enter" or "escape"
538if 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);
546end
547if isequal(get(hObject,'CurrentKey'),'return')
548    uiresume(handles.browse_data);
549end
550
551
552% --- Executes on button press in Up.
553function Up_Callback(hObject, eventdata, handles)
554SourceDir=get(handles.SourceDir,'String');
555% Device=DataSeries{get(handles.DataSeries,'Value')};
556% DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir');
557% uiresume(handles.browse_data);
558browse_data(SourceDir)
559
560
561% --- Executes on button press in Down.
562function Down_Callback(hObject, eventdata, handles)
563SourceDir=get(handles.SourceDir,'String');
564ListExperiments=get(handles.ListExperiments,'String');
565list_val=get(handles.ListExperiments,'Value');
566SourceFolder=regexprep(ListExperiments{list_val(1)},'+','');
567set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder))
568DataSeries=get(handles.DataSeries,'String');
569ValueDevice=get(handles.DataSeries,'Value');
570set(handles.ListExperiments,'String',DataSeries)
571set(handles.ListExperiments,'Value',ValueDevice)
572ListExperiments_Callback(hObject, [], handles)
573% Device=regexprep(DataSeries{get(handles.DataSeries,'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))
580
581
582% --- Executes on selection change in DataSeries.
583function DataSeries_Callback(hObject, eventdata, handles)
584% hObject    handle to DataSeries (see GCBO)
585% eventdata  reserved - to be defined in a future version of MATLAB
586% handles    structure with handles and user data (see GUIDATA)
587
588% Hints: contents = cellstr(get(hObject,'String')) returns DataSeries contents as cell array
589%        contents{get(hObject,'Value')} returns selected item from DataSeries
590
591
592% --- Executes on button press in CheckDevices.
593function CheckDevices_Callback(hObject, eventdata, handles)
594if get(handles.CheckDevices,'Value')
595    set(handles.ListDevices,'Visible','on')
596else
597    set(handles.ListDevices,'Visible','off')
598end
Note: See TracBrowser for help on using the repository browser.