- Timestamp:
- Jul 9, 2019, 10:10:18 AM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 11 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 -
trunk/src/geometry_calib.m
r1063 r1068 273 273 hbrowse=findobj(allchild(0),'Tag','browse_data'); 274 274 if ~isempty(hbrowse)% look for the GUI 'replicate' 275 BrowseHandles=guidata(hbrowse); 276 SourceDir=get(BrowseHandles.SourceDir,'String'); 277 ListExperiments=get(BrowseHandles.ListExperiments,'String'); 278 ListValues=get(BrowseHandles.ListExperiments,'Value'); 279 ListExperiments=ListExperiments(ListValues); 280 DataSeries=get(BrowseHandles.DataSeries,'String'); 281 Val=get(BrowseHandles.DataSeries,'Value'); 282 DataFolder=DataSeries{Val}; 283 for ilist=1:numel(ListExperiments) 284 SubDirBase=regexprep(DataFolder,'+/',''); 285 ListExperiments{ilist}=regexprep(ListExperiments{ilist},'+/',''); 286 XmlName=fullfile(SourceDir,ListExperiments{ilist},[SubDirBase '.xml']); 275 BrowseData=guidata(hbrowse); 276 SourceDir=get(BrowseData.SourceDir,'String'); 277 ListExp=get(BrowseData.ListExperiments,'String'); 278 ExpIndices=get(BrowseData.ListExperiments,'Value'); 279 ListExp=ListExp(ExpIndices); 280 ListDevices=get(BrowseData.ListDevices,'String'); 281 DeviceIndices=get(BrowseData.ListDevices,'Value'); 282 ListDevices=ListDevices(DeviceIndices); 283 ListDataSeries=get(BrowseData.DataSeries,'String'); 284 DataSeriesIndices=get(BrowseData.DataSeries,'Value'); 285 ListDataSeries=ListDataSeries(DataSeriesIndices); 286 NbExp=0; % counter of the number of experiments set by the GUI browse_data 287 for iexp=1:numel(ListExp) 288 if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder 289 for idevice=1:numel(ListDevices) 290 if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder 291 for isubdir=1:numel(ListDataSeries) 292 if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder 293 lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),... 294 regexprep(ListDevices{idevice},'^\+/','')); 295 ldir= regexprep(ListDataSeries{isubdir},'^\+/',''); 296 if exist(fullfile(lpath,ldir),'dir') 297 NbExp=NbExp+1; 298 ListPath{NbExp}=lpath; 299 ListSubdir{NbExp}=ldir; 300 ExpIndex{NbExp}=iexp; 301 end 302 end 303 end 304 end 305 end 306 end 307 end 308 for iexp=1:NbExp 309 XmlName=fullfile(ListPath{iexp},[ListSubdir{iexp} '.xml']); 310 if exist(XmlName,'file') 311 check_update=1; 312 else 313 check_update=0; 314 end 287 315 errormsg=update_imadoc(GeometryCalib,XmlName,'GeometryCalib');% introduce the calibration data in the xml file 288 316 if ~strcmp(errormsg,'') 289 317 msgbox_uvmat('ERROR',errormsg); 290 318 else 291 display([XmlName ' updated with calibration parameters']) 319 if check_update 320 display([XmlName ' updated with calibration parameters']) 321 else 322 display([XmlName ' created with calibration parameters']) 323 end 292 324 nbcalib=nbcalib+1; 293 325 end 294 326 end 295 327 end 296 msgbox_uvmat('CONFIMATION',[ SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']);328 msgbox_uvmat('CONFIMATION',['calibration replicated for ' num2str(NbExp) ' experiments']); 297 329 else 298 330 %% copy the xml file from the old location if appropriate, then update with the calibration parameters -
trunk/src/plot_field.m
r1061 r1068 1408 1408 yi=rangy(1):dxy(1):rangy(2); 1409 1409 A=griddata(vec_X,vec_Y,vec_A,xi,yi'); 1410 A=reshape(A,length(yi),length(xi)); 1410 A=reshape(A,length(yi),length(xi));total 1411 1411 else 1412 1412 x=vec_X(1:index(1));% the set of abscissa (obtained on the first line) -
trunk/src/series.m
r1067 r1068 1594 1594 end 1595 1595 1596 %% Look for prcessing on multiple experiments set by the GUI browse_data 1597 NbExp=1; 1598 ListExp=Param.InputTable(1,1); 1599 1596 %% Look for processing on multiple experiments set by the GUI browse_data 1597 NbExp=1;% initiate the number of experiments set by the GUI browse_data, =1 otherwise 1600 1598 if get(handles.Replicate,'Value') 1599 set(handles.Replicate,'BackgroundColor',[1 1 0])%paint Relicate button in yellow 1601 1600 hh=findobj(allchild(0),'Tag','browse_data'); 1602 1601 BrowseData=guidata(hh); 1603 1602 SourceDir=get(BrowseData.SourceDir,'String'); 1604 1603 ListExp=get(BrowseData.ListExperiments,'String'); 1605 ListExp=ListExp(get(BrowseData.ListExperiments,'Value')); 1606 NbExp=numel(ListExp) % number of experiments set possibly by the GUI browse_data, =1 otherwise 1607 for ilist=1:NbExp 1608 ListExp{ilist}=regexprep(ListExp{ilist},'+',''); 1609 ListExp{ilist}= [SourceDir ListExp{ilist}]; 1610 end 1611 end 1612 1604 ExpIndices=get(BrowseData.ListExperiments,'Value'); 1605 ListExp=ListExp(ExpIndices); 1606 ListDevices=get(BrowseData.ListDevices,'String'); 1607 DeviceIndices=get(BrowseData.ListDevices,'Value'); 1608 ListDevices=ListDevices(DeviceIndices); 1609 ListDataSeries=get(BrowseData.DataSeries,'String'); 1610 DataSeriesIndices=get(BrowseData.DataSeries,'Value'); 1611 ListDataSeries=ListDataSeries(DataSeriesIndices); 1612 NbExp=0; % counter of the number of experiments set by the GUI browse_data 1613 for iexp=1:numel(ListExp) 1614 if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder 1615 for idevice=1:numel(ListDevices) 1616 if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder 1617 for isubdir=1:numel(ListDataSeries) 1618 if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder 1619 lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),... 1620 regexprep(ListDevices{idevice},'^\+/','')); 1621 ldir= regexprep(ListDataSeries{isubdir},'^\+/',''); 1622 if exist(fullfile(lpath,ldir),'dir') 1623 NbExp=NbExp+1; 1624 ListPath{NbExp}=lpath; 1625 ListSubdir{NbExp}=ldir; 1626 ExpIndex{NbExp}=iexp; 1627 end 1628 end 1629 end 1630 end 1631 end 1632 end 1633 end 1634 answer=msgbox_uvmat('INPUT_Y-N-Cancel',['replicate the processing on ' num2str(NbExp) ' data series']); 1635 if strcmp(answer,'Cancel')||strcmp(answer,'No') 1636 return 1637 end 1638 end 1639 % set(handles.OutputSubDir,'String',SubDir) 1640 % Param.OutputSubDir=SubDir; 1613 1641 %%%%%%%%%%%%%%%%%%% LOOP ON EXPERIMENTS POSSIBLY SET BY THE GUI browse_data, NbExp=1 otherwise %%%%%%%%% 1614 1642 for iexp=1:NbExp 1615 Param.InputTable{1,1}=ListExp{iexp}; 1616 set(handles.InputTable,'Data',Param.InputTable) 1617 [xx,ExpName]=fileparts(ListExp{iexp}); 1643 if get(handles.Replicate,'Value') 1644 if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action 1645 disp('program stopped by user') 1646 return 1647 end 1648 set(BrowseData.ListExperiments,'Value',ExpIndex{iexp}) 1649 Param.InputTable{1,1}=ListPath{iexp}; 1650 Param.InputTable{1,2}=ListSubdir{iexp}; 1651 Param.OutputSubDir=ListSubdir{iexp}; 1652 set(handles.InputTable,'Data',Param.InputTable) 1653 % set(handles.OutputSubDir,'String',ListSubdir{iexp}) 1654 end 1655 [xx,ExpName]=fileparts(Param.InputTable{1,1}); 1618 1656 Param.IndexRange.first_i=str2num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess 1619 1657 Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String')); … … 1621 1659 OutputDir=''; 1622 1660 answer=''; 1623 if isfield(Param,'OutputSubDir') 1661 if isfield(Param,'OutputSubDir')% possibly update the output dir if it already exists 1624 1662 SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt]; 1625 1663 SubDirOutNew=SubDirOut; … … 1659 1697 Param.OutputRootFile=Param.InputTable{1,3}; % the first sorted RootFile taken for output 1660 1698 set(handles.OutputDirExt,'String',Param.OutputDirExt) 1661 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]) ;% full name (with path) of output directory1699 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]) % full name (with path) of output directory 1662 1700 if check_create % create output directory if it does not exist 1663 1701 [tild,msg1]=mkdir(OutputDir); … … 1677 1715 errormsg=['cannot create ' DirXml ': ' msg1]; % error message for directory creation 1678 1716 return 1717 end 1718 [success,msg] = fileattrib(DirXml,'+w','g','s'); % allow writing access for the group of users, recursively in the folder 1719 if success==0 1720 msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg}); % error message for directory creation 1679 1721 end 1680 1722 end … … 1861 1903 return 1862 1904 end 1905 [success,msg] = fileattrib(DirExe,'+w','g','s'); % allow writing access for the group of users, recursively in the folder 1906 if success==0 1907 msgbox_uvmat('WARNING',{['unable to set group write access to ' DirExe ':']; msg}); % error message for directory creation 1908 end 1863 1909 end 1864 1910 %create subdirectory for log files … … 1869 1915 errormsg=['cannot create ' DirLog ': ' msg1]; % error message for directory creation 1870 1916 return 1917 end 1918 [success,msg] = fileattrib(DirLog,'+w','g','s'); % allow writing access for the group of users, recursively in the folder 1919 if success==0 1920 msgbox_uvmat('WARNING',{['unable to set group write access to ' DirLog ':']; msg}); % error message for directory creation 1871 1921 end 1872 1922 end … … 2024 2074 fclose(fid); 2025 2075 if status==0 2026 msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched for ' ExpName ' as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])2076 msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched for ' ExpName ' as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results']) 2027 2077 else 2028 msgbox_uvmat('ERROR',result)2078 msgbox_uvmat('ERROR',result) 2029 2079 end 2030 2080 % case 'cluster_pbs' % for LMFA Kepler machine: trqnsferred to fct … … 2144 2194 end 2145 2195 end 2196 set(handles.Replicate,'BackgroundColor',[0 1 0]) 2197 if NbExp>1 2198 set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta (input file features need to be updated) 2199 end 2146 2200 %------------------------------------------------------------------------ 2147 2201 function STOP_Callback(hObject, eventdata, handles) … … 2160 2214 Param=read_GUI(handles.series); 2161 2215 2162 %% clean the output structure by removing unused information 2216 %% clean the output structure by removing unused information 2163 2217 if isfield(Param,'Pairs') 2164 2218 Param=rmfield(Param,'Pairs'); % info Pairs not needed for output … … 2203 2257 ActionList=get(handles.ActionName,'String'); % list menu fields 2204 2258 ActionIndex=get(handles.ActionName,'Value'); 2205 if ~isequal(ActionIndex,1)% if we are not just opening series 2259 if ~isequal(ActionIndex,1)% if we are not just opening series 2206 2260 InputTable=get(handles.InputTable,'Data'); 2207 2261 if isempty(InputTable{1,4}) … … 2301 2355 2302 2356 set(handles.ActionInput,'BackgroundColor',[1 1 0]) 2357 SeriesData=get(handles.series,'UserData'); % info on the input file series 2303 2358 2304 2359 %% create the function handle for Action … … 2308 2363 if ~exist(ActionPath,'dir') 2309 2364 ActionName_Callback(handles.ActionName, ActionPath, handles)% update the function 2310 % msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);2311 2365 return 2312 2366 end … … 2319 2373 Param=read_GUI_series(handles); % read the parameters from the GUI series 2320 2374 Param.Action.RUN=0; 2375 Param.SeriesData=SeriesData; 2321 2376 ParamOut=h_fun(Param); % run the selected Action function to get the relevant input 2322 2377 … … 2337 2392 2338 2393 %% Detect the types of input files and set menus and default options in 'VelType' 2339 SeriesData=get(handles.series,'UserData'); % info on the input file series2340 2394 iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); 2341 2395 iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); % all nc files, icluding civ … … 2469 2523 set(handles.MinIndex_j,'Data',MinIndex_j(iview,:)); 2470 2524 set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:)); 2471 set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:)); 2525 set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));; 2472 2526 TimeTable=get(handles.TimeTable,'Data'); 2473 set(handles.TimeTable,'Data',TimeTable(iview,:)); 2527 if size(TimeTable,1)<size(Param.InputTable,1)%if the time table is not complete, copy the missing lines from the previous ones 2528 for iline=size(TimeTable,1)+1:size(Param.InputTable,1) 2529 TimeTable(iline,:)=TimeTable(iline-1,:); 2530 end 2531 end 2532 set(handles.TimeTable,'Data',TimeTable(iview,:));% sort the time tables 2474 2533 PairString=get(handles.PairString,'Data'); 2475 2534 set(handles.PairString,'Data',PairString(iview,:)); -
trunk/src/series/civ_series.m
r1065 r1068 89 89 end 90 90 % estimated CPUTime 91 Data.CPUTime=1; % 1 minute per field pair 91 CPUtime_unit=0.01;%estimated time for a multiplication (in microsecond) 92 if isfield(Param.SeriesData,'FileInfo')&&isfield(Param.SeriesData.FileInfo{1},'Height')&&isfield(Param.SeriesData.FileInfo{1},'Width') 93 pixnbre=Param.SeriesData.FileInfo{1}.Height*Param.SeriesData.FileInfo{1}.Width; % total number of pxels for input images 94 CPUtime=0; 95 if isfield(Data.ActionInput,'Civ1') 96 %BoxSize=Data.ActionInput.Civ1.CorrBoxSize(1)*Data.ActionInput.Civ1.CorrBoxSize(2); 97 tic 98 testboxa=rand(Data.ActionInput.Civ1.CorrBoxSize(1),Data.ActionInput.Civ1.CorrBoxSize(2)); 99 testboxb=rand(Data.ActionInput.Civ1.SearchBoxSize(1),Data.ActionInput.Civ1.SearchBoxSize(2)); 100 anss=conv2(testboxa,testboxb); 101 CPUtime_unit=toc; 102 nb_box=pixnbre/(Data.ActionInput.Civ1.Dx*Data.ActionInput.Civ1.Dy); 103 %nbpos=Data.ActionInput.Civ1.SearchBoxSize-Data.ActionInput.Civ1.CorrBoxSize; 104 CPUtime=2*CPUtime_unit*nb_box%*BoxSize*nbpos(1)*nbpos(2);% adjustement factor 2 used 105 end 106 if isfield(Data.ActionInput,'Patch1') 107 CPUtime=2*CPUtime; 108 end 109 if isfield(Data.ActionInput,'Civ2') 110 tic 111 testboxa=rand(Data.ActionInput.Civ2.CorrBoxSize(1),Data.ActionInput.Civ2.CorrBoxSize(2)); 112 testboxb=rand(Data.ActionInput.Civ2.SearchBoxSize(1),Data.ActionInput.Civ2.SearchBoxSize(2)); 113 anss=conv2(testboxa,testboxb); 114 CPUtime_unit=toc; 115 nb_box=pixnbre/(Data.ActionInput.Civ2.Dx*Data.ActionInput.Civ2.Dy); 116 %BoxSize=Data.ActionInput.Civ2.CorrBoxSize(1)*Data.ActionInput.Civ2.CorrBoxSize(2); 117 %nbpos=Data.ActionInput.Civ2.SearchBoxSize-Data.ActionInput.Civ2.CorrBoxSize; 118 CPUtime=CPUtime+2*CPUtime_unit*nb_box;%*BoxSize*nbpos(1)*nbpos(2); 119 end 120 if isfield(Data.ActionInput,'Patch2') 121 CPUtime=(4/3)*CPUtime; 122 end 123 Data.CPUTime=ceil(CPUtime/6); % estimated CPU time per field pair in minute 124 Data.CPUTime=Data.CPUTime/10; % displqy CPU time with 1 digit beyond dot 125 end 92 126 return 93 127 end -
trunk/src/series/extract_multitif.m
r1061 r1068 73 73 ParamOut.OutputDirExt='.png';%set the output dir extension 74 74 ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice 75 ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1) 75 ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1) 76 ParamOut.CPUTime=7;% expected time for writting one image ( in minute) 76 77 %% root input file(s) and type 77 78 % check the existence of the first file in the series … … 113 114 end 114 115 115 %% list of input images116 % DirImages=fullfile(Param.InputTable{1,1},Param.InputTable{1,2});117 % ListStruct=dir(DirImages);118 % ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray119 % check_bad=strcmp('.',ListCells(1,:))|strcmp('..',ListCells(1,:));%detect the dir '.' to exclude it120 % check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files121 % ListFile=ListCells(1,find(~check_dir & ~check_bad));122 123 %% check file names124 % RootName=regexprep(ListFile{1},'.tif$','')125 % rank(1)=1;126 % for ilist=2:numel(ListFile)127 % rank_str=regexprep(ListFile{ilist},'.tif$','');128 % rank(ilist)=regexprep(rank_str,['^' RootName '@'],'');129 % % if ~isequal(str2num(rank),ilist-1)130 % % disp(['error in the list of input file # ' num2str(ilist-1)])131 % % return132 % % end133 % end134 135 116 %% output directory 136 117 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]); … … 156 137 end 157 138 158 %% Main loop159 160 161 % count=0;162 %count=316;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP08: 4684 images -> start at 316 start 67->_11_1163 %count=1934%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP07: 3066 images164 139 %% loop on the files 165 140 % include the first tiff file with no index in the first iteration … … 174 149 end 175 150 for ifile=firstindex:Param.IndexRange.last_i 151 tic 176 152 if firstindex==0 && ifile==0% first slice of processing 177 153 ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},'im.tif') … … 181 157 NbFrames=numel(imfinfo(ImageName)); 182 158 for iframe=1:NbFrames 183 iframe184 159 if isequal(ImagesPerLevel,1)% mode series 185 160 OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']); … … 198 173 count=count+1; 199 174 end 175 tt=toc; 176 disp(['elapsed time (in min.) for the file im@' num2str(ifile,'%04d')]) 177 disp(num2str(tt/60)) 200 178 end 201 179 -
trunk/src/series/extract_rdvision.m
r1066 r1068 489 489 490 490 %% correct NbDtj and NbDti (error from RDvision) 491 if NbDtj==numel(Dtj)% case of bursts492 NbDtj=1;493 uid_motor_nbslice=find(t,'ImaDoc/TranslationMotor/Nbslice');494 if ~isempty(uid_motor_nbslice)&& ~isempty(uid_Dtk)% case of multilevel495 NbSlice=str2num(get(t,get(t,uid_motor_nbslice,'contents'),'value'));496 NbDti=NbSlice-1;497 end498 end491 % if NbDtj==numel(Dtj)% case of bursts 492 % NbDtj=1; 493 % uid_motor_nbslice=find(t,'ImaDoc/TranslationMotor/Nbslice'); 494 % if ~isempty(uid_motor_nbslice)&& ~isempty(uid_Dtk)% case of multilevel 495 % NbSlice=str2num(get(t,get(t,uid_motor_nbslice,'contents'),'value')); 496 % NbDti=NbSlice-1; 497 % end 498 % end 499 499 500 500 if isempty(Dtj)% case of simple series … … 509 509 nbfield2=NbDtj*numel(Dtj)+1; 510 510 NbFrames_xml=nbfield1*nbfield2; 511 if NbFrames_xml<numel(timestamp)512 disp(['ERROR: size from xml ' num2str(NbFrame_xml) ' smaller than timestamp size ' num2str(numel(timestamp))])513 return514 end515 if NbFrames_xml>numel(timestamp)516 nbfield1=floor(numel(timestamp)/nbfield2);517 nbfieldk=floor(nbfield1/nbfieldi);518 nbfield1=nbfieldi*nbfieldk;519 NbDtk=nbfieldk-1;520 t=set(t,uid_content_NbDtk,'value',num2str(NbDtk));% correct NbDtk in the xml file (in practice numel(Dtk)=1;521 timestamp=timestamp(1:nbfield1*nbfield2);522 disp(['image record stopped before end: max index i= ' num2str(nbfield1)]);523 timestamp=reshape(timestamp,nbfield2,nbfield1);524 end525 % check Dtj with respect to timestamp526 timestamp=(reshape(timestamp,nbfield2,[]))';527 diff_Dtj=diff(timestamp(1,:))-Dtj;528 if max(abs(diff_Dtj))>min(Dtj)/1000529 disp(['Dtj from xml file differs from time stamp by ' num2str(max(abs(diff_Dtj))) ', '])%'530 else531 disp('Dtj OK');532 end511 % if NbFrames_xml<numel(timestamp) 512 % disp(['ERROR: size from xml ' num2str(NbFrame_xml) ' smaller than timestamp size ' num2str(numel(timestamp))]) 513 % return 514 % end 515 % if NbFrames_xml>numel(timestamp) 516 % nbfield1=floor(numel(timestamp)/nbfield2); 517 % nbfieldk=floor(nbfield1/nbfieldi); 518 % nbfield1=nbfieldi*nbfieldk; 519 % NbDtk=nbfieldk-1; 520 % t=set(t,uid_content_NbDtk,'value',num2str(NbDtk));% correct NbDtk in the xml file (in practice numel(Dtk)=1; 521 % timestamp=timestamp(1:nbfield1*nbfield2); 522 % disp(['image record stopped before end: max index i= ' num2str(nbfield1)]); 523 % timestamp=reshape(timestamp,nbfield2,nbfield1); 524 % end 525 % % check Dtj with respect to timestamp 526 % timestamp=(reshape(timestamp,nbfield2,[]))'; 527 % diff_Dtj=diff(timestamp(1,:))-Dtj; 528 % if max(abs(diff_Dtj))>min(Dtj)/1000 529 % disp(['Dtj from xml file differs from time stamp by ' num2str(max(abs(diff_Dtj))) ', '])%' 530 % else 531 % disp('Dtj OK'); 532 % end 533 533 end 534 534 535 535 %% adjust Dti 536 if NbDti+1>size(timestamp,1)537 NbDti=size(timestamp,1)-1;538 end539 Dti_stamp=(timestamp(1+NbDti,1)-timestamp(1,1))/NbDti;540 Dti_stamp=(timestamp(1+NbDti,1)-timestamp(2,1))/(NbDti-1);541 t=set(t,uid_content_Dti,'value',num2str(Dti_stamp));%corret Dti542 if abs(Dti_stamp-Dti)>Dti/1000543 disp([msg 'Dti from xml file corrected by ' num2str(Dti_stamp-Dti) ', ']);%'544 else545 disp('Dti OK')546 end536 % if NbDti+1>size(timestamp,1) 537 % NbDti=size(timestamp,1)-1; 538 % end 539 % Dti_stamp=(timestamp(1+NbDti,1)-timestamp(1,1))/NbDti; 540 % Dti_stamp=(timestamp(1+NbDti,1)-timestamp(2,1))/(NbDti-1); 541 % t=set(t,uid_content_Dti,'value',num2str(Dti_stamp));%corret Dti 542 % if abs(Dti_stamp-Dti)>Dti/1000 543 % disp([msg 'Dti from xml file corrected by ' num2str(Dti_stamp-Dti) ', ']);%' 544 % else 545 % disp('Dti OK') 546 % end 547 547 548 548 %% adjust Dtk -
trunk/src/series/merge_proj_polar.m
r1061 r1068 63 63 ParamOut.AllowInputSort='on';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 64 64 ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 65 ParamOut.NbSlice='o n'; %nbre of slices ('off' by default)65 ParamOut.NbSlice='off'; %nbre of slices ('off' by default) 66 66 ParamOut.VelType='one';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 67 67 ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) … … 268 268 CheckOverwrite=Param.CheckOverwrite; 269 269 end 270 270 NbField 271 271 for index=1:NbField 272 disp(['index=' num2str(index)])273 disp(['ellapsed time ' num2str(toc(tstart)/60,4) ' minutes'])274 272 update_waitbar(WaitbarHandle,index/NbField) 275 273 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') … … 352 350 %% calculate tps coefficients 353 351 Data{iview}=tps_coeff_field(Data{iview},1); 354 352 'tps_coeff done' 355 353 %% projection on the polar grid 356 354 [DataOut,VarAttribute,errormsg]=calc_field_tps(Data{iview}.Coord_tps,Data{iview}.NbCentre,Data{iview}.SubRange,... 357 355 cat(3,Data{iview}.U_tps,Data{iview}.V_tps),FieldNames,cat(3,XI,YI)); 356 if ~isempty(errormsg) 357 disp(errormsg) 358 end 359 358 360 % set to NaN interpolation points which are too far from any initial data (more than 2 CoordMesh) 359 361 Coord=permute(Data{iview}.Coord_tps,[1 3 2]); … … 366 368 G=TriScatteredInterp(Coord,Coord(:,2),'nearest'); 367 369 end 370 'Interp done' 368 371 Distx=F(XI,YI)-XI;% diff of x coordinates with the nearest measurement point 369 372 Disty=G(XI,YI)-YI;% diff of y coordinates with the nearest measurement point … … 390 393 391 394 %% merge the NbView fields 395 ProjData 392 396 [MergeData,errormsg]=merge_field(ProjData); 393 397 if ~isempty(errormsg) … … 446 450 TimeData.div=MergeData.div; 447 451 448 [error,ncid]=struct2nc(OutputFile,TimeData);%save result file452 error=struct2nc(OutputFile,TimeData);%save result file 449 453 if isempty(error) 450 454 disp(['output file ' OutputFile ' written']) … … 453 457 end 454 458 ellapsed_time=toc(tstart); 455 disp(['total ellapsed time ' num2str(ellapsed_time/60,2) ' minutes']) 456 end 457 458 ellapsed_time=toc(tstart); 459 disp(['total ellapsed time ' num2str(ellapsed_time/60,2) ' minutes']) 459 disp(['ellapsed time since start ' num2str(ellapsed_time/60,2) ' minutes']) 460 end 461 460 462 disp([ num2str(ellapsed_time/(60*NbField),3) ' minutes per iteration']) 461 463 -
trunk/src/uvmat.m
r1065 r1068 254 254 255 255 %% case of an input argument for uvmat 256 testinputfield=0;256 %testinputfield=0; 257 257 inputfile=[]; 258 Field=[];258 %Field=[]; 259 259 if exist('input','var') 260 260 if ishandle(handles.UVMAT_title) … … 790 790 %aviobj=avifile(MovieName,'Compression','None','fps',fps); 791 791 792 aviobj = VideoWriter(MovieName,' UncompressedAVI');792 aviobj = VideoWriter(MovieName,'Motion JPEG AVI'); 793 793 open(aviobj) 794 794 %% get info from uvmat and adjust it … … 812 812 set(htitle,'String',regexprep(Title,'t=\d+.\d*',['t=' time_str])) 813 813 mov=getframe(figure_movie); 814 % aviobj=addframe(aviobj,mov);815 814 writeVideo(aviobj,mov); 816 815 end
Note: See TracChangeset
for help on using the changeset viewer.