[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 | %======================================================================= |
---|
[1061] | 8 | % Copyright 2008-2019, 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 | |
---|
[1068] | 27 | % Last Modified by GUIDE v2.5 08-Jul-2019 23:32:39 |
---|
[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', []); |
---|
| 37 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
[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 | |
---|
| 48 | %------------------------------------------------------------------------ |
---|
| 49 | % --- Executes just before browse_data is made visible. |
---|
[1059] | 50 | function browse_data_OpeningFcn(hObject, eventdata, handles, InputDir,EnableMirror,MultiDevices) |
---|
[569] | 51 | %------------------------------------------------------------------------ |
---|
[581] | 52 | |
---|
| 53 | %% Choose default command line output for browse_data |
---|
[1059] | 54 | handles.output =hObject;% 'Cancel'; |
---|
[569] | 55 | |
---|
[581] | 56 | %% Update handles structure |
---|
[569] | 57 | guidata(hObject, handles); |
---|
[581] | 58 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[1059] | 59 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
[569] | 60 | |
---|
[581] | 61 | %% Determine the position of the dialog - centered on the screen |
---|
[569] | 62 | FigPos=get(0,'DefaultFigurePosition'); |
---|
| 63 | OldUnits = get(hObject, 'Units'); |
---|
| 64 | set(hObject, 'Units', 'pixels'); |
---|
| 65 | OldPos = get(hObject,'Position'); |
---|
| 66 | FigWidth = OldPos(3); |
---|
| 67 | FigHeight = OldPos(4); |
---|
| 68 | ScreenUnits=get(0,'Units'); |
---|
| 69 | set(0,'Units','pixels'); |
---|
| 70 | ScreenSize=get(0,'ScreenSize'); |
---|
| 71 | set(0,'Units',ScreenUnits); |
---|
| 72 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth); |
---|
| 73 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight); |
---|
| 74 | FigPos(3:4)=[FigWidth FigHeight]; |
---|
| 75 | set(hObject, 'Position', FigPos); |
---|
| 76 | set(hObject, 'Units', OldUnits); |
---|
[1068] | 77 | % if exist('MultiDevices','var') && strcmp(MultiDevices,'on') |
---|
| 78 | % set(handles.DataSeries,'Max',2) |
---|
| 79 | % else |
---|
| 80 | % set(handles.DataSeries,'Max',1) |
---|
| 81 | % end |
---|
[837] | 82 | if exist('EnableMirror','var') && strcmp(EnableMirror,'on') |
---|
| 83 | set(handles.CreateMirror,'Visible','on') |
---|
| 84 | set(handles.mirror_txt,'Visible','on') |
---|
| 85 | else |
---|
| 86 | set(handles.CreateMirror,'Visible','off') |
---|
| 87 | set(handles.mirror_txt,'Visible','off') |
---|
| 88 | end |
---|
[856] | 89 | |
---|
| 90 | %% initialize the GUI |
---|
[1059] | 91 | if isempty(regexp(InputDir,'^http:'))&& ~(exist('InputDir','var') && ischar(InputDir) && exist(InputDir,'dir')) |
---|
| 92 | InputDir=pwd;% current dir is the starting data series by default |
---|
[856] | 93 | end |
---|
[1069] | 94 | if ischar(InputDir),InputDir={InputDir};end |
---|
| 95 | for ilist=1:numel(InputDir) |
---|
| 96 | [ExpWithPath,DataSeries{ilist},Ext]=fileparts(InputDir{ilist}); |
---|
| 97 | DataSeries{ilist}=['+/' DataSeries{ilist} Ext]; |
---|
| 98 | [Experiment{ilist},Device{ilist},Ext]=fileparts(ExpWithPath); |
---|
| 99 | Device{ilist}=['+/' Device{ilist} Ext]; |
---|
| 100 | [SourceDir{ilist},Experiment{ilist},Ext]=fileparts(Experiment{ilist}); |
---|
| 101 | Experiment{ilist}=['+/' Experiment{ilist} Ext]; |
---|
| 102 | if ~strcmp(SourceDir{ilist},SourceDir{1})||~strcmp(Experiment{ilist},Experiment{1}) |
---|
| 103 | msgbox_uvmat('ERROR','replicate cannot be used with multiple root folders') |
---|
| 104 | return |
---|
| 105 | end |
---|
| 106 | if ~strcmp(DataSeries{ilist},DataSeries{1}) |
---|
| 107 | set(handles.DataSeries,'enable','off') |
---|
| 108 | end |
---|
| 109 | if ~strcmp(Device{ilist},Device{1}) |
---|
| 110 | set(handles.ListDevices,'enable','off') |
---|
| 111 | end |
---|
| 112 | end |
---|
[856] | 113 | s=[]; |
---|
[1068] | 114 | % if exist(RootXml,'file') |
---|
| 115 | % [s,Heading]=xml2struct(RootXml);%read the xml file |
---|
| 116 | % if isfield(s,'SourceDir') |
---|
| 117 | % set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened |
---|
| 118 | % set(handles.MirrorDir,'Visible','on');% mirror dir display |
---|
| 119 | % set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir |
---|
| 120 | % set(handles.CreateMirror,'String','update_mirror') |
---|
| 121 | % end |
---|
| 122 | % end |
---|
[856] | 123 | if isempty(s) %a source dir has been opened |
---|
[1069] | 124 | set(handles.SourceDir,'String',SourceDir{1}); |
---|
[856] | 125 | set(handles.MirrorDir,'Visible','off');% no mirror dir display |
---|
| 126 | set(handles.CreateMirror,'String','create_mirror') |
---|
| 127 | end |
---|
[1069] | 128 | set(handles.DataSeries,'String',DataSeries); |
---|
| 129 | set(handles.DataSeries,'Value',(1:numel(DataSeries))); |
---|
| 130 | set(handles.ListDevices,'String',Device); |
---|
| 131 | set(handles.ListDevices,'Value',(1:numel(Device))); |
---|
| 132 | errormsg=scan_campaign(handles,SourceDir{1},Experiment{1}); |
---|
[856] | 133 | if ~isempty(errormsg) |
---|
| 134 | msgbox_uvmat('ERROR',errormsg) |
---|
| 135 | return |
---|
| 136 | end |
---|
[569] | 137 | |
---|
[856] | 138 | set(hObject,'Visible','on') |
---|
[1068] | 139 | drawnow |
---|
| 140 | |
---|
[569] | 141 | %------------------------------------------------------------------------ |
---|
| 142 | % --- Outputs from this function are returned to the command line. |
---|
| 143 | function varargout = browse_data_OutputFcn(hObject, eventdata, handles) |
---|
| 144 | %------------------------------------------------------------------------ |
---|
| 145 | % Get default command line output from handles structure |
---|
| 146 | varargout{1} = handles.output; |
---|
[1059] | 147 | %%%%%%%%%%%%%%%%%%delete(handles.browse_data) |
---|
[569] | 148 | |
---|
| 149 | %------------------------------------------------------------------------ |
---|
| 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,:); |
---|
| 343 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 344 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
| 345 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 346 | check_keep=cellfun('isempty', cell_remove); |
---|
| 347 | ListFiles=sort((ListFiles(check_keep))'); |
---|
| 348 | |
---|
| 349 | if ischar(ListSub) |
---|
| 350 | indices=find(strcmp(ListSub,ListFiles)); |
---|
| 351 | else |
---|
| 352 | indices=[]; |
---|
| 353 | for ilist=1:numel(ListSub) |
---|
| 354 | index=find(strcmp(ListSub{ilist},ListFiles)); |
---|
| 355 | indices=[indices index]; |
---|
| 356 | end |
---|
| 357 | end |
---|
| 358 | if isempty(indices), indices=1; end |
---|
| 359 | |
---|
| 360 | %------------------------------------------------------------------------ |
---|
| 361 | % Provide a list to display |
---|
| 362 | %------------------------------------------------------------------------ |
---|
[1069] | 363 | function [ListFilesTot,indices]=list_dir_2(SourceDir,ListDir,ListSub,check_fix) |
---|
[1068] | 364 | ListFilesTot={}; |
---|
| 365 | for ilist=1:numel(ListDir) |
---|
| 366 | if ~isempty(regexp(ListDir{ilist},'^\+/')) |
---|
| 367 | ListDir{ilist}=regexprep(ListDir{ilist},'^\+/',''); |
---|
| 368 | ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist})); %list files and dirs, extende to OpenDAP case |
---|
| 369 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
| 370 | ListFiles=ListCells(1,:); |
---|
| 371 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 372 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
| 373 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 374 | check_keep=cellfun('isempty', cell_remove); |
---|
[1069] | 375 | ListFilesTot=[ListFilesTot (ListFiles(check_keep))]; |
---|
[1068] | 376 | end |
---|
| 377 | end |
---|
| 378 | ListFilesTot=unique(ListFilesTot); |
---|
| 379 | if ischar(ListSub) |
---|
| 380 | indices=find(strcmp(ListSub,ListFilesTot)); |
---|
| 381 | else |
---|
| 382 | indices=[]; |
---|
| 383 | for ilist=1:numel(ListSub) |
---|
| 384 | index=find(strcmp(ListSub{ilist},ListFilesTot)); |
---|
| 385 | indices=[indices index]; |
---|
| 386 | end |
---|
[1069] | 387 | if check_fix |
---|
| 388 | index_init=1:numel(ListFilesTot); |
---|
| 389 | %indices=sort(indices) |
---|
| 390 | index_init(indices)=[]; |
---|
| 391 | ListFilesTot=ListFilesTot([indices index_init]); |
---|
| 392 | indices=1:numel(indices); |
---|
| 393 | end |
---|
[1068] | 394 | end |
---|
| 395 | if isempty(indices), indices=1; end |
---|
| 396 | |
---|
| 397 | |
---|
| 398 | %------------------------------------------------------------------------ |
---|
| 399 | % Provide a list to display |
---|
| 400 | %------------------------------------------------------------------------ |
---|
[1069] | 401 | function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub,check_fix) |
---|
[1068] | 402 | ListFilesTot={}; |
---|
| 403 | for ilist=1:numel(ListDir) |
---|
| 404 | if ~isempty(regexp(ListDir{ilist},'^\+/')) |
---|
| 405 | ListDir{ilist}=regexprep(ListDir{ilist},'^\+/',''); |
---|
| 406 | for isub=1:numel(ListSub) |
---|
| 407 | if ~isempty(regexp(ListSub{isub},'^\+/')) |
---|
| 408 | ListSub{isub}=regexprep(ListSub{isub},'^\+/',''); |
---|
| 409 | ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist},ListSub{isub})); %list files and dirs, extende to OpenDAP case |
---|
| 410 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
| 411 | ListFiles=ListCells(1,:); |
---|
| 412 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 413 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
| 414 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 415 | check_keep=cellfun('isempty', cell_remove); |
---|
[1069] | 416 | ListFilesTot=[ListFilesTot (ListFiles(check_keep))]; |
---|
[733] | 417 | end |
---|
| 418 | end |
---|
| 419 | end |
---|
| 420 | end |
---|
[1068] | 421 | ListFilesTot=unique(ListFilesTot); |
---|
| 422 | if ischar(ListSubSub) |
---|
| 423 | indices=find(strcmp(ListSubSub,ListFilesTot)); |
---|
[1064] | 424 | else |
---|
[1068] | 425 | indices=[]; |
---|
| 426 | for ilist=1:numel(ListSubSub) |
---|
| 427 | index=find(strcmp(ListSubSub{ilist},ListFilesTot)); |
---|
| 428 | indices=[indices index]; |
---|
| 429 | end |
---|
[1069] | 430 | if check_fix |
---|
| 431 | index_init=1:numel(ListFilesTot); |
---|
| 432 | index_init(indices)=[]; |
---|
| 433 | ListFilesTot=ListFilesTot([indices index_init]); |
---|
| 434 | indices=1:numel(indices); |
---|
| 435 | end |
---|
[1064] | 436 | end |
---|
[1068] | 437 | if isempty(indices), indices=1; end |
---|
[733] | 438 | |
---|
[1068] | 439 | |
---|
[571] | 440 | %------------------------------------------------------------------------ |
---|
[733] | 441 | % --- Executes when the mirror is created or updated |
---|
[651] | 442 | %------------------------------------------------------------------------ |
---|
[1068] | 443 | function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath) |
---|
[651] | 444 | |
---|
[1063] | 445 | DataSeries={}; |
---|
[569] | 446 | for iexp=1:numel(ListExperiments) |
---|
[651] | 447 | if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory |
---|
| 448 | ListExperiments{iexp}(1)=[]; |
---|
[733] | 449 | ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the source experiment directory |
---|
| 450 | ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray |
---|
[651] | 451 | ListFiles=ListCells(1,:);%list of dir and file names |
---|
| 452 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
| 453 | check_keep=cellfun('isempty', cell_remove); |
---|
| 454 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
| 455 | for ilist=1:numel(ListFiles) |
---|
[733] | 456 | if check_keep(ilist)% loop on eligible DataSeries folders |
---|
| 457 | DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});%source folder |
---|
[651] | 458 | if ~isempty(MirrorPath) |
---|
| 459 | mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist}); |
---|
[741] | 460 | if exist(mirror,'file')% if mirror already exists as a file or folder |
---|
[733] | 461 | [tild,msg]=fileattrib(mirror); |
---|
| 462 | if strcmp(msg.Name,mirror)%if the mirror name already exists as a local file or dir |
---|
[741] | 463 | if msg.directory% case of a folder |
---|
[733] | 464 | answer=msgbox_uvmat('INPUT_Y-N',['replace local folder ' msg.Name ' by a link to the source dir']); |
---|
| 465 | if strcmp(answer,'Yes') |
---|
| 466 | [ss,msg]=rmdir(mirror); |
---|
| 467 | if ss==1 |
---|
| 468 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
| 469 | else |
---|
| 470 | msgbox_uvmat('ERROR',['enable to delete local folder: ' msg]); |
---|
| 471 | end |
---|
| 472 | end |
---|
[741] | 473 | else % case of an existing mirror file |
---|
[733] | 474 | answer=msgbox_uvmat('INPUT_Y-N',['replace local file ' msg.Name ' by a link to the source file']); |
---|
| 475 | if strcmp(answer,'Yes') |
---|
| 476 | delete(mirror); |
---|
[1068] | 477 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
[733] | 478 | end |
---|
| 479 | end |
---|
| 480 | end |
---|
[741] | 481 | else% create mirror to the data series if needed |
---|
[1068] | 482 | system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder |
---|
[651] | 483 | end |
---|
[1063] | 484 | if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries |
---|
[733] | 485 | if check_dir(ilist) |
---|
| 486 | ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list |
---|
| 487 | end |
---|
[1063] | 488 | DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list |
---|
[651] | 489 | end |
---|
| 490 | end |
---|
[570] | 491 | end |
---|
[569] | 492 | end |
---|
| 493 | end |
---|
| 494 | end |
---|
[1063] | 495 | set(handles.DataSeries,'String',sort(DataSeries)) |
---|
[569] | 496 | |
---|
| 497 | %------------------------------------------------------------------------ |
---|
| 498 | % --- Executes on button press in CampaignDoc. |
---|
| 499 | function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
[1068] | 500 | %------------------------------------------------------------------------ |
---|
[651] | 501 | 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] | 502 | if ~isequal(answer{1},'OK') |
---|
| 503 | return |
---|
| 504 | end |
---|
| 505 | set(handles.ListExperiments,'Value',1) |
---|
| 506 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
[581] | 507 | DataviewData=get(handles.browse_data,'UserData'); |
---|
[569] | 508 | List=DataviewData.List; |
---|
| 509 | Currentpath=get(handles.SourceDir,'String'); |
---|
| 510 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 511 | Campaign=[Campaign DirExt]; |
---|
| 512 | t=xmltree; |
---|
| 513 | t=set(t,1,'name','CampaignDoc'); |
---|
| 514 | t = attributes(t,'add',1,'source','directory'); |
---|
| 515 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 516 | root_uid=1; |
---|
| 517 | if SubCampaignTest |
---|
| 518 | %TO DO open an exoiting xml doc |
---|
| 519 | [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
| 520 | t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
| 521 | end |
---|
| 522 | for iexp=1:length(List.Experiment) |
---|
| 523 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 524 | drawnow |
---|
| 525 | test_mod=0; |
---|
| 526 | [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
| 527 | t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
| 528 | ExpName=List.Experiment{iexp}.name; |
---|
| 529 | t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
[1068] | 530 | |
---|
[569] | 531 | if isfield(List.Experiment{iexp},'Device') |
---|
| 532 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 533 | [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
| 534 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
[1068] | 535 | t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
[569] | 536 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 537 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 538 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 539 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
| 540 | if test |
---|
[651] | 541 | disp([List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']) |
---|
[569] | 542 | end |
---|
| 543 | if isequal(Title,'ImaDoc') |
---|
| 544 | [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
| 545 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
[1068] | 546 | [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
[569] | 547 | end |
---|
| 548 | end |
---|
[1068] | 549 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
[569] | 550 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 551 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 552 | [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
| 553 | t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
| 554 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 555 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 556 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 557 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
| 558 | if test |
---|
[651] | 559 | disp([FileName ' , Heading updated']) |
---|
[569] | 560 | end |
---|
| 561 | [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
| 562 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 563 | [t]=add(t,uid_xml,'chardata',FileName); |
---|
| 564 | end |
---|
| 565 | end |
---|
| 566 | end |
---|
| 567 | end |
---|
| 568 | end |
---|
| 569 | end |
---|
| 570 | end |
---|
| 571 | set(handles.ListExperiments,'Value',1) |
---|
| 572 | outputdir=get(handles.SourceDir,'String'); |
---|
| 573 | [path,dirname]=fileparts(outputdir); |
---|
| 574 | outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
| 575 | %campaigndoc(t); |
---|
| 576 | save(t,outputfile) |
---|
| 577 | |
---|
| 578 | |
---|
[1059] | 579 | |
---|
[1068] | 580 | % %------------------------------------------------------------------------ |
---|
| 581 | % % --- Executes on button press in OK. |
---|
| 582 | % %------------------------------------------------------------------------ |
---|
| 583 | % function OK_Callback(hObject, eventdata, handles) |
---|
| 584 | % |
---|
| 585 | % if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 586 | % Campaign=get(handles.MirrorDir,'String'); |
---|
| 587 | % else |
---|
| 588 | % Campaign=get(handles.SourceDir,'String'); |
---|
| 589 | % end |
---|
| 590 | % handles.output=[]; |
---|
| 591 | % handles.output.Campaign=Campaign; |
---|
| 592 | % Experiment=get(handles.ListExperiments,'String'); |
---|
| 593 | % IndicesExp=get(handles.ListExperiments,'Value'); |
---|
| 594 | % if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected |
---|
| 595 | % Experiment=Experiment(IndicesExp);% use the selection of the list of experiments |
---|
| 596 | % end |
---|
| 597 | % Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir |
---|
| 598 | % Device=get(handles.DataSeries,'String'); |
---|
| 599 | % Value=get(handles.DataSeries,'Value'); |
---|
| 600 | % Device=Device(Value); |
---|
| 601 | % Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir |
---|
| 602 | % Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link |
---|
| 603 | % handles.output.Experiment=Experiment; |
---|
| 604 | % handles.output.DataSeries=Device; |
---|
| 605 | % guidata(hObject, handles);% Update handles structure |
---|
| 606 | % uiresume(handles.browse_data); |
---|
| 607 | % drawnow |
---|
[651] | 608 | |
---|
| 609 | %------------------------------------------------------------------------ |
---|
| 610 | % --- Executes on button press in HELP. |
---|
| 611 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 612 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 613 | pathelp=fileparts(path_to_uvmat); |
---|
| 614 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 615 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
[569] | 616 | else |
---|
[651] | 617 | web([helpfile '#dataview']) |
---|
[569] | 618 | end |
---|
| 619 | |
---|
[651] | 620 | %------------------------------------------------------------------------ |
---|
[581] | 621 | % --- Executes when user attempts to close browse_data. |
---|
[651] | 622 | %------------------------------------------------------------------------ |
---|
[1059] | 623 | function closefcn(gcbo, eventdata) |
---|
[1068] | 624 | |
---|
[1059] | 625 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 626 | if ~isempty(hseries) |
---|
| 627 | hreplicate=findobj(hseries,'Tag','Replicate'); |
---|
| 628 | set(hreplicate,'Value',0) |
---|
[569] | 629 | end |
---|
[1059] | 630 | hcalib=findobj(allchild(0),'Tag','geometry_calib'); |
---|
| 631 | if ~isempty(hcalib) |
---|
| 632 | hreplicate=findobj(hcalib,'Tag','Replicate'); |
---|
| 633 | set(hreplicate,'Value',0) |
---|
| 634 | end |
---|
[569] | 635 | |
---|
[1068] | 636 | % %------------------------------------------------------------------------ |
---|
| 637 | % % --- Executes on key press over figure1 with no controls selected. |
---|
| 638 | % %------------------------------------------------------------------------ |
---|
| 639 | % function browse_data_KeyPressFcn(hObject, eventdata, handles) |
---|
[651] | 640 | |
---|
[1068] | 641 | % % Check for "enter" or "escape" |
---|
| 642 | % if isequal(get(hObject,'CurrentKey'),'escape') |
---|
| 643 | % % User said no by hitting escape |
---|
| 644 | % handles.output = 'Cancel'; |
---|
| 645 | % |
---|
| 646 | % % Update handles structure |
---|
| 647 | % guidata(hObject, handles); |
---|
| 648 | % |
---|
| 649 | % uiresume(handles.browse_data); |
---|
| 650 | % end |
---|
| 651 | % if isequal(get(hObject,'CurrentKey'),'return') |
---|
| 652 | % uiresume(handles.browse_data); |
---|
| 653 | % end |
---|
[733] | 654 | |
---|
| 655 | |
---|
[1059] | 656 | % --- Executes on button press in Up. |
---|
[1068] | 657 | function Down_Callback(hObject, eventdata, handles) |
---|
[1059] | 658 | SourceDir=get(handles.SourceDir,'String'); |
---|
[1068] | 659 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 660 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 661 | if ischar(ListExperiments) |
---|
| 662 | Exp=ListExperiments; |
---|
| 663 | else |
---|
| 664 | Exp=ListExperiments{list_val(1)}; |
---|
| 665 | end |
---|
| 666 | Exp=regexprep(Exp,'^\+/',''); |
---|
| 667 | SourceDirNew=fullfile(SourceDir,Exp); |
---|
| 668 | set(handles.SourceDir,'String',SourceDirNew);% New SourceDir |
---|
| 669 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 670 | DeviceIndices=get(handles.ListDevices,'Value'); |
---|
| 671 | set(handles.ListExperiments,'String',ListDevices);%replace Experiments by Devices |
---|
| 672 | set(handles.ListExperiments,'Value',DeviceIndices);%replace Experiments by Devices |
---|
| 673 | DataSeries=get(handles.DataSeries,'String'); |
---|
| 674 | list_val=get(handles.DataSeries,'Value'); |
---|
| 675 | set(handles.ListDevices,'String',DataSeries);%replace Devices by DataSeries |
---|
| 676 | set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries |
---|
[1059] | 677 | |
---|
[1068] | 678 | [ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[]); |
---|
| 679 | set(handles.DataSeries,'String',ListFiles) |
---|
| 680 | set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input |
---|
[1059] | 681 | |
---|
[1068] | 682 | |
---|
[1059] | 683 | % --- Executes on button press in Down. |
---|
[1068] | 684 | function Up_Callback(hObject, eventdata, handles) |
---|
[1059] | 685 | SourceDir=get(handles.SourceDir,'String'); |
---|
[1068] | 686 | [SourceDir,Exp]=fileparts(SourceDir); |
---|
| 687 | set(handles.SourceDir,'String',SourceDir) |
---|
| 688 | |
---|
| 689 | % set(handles.ListExperiments,'Value',indices) |
---|
| 690 | %[ListFiles,indices]=list_dir_1(SourceDir,Exp); |
---|
| 691 | % set(handles.ListExperiments,'String',ListFiles) |
---|
| 692 | % set(handles.ListExperiments,'Value',indices) |
---|
| 693 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 694 | DeviceIndices=get(handles.ListDevices,'Value'); |
---|
| 695 | set(handles.DataSeries,'String',ListDevices); |
---|
| 696 | set(handles.DataSeries,'Value',DeviceIndices); |
---|
| 697 | |
---|
[1059] | 698 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
[1068] | 699 | ExpIndices=get(handles.ListExperiments,'Value'); |
---|
| 700 | set(handles.ListDevices,'String',ListExperiments); |
---|
| 701 | set(handles.ListDevices,'Value',ExpIndices); |
---|
[1063] | 702 | |
---|
[1068] | 703 | set(handles.ListExperiments,'String',{['+/' Exp]}) |
---|
| 704 | set(handles.ListExperiments,'Value',1) |
---|
[1063] | 705 | |
---|
[1068] | 706 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 707 | % list_val=get(handles.ListExperiments,'Value'); |
---|
| 708 | % SourceFolder=regexprep(ListExperiments{list_val(1)},'+',''); |
---|
| 709 | % set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder)) |
---|
| 710 | % DataSeries=get(handles.DataSeries,'String'); |
---|
| 711 | % ValueDevice=get(handles.DataSeries,'Value'); |
---|
| 712 | % set(handles.ListExperiments,'String',DataSeries) |
---|
| 713 | % set(handles.ListExperiments,'Value',ValueDevice) |
---|
| 714 | % ListExperiments_Callback(hObject, [], handles) |
---|
[1063] | 715 | |
---|
| 716 | |
---|
[1068] | 717 | % % --- Executes on selection change in DataSeries. |
---|
| 718 | % function DataSeries_Callback(hObject, eventdata, handles) |
---|
| 719 | % SourceDir=get(handles.SourceDir,'String'); |
---|
| 720 | % ListData=get(handles.DataSeries,'String'); |
---|
| 721 | % Folder=ListData{get(handles.DataSeries,'Value')}; |
---|
| 722 | % if ~isempty(regexp(Folder,'^\+/'))% if a folder is selected |
---|
| 723 | % Folder=regexprep(Folder,'\+/',''); |
---|
| 724 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 725 | % list_val=get(handles.ListExperiments,'Value'); |
---|
| 726 | % for iexp=1:numel(list_val) |
---|
| 727 | % ExpName=regexprep(ListExperiments{list_val(iexp)},'\+/',''); |
---|
| 728 | % FullName=fullfile(SourceDir,ExpName,Folder); |
---|
| 729 | % dd=dir(FullName); |
---|
| 730 | % check_sub=1; |
---|
| 731 | % for idir=1:numel(dd) |
---|
| 732 | % ListData{ilist}=dd(ilist).name; |
---|
| 733 | % if dd(ilist).isdir && ~strcmp(dd(ilist).name,'.')&& ~strcmp(dd(ilist).name,'..')&& isempty(regexp(dd(ilist).name,'^_LOG'))... |
---|
| 734 | % && isempty(regexp(dd(ilist).name,'^_LOG'))&& isempty(regexp(dd(ilist).name,'^_XML')) |
---|
| 735 | % check_sub=1; |
---|
| 736 | % ListData{ilist}=['+/' dd(ilist).name]; |
---|
| 737 | % end |
---|
| 738 | % end |
---|
| 739 | % if check_sub |
---|
| 740 | % set(handles.ListDevices,'String',ListData); |
---|
| 741 | % set(handles.ListDevices,'Visible','on'); |
---|
| 742 | % set(handles.DataSeries,'String',ListData) |
---|
| 743 | % break |
---|
| 744 | % end |
---|
| 745 | % end |
---|
| 746 | % end |
---|
| 747 | |
---|
| 748 | % % --- Executes on button press in CheckDevices. |
---|
| 749 | % function CheckDevices_Callback(hObject, eventdata, handles) |
---|
| 750 | % if get(handles.CheckDevices,'Value') |
---|
| 751 | % set(handles.ListDevices,'Visible','on') |
---|
| 752 | % ListDevices=get(handles.DataSeries,'String'); |
---|
| 753 | % Index=get(handles.DataSeries,'Value'); |
---|
| 754 | % set(handles.ListDevices,'String',ListDevices) |
---|
| 755 | % set(handles.ListDevices,'Value',Index) |
---|
| 756 | % set(handles.DataSeries,'Value',1) |
---|
| 757 | % if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 758 | % MirrorPath=get(handles.MirrorDir,'String'); |
---|
| 759 | % else |
---|
| 760 | % MirrorPath=get(handles.SourceDir,'String'); |
---|
| 761 | % end |
---|
| 762 | % IndexExperiment=get(handles.ListExperiments,'Value'); |
---|
| 763 | % ListExperiment=get(handles.ListExperiments,'String'); |
---|
| 764 | % Experiment=ListExperiment{get(handles.ListExperiments,'Value')}; |
---|
| 765 | % Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir |
---|
| 766 | % Experiment=regexprep(Experiment,'^~','');% remove the ~ used to mark symbolic link |
---|
| 767 | % Device=regexprep(ListDevices{Index},'^\+/','');% remove the +/ used to mark dir |
---|
| 768 | % Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link |
---|
| 769 | % DataSeries=dir(fullfile(MirrorPath,Experiment,Device)); |
---|
| 770 | % DataSeriesCell=struct2cell(DataSeries); |
---|
| 771 | % set(handles.DataSeries,'String',DataSeriesCell(1,:)') |
---|
| 772 | % else |
---|
| 773 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 774 | % Index=get(handles.ListDevices,'Value'); |
---|
| 775 | % set(handles.ListDevices,'Visible','off') |
---|
| 776 | % set(handles.DataSeries,'String',ListDevices) |
---|
| 777 | % set(handles.DataSeries,'Value',Index) |
---|
| 778 | % end |
---|