Changeset 1068 for trunk/src/browse_data.m
- Timestamp:
- Jul 9, 2019, 10:10:18 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r1064 r1068 1 %'browse_data': function for scanning directories in a campaign 1 2 %'browse_data': function for scanning directories in a campaign 2 3 %------------------------------------------------------------------------ 3 4 % function varargout = series(varargin) … … 24 25 function varargout = browse_data(varargin) 25 26 26 % Last Modified by GUIDE v2.5 17-Apr-2019 18:15:2427 % Last Modified by GUIDE v2.5 08-Jul-2019 23:32:39 27 28 28 29 % Begin initialization code - DO NOT EDIT 29 30 gui_Singleton = 1; 30 31 gui_State = struct('gui_Name', mfilename, ... 31 32 33 34 35 36 if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) 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')) 37 38 gui_State.gui_Callback = str2func(varargin{1}); 38 39 end … … 74 75 set(hObject, 'Position', FigPos); 75 76 set(hObject, 'Units', OldUnits); 76 if exist('MultiDevices','var') && strcmp(MultiDevices,'on')77 set(handles.DataSeries,'Max',2)78 else79 set(handles.DataSeries,'Max',1)80 end77 % if exist('MultiDevices','var') && strcmp(MultiDevices,'on') 78 % set(handles.DataSeries,'Max',2) 79 % else 80 % set(handles.DataSeries,'Max',1) 81 % end 81 82 if exist('EnableMirror','var') && strcmp(EnableMirror,'on') 82 83 set(handles.CreateMirror,'Visible','on') … … 91 92 InputDir=pwd;% current dir is the starting data series by default 92 93 end 93 % [Experiment,DataSeries,Ext]=fileparts(DataSeries); 94 % DataSeries=[DataSeries Ext]; 95 % [Campaign,Experiment,Ext]=fileparts(Experiment); 96 % Experiment=[Experiment Ext]; 94 97 95 [ExpWithPath,DataSeries]=fileparts(InputDir); 98 [Campaign,Experiment,Ext]=fileparts(ExpWithPath); 99 [tild,CampaignName]=fileparts(Campaign); 100 RootXml=fullfile(Campaign,[CampaignName '.xml']); 96 [Experiment,Device,Ext]=fileparts(ExpWithPath); 97 Device=[Device Ext]; 98 [SourceDir,Experiment,Ext]=fileparts(Experiment); 99 Experiment=[Experiment Ext]; 100 % [tild,CampaignName]=fileparts(Campaign); 101 % RootXml=fullfile(Campaign,[CampaignName '.xml']); 101 102 s=[]; 102 if exist(RootXml,'file')103 [s,Heading]=xml2struct(RootXml);%read the xml file104 if isfield(s,'SourceDir')105 set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened106 set(handles.MirrorDir,'Visible','on');% mirror dir display107 set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir108 set(handles.CreateMirror,'String','update_mirror')109 end110 end103 % if exist(RootXml,'file') 104 % [s,Heading]=xml2struct(RootXml);%read the xml file 105 % if isfield(s,'SourceDir') 106 % set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened 107 % set(handles.MirrorDir,'Visible','on');% mirror dir display 108 % set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir 109 % set(handles.CreateMirror,'String','update_mirror') 110 % end 111 % end 111 112 if isempty(s) %a source dir has been opened 112 set(handles.SourceDir,'String', Campaign);113 set(handles.SourceDir,'String',SourceDir); 113 114 set(handles.MirrorDir,'Visible','off');% no mirror dir display 114 115 set(handles.CreateMirror,'String','create_mirror') 115 116 end 116 errormsg=scan_campaign(handles,Campaign,Experiment,ExpWithPath); 117 set(handles.DataSeries,'String',{['+/' DataSeries]}); 118 set(handles.ListDevices,'String',{['+/' Device]}); 119 errormsg=scan_campaign(handles,SourceDir,['+/' Experiment]); 117 120 if ~isempty(errormsg) 118 121 msgbox_uvmat('ERROR',errormsg) 119 122 return 120 123 end 121 % set(handles.OK,'Visible','on') 122 % set(handles.Cancel,'Visible','on') 123 124 %set(handles.browse_data,'WindowStyle','modal')% Make the GUI 125 %modal%%%%%%%%%%%%%%%%%%%%%%% 124 126 125 set(hObject,'Visible','on') 127 drawnow 128 % UIWAIT makes GUI wait for user response (see UIRESUME)%%%%%%%%%%%%%%%%TO 129 % CHECK 130 %uiwait(handles.browse_data); 131 132 133 126 drawnow 127 134 128 %------------------------------------------------------------------------ 135 129 % --- Outputs from this function are returned to the command line. … … 149 143 [SourcePath,ProjectName]=fileparts(SourceDir); 150 144 if strcmp(get(handles.MirrorDir,'Visible'),'on') 151 145 MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder 152 146 else% create the mirror folder if it does not exist 153 154 155 156 157 158 159 160 161 162 163 msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) 164 165 166 167 168 msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) 169 170 171 172 173 174 175 176 177 178 147 MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir'); 148 if isempty(MirrorRoot) 149 return 150 elseif strcmp(MirrorRoot,SourcePath) 151 msgbox_uvmat('ERROR','The mirror folder must be different from the source') 152 return 153 else 154 MirrorDir=fullfile(MirrorRoot,ProjectName); 155 end 156 if exist(MirrorDir,'dir') 157 msgbox_uvmat('ERROR',['The folder ' MirrorDir ' chosen as new mirror campaign already exists']) 158 return 159 else 160 [s,errormsg]=mkdir(MirrorDir)% create the mirror dir 161 if s~=1 162 msgbox_uvmat('ERROR',['error in creating ' MirrorDir ': ' errormsg]) 163 return 164 end 165 end 166 MirrorDoc.SourceDir=SourceDir; 167 t=struct2xml(MirrorDoc); 168 set(t,1,'name','DataTree'); 169 save(t,fullfile(MirrorDir,[ProjectName '.xml']))% create an xml file in the mirror folder to indicate its source folder 170 set(handles.MirrorDir,'String',MirrorDir) 171 set(handles.MirrorDir,'Visible','on') 172 set(handles.CreateMirror,'String','update_mirror') 179 173 end 180 174 ExpName={''}; … … 182 176 %% update the mirror from the source dir 183 177 if exist(SourceDir,'dir') 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 else 207 178 hdir=dir(SourceDir); %list files and dirs 179 idir=0; 180 for ilist=1:length(hdir) 181 if hdir(ilist).isdir% scan all subfolders 182 dirname=hdir(ilist).name;% 183 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0' 184 idir=idir+1; 185 mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror 186 if ~exist(mirror,'dir') 187 mkdir(mirror)% create the mirror folder if it does not exist 188 end 189 ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder 190 end 191 % look for the list of 'devices' 192 else 193 %warning for isolated files 194 end 195 end 196 set(handles.ListExperiments,'String',[{'*'};ExpName']) 197 set(handles.ListExperiments,'Value',1) 198 update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir) 199 % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment 200 else 201 msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) 208 202 end 209 203 set(handles.SourceDir,'BackgroundColor',[1 1 1]) … … 212 206 % List the experiments in a campaign, filling the menu ListExperiments 213 207 %------------------------------------------------------------------------ 214 function errormsg=scan_campaign(handles, Campaign,Experiment,DataInput)208 function errormsg=scan_campaign(handles,SourceDir,Experiment) 215 209 %------------------------------------------------------------------------ 216 210 errormsg=''; 217 if ~isempty(regexp( Campaign,'^http'))|| exist(Campaign,'dir')218 ListStruct=dir_uvmat( Campaign); %list files and dirs211 if ~isempty(regexp(SourceDir,'^http'))|| exist(SourceDir,'dir') 212 ListStruct=dir_uvmat(SourceDir); %list files and dirs, extende to OpenDAP case 219 213 if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders 220 errormsg=[ Campaign' contains too many items (>1000) to be a Project folder'];214 errormsg=[SourceDir ' contains too many items (>1000) to be a Project folder']; 221 215 return 222 216 end 217 [ListFiles,index]=list_dir_1(SourceDir,Experiment); 218 set(handles.ListExperiments,'String',ListFiles) 219 set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input 220 ListExperiments_Callback([],[], handles) 221 else 222 msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) 223 end 224 225 %------------------------------------------------------------------------ 226 % --- Executes on selection change in ListExperiments. 227 %------------------------------------------------------------------------ 228 function ListExperiments_Callback(hObject, eventdata, handles) 229 230 if strcmp(get(handles.MirrorDir,'Visible'),'on') 231 SourceDir=get(handles.MirrorDir,'String'); 232 else 233 SourceDir=get(handles.SourceDir,'String'); 234 end 235 ListExperiments=get(handles.ListExperiments,'String'); 236 list_val=get(handles.ListExperiments,'Value'); 237 ListExperiments=ListExperiments(list_val);%choose the selected experiments 238 ListDevices=get(handles.ListDevices,'String');% list of devices 239 list_val=get(handles.ListDevices,'Value');% currently selected devices 240 Device=''; 241 if numel(ListDevices)>=list_val 242 Device=ListDevices(list_val);%choose selected devices 243 end 244 [ListFiles,indices]=list_dir_2(SourceDir,ListExperiments,Device); 245 set(handles.ListDevices,'String',ListFiles) 246 set(handles.ListDevices,'Value',indices)% initialise the menu selection with the folder defined by the input 247 ListDevices_Callback([],[], handles) 248 249 %------------------------------------------------------------------------ 250 % --- Executes on selection change in ListExperiments. 251 %------------------------------------------------------------------------ 252 function ListDevices_Callback(hObject, eventdata, handles) 253 254 ListDevices=get(handles.ListDevices,'String');% list of devices 255 list_val=get(handles.ListDevices,'Value');% currently selected devices 256 ListDevices=ListDevices(list_val);%choose selected devices 257 if strcmp(get(handles.MirrorDir,'Visible'),'on') 258 SourceDir=get(handles.MirrorDir,'String'); 259 else 260 SourceDir=get(handles.SourceDir,'String'); 261 end 262 ListExperiments=get(handles.ListExperiments,'String'); 263 list_val=get(handles.ListExperiments,'Value'); 264 ListExperiments=ListExperiments(list_val);%choose the selected experiments 265 266 DataSeries=get(handles.DataSeries,'String'); 267 list_val=get(handles.DataSeries,'Value'); 268 if numel(DataSeries)>=list_val 269 DataSeries=DataSeries(list_val); 270 else 271 DataSeries=[]; 272 end 273 [ListFiles,indices]=list_dir_3(SourceDir,ListExperiments,ListDevices,DataSeries); 274 set(handles.DataSeries,'String',ListFiles) 275 set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input 276 277 %------------------------------------------------------------------------ 278 % --- List the DataSeries when a set of experiments is selected 279 %------------------------------------------------------------------------ 280 % function list_dataseries(handles,ListExperiments,MirrorPath) 281 % 282 % DataSeries={}; 283 % for iexp=1:numel(ListExperiments) 284 % if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory 285 % ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders 286 % ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory 287 % ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray 288 % ListFiles=ListCells(1,:);%list of dir and file names 289 % cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 290 % cell_remove_tild=regexp(ListFiles,'~$');% detect tild the end of file nqme (do not list) 291 % check_keep=cellfun('isempty', cell_remove) & cellfun('isempty', cell_remove_tild); 292 % check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 293 % for ilist=1:numel(ListFiles) 294 % if check_keep(ilist)% loop on eligible DataSeries folders 295 % mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder 296 % if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link 297 % delete(mirror)% delete broken link 298 % else %update the list of dataSeries 299 % [tild,msg]=fileattrib(mirror); 300 % if check_dir(ilist) 301 % ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list 302 % end 303 % if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries 304 % DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list 305 % end 306 % end 307 % end 308 % end 309 % end 310 % end 311 % if get(handles.CheckDevices,'Value') 312 % set(handles.ListDevices,'Value',1) 313 % set(handles.ListDevices,'String',sort(DataSeries)) 314 % CheckDevices_Callback([],[], handles) 315 % else 316 % set(handles.DataSeries,'Value',1) 317 % set(handles.DataSeries,'String',sort(DataSeries)) 318 % end 319 320 %------------------------------------------------------------------------ 321 % Provide a list to display 322 %------------------------------------------------------------------------ 323 function [ListFiles,indices]=list_dir_1(SourceDir,ListSub) 324 325 ListStruct=dir_uvmat(SourceDir); %list files and dirs, extende to OpenDAP case 223 326 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 224 ListFiles=ListCells(1,:); %list of dir and file names327 ListFiles=ListCells(1,:); 225 328 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 226 329 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display … … 228 331 check_keep=cellfun('isempty', cell_remove); 229 332 ListFiles=sort((ListFiles(check_keep))'); 230 index=find(strcmp(['+/' Experiment],ListFiles)); 231 if isempty(index), index=1; end 232 set(handles.ListExperiments,'String',ListFiles) 233 set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input 234 ListExperiments_Callback([],[], handles) 235 DataSeries=get(handles.DataSeries,'String'); 236 index=find(strcmp(['+/' DataInput],DataSeries)); 237 if isempty(index) 238 index=find(strcmp(['~/' DataInput],DataSeries)); 333 334 if ischar(ListSub) 335 indices=find(strcmp(ListSub,ListFiles)); 336 else 337 indices=[]; 338 for ilist=1:numel(ListSub) 339 index=find(strcmp(ListSub{ilist},ListFiles)); 340 indices=[indices index]; 239 341 end 240 if ~isempty(index) 241 set(handles.DataSeries,'Value',index) 342 end 343 if isempty(indices), indices=1; end 344 345 %------------------------------------------------------------------------ 346 % Provide a list to display 347 %------------------------------------------------------------------------ 348 function [ListFilesTot,indices]=list_dir_2(SourceDir,ListDir,ListSub) 349 ListFilesTot={}; 350 for ilist=1:numel(ListDir) 351 if ~isempty(regexp(ListDir{ilist},'^\+/')) 352 ListDir{ilist}=regexprep(ListDir{ilist},'^\+/',''); 353 ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist})); %list files and dirs, extende to OpenDAP case 354 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 355 ListFiles=ListCells(1,:); 356 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 357 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 358 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 359 check_keep=cellfun('isempty', cell_remove); 360 ListFilesTot=[ListFilesTot;(ListFiles(check_keep))']; 242 361 end 243 else 244 msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) 245 end 246 247 %------------------------------------------------------------------------ 248 % --- Executes on selection change in ListExperiments. 249 %------------------------------------------------------------------------ 250 function ListExperiments_Callback(hObject, eventdata, handles) 251 252 if strcmp(get(handles.MirrorDir,'Visible'),'on') 253 MirrorPath=get(handles.MirrorDir,'String'); 254 else 255 MirrorPath=get(handles.SourceDir,'String'); 256 end 257 ListExperiments=get(handles.ListExperiments,'String'); 258 list_val=get(handles.ListExperiments,'Value'); 259 ListExperiments=ListExperiments(list_val);%choose selected experiments 260 list_dataseries(handles,ListExperiments,MirrorPath) 261 262 %------------------------------------------------------------------------ 263 % --- List the DataSeries when a set of experiments is selected 264 %------------------------------------------------------------------------ 265 function list_dataseries(handles,ListExperiments,MirrorPath) 266 267 DataSeries={}; 268 for iexp=1:numel(ListExperiments) 269 if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory 270 ListExperiments{iexp}(1)=[];%remove the first char '+' used to mark folders 271 ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory 272 ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray 273 ListFiles=ListCells(1,:);%list of dir and file names 274 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 275 cell_remove_tild=regexp(ListFiles,'~$');% detect tild the end of file nqme (do not list) 276 check_keep=cellfun('isempty', cell_remove) & cellfun('isempty', cell_remove_tild); 277 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 278 for ilist=1:numel(ListFiles) 279 if check_keep(ilist)% loop on eligible DataSeries folders 280 mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder 281 if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link 282 delete(mirror)% delete broken link 283 else %update the list of dataSeries 284 [tild,msg]=fileattrib(mirror); 285 % msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name 286 % if ~strcmp(msg.Name,mirror)% if it is a link 287 % ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list 288 % end 289 if check_dir(ilist) 290 ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list 291 end 292 if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries 293 DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list 294 end 295 end 362 end 363 ListFilesTot=unique(ListFilesTot); 364 if ischar(ListSub) 365 indices=find(strcmp(ListSub,ListFilesTot)); 366 else 367 indices=[]; 368 for ilist=1:numel(ListSub) 369 index=find(strcmp(ListSub{ilist},ListFilesTot)); 370 indices=[indices index]; 371 end 372 end 373 if isempty(indices), indices=1; end 374 375 376 %------------------------------------------------------------------------ 377 % Provide a list to display 378 %------------------------------------------------------------------------ 379 function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub) 380 ListFilesTot={}; 381 for ilist=1:numel(ListDir) 382 if ~isempty(regexp(ListDir{ilist},'^\+/')) 383 ListDir{ilist}=regexprep(ListDir{ilist},'^\+/',''); 384 for isub=1:numel(ListSub) 385 if ~isempty(regexp(ListSub{isub},'^\+/')) 386 ListSub{isub}=regexprep(ListSub{isub},'^\+/',''); 387 ListStruct=dir_uvmat(fullfile(SourceDir,ListDir{ilist},ListSub{isub})); %list files and dirs, extende to OpenDAP case 388 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 389 ListFiles=ListCells(1,:); 390 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 391 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 392 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 393 check_keep=cellfun('isempty', cell_remove); 394 ListFilesTot=[ListFilesTot;(ListFiles(check_keep))']; 296 395 end 297 396 end 298 397 end 299 398 end 300 if get(handles.CheckDevices,'Value') 301 set(handles.ListDevices,'Value',1) 302 set(handles.ListDevices,'String',sort(DataSeries)) 303 CheckDevices_Callback([],[], handles) 304 else 305 set(handles.DataSeries,'Value',1) 306 set(handles.DataSeries,'String',sort(DataSeries)) 307 end 399 ListFilesTot=unique(ListFilesTot); 400 if ischar(ListSubSub) 401 indices=find(strcmp(ListSubSub,ListFilesTot)); 402 else 403 indices=[]; 404 for ilist=1:numel(ListSubSub) 405 index=find(strcmp(ListSubSub{ilist},ListFilesTot)); 406 indices=[indices index]; 407 end 408 end 409 if isempty(indices), indices=1; end 410 308 411 309 412 %------------------------------------------------------------------------ 310 413 % --- Executes when the mirror is created or updated 311 414 %------------------------------------------------------------------------ 312 415 function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath) 313 416 314 417 DataSeries={}; … … 344 447 if strcmp(answer,'Yes') 345 448 delete(mirror); 346 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 449 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 347 450 end 348 451 end 349 452 end 350 453 else% create mirror to the data series if needed 351 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 454 system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder 352 455 end 353 456 if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries … … 367 470 % --- Executes on button press in CampaignDoc. 368 471 function CampaignDoc_Callback(hObject, eventdata, handles) 369 %------------------------------------------------------------------------ 472 %------------------------------------------------------------------------ 370 473 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'); 371 474 if ~isequal(answer{1},'OK') … … 397 500 ExpName=List.Experiment{iexp}.name; 398 501 t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); 399 502 400 503 if isfield(List.Experiment{iexp},'Device') 401 504 for idevice=1:length(List.Experiment{iexp}.Device) 402 505 [t,uid_device]=add(t,uid_exp,'element','Device'); 403 506 DeviceName=List.Experiment{iexp}.Device{idevice}.name; 404 t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); 507 t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); 405 508 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 406 509 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) … … 413 516 [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); 414 517 t = attributes(t,'add',uid_xml,'source','file'); 415 [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); 518 [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); 416 519 end 417 520 end 418 521 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 419 522 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 420 523 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; … … 447 550 448 551 449 % ------------------------------------------------------------------------450 % --- Executes on button press in OK.451 % ------------------------------------------------------------------------452 function OK_Callback(hObject, eventdata, handles)453 454 if strcmp(get(handles.MirrorDir,'Visible'),'on')455 Campaign=get(handles.MirrorDir,'String');456 else457 Campaign=get(handles.SourceDir,'String');458 end459 handles.output=[];460 handles.output.Campaign=Campaign;461 Experiment=get(handles.ListExperiments,'String');462 IndicesExp=get(handles.ListExperiments,'Value');463 if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected464 Experiment=Experiment(IndicesExp);% use the selection of the list of experiments465 end466 Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir467 Device=get(handles.DataSeries,'String');468 Value=get(handles.DataSeries,'Value');469 Device=Device(Value);470 Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir471 Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link472 handles.output.Experiment=Experiment;473 handles.output.DataSeries=Device;474 guidata(hObject, handles);% Update handles structure475 uiresume(handles.browse_data);476 drawnow552 % %------------------------------------------------------------------------ 553 % % --- Executes on button press in OK. 554 % %------------------------------------------------------------------------ 555 % function OK_Callback(hObject, eventdata, handles) 556 % 557 % if strcmp(get(handles.MirrorDir,'Visible'),'on') 558 % Campaign=get(handles.MirrorDir,'String'); 559 % else 560 % Campaign=get(handles.SourceDir,'String'); 561 % end 562 % handles.output=[]; 563 % handles.output.Campaign=Campaign; 564 % Experiment=get(handles.ListExperiments,'String'); 565 % IndicesExp=get(handles.ListExperiments,'Value'); 566 % if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected 567 % Experiment=Experiment(IndicesExp);% use the selection of the list of experiments 568 % end 569 % Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir 570 % Device=get(handles.DataSeries,'String'); 571 % Value=get(handles.DataSeries,'Value'); 572 % Device=Device(Value); 573 % Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir 574 % Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link 575 % handles.output.Experiment=Experiment; 576 % handles.output.DataSeries=Device; 577 % guidata(hObject, handles);% Update handles structure 578 % uiresume(handles.browse_data); 579 % drawnow 477 580 478 581 %------------------------------------------------------------------------ … … 491 594 %------------------------------------------------------------------------ 492 595 function closefcn(gcbo, eventdata) 493 % if isequal(get(handles.browse_data, 'waitstatus'), 'waiting') 494 % % The GUI is still in UIWAIT, us UIRESUME 495 % handles.output = get(hObject,'String'); 496 % guidata(hObject, handles); % Update handles structure 497 % uiresume(handles.browse_data); 498 % else 499 % % The GUI is no longer waiting, just close it 500 % delete(handles.browse_data); 501 % end 596 502 597 hseries=findobj(allchild(0),'Tag','series'); 503 598 if ~isempty(hseries) … … 511 606 end 512 607 513 % ------------------------------------------------------------------------514 % --- Executes on key press over figure1 with no controls selected.515 % ------------------------------------------------------------------------516 function browse_data_KeyPressFcn(hObject, eventdata, handles)608 % %------------------------------------------------------------------------ 609 % % --- Executes on key press over figure1 with no controls selected. 610 % %------------------------------------------------------------------------ 611 % function browse_data_KeyPressFcn(hObject, eventdata, handles) 517 612 518 % Check for "enter" or "escape"519 if isequal(get(hObject,'CurrentKey'),'escape')520 % User said no by hitting escape521 handles.output = 'Cancel';522 523 % Update handles structure524 guidata(hObject, handles);525 526 uiresume(handles.browse_data);527 end528 if isequal(get(hObject,'CurrentKey'),'return')529 uiresume(handles.browse_data);530 end613 % % Check for "enter" or "escape" 614 % if isequal(get(hObject,'CurrentKey'),'escape') 615 % % User said no by hitting escape 616 % handles.output = 'Cancel'; 617 % 618 % % Update handles structure 619 % guidata(hObject, handles); 620 % 621 % uiresume(handles.browse_data); 622 % end 623 % if isequal(get(hObject,'CurrentKey'),'return') 624 % uiresume(handles.browse_data); 625 % end 531 626 532 627 533 628 % --- Executes on button press in Up. 534 function Up_Callback(hObject, eventdata, handles)535 SourceDir=get(handles.SourceDir,'String');536 browse_data(SourceDir)537 538 539 % --- Executes on button press in Down.540 629 function Down_Callback(hObject, eventdata, handles) 541 630 SourceDir=get(handles.SourceDir,'String'); 542 631 ListExperiments=get(handles.ListExperiments,'String'); 543 632 list_val=get(handles.ListExperiments,'Value'); 544 SourceFolder=regexprep(ListExperiments{list_val(1)},'+',''); 545 set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder)) 633 if ischar(ListExperiments) 634 Exp=ListExperiments; 635 else 636 Exp=ListExperiments{list_val(1)}; 637 end 638 Exp=regexprep(Exp,'^\+/',''); 639 SourceDirNew=fullfile(SourceDir,Exp); 640 set(handles.SourceDir,'String',SourceDirNew);% New SourceDir 641 ListDevices=get(handles.ListDevices,'String'); 642 DeviceIndices=get(handles.ListDevices,'Value'); 643 set(handles.ListExperiments,'String',ListDevices);%replace Experiments by Devices 644 set(handles.ListExperiments,'Value',DeviceIndices);%replace Experiments by Devices 546 645 DataSeries=get(handles.DataSeries,'String'); 547 ValueDevice=get(handles.DataSeries,'Value'); 548 set(handles.ListExperiments,'String',DataSeries) 549 set(handles.ListExperiments,'Value',ValueDevice) 550 ListExperiments_Callback(hObject, [], handles) 551 552 553 % --- Executes on selection change in DataSeries. 554 function DataSeries_Callback(hObject, eventdata, handles) 555 556 557 % --- Executes on button press in CheckDevices. 558 function CheckDevices_Callback(hObject, eventdata, handles) 559 if get(handles.CheckDevices,'Value') 560 set(handles.ListDevices,'Visible','on') 561 ListDevices=get(handles.DataSeries,'String'); 562 Index=get(handles.DataSeries,'Value'); 563 set(handles.ListDevices,'String',ListDevices) 564 set(handles.ListDevices,'Value',Index) 565 set(handles.DataSeries,'Value',1) 566 if strcmp(get(handles.MirrorDir,'Visible'),'on') 567 MirrorPath=get(handles.MirrorDir,'String'); 568 else 569 MirrorPath=get(handles.SourceDir,'String'); 570 end 571 IndexExperiment=get(handles.ListExperiments,'Value'); 572 ListExperiment=get(handles.ListExperiments,'String'); 573 Experiment=ListExperiment{get(handles.ListExperiments,'Value')}; 574 Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir 575 Experiment=regexprep(Experiment,'^~','');% remove the ~ used to mark symbolic link 576 Device=regexprep(ListDevices{Index},'^\+/','');% remove the +/ used to mark dir 577 Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link 578 DataSeries=dir(fullfile(MirrorPath,Experiment,Device)); 579 DataSeriesCell=struct2cell(DataSeries); 580 set(handles.DataSeries,'String',DataSeriesCell(1,:)') 581 else 582 ListDevices=get(handles.ListDevices,'String'); 583 Index=get(handles.ListDevices,'Value'); 584 set(handles.ListDevices,'Visible','off') 585 set(handles.DataSeries,'String',ListDevices) 586 set(handles.DataSeries,'Value',Index) 587 end 646 list_val=get(handles.DataSeries,'Value'); 647 set(handles.ListDevices,'String',DataSeries);%replace Devices by DataSeries 648 set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries 649 650 [ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[]); 651 set(handles.DataSeries,'String',ListFiles) 652 set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input 653 654 655 % --- Executes on button press in Down. 656 function Up_Callback(hObject, eventdata, handles) 657 SourceDir=get(handles.SourceDir,'String'); 658 [SourceDir,Exp]=fileparts(SourceDir); 659 set(handles.SourceDir,'String',SourceDir) 660 661 % set(handles.ListExperiments,'Value',indices) 662 %[ListFiles,indices]=list_dir_1(SourceDir,Exp); 663 % set(handles.ListExperiments,'String',ListFiles) 664 % set(handles.ListExperiments,'Value',indices) 665 ListDevices=get(handles.ListDevices,'String'); 666 DeviceIndices=get(handles.ListDevices,'Value'); 667 set(handles.DataSeries,'String',ListDevices); 668 set(handles.DataSeries,'Value',DeviceIndices); 669 670 ListExperiments=get(handles.ListExperiments,'String'); 671 ExpIndices=get(handles.ListExperiments,'Value'); 672 set(handles.ListDevices,'String',ListExperiments); 673 set(handles.ListDevices,'Value',ExpIndices); 674 675 set(handles.ListExperiments,'String',{['+/' Exp]}) 676 set(handles.ListExperiments,'Value',1) 677 678 % ListExperiments=get(handles.ListExperiments,'String'); 679 % list_val=get(handles.ListExperiments,'Value'); 680 % SourceFolder=regexprep(ListExperiments{list_val(1)},'+',''); 681 % set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder)) 682 % DataSeries=get(handles.DataSeries,'String'); 683 % ValueDevice=get(handles.DataSeries,'Value'); 684 % set(handles.ListExperiments,'String',DataSeries) 685 % set(handles.ListExperiments,'Value',ValueDevice) 686 % ListExperiments_Callback(hObject, [], handles) 687 688 689 % % --- Executes on selection change in DataSeries. 690 % function DataSeries_Callback(hObject, eventdata, handles) 691 % SourceDir=get(handles.SourceDir,'String'); 692 % ListData=get(handles.DataSeries,'String'); 693 % Folder=ListData{get(handles.DataSeries,'Value')}; 694 % if ~isempty(regexp(Folder,'^\+/'))% if a folder is selected 695 % Folder=regexprep(Folder,'\+/',''); 696 % ListExperiments=get(handles.ListExperiments,'String'); 697 % list_val=get(handles.ListExperiments,'Value'); 698 % for iexp=1:numel(list_val) 699 % ExpName=regexprep(ListExperiments{list_val(iexp)},'\+/',''); 700 % FullName=fullfile(SourceDir,ExpName,Folder); 701 % dd=dir(FullName); 702 % check_sub=1; 703 % for idir=1:numel(dd) 704 % ListData{ilist}=dd(ilist).name; 705 % if dd(ilist).isdir && ~strcmp(dd(ilist).name,'.')&& ~strcmp(dd(ilist).name,'..')&& isempty(regexp(dd(ilist).name,'^_LOG'))... 706 % && isempty(regexp(dd(ilist).name,'^_LOG'))&& isempty(regexp(dd(ilist).name,'^_XML')) 707 % check_sub=1; 708 % ListData{ilist}=['+/' dd(ilist).name]; 709 % end 710 % end 711 % if check_sub 712 % set(handles.ListDevices,'String',ListData); 713 % set(handles.ListDevices,'Visible','on'); 714 % set(handles.DataSeries,'String',ListData) 715 % break 716 % end 717 % end 718 % end 719 720 % % --- Executes on button press in CheckDevices. 721 % function CheckDevices_Callback(hObject, eventdata, handles) 722 % if get(handles.CheckDevices,'Value') 723 % set(handles.ListDevices,'Visible','on') 724 % ListDevices=get(handles.DataSeries,'String'); 725 % Index=get(handles.DataSeries,'Value'); 726 % set(handles.ListDevices,'String',ListDevices) 727 % set(handles.ListDevices,'Value',Index) 728 % set(handles.DataSeries,'Value',1) 729 % if strcmp(get(handles.MirrorDir,'Visible'),'on') 730 % MirrorPath=get(handles.MirrorDir,'String'); 731 % else 732 % MirrorPath=get(handles.SourceDir,'String'); 733 % end 734 % IndexExperiment=get(handles.ListExperiments,'Value'); 735 % ListExperiment=get(handles.ListExperiments,'String'); 736 % Experiment=ListExperiment{get(handles.ListExperiments,'Value')}; 737 % Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir 738 % Experiment=regexprep(Experiment,'^~','');% remove the ~ used to mark symbolic link 739 % Device=regexprep(ListDevices{Index},'^\+/','');% remove the +/ used to mark dir 740 % Device=regexprep(Device,'^~','');% remove the ~ used to mark symbolic link 741 % DataSeries=dir(fullfile(MirrorPath,Experiment,Device)); 742 % DataSeriesCell=struct2cell(DataSeries); 743 % set(handles.DataSeries,'String',DataSeriesCell(1,:)') 744 % else 745 % ListDevices=get(handles.ListDevices,'String'); 746 % Index=get(handles.ListDevices,'Value'); 747 % set(handles.ListDevices,'Visible','off') 748 % set(handles.DataSeries,'String',ListDevices) 749 % set(handles.DataSeries,'Value',Index) 750 % end
Note: See TracChangeset
for help on using the changeset viewer.