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