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