[1068] | 1 | |
---|
| 2 | %'browse_data': function for scanning directories in a campaign |
---|
[569] | 3 | %------------------------------------------------------------------------ |
---|
| 4 | % function varargout = series(varargin) |
---|
| 5 | % associated with the GUI browse_data.fig |
---|
| 6 | |
---|
[809] | 7 | %======================================================================= |
---|
[1071] | 8 | % Copyright 2008-2020, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[809] | 9 | % http://www.legi.grenoble-inp.fr |
---|
| 10 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
| 11 | % |
---|
[569] | 12 | % This file is part of the toolbox UVMAT. |
---|
[809] | 13 | % |
---|
[569] | 14 | % UVMAT is free software; you can redistribute it and/or modify |
---|
[809] | 15 | % it under the terms of the GNU General Public License as published |
---|
| 16 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 17 | % or (at your option) any later version. |
---|
| 18 | % |
---|
[569] | 19 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[809] | 22 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 23 | %======================================================================= |
---|
[569] | 24 | |
---|
| 25 | function varargout = browse_data(varargin) |
---|
| 26 | |
---|
[1070] | 27 | % Last Modified by GUIDE v2.5 11-Jul-2019 18:52:06 |
---|
[569] | 28 | |
---|
| 29 | % Begin initialization code - DO NOT EDIT |
---|
| 30 | gui_Singleton = 1; |
---|
| 31 | gui_State = struct('gui_Name', mfilename, ... |
---|
[1068] | 32 | 'gui_Singleton', gui_Singleton, ... |
---|
| 33 | 'gui_OpeningFcn', @browse_data_OpeningFcn, ... |
---|
| 34 | 'gui_OutputFcn', @browse_data_OutputFcn, ... |
---|
| 35 | 'gui_LayoutFcn', [] , ... |
---|
| 36 | 'gui_Callback', []); |
---|
[1070] | 37 | if nargin && ischar(varargin{1}) |
---|
[569] | 38 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 39 | end |
---|
| 40 | |
---|
| 41 | if nargout |
---|
| 42 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 43 | else |
---|
| 44 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 45 | end |
---|
| 46 | % End initialization code - DO NOT EDIT |
---|
| 47 | |
---|
[1070] | 48 | |
---|
[569] | 49 | %------------------------------------------------------------------------ |
---|
| 50 | % --- Executes just before browse_data is made visible. |
---|
[1059] | 51 | function browse_data_OpeningFcn(hObject, eventdata, handles, InputDir,EnableMirror,MultiDevices) |
---|
[569] | 52 | %------------------------------------------------------------------------ |
---|
[581] | 53 | |
---|
| 54 | %% Choose default command line output for browse_data |
---|
[1059] | 55 | handles.output =hObject;% 'Cancel'; |
---|
[569] | 56 | |
---|
[581] | 57 | %% Update handles structure |
---|
[569] | 58 | guidata(hObject, handles); |
---|
[581] | 59 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[1059] | 60 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
[569] | 61 | |
---|
[581] | 62 | %% Determine the position of the dialog - centered on the screen |
---|
[569] | 63 | FigPos=get(0,'DefaultFigurePosition'); |
---|
| 64 | OldUnits = get(hObject, 'Units'); |
---|
| 65 | set(hObject, 'Units', 'pixels'); |
---|
| 66 | OldPos = get(hObject,'Position'); |
---|
| 67 | FigWidth = OldPos(3); |
---|
| 68 | FigHeight = OldPos(4); |
---|
| 69 | ScreenUnits=get(0,'Units'); |
---|
| 70 | set(0,'Units','pixels'); |
---|
| 71 | ScreenSize=get(0,'ScreenSize'); |
---|
| 72 | set(0,'Units',ScreenUnits); |
---|
| 73 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth); |
---|
| 74 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight); |
---|
| 75 | FigPos(3:4)=[FigWidth FigHeight]; |
---|
| 76 | set(hObject, 'Position', FigPos); |
---|
| 77 | set(hObject, 'Units', OldUnits); |
---|
[1068] | 78 | % if exist('MultiDevices','var') && strcmp(MultiDevices,'on') |
---|
| 79 | % set(handles.DataSeries,'Max',2) |
---|
| 80 | % else |
---|
| 81 | % set(handles.DataSeries,'Max',1) |
---|
| 82 | % end |
---|
[837] | 83 | if exist('EnableMirror','var') && strcmp(EnableMirror,'on') |
---|
| 84 | set(handles.CreateMirror,'Visible','on') |
---|
| 85 | set(handles.mirror_txt,'Visible','on') |
---|
| 86 | else |
---|
| 87 | set(handles.CreateMirror,'Visible','off') |
---|
| 88 | set(handles.mirror_txt,'Visible','off') |
---|
| 89 | end |
---|
[856] | 90 | |
---|
| 91 | %% initialize the GUI |
---|
[1059] | 92 | if isempty(regexp(InputDir,'^http:'))&& ~(exist('InputDir','var') && ischar(InputDir) && exist(InputDir,'dir')) |
---|
| 93 | InputDir=pwd;% current dir is the starting data series by default |
---|
[856] | 94 | end |
---|
[1069] | 95 | if ischar(InputDir),InputDir={InputDir};end |
---|
| 96 | for ilist=1:numel(InputDir) |
---|
| 97 | [ExpWithPath,DataSeries{ilist},Ext]=fileparts(InputDir{ilist}); |
---|
| 98 | DataSeries{ilist}=['+/' DataSeries{ilist} Ext]; |
---|
| 99 | [Experiment{ilist},Device{ilist},Ext]=fileparts(ExpWithPath); |
---|
| 100 | Device{ilist}=['+/' Device{ilist} Ext]; |
---|
| 101 | [SourceDir{ilist},Experiment{ilist},Ext]=fileparts(Experiment{ilist}); |
---|
| 102 | Experiment{ilist}=['+/' Experiment{ilist} Ext]; |
---|
| 103 | if ~strcmp(SourceDir{ilist},SourceDir{1})||~strcmp(Experiment{ilist},Experiment{1}) |
---|
| 104 | msgbox_uvmat('ERROR','replicate cannot be used with multiple root folders') |
---|
| 105 | return |
---|
| 106 | end |
---|
| 107 | if ~strcmp(DataSeries{ilist},DataSeries{1}) |
---|
| 108 | set(handles.DataSeries,'enable','off') |
---|
| 109 | end |
---|
| 110 | if ~strcmp(Device{ilist},Device{1}) |
---|
| 111 | set(handles.ListDevices,'enable','off') |
---|
| 112 | end |
---|
| 113 | end |
---|
[856] | 114 | s=[]; |
---|
[1068] | 115 | % if exist(RootXml,'file') |
---|
| 116 | % [s,Heading]=xml2struct(RootXml);%read the xml file |
---|
| 117 | % if isfield(s,'SourceDir') |
---|
| 118 | % set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened |
---|
| 119 | % set(handles.MirrorDir,'Visible','on');% mirror dir display |
---|
| 120 | % set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir |
---|
| 121 | % set(handles.CreateMirror,'String','update_mirror') |
---|
| 122 | % end |
---|
| 123 | % end |
---|
[856] | 124 | if isempty(s) %a source dir has been opened |
---|
[1069] | 125 | set(handles.SourceDir,'String',SourceDir{1}); |
---|
[856] | 126 | set(handles.MirrorDir,'Visible','off');% no mirror dir display |
---|
| 127 | set(handles.CreateMirror,'String','create_mirror') |
---|
| 128 | end |
---|
[1069] | 129 | set(handles.DataSeries,'String',DataSeries); |
---|
| 130 | set(handles.DataSeries,'Value',(1:numel(DataSeries))); |
---|
| 131 | set(handles.ListDevices,'String',Device); |
---|
| 132 | set(handles.ListDevices,'Value',(1:numel(Device))); |
---|
| 133 | errormsg=scan_campaign(handles,SourceDir{1},Experiment{1}); |
---|
[856] | 134 | if ~isempty(errormsg) |
---|
| 135 | msgbox_uvmat('ERROR',errormsg) |
---|
| 136 | return |
---|
| 137 | end |
---|
[569] | 138 | |
---|
[856] | 139 | set(hObject,'Visible','on') |
---|
[1068] | 140 | drawnow |
---|
| 141 | |
---|
[569] | 142 | %------------------------------------------------------------------------ |
---|
| 143 | % --- Outputs from this function are returned to the command line. |
---|
| 144 | function varargout = browse_data_OutputFcn(hObject, eventdata, handles) |
---|
| 145 | %------------------------------------------------------------------------ |
---|
| 146 | % Get default command line output from handles structure |
---|
| 147 | varargout{1} = handles.output; |
---|
[1059] | 148 | %%%%%%%%%%%%%%%%%%delete(handles.browse_data) |
---|
[569] | 149 | |
---|
| 150 | %------------------------------------------------------------------------ |
---|
[1070] | 151 | % --- Executes on button press in SourceDir. |
---|
| 152 | function SourceDir_Callback(hObject, eventdata, handles) |
---|
| 153 | SourceDir=get(handles.SourceDir,'String'); |
---|
| 154 | ListExp=get(handles.ListExperiments,'String'); |
---|
| 155 | ListExp=ListExp(get(handles.ListExperiments,'Value')); |
---|
| 156 | errormsg=scan_campaign(handles,SourceDir,ListExp); |
---|
| 157 | if ~isempty(errormsg) |
---|
| 158 | msgbox_uvmat('ERROR',errormsg) |
---|
| 159 | return |
---|
| 160 | end |
---|
| 161 | %------------------------------------------------------------------------ |
---|
| 162 | |
---|
| 163 | %------------------------------------------------------------------------ |
---|
[569] | 164 | % --- Executes on button press in CreateMirror. |
---|
| 165 | function CreateMirror_Callback(hObject, eventdata, handles) |
---|
| 166 | %------------------------------------------------------------------------ |
---|
[733] | 167 | set(handles.SourceDir,'BackgroundColor',[1 1 0])% indicate action of button by yellow color |
---|
| 168 | drawnow |
---|
[571] | 169 | SourceDir=get(handles.SourceDir,'String'); |
---|
| 170 | [SourcePath,ProjectName]=fileparts(SourceDir); |
---|
| 171 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
[1068] | 172 | MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder |
---|
[733] | 173 | else% create the mirror folder if it does not exist |
---|
[1068] | 174 | MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir'); |
---|
| 175 | if isempty(MirrorRoot) |
---|
| 176 | return |
---|
| 177 | elseif strcmp(MirrorRoot,SourcePath) |
---|
| 178 | msgbox_uvmat('ERROR','The mirror folder must be different from the source') |
---|
| 179 | return |
---|
| 180 | else |
---|
| 181 | MirrorDir=fullfile(MirrorRoot,ProjectName); |
---|
[569] | 182 | end |
---|
[1068] | 183 | if exist(MirrorDir,'dir') |
---|
| 184 | msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) |
---|
| 185 | return |
---|
| 186 | else |
---|
| 187 | [s,errormsg]=mkdir(MirrorDir)% create the mirror dir |
---|
| 188 | if s~=1 |
---|
| 189 | msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) |
---|
| 190 | return |
---|
| 191 | end |
---|
| 192 | end |
---|
| 193 | MirrorDoc.SourceDir=SourceDir; |
---|
| 194 | t=struct2xml(MirrorDoc); |
---|
| 195 | set(t,1,'name','DataTree'); |
---|
| 196 | save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder |
---|
| 197 | set(handles.MirrorDir,'String',MirrorDir) |
---|
| 198 | set(handles.MirrorDir,'Visible','on') |
---|
| 199 | set(handles.CreateMirror,'String','update_mirror') |
---|
| 200 | end |
---|
[569] | 201 | ExpName={''}; |
---|
[733] | 202 | |
---|
| 203 | %% update the mirror from the source dir |
---|
[569] | 204 | if exist(SourceDir,'dir') |
---|
[1068] | 205 | hdir=dir(SourceDir); %list files and dirs |
---|
| 206 | idir=0; |
---|
| 207 | for ilist=1:length(hdir) |
---|
| 208 | if hdir(ilist).isdir% scan all subfolders |
---|
| 209 | dirname=hdir(ilist).name;% |
---|
| 210 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0' |
---|
| 211 | idir=idir+1; |
---|
| 212 | mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror |
---|
| 213 | if ~exist(mirror,'dir') |
---|
| 214 | mkdir(mirror)% create the mirror folder if it does not exist |
---|
| 215 | end |
---|
| 216 | ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder |
---|
| 217 | end |
---|
| 218 | % look for the list of 'devices' |
---|
[569] | 219 | else |
---|
[1068] | 220 | %warning for isolated files |
---|
[569] | 221 | end |
---|
[1068] | 222 | end |
---|
| 223 | set(handles.ListExperiments,'String',[{'*'};ExpName']) |
---|
| 224 | set(handles.ListExperiments,'Value',1) |
---|
| 225 | update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir) |
---|
| 226 | % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment |
---|
| 227 | else |
---|
| 228 | msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) |
---|
| 229 | end |
---|
[569] | 230 | set(handles.SourceDir,'BackgroundColor',[1 1 1]) |
---|
| 231 | |
---|
| 232 | %------------------------------------------------------------------------ |
---|
[856] | 233 | % List the experiments in a campaign, filling the menu ListExperiments |
---|
[569] | 234 | %------------------------------------------------------------------------ |
---|
[1068] | 235 | function errormsg=scan_campaign(handles,SourceDir,Experiment) |
---|
[856] | 236 | %------------------------------------------------------------------------ |
---|
[733] | 237 | errormsg=''; |
---|
[1068] | 238 | if ~isempty(regexp(SourceDir,'^http'))|| exist(SourceDir,'dir') |
---|
| 239 | ListStruct=dir_uvmat(SourceDir); %list files and dirs, extende to OpenDAP case |
---|
[733] | 240 | if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders |
---|
[1068] | 241 | errormsg=[SourceDir ' contains too many items (>1000) to be a Project folder']; |
---|
[733] | 242 | return |
---|
| 243 | end |
---|
[1068] | 244 | [ListFiles,index]=list_dir_1(SourceDir,Experiment); |
---|
[1059] | 245 | set(handles.ListExperiments,'String',ListFiles) |
---|
| 246 | set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input |
---|
[570] | 247 | ListExperiments_Callback([],[], handles) |
---|
[569] | 248 | else |
---|
[570] | 249 | msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) |
---|
[569] | 250 | end |
---|
| 251 | |
---|
| 252 | %------------------------------------------------------------------------ |
---|
| 253 | % --- Executes on selection change in ListExperiments. |
---|
[651] | 254 | %------------------------------------------------------------------------ |
---|
[1068] | 255 | function ListExperiments_Callback(hObject, eventdata, handles) |
---|
[651] | 256 | |
---|
[571] | 257 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
[1068] | 258 | SourceDir=get(handles.MirrorDir,'String'); |
---|
[741] | 259 | else |
---|
[1068] | 260 | SourceDir=get(handles.SourceDir,'String'); |
---|
[571] | 261 | end |
---|
[569] | 262 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 263 | list_val=get(handles.ListExperiments,'Value'); |
---|
[1068] | 264 | ListExperiments=ListExperiments(list_val);%choose the selected experiments |
---|
| 265 | ListDevices=get(handles.ListDevices,'String');% list of devices |
---|
| 266 | list_val=get(handles.ListDevices,'Value');% currently selected devices |
---|
| 267 | Device=''; |
---|
| 268 | if numel(ListDevices)>=list_val |
---|
| 269 | Device=ListDevices(list_val);%choose selected devices |
---|
| 270 | end |
---|
[1069] | 271 | check_fix=strcmp(get(handles.ListDevices,'enable'),'off'); |
---|
| 272 | [ListFiles,indices]=list_dir_2(SourceDir,ListExperiments,Device,check_fix); |
---|
[1068] | 273 | set(handles.ListDevices,'String',ListFiles) |
---|
| 274 | set(handles.ListDevices,'Value',indices)% initialise the menu selection with the folder defined by the input |
---|
| 275 | ListDevices_Callback([],[], handles) |
---|
[571] | 276 | |
---|
[733] | 277 | %------------------------------------------------------------------------ |
---|
[1068] | 278 | % --- Executes on selection change in ListExperiments. |
---|
| 279 | %------------------------------------------------------------------------ |
---|
| 280 | function ListDevices_Callback(hObject, eventdata, handles) |
---|
| 281 | |
---|
| 282 | ListDevices=get(handles.ListDevices,'String');% list of devices |
---|
| 283 | list_val=get(handles.ListDevices,'Value');% currently selected devices |
---|
| 284 | ListDevices=ListDevices(list_val);%choose selected devices |
---|
| 285 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 286 | SourceDir=get(handles.MirrorDir,'String'); |
---|
| 287 | else |
---|
| 288 | SourceDir=get(handles.SourceDir,'String'); |
---|
| 289 | end |
---|
| 290 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 291 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 292 | ListExperiments=ListExperiments(list_val);%choose the selected experiments |
---|
| 293 | |
---|
| 294 | DataSeries=get(handles.DataSeries,'String'); |
---|
| 295 | list_val=get(handles.DataSeries,'Value'); |
---|
| 296 | if numel(DataSeries)>=list_val |
---|
| 297 | DataSeries=DataSeries(list_val); |
---|
| 298 | else |
---|
| 299 | DataSeries=[]; |
---|
| 300 | end |
---|
[1069] | 301 | check_fix=strcmp(get(handles.DataSeries,'enable'),'off'); |
---|
| 302 | [ListFiles,indices]=list_dir_3(SourceDir,ListExperiments,ListDevices,DataSeries,check_fix); |
---|
[1068] | 303 | set(handles.DataSeries,'String',ListFiles) |
---|
| 304 | set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input |
---|
| 305 | |
---|
| 306 | %------------------------------------------------------------------------ |
---|
[733] | 307 | % --- List the DataSeries when a set of experiments is selected |
---|
| 308 | %------------------------------------------------------------------------ |
---|
[1068] | 309 | % function list_dataseries(handles,ListExperiments,MirrorPath) |
---|
| 310 | % |
---|
| 311 | % DataSeries={}; |
---|
| 312 | % for iexp=1:numel(ListExperiments) |
---|
| 313 | % if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory |
---|
| 314 | % ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders |
---|
| 315 | % ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory |
---|
| 316 | % ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray |
---|
| 317 | % ListFiles=ListCells(1,:);%list of dir and file names |
---|
| 318 | % cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 319 | % cell_remove_tild=regexp(ListFiles,'~$');% detect tild the end of file nqme (do not list) |
---|
| 320 | % check_keep=cellfun('isempty', cell_remove) & cellfun('isempty', cell_remove_tild); |
---|
| 321 | % check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 322 | % for ilist=1:numel(ListFiles) |
---|
| 323 | % if check_keep(ilist)% loop on eligible DataSeries folders |
---|
| 324 | % mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder |
---|
| 325 | % if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link |
---|
| 326 | % delete(mirror)% delete broken link |
---|
| 327 | % else %update the list of dataSeries |
---|
| 328 | % [tild,msg]=fileattrib(mirror); |
---|
| 329 | % if check_dir(ilist) |
---|
| 330 | % ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list |
---|
| 331 | % end |
---|
| 332 | % if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries |
---|
| 333 | % DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list |
---|
| 334 | % end |
---|
| 335 | % end |
---|
| 336 | % end |
---|
| 337 | % end |
---|
| 338 | % end |
---|
| 339 | % end |
---|
| 340 | % if get(handles.CheckDevices,'Value') |
---|
| 341 | % set(handles.ListDevices,'Value',1) |
---|
| 342 | % set(handles.ListDevices,'String',sort(DataSeries)) |
---|
| 343 | % CheckDevices_Callback([],[], handles) |
---|
| 344 | % else |
---|
| 345 | % set(handles.DataSeries,'Value',1) |
---|
| 346 | % set(handles.DataSeries,'String',sort(DataSeries)) |
---|
| 347 | % end |
---|
[571] | 348 | |
---|
[1068] | 349 | %------------------------------------------------------------------------ |
---|
| 350 | % Provide a list to display |
---|
| 351 | %------------------------------------------------------------------------ |
---|
| 352 | function [ListFiles,indices]=list_dir_1(SourceDir,ListSub) |
---|
| 353 | |
---|
| 354 | ListStruct=dir_uvmat(SourceDir); %list files and dirs, extende to OpenDAP case |
---|
| 355 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
| 356 | ListFiles=ListCells(1,:); |
---|
| 357 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 358 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
| 359 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 360 | check_keep=cellfun('isempty', cell_remove); |
---|
| 361 | ListFiles=sort((ListFiles(check_keep))'); |
---|
| 362 | |
---|
| 363 | if ischar(ListSub) |
---|
| 364 | indices=find(strcmp(ListSub,ListFiles)); |
---|
| 365 | else |
---|
| 366 | indices=[]; |
---|
| 367 | for ilist=1:numel(ListSub) |
---|
| 368 | index=find(strcmp(ListSub{ilist},ListFiles)); |
---|
| 369 | indices=[indices index]; |
---|
| 370 | end |
---|
| 371 | end |
---|
| 372 | if isempty(indices), indices=1; end |
---|
| 373 | |
---|
| 374 | %------------------------------------------------------------------------ |
---|
| 375 | % Provide a list to display |
---|
| 376 | %------------------------------------------------------------------------ |
---|
[1069] | 377 | function [ListFilesTot,indices]=list_dir_2(SourceDir,ListDir,ListSub,check_fix) |
---|
[1068] | 378 | ListFilesTot={}; |
---|
| 379 | for ilist=1:numel(ListDir) |
---|
| 380 | if ~isempty(regexp(ListDir{ilist},'^\+/')) |
---|
| 381 | ListDir{ilist}=regexprep(ListDir{ilist},'^\+/',''); |
---|
| 382 | ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist})); %list files and dirs, extende to OpenDAP case |
---|
| 383 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
| 384 | ListFiles=ListCells(1,:); |
---|
| 385 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 386 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
| 387 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 388 | check_keep=cellfun('isempty', cell_remove); |
---|
[1069] | 389 | ListFilesTot=[ListFilesTot (ListFiles(check_keep))]; |
---|
[1068] | 390 | end |
---|
| 391 | end |
---|
| 392 | ListFilesTot=unique(ListFilesTot); |
---|
| 393 | if ischar(ListSub) |
---|
| 394 | indices=find(strcmp(ListSub,ListFilesTot)); |
---|
| 395 | else |
---|
| 396 | indices=[]; |
---|
| 397 | for ilist=1:numel(ListSub) |
---|
| 398 | index=find(strcmp(ListSub{ilist},ListFilesTot)); |
---|
| 399 | indices=[indices index]; |
---|
| 400 | end |
---|
[1069] | 401 | if check_fix |
---|
| 402 | index_init=1:numel(ListFilesTot); |
---|
| 403 | %indices=sort(indices) |
---|
| 404 | index_init(indices)=[]; |
---|
| 405 | ListFilesTot=ListFilesTot([indices index_init]); |
---|
| 406 | indices=1:numel(indices); |
---|
| 407 | end |
---|
[1068] | 408 | end |
---|
| 409 | if isempty(indices), indices=1; end |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | %------------------------------------------------------------------------ |
---|
[1070] | 413 | % Provide the list (ListFilesTot) to display in DataSeries with the selected indices |
---|
[1068] | 414 | %------------------------------------------------------------------------ |
---|
[1069] | 415 | function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub,check_fix) |
---|
[1070] | 416 | % INPUT: |
---|
| 417 | %SourceDir: path to the displayed directories |
---|
| 418 | %ListDir: list of file and folder names under SourceDir (column 'Experiments') |
---|
| 419 | %ListSub: list of file and folder in the second column 'Devices') |
---|
| 420 | %ListSubSub: prvious list of file and folder in the third column 'DataSeries', used to mark the selected indices |
---|
[1068] | 421 | ListFilesTot={}; |
---|
| 422 | for ilist=1:numel(ListDir) |
---|
| 423 | if ~isempty(regexp(ListDir{ilist},'^\+/')) |
---|
| 424 | ListDir{ilist}=regexprep(ListDir{ilist},'^\+/',''); |
---|
| 425 | for isub=1:numel(ListSub) |
---|
| 426 | if ~isempty(regexp(ListSub{isub},'^\+/')) |
---|
| 427 | ListSub{isub}=regexprep(ListSub{isub},'^\+/',''); |
---|
| 428 | ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist},ListSub{isub})); %list files and dirs, extende to OpenDAP case |
---|
| 429 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
| 430 | ListFiles=ListCells(1,:); |
---|
[1070] | 431 | check_xml=~cellfun('isempty',regexp(ListFiles,'(\.xml|~)$'));% detect non xml files and files not marked by ~ |
---|
[1068] | 432 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
[1070] | 433 | nbfiles=numel(find(~check_xml & ~check_dir));% number of non xml files |
---|
| 434 | check_dir=check_dir & cellfun('isempty', regexp(ListFiles,'^(-|\.|\+/\.)'));% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
[1068] | 435 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
[1070] | 436 | %cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 437 | ListFiles=ListFiles(check_dir | check_xml); |
---|
| 438 | ListFilesTot=[ListFilesTot ListFiles]; |
---|
| 439 | if nbfiles>0 |
---|
| 440 | ListFilesTot=[ListFilesTot {[num2str(nbfiles) ' files']}]; |
---|
| 441 | end |
---|
[733] | 442 | end |
---|
| 443 | end |
---|
| 444 | end |
---|
| 445 | end |
---|
[1068] | 446 | ListFilesTot=unique(ListFilesTot); |
---|
| 447 | if ischar(ListSubSub) |
---|
| 448 | indices=find(strcmp(ListSubSub,ListFilesTot)); |
---|
[1064] | 449 | else |
---|
[1068] | 450 | indices=[]; |
---|
| 451 | for ilist=1:numel(ListSubSub) |
---|
| 452 | index=find(strcmp(ListSubSub{ilist},ListFilesTot)); |
---|
[1070] | 453 | if check_fix && isempty(index) |
---|
| 454 | ListFilesTot=[ListFilesTot {['---' ListSubSub{ilist}]}]; |
---|
| 455 | index=numel(ListFilesTot); |
---|
| 456 | end |
---|
[1068] | 457 | indices=[indices index]; |
---|
| 458 | end |
---|
[1069] | 459 | if check_fix |
---|
| 460 | index_init=1:numel(ListFilesTot); |
---|
| 461 | index_init(indices)=[]; |
---|
| 462 | ListFilesTot=ListFilesTot([indices index_init]); |
---|
| 463 | indices=1:numel(indices); |
---|
| 464 | end |
---|
[1064] | 465 | end |
---|
[1068] | 466 | if isempty(indices), indices=1; end |
---|
[733] | 467 | |
---|
[1068] | 468 | |
---|
[571] | 469 | %------------------------------------------------------------------------ |
---|
[733] | 470 | % --- Executes when the mirror is created or updated |
---|
[651] | 471 | %------------------------------------------------------------------------ |
---|
[1068] | 472 | function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath) |
---|
[651] | 473 | |
---|
[1063] | 474 | DataSeries={}; |
---|
[569] | 475 | for iexp=1:numel(ListExperiments) |
---|
[651] | 476 | if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory |
---|
| 477 | ListExperiments{iexp}(1)=[]; |
---|
[733] | 478 | ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the source experiment directory |
---|
| 479 | ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray |
---|
[651] | 480 | ListFiles=ListCells(1,:);%list of dir and file names |
---|
| 481 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 482 | check_keep=cellfun('isempty', cell_remove); |
---|
| 483 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 484 | for ilist=1:numel(ListFiles) |
---|
[733] | 485 | if check_keep(ilist)% loop on eligible DataSeries folders |
---|
| 486 | DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});%source folder |
---|
[651] | 487 | if ~isempty(MirrorPath) |
---|
| 488 | mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist}); |
---|
[741] | 489 | if exist(mirror,'file')% if mirror already exists as a file or folder |
---|
[733] | 490 | [tild,msg]=fileattrib(mirror); |
---|
| 491 | if strcmp(msg.Name,mirror)%if the mirror name already exists as a local file or dir |
---|
[741] | 492 | if msg.directory% case of a folder |
---|
[733] | 493 | answer=msgbox_uvmat('INPUT_Y-N',['replace local folder ' msg.Name ' by a link to the source dir']); |
---|
| 494 | if strcmp(answer,'Yes') |
---|
| 495 | [ss,msg]=rmdir(mirror); |
---|
| 496 | if ss==1 |
---|
| 497 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
| 498 | else |
---|
| 499 | msgbox_uvmat('ERROR',['enable to delete local folder: ' msg]); |
---|
| 500 | end |
---|
| 501 | end |
---|
[741] | 502 | else % case of an existing mirror file |
---|
[733] | 503 | answer=msgbox_uvmat('INPUT_Y-N',['replace local file ' msg.Name ' by a link to the source file']); |
---|
| 504 | if strcmp(answer,'Yes') |
---|
| 505 | delete(mirror); |
---|
[1068] | 506 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
[733] | 507 | end |
---|
| 508 | end |
---|
| 509 | end |
---|
[741] | 510 | else% create mirror to the data series if needed |
---|
[1068] | 511 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
[651] | 512 | end |
---|
[1063] | 513 | if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries |
---|
[733] | 514 | if check_dir(ilist) |
---|
| 515 | ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list |
---|
| 516 | end |
---|
[1063] | 517 | DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list |
---|
[651] | 518 | end |
---|
| 519 | end |
---|
[570] | 520 | end |
---|
[569] | 521 | end |
---|
| 522 | end |
---|
| 523 | end |
---|
[1063] | 524 | set(handles.DataSeries,'String',sort(DataSeries)) |
---|
[569] | 525 | |
---|
| 526 | %------------------------------------------------------------------------ |
---|
| 527 | % --- Executes on button press in CampaignDoc. |
---|
| 528 | function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
[1068] | 529 | %------------------------------------------------------------------------ |
---|
[651] | 530 | 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'); |
---|
[569] | 531 | if ~isequal(answer{1},'OK') |
---|
| 532 | return |
---|
| 533 | end |
---|
| 534 | set(handles.ListExperiments,'Value',1) |
---|
| 535 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
[581] | 536 | DataviewData=get(handles.browse_data,'UserData'); |
---|
[569] | 537 | List=DataviewData.List; |
---|
| 538 | Currentpath=get(handles.SourceDir,'String'); |
---|
| 539 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 540 | Campaign=[Campaign DirExt]; |
---|
| 541 | t=xmltree; |
---|
| 542 | t=set(t,1,'name','CampaignDoc'); |
---|
| 543 | t = attributes(t,'add',1,'source','directory'); |
---|
| 544 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 545 | root_uid=1; |
---|
| 546 | if SubCampaignTest |
---|
| 547 | %TO DO open an exoiting xml doc |
---|
| 548 | [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
| 549 | t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
| 550 | end |
---|
| 551 | for iexp=1:length(List.Experiment) |
---|
| 552 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 553 | drawnow |
---|
| 554 | test_mod=0; |
---|
| 555 | [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
| 556 | t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
| 557 | ExpName=List.Experiment{iexp}.name; |
---|
| 558 | t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
[1068] | 559 | |
---|
[569] | 560 | if isfield(List.Experiment{iexp},'Device') |
---|
| 561 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 562 | [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
| 563 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
[1068] | 564 | t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
[569] | 565 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 566 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 567 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 568 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
| 569 | if test |
---|
[651] | 570 | disp([List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']) |
---|
[569] | 571 | end |
---|
| 572 | if isequal(Title,'ImaDoc') |
---|
| 573 | [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
| 574 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
[1068] | 575 | [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
[569] | 576 | end |
---|
| 577 | end |
---|
[1068] | 578 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
[569] | 579 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 580 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 581 | [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
| 582 | t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
| 583 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 584 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 585 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 586 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
| 587 | if test |
---|
[651] | 588 | disp([FileName ' , Heading updated']) |
---|
[569] | 589 | end |
---|
| 590 | [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
| 591 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 592 | [t]=add(t,uid_xml,'chardata',FileName); |
---|
| 593 | end |
---|
| 594 | end |
---|
| 595 | end |
---|
| 596 | end |
---|
| 597 | end |
---|
| 598 | end |
---|
| 599 | end |
---|
| 600 | set(handles.ListExperiments,'Value',1) |
---|
| 601 | outputdir=get(handles.SourceDir,'String'); |
---|
| 602 | [path,dirname]=fileparts(outputdir); |
---|
| 603 | outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
| 604 | %campaigndoc(t); |
---|
| 605 | save(t,outputfile) |
---|
| 606 | |
---|
| 607 | |
---|
[1059] | 608 | |
---|
[1068] | 609 | % %------------------------------------------------------------------------ |
---|
| 610 | % % --- Executes on button press in OK. |
---|
| 611 | % %------------------------------------------------------------------------ |
---|
| 612 | % function OK_Callback(hObject, eventdata, handles) |
---|
| 613 | % |
---|
| 614 | % if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 615 | % Campaign=get(handles.MirrorDir,'String'); |
---|
| 616 | % else |
---|
| 617 | % Campaign=get(handles.SourceDir,'String'); |
---|
| 618 | % end |
---|
| 619 | % handles.output=[]; |
---|
| 620 | % handles.output.Campaign=Campaign; |
---|
| 621 | % Experiment=get(handles.ListExperiments,'String'); |
---|
| 622 | % IndicesExp=get(handles.ListExperiments,'Value'); |
---|
| 623 | % if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected |
---|
| 624 | % Experiment=Experiment(IndicesExp);% use the selection of the list of experiments |
---|
| 625 | % end |
---|
| 626 | % Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir |
---|
| 627 | % Device=get(handles.DataSeries,'String'); |
---|
| 628 | % Value=get(handles.DataSeries,'Value'); |
---|
| 629 | % Device=Device(Value); |
---|
| 630 | % Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir |
---|
| 631 | % Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link |
---|
| 632 | % handles.output.Experiment=Experiment; |
---|
| 633 | % handles.output.DataSeries=Device; |
---|
| 634 | % guidata(hObject, handles);% Update handles structure |
---|
| 635 | % uiresume(handles.browse_data); |
---|
| 636 | % drawnow |
---|
[651] | 637 | |
---|
| 638 | %------------------------------------------------------------------------ |
---|
| 639 | % --- Executes on button press in HELP. |
---|
| 640 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 641 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 642 | pathelp=fileparts(path_to_uvmat); |
---|
| 643 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 644 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
[569] | 645 | else |
---|
[651] | 646 | web([helpfile '#dataview']) |
---|
[569] | 647 | end |
---|
| 648 | |
---|
[651] | 649 | %------------------------------------------------------------------------ |
---|
[581] | 650 | % --- Executes when user attempts to close browse_data. |
---|
[651] | 651 | %------------------------------------------------------------------------ |
---|
[1059] | 652 | function closefcn(gcbo, eventdata) |
---|
[1068] | 653 | |
---|
[1059] | 654 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 655 | if ~isempty(hseries) |
---|
| 656 | hreplicate=findobj(hseries,'Tag','Replicate'); |
---|
| 657 | set(hreplicate,'Value',0) |
---|
[569] | 658 | end |
---|
[1059] | 659 | hcalib=findobj(allchild(0),'Tag','geometry_calib'); |
---|
| 660 | if ~isempty(hcalib) |
---|
| 661 | hreplicate=findobj(hcalib,'Tag','Replicate'); |
---|
| 662 | set(hreplicate,'Value',0) |
---|
| 663 | end |
---|
[569] | 664 | |
---|
[1068] | 665 | % %------------------------------------------------------------------------ |
---|
| 666 | % % --- Executes on key press over figure1 with no controls selected. |
---|
| 667 | % %------------------------------------------------------------------------ |
---|
| 668 | % function browse_data_KeyPressFcn(hObject, eventdata, handles) |
---|
[651] | 669 | |
---|
[1068] | 670 | % % Check for "enter" or "escape" |
---|
| 671 | % if isequal(get(hObject,'CurrentKey'),'escape') |
---|
| 672 | % % User said no by hitting escape |
---|
| 673 | % handles.output = 'Cancel'; |
---|
| 674 | % |
---|
| 675 | % % Update handles structure |
---|
| 676 | % guidata(hObject, handles); |
---|
| 677 | % |
---|
| 678 | % uiresume(handles.browse_data); |
---|
| 679 | % end |
---|
| 680 | % if isequal(get(hObject,'CurrentKey'),'return') |
---|
| 681 | % uiresume(handles.browse_data); |
---|
| 682 | % end |
---|
[733] | 683 | |
---|
| 684 | |
---|
[1059] | 685 | % --- Executes on button press in Up. |
---|
[1068] | 686 | function Down_Callback(hObject, eventdata, handles) |
---|
[1059] | 687 | SourceDir=get(handles.SourceDir,'String'); |
---|
[1068] | 688 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 689 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 690 | if ischar(ListExperiments) |
---|
| 691 | Exp=ListExperiments; |
---|
| 692 | else |
---|
| 693 | Exp=ListExperiments{list_val(1)}; |
---|
| 694 | end |
---|
| 695 | Exp=regexprep(Exp,'^\+/',''); |
---|
| 696 | SourceDirNew=fullfile(SourceDir,Exp); |
---|
| 697 | set(handles.SourceDir,'String',SourceDirNew);% New SourceDir |
---|
| 698 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 699 | DeviceIndices=get(handles.ListDevices,'Value'); |
---|
| 700 | set(handles.ListExperiments,'String',ListDevices);%replace Experiments by Devices |
---|
| 701 | set(handles.ListExperiments,'Value',DeviceIndices);%replace Experiments by Devices |
---|
| 702 | DataSeries=get(handles.DataSeries,'String'); |
---|
| 703 | list_val=get(handles.DataSeries,'Value'); |
---|
| 704 | set(handles.ListDevices,'String',DataSeries);%replace Devices by DataSeries |
---|
| 705 | set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries |
---|
[1059] | 706 | |
---|
[1070] | 707 | [ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[],0); |
---|
[1068] | 708 | set(handles.DataSeries,'String',ListFiles) |
---|
| 709 | set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input |
---|
[1059] | 710 | |
---|
[1068] | 711 | |
---|
[1059] | 712 | % --- Executes on button press in Down. |
---|
[1068] | 713 | function Up_Callback(hObject, eventdata, handles) |
---|
[1059] | 714 | SourceDir=get(handles.SourceDir,'String'); |
---|
[1068] | 715 | [SourceDir,Exp]=fileparts(SourceDir); |
---|
| 716 | set(handles.SourceDir,'String',SourceDir) |
---|
| 717 | |
---|
| 718 | % set(handles.ListExperiments,'Value',indices) |
---|
| 719 | %[ListFiles,indices]=list_dir_1(SourceDir,Exp); |
---|
| 720 | % set(handles.ListExperiments,'String',ListFiles) |
---|
| 721 | % set(handles.ListExperiments,'Value',indices) |
---|
| 722 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 723 | DeviceIndices=get(handles.ListDevices,'Value'); |
---|
| 724 | set(handles.DataSeries,'String',ListDevices); |
---|
| 725 | set(handles.DataSeries,'Value',DeviceIndices); |
---|
| 726 | |
---|
[1059] | 727 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
[1068] | 728 | ExpIndices=get(handles.ListExperiments,'Value'); |
---|
| 729 | set(handles.ListDevices,'String',ListExperiments); |
---|
| 730 | set(handles.ListDevices,'Value',ExpIndices); |
---|
[1063] | 731 | |
---|
[1068] | 732 | set(handles.ListExperiments,'String',{['+/' Exp]}) |
---|
| 733 | set(handles.ListExperiments,'Value',1) |
---|
[1063] | 734 | |
---|
[1068] | 735 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 736 | % list_val=get(handles.ListExperiments,'Value'); |
---|
| 737 | % SourceFolder=regexprep(ListExperiments{list_val(1)},'+',''); |
---|
| 738 | % set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder)) |
---|
| 739 | % DataSeries=get(handles.DataSeries,'String'); |
---|
| 740 | % ValueDevice=get(handles.DataSeries,'Value'); |
---|
| 741 | % set(handles.ListExperiments,'String',DataSeries) |
---|
| 742 | % set(handles.ListExperiments,'Value',ValueDevice) |
---|
| 743 | % ListExperiments_Callback(hObject, [], handles) |
---|
[1063] | 744 | |
---|
| 745 | |
---|
[1068] | 746 | % % --- Executes on selection change in DataSeries. |
---|
| 747 | % function DataSeries_Callback(hObject, eventdata, handles) |
---|
| 748 | % SourceDir=get(handles.SourceDir,'String'); |
---|
| 749 | % ListData=get(handles.DataSeries,'String'); |
---|
| 750 | % Folder=ListData{get(handles.DataSeries,'Value')}; |
---|
| 751 | % if ~isempty(regexp(Folder,'^\+/'))% if a folder is selected |
---|
| 752 | % Folder=regexprep(Folder,'\+/',''); |
---|
| 753 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 754 | % list_val=get(handles.ListExperiments,'Value'); |
---|
| 755 | % for iexp=1:numel(list_val) |
---|
| 756 | % ExpName=regexprep(ListExperiments{list_val(iexp)},'\+/',''); |
---|
| 757 | % FullName=fullfile(SourceDir,ExpName,Folder); |
---|
| 758 | % dd=dir(FullName); |
---|
| 759 | % check_sub=1; |
---|
| 760 | % for idir=1:numel(dd) |
---|
| 761 | % ListData{ilist}=dd(ilist).name; |
---|
| 762 | % if dd(ilist).isdir && ~strcmp(dd(ilist).name,'.')&& ~strcmp(dd(ilist).name,'..')&& isempty(regexp(dd(ilist).name,'^_LOG'))... |
---|
| 763 | % && isempty(regexp(dd(ilist).name,'^_LOG'))&& isempty(regexp(dd(ilist).name,'^_XML')) |
---|
| 764 | % check_sub=1; |
---|
| 765 | % ListData{ilist}=['+/' dd(ilist).name]; |
---|
| 766 | % end |
---|
| 767 | % end |
---|
| 768 | % if check_sub |
---|
| 769 | % set(handles.ListDevices,'String',ListData); |
---|
| 770 | % set(handles.ListDevices,'Visible','on'); |
---|
| 771 | % set(handles.DataSeries,'String',ListData) |
---|
| 772 | % break |
---|
| 773 | % end |
---|
| 774 | % end |
---|
| 775 | % end |
---|
| 776 | |
---|
| 777 | % % --- Executes on button press in CheckDevices. |
---|
| 778 | % function CheckDevices_Callback(hObject, eventdata, handles) |
---|
| 779 | % if get(handles.CheckDevices,'Value') |
---|
| 780 | % set(handles.ListDevices,'Visible','on') |
---|
| 781 | % ListDevices=get(handles.DataSeries,'String'); |
---|
| 782 | % Index=get(handles.DataSeries,'Value'); |
---|
| 783 | % set(handles.ListDevices,'String',ListDevices) |
---|
| 784 | % set(handles.ListDevices,'Value',Index) |
---|
| 785 | % set(handles.DataSeries,'Value',1) |
---|
| 786 | % if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 787 | % MirrorPath=get(handles.MirrorDir,'String'); |
---|
| 788 | % else |
---|
| 789 | % MirrorPath=get(handles.SourceDir,'String'); |
---|
| 790 | % end |
---|
| 791 | % IndexExperiment=get(handles.ListExperiments,'Value'); |
---|
| 792 | % ListExperiment=get(handles.ListExperiments,'String'); |
---|
| 793 | % Experiment=ListExperiment{get(handles.ListExperiments,'Value')}; |
---|
| 794 | % Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir |
---|
| 795 | % Experiment=regexprep(Experiment,'^~','');% remove the ~ used to mark symbolic link |
---|
| 796 | % Device=regexprep(ListDevices{Index},'^\+/','');% remove the +/ used to mark dir |
---|
| 797 | % Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link |
---|
| 798 | % DataSeries=dir(fullfile(MirrorPath,Experiment,Device)); |
---|
| 799 | % DataSeriesCell=struct2cell(DataSeries); |
---|
| 800 | % set(handles.DataSeries,'String',DataSeriesCell(1,:)') |
---|
| 801 | % else |
---|
| 802 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 803 | % Index=get(handles.ListDevices,'Value'); |
---|
| 804 | % set(handles.ListDevices,'Visible','off') |
---|
| 805 | % set(handles.DataSeries,'String',ListDevices) |
---|
| 806 | % set(handles.DataSeries,'Value',Index) |
---|
| 807 | % end |
---|
[1070] | 808 | |
---|
| 809 | |
---|
| 810 | % --- Executes when user attempts to close browse_data. |
---|
| 811 | function browse_data_CloseRequestFcn(hObject, eventdata, handles) |
---|
| 812 | % hObject handle to browse_data (see GCBO) |
---|
| 813 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 814 | % handles structure with handles and user data (see GUIDATA) |
---|
| 815 | |
---|
| 816 | % Hint: delete(hObject) closes the figure |
---|
| 817 | delete(hObject); |
---|