- Timestamp:
- Jul 29, 2012, 11:18:31 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/compile_functions.m
r503 r507 1 1 % check 2 if isempty(which('mcc') 2 if isempty(which('mcc')) 3 3 msgbox_uvmat('no Matlab compiler toolbox mcc installed') 4 4 return -
trunk/src/datatree_browser.m
r503 r507 22 22 function varargout = datatree_browser(varargin) 23 23 24 % Last Modified by GUIDE v2.5 2 6-Jul-2012 08:24:2624 % Last Modified by GUIDE v2.5 29-Jul-2012 08:49:20 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before datatree_browser is made visible. 47 function datatree_browser_OpeningFcn(hObject, eventdata, handles, projectxml)47 function datatree_browser_OpeningFcn(hObject, eventdata, handles, InputName) 48 48 %------------------------------------------------------------------------ 49 49 % Choose default command line output for datatree_browser … … 74 74 set(hObject, 'Units', OldUnits); 75 75 76 % % Show a question icon from dialogicons.mat - variables questIconData and questIconMap 77 % load dialogicons.mat 78 % eval(['IconData=' icontype 'IconData;']) 79 % eval(['IconCMap=' icontype 'IconMap;']) 80 % questIconMap(256,:) = get(handles.figure1, 'Color'); 81 % Img=image(IconData, 'Parent', handles.axes1); 82 % set(handles.figure1, 'Colormap', IconCMap); 83 % set(handles.axes1, ... 84 % 'Visible', 'off', ... 85 % 'YDir' , 'reverse' , ... 86 % 'XLim' , get(Img,'XData'), ... 87 % 'YLim' , get(Img,'YData') ... 88 % ); 89 % if exist('GeometryCalib','var') 90 % DataviewData.GeometryCalib=GeometryCalib; 91 % set(hObject,'UserData',DataviewData) 92 % end 93 % if exist('SubCampaignTst','var') && isequal(SubCampaignTst,'y') 94 % set(handles.SubCampaignTest,'Value',1); 95 % end 96 if ~isempty(regexp(projectxml,'.project.xml$')) 97 if exist(regexprep(projectxml,'.project.xml$','.link'),'dir') 98 99 set(handles.LinkDir,'String',regexprep(projectxml,'.project.xml$','.link')) 100 XmlContent=xml2struct(projectxml); 101 set(handles.SourceDir,'String',XmlContent.SourceDir) 102 set(handles.UpdateLink,'String','UpdateLink') 103 % datatree_browser(regexprep(fileinput,'.project.xml$','.link')) 104 105 elseif exist(regexprep(projectxml,'.project.xml$',''),'dir') 106 set(handles.SourceDir,'String',regexprep(projectxml,'.project.xml$','')) 76 if exist('InputName','var') 77 if isdir(InputName)% opening by uvmat/MenuSetProject 78 set(handles.SourceDir,'String',InputName)% the input directory is considered as a project 79 set(handles.LinkDir,'Visible','off') 80 set(handles.UpdateLink,'String','create_link') 81 set(handles.MarkupDir,'Visible','on') 82 83 else% opening by uvmat/Open 84 InputDir=regexprep(InputName,'.xml$',''); 85 if exist(InputDir,'dir') 86 s=xml2struct(InputName); 87 if isfield(s,'SourceDir') 88 set(handles.SourceDir,'String',s.SourceDir) 89 set(handles.LinkDir,'String',InputDir) 90 set(handles.LinkDir,'Visible','on') 91 else 92 set(handles.SourceDir,'String',InputDir) 107 93 set(handles.LinkDir,'Visible','off') 108 set(handles.UpdateLink,'String','CreateLink') 94 set(handles.MarkupDir,'String','CreateLink') 95 end 109 96 end 110 set(handles.OK,'Visible','on') 111 set(handles.Cancel,'Visible','on') 112 set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 113 drawnow 114 uiwait(handles.figure); 115 end 116 % if exist('RootDir','var') 117 % set(handles.SourceDir,'String',RootDir); 118 % % set(handles.clean_civ_cmx,'Visible','off') 119 % set(handles.edit_xml,'Visible','off') 120 % set(handles.HELP,'Visible','off') 121 % set(handles.OK,'Visible','on') 122 % set(handles.Cancel,'Visible','on') 123 % set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 124 % set(hObject,'Visible','on') 125 % drawnow 126 % %RootDirectory_Callback(hObject, eventdata, handles) 127 % % UIWAIT makes translate_points wait for user response (see UIRESUME) 128 % uiwait(handles.figure); 129 % end 97 FillExperiments(handles) 98 set(handles.OK,'Visible','on') 99 drawnow 100 101 end 102 end 103 130 104 131 105 %------------------------------------------------------------------------ … … 135 109 % Get default command line output from handles structure 136 110 varargout{1} = handles.output; 137 %delete(handles.figure) 138 139 %------------------------------------------------------------------------ 140 % --- Executes on button press in UpdateLink. 111 %delete(handles.datatree_browser) 112 113 %------------------------------------------------------------------------ 114 % --- Executes on button press in MarkupDir: create a xml file to mark SourceDir as project source 115 function MarkupDir_Callback(hObject, eventdata, handles) 116 %------------------------------------------------------------------------ 117 SourceDir=get(handles.SourceDir,'String'); 118 t=xmltree; 119 t=set(t,1,'name','Project'); 120 try 121 save(t,[SourceDir '.xml']) 122 catch ME 123 msgbox_uvmat('ERROR',ME.message) 124 end 125 126 %------------------------------------------------------------------------ 127 % --- Executes on button press in UpdateLink: create a link dir or update it if it exists 141 128 function UpdateLink_Callback(hObject, eventdata, handles) 142 129 %------------------------------------------------------------------------ 143 InputString=get(handles.UpdateLink,'String') 144 switch InputString 145 case 'CreateLink' 146 CurrentDir=fileparts(get(handles.SourceDir,'String')); 147 if ~exist(CurrentDir,'dir') 148 CurrentDir=''; 149 end 150 SourceDir=uigetdir(CurrentDir,'pick up the source project directory'); %file browser 151 if isequal(SourceDir,0) 152 return 153 else 154 set(handles.SourceDir,'String',SourceDir) 155 end 156 drawnow 157 [SourcePath,ProjectName]=fileparts(SourceDir); 158 MirrorRoot=uigetdir(CurrentDir,'path to the link directory'); %file browser 159 if isempty(MirrorRoot) 160 return 161 else 162 MirrorDir=fullfile(MirrorRoot,[ProjectName '.link']); 163 end 164 if ~exist(MirrorDir,'dir') 165 mkdir(MirrorDir) 166 end 167 MirrorDoc.SourceDir=SourceDir; 168 t=struct2xml(MirrorDoc); 169 set(t,1,'name','DataTree'); 170 save(t,fullfile(MirrorDir,[ProjectName '.xml'])) 171 set(handles.LinkDir,'String',MirrorDir) 172 173 %update_link(SourceDir,LinkDir) 174 SourceDir_Callback([],[], handles) 175 case 'UpDateLink' 176 % MirrorDir=get(handles.LinkDir,'String'); 177 % menu={'*.xml', ' (*.xml)'; 178 % '*.xml', '.xml files '; ... 179 % '*.*', 'All Files (*.*)'}; 180 % [MirrorXml, PathName] = uigetfile( menu, 'Pick the head xml file in the link directory',MirrorDir); 181 [MirrorXml, PathName]=fileparts(get(handles.LinkDir,'String')); 182 %set(handles.LinkDir,'String',fullfile(PathName,regexprep(MirrorXml,'.xml$','.link'))) 183 LinkDir_Callback(hObject, eventdata, handles) 184 end 185 186 % RootDirectory_Callback(hObject, eventdata, handles) 187 %------------------------------------------------------------------------ 188 % --- Executes on button press in open_SubCampaign. 189 function UpdateMirror_Callback(hObject, eventdata, handles) 190 %------------------------------------------------------------------------ 191 % MirrorDir=get(handles.LinkDir,'String'); 192 % menu={'*.xml', ' (*.xml)'; 193 % '*.xml', '.xml files '; ... 194 % '*.*', 'All Files (*.*)'}; 195 % [MirrorXml, PathName] = uigetfile( menu, 'Pick the head xml file in the link directory',MirrorDir); 196 % set(handles.LinkDir,'String',fullfile(PathName,regexprep(MirrorXml,'.xml$','.link'))) 197 % MirrorDir_Callback(hObject, eventdata, handles) 198 199 200 %------------------------------------------------------------------------ 201 function LinkDir_Callback(hObject, eventdata, handles) 202 %------------------------------------------------------------------------ 203 MirrorDir=get(handles.LinkDir,'String'); 204 [tild,MirrorName]=fileparts(MirrorDir); 205 s=xml2struct(fullfile(MirrorDir,[MirrorName '.xml'])); 206 set(handles.SourceDir,'String',s.SourceDir) 207 SourceDir_Callback([],[], handles) 208 %update_link(s.SourceDir, LinkDir) 209 210 211 % %------------------------------------------------------------------------ 212 % function update_link(SourceDir,LinkDir,handles) 213 % %------------------------------------------------------------------------ 214 % SourceDir_Callback([],[], handles) 215 216 %------------------------------------------------------------------------ 217 function SourceDir_Callback(hObject, eventdata, handles) 218 %------------------------------------------------------------------------ 219 set(handles.SourceDir,'BackgroundColor',[1 1 0]) 220 drawnow 130 [SourcePath,ProjectName]=fileparts(get(handles.SourceDir,'String')); 131 LinkDir=get(handles.LinkDir,'String'); 132 if isempty(LinkDir)||strcmp(get(handles.LinkDir,'Visible'),'off') 133 LinkRoot=uigetdir(LinkDir,'pick up the path to the link directory'); %file browser 134 if isempty(LinkRoot),return,end 135 LinkDir=fullfile(LinkRoot,[ProjectName '.link']); 136 set(handles.LinkDir,'Visible','on') 137 set(handles.LinkDir,'String',LinkDir) 138 end 139 140 if ~exist(LinkDir,'dir') 141 try 142 mkdir(LinkDir) 143 catch ME 144 msgbox_uvmat('ERROR',ME.message) 145 end 146 end 147 LinkDirXml=fullfile(fileparts(LinkDir),[ProjectName '.link.xml']); 148 if ~exist(LinkDirXml,'file') 149 LinkDoc.SourceDir=get(handles.SourceDir,'String'); 150 t=struct2xml(LinkDoc); 151 t=set(t,1,'name','Project'); 152 save(t,LinkDirXml) 153 set(handles.UpdateLink,'String','update_link') 154 end 155 156 FillExperiments(handles) 157 158 %------------------------------------------------------------------------ 159 % --- Fill the column 'Experiments' with the list of detected directries 160 function FillExperiments(handles) 161 %------------------------------------------------------------------------ 221 162 SourceDir=get(handles.SourceDir,'String'); 222 MirrorDir=get(handles.LinkDir,'String'); 223 ExpName={''}; 224 if exist(SourceDir,'dir') 225 hdir=dir(SourceDir); %list files and dirs 226 idir=0; 227 for ilist=1:length(hdir) 228 if hdir(ilist).isdir 229 dirname=hdir(ilist).name; 230 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') 231 idir=idir+1; 232 ExpName{idir}=hdir(ilist).name; 233 link=fullfile(MirrorDir,ExpName{idir}) 163 LinkDir=''; 164 if strcmp(get(handles.LinkDir,'Visible'),'on') 165 LinkDir=get(handles.LinkDir,'String'); 166 end 167 168 hdir=dir(SourceDir); %list files and dirs 169 idir=0; 170 ExpName=cell(length(hdir),1); 171 for ilist=1:length(hdir) 172 if hdir(ilist).isdir 173 dirname=hdir(ilist).name; 174 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')% do not list directories beginning by '0' 175 idir=idir+1; 176 ExpName{idir}=hdir(ilist).name; 177 if ~isempty(LinkDir) 178 link=fullfile(LinkDir,ExpName{idir}); 234 179 if ~exist(link,'dir') 235 mkdir(link) 236 end 237 end 238 % look for the list of 'devices' 239 else 240 %warning for isolated files 241 end 242 end 243 set(handles.ListExperiments,'String',[{'*'};ExpName']) 244 set(handles.ListExperiments,'Value',1) 245 ListExperiments_Callback(hObject, eventdata, handles) 246 else 247 msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) 248 end 249 set(handles.SourceDir,'BackgroundColor',[1 1 1]) 250 251 252 %------------------------------------------------------------------------ 253 % --- Executes on selection change in ListExperiments. 254 function ListExperiments_Callback(hObject, eventdata, handles) 255 %------------------------------------------------------------------------ 256 SourcePath=get(handles.SourceDir,'String'); 257 MirrorPath=get(handles.LinkDir,'String'); 258 ListExperiments=get(handles.ListExperiments,'String'); 259 ListDevices={}; 260 list_val=get(handles.ListExperiments,'Value'); 261 if isequal(list_val(1),1) 262 ListExperiments=ListExperiments(2:end); %choose all experiments 263 testList=1; 264 set(handles.ListExperiments,'Value',1) 265 else 266 ListExperiments=ListExperiments(list_val);%choose selected experiments 267 testList=0; 268 end 269 for iexp=1:numel(ListExperiments) 270 hdir=dir(fullfile(SourcePath,ListExperiments{iexp})); %list files and dirs 271 idir=0; 272 for ilist=1:length(hdir) 273 if ~isequal(hdir(ilist).name(1),'.') 274 source=fullfile(SourcePath,ListExperiments{iexp},hdir(ilist).name); 275 link=fullfile(MirrorPath,ListExperiments{iexp},hdir(ilist).name); 276 if ~exist(link) 277 system(['ln -s ' source ' ' link]) 278 end 279 check_list=strcmp(hdir(ilist).name,ListDevices); 280 if isempty(find(check_list)) 281 ListDevices=[ListDevices;hdir(ilist).name]; 282 end 283 end 284 end 285 end 286 set(handles.ListDevices,'String',ListDevices) 287 % if hdir(ilist).isdir 288 % dirname=hdir(ilist).name; 289 % if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') 290 % idir=idir+1; 291 % ExpName{idir}=hdir(ilist).name; 292 % link=fullfile(LinkDir,ExpName{idir}); 293 % if ~exist(link,'dir') 294 % mkdir(link) 295 % end 296 % end 297 % % look for the list of 'devices' 298 % else 299 % %warning for isolated files 300 % end 301 % end 302 % set(handles.ListExperiments,'String',[{'*'};ExpName']) 303 % set(handles.ListExperiments,'Value',1) 304 % ListExperiments_Callback(hObject, eventdata, handles) 305 306 307 % set(handles.ListDevices,'Value',1) 308 % set(handles.ListRecords,'Value',1) 309 % set(handles.ListXml,'Value',1) 310 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,{},{}); 311 % set(handles.ListRecords,'String',[{'*'};ListRecords']) 312 % set(handles.ListDevices,'String',[{'*'};ListDevices']) 313 % set(handles.ListXml,'String',[{'*'};ListXml']) 314 % if testList 315 % DataviewData=get(handles.figure,'UserData'); 316 % DataviewData.List=List; 317 % set(handles.figure,'UserData',DataviewData) 318 % end 319 % set(handles.CampaignDoc,'Visible','on') 320 % set(handles.edit_xml,'Visible','on') 321 322 %------------------------------------------------------------------------ 323 % --- Executes on button press in update_headings. 324 function ListDevices_Callback(hObject, eventdata, handles) 325 CurrentPath=get(handles.SourceDir,'String'); 326 ListExperiments=get(handles.ListExperiments,'String'); 327 list_val=get(handles.ListExperiments,'Value'); 328 if isequal(list_val,1) 329 ListExperiments=ListExperiments(2:end); 330 else 331 ListExperiments=ListExperiments(list_val); 332 end 333 set(handles.ListRecords,'Value',1) 334 set(handles.ListXml,'Value',1) 335 ListDevices=get(handles.ListDevices,'String'); 336 list_val=get(handles.ListDevices,'Value'); 337 if isequal(list_val,1) 338 ListDevices=ListDevices(2:end); 339 else 340 ListDevices=ListDevices(list_val); 341 end 342 [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); 343 set(handles.ListRecords,'String',[{'*'};ListRecords']) 344 set(handles.ListXml,'String',[{'*'};ListXml']) 345 346 347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 348 349 350 351 %------------------------------------------------------------------------ 352 % --- Executes on selection change in ListRecords. 353 function ListRecords_Callback(hObject, eventdata, handles) 354 Value=get(handles.ListRecords,'Value'); 355 if isequal(Value(1),1) 356 set(handles.ListRecords,'Value',1); 357 end 358 359 %------------------------------------------------------------------------ 360 % --- Executes on button press in CampaignDoc. 361 function CampaignDoc_Callback(hObject, eventdata, handles) 362 %------------------------------------------------------------------------ 363 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') 364 if ~isequal(answer{1},'OK') 365 return 366 end 367 set(handles.ListExperiments,'Value',1) 368 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 369 DataviewData=get(handles.figure,'UserData'); 370 List=DataviewData.List; 371 Currentpath=get(handles.SourceDir,'String'); 372 [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 373 Campaign=[Campaign DirExt]; 374 t=xmltree; 375 t=set(t,1,'name','CampaignDoc'); 376 t = attributes(t,'add',1,'source','directory'); 377 SubCampaignTest=get(handles.SubCampaignTest,'Value'); 378 root_uid=1; 379 if SubCampaignTest 380 %TO DO open an exoiting xml doc 381 [t,root_uid]=add(t,1,'element','SubCampaign'); 382 t =attributes(t,'add',root_uid,'DirName',Campaign); 383 end 384 for iexp=1:length(List.Experiment) 385 set(handles.ListExperiments,'Value',iexp+1) 386 drawnow 387 test_mod=0; 388 [t,uid_exp]=add(t,root_uid,'element','Experiment'); 389 t = attributes(t,'add',uid_exp,'i',num2str(iexp)); 390 ExpName=List.Experiment{iexp}.name; 391 t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); 392 393 if isfield(List.Experiment{iexp},'Device') 394 for idevice=1:length(List.Experiment{iexp}.Device) 395 [t,uid_device]=add(t,uid_exp,'element','Device'); 396 DeviceName=List.Experiment{iexp}.Device{idevice}.name; 397 t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); 398 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 399 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 400 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 401 [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); 402 if test 403 [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] 404 end 405 if isequal(Title,'ImaDoc') 406 [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); 407 t = attributes(t,'add',uid_xml,'source','file'); 408 [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); 409 end 410 end 411 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 412 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 413 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 414 [t,uid_record]=add(t,uid_device,'element','Record'); 415 t = attributes(t,'add',uid_record,'DirName',RecordName); 416 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 417 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 418 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 419 [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); 420 if test 421 [FileName ' , Heading updated'] 422 end 423 [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); 424 t = attributes(t,'add',uid_xml,'source','file'); 425 [t]=add(t,uid_xml,'chardata',FileName); 426 end 427 end 180 mkdir(link)% create the directory containing links 428 181 end 429 182 end … … 431 184 end 432 185 end 186 set(handles.ListExperiments,'String',[{'*'};ExpName(1:idir)]) 433 187 set(handles.ListExperiments,'Value',1) 434 outputdir=get(handles.SourceDir,'String'); 435 [path,dirname]=fileparts(outputdir); 436 outputfile=fullfile(outputdir,[dirname '.xml']); 437 % campaigndoc(t);438 save(t,outputfile) 439 440 %------------------------------------------------------------------------ 441 % --- Executes on button press in CampaignDoc. 442 function edit_xml_Callback(hObject, eventdata, handles) 443 %------------------------------------------------------------------------ 444 CurrentPath=get(handles.SourceDir,'String');445 %[CurrentPath,Name,Ext]=fileparts(CurrentDir); 188 ListExperiments_Callback([],[], handles) 189 190 191 %------------------------------------------------------------------------ 192 % --- Executes on selection change in ListExperiments. 193 function ListExperiments_Callback(hObject,eventdata,handles) 194 %------------------------------------------------------------------------ 195 SourcePath=get(handles.SourceDir,'String'); 196 MirrorPath=''; 197 if strcmp(get(handles.LinkDir,'Visible'),'on') 198 MirrorPath=get(handles.LinkDir,'String'); 199 end 446 200 ListExperiments=get(handles.ListExperiments,'String'); 447 Value=get(handles.ListExperiments,'Value'); 448 if ~isequal(Value,1) 449 ListExperiments=ListExperiments(Value); 450 end 451 ListDevices=get(handles.ListDevices,'String'); 452 Value=get(handles.ListDevices,'Value'); 453 if ~isequal(Value,1) 454 ListDevices=ListDevices(Value); 455 end 456 ListRecords=get(handles.ListRecords,'String'); 457 Value=get(handles.ListRecords,'Value'); 458 if ~isequal(Value,1) 459 ListRecords=ListRecords(Value); 460 end 461 [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 462 ListXml=get(handles.ListXml,'String'); 463 Value=get(handles.ListXml,'Value'); 464 set(handles.ListXml,'Value',Value(1)); 465 if isequal(Value(1),1) 466 msgbox_uvmat('ERROR','an xml file needs to be selected') 467 return 201 if isequal(get(handles.ListExperiments,'Value'),1) 202 ListExperiments=ListExperiments(2:end); %choose all experiments 468 203 else 469 XmlName=ListXml{Value(1)};470 end 471 for iexp=1:length(List.Experiment) 472 ExpName=List.Experiment{iexp}.name; 473 if isfield(List.Experiment{iexp},'Device')474 for idevice=1:length(List.Experiment{iexp}.Device)475 DeviceName=List.Experiment{iexp}.Device{idevice}.name;476 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')477 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)478 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}479 if isequal(FileName,XmlName)480 editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));481 return482 end204 ListExperiments=ListExperiments(get(handles.ListExperiments,'Value')); 205 end 206 ListDevices={}; 207 208 for iexp=1:numel(ListExperiments) 209 hdir=dir(fullfile(SourcePath,ListExperiments{iexp})); %list files and dirs 210 for ilist=1:length(hdir) 211 Device=hdir(ilist).name; 212 if ~isequal(Device(1),'.') 213 if ~isempty(MirrorPath)% we list the links to the data directories of files 214 link=fullfile(MirrorPath,ListExperiments{iexp},Device); 215 if ~exist(link) 216 source=fullfile(SourcePath,ListExperiments{iexp},Device); 217 system(['ln -s ' source ' ' link])%TODO translate for DOS 483 218 end 484 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 485 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 486 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 487 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 488 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 489 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 490 if isequal(FileName,XmlName) 491 editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); 492 return 493 end 494 end 495 end 496 end 219 Device=['@' Device]; 220 end 221 if hdir(ilist).isdir 222 Device=[Device '/']; 223 end 224 check_list=strcmp(Device,ListDevices); 225 if isempty(find(check_list)) 226 ListDevices=[ListDevices;Device]; 497 227 end 498 228 end 499 229 end 500 230 end 501 502 503 504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 505 % CurrentPath/Campaign: root directory 506 function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) 507 508 %Shema for Heading: 509 % Campaign 510 % (SubCampaign) 511 % Experiment 512 % Device 513 % (Record) 514 % ImageName 515 % DateExp 516 % old: %Project: suppressed ( changed to Campaign) 517 %Exp: suppressed (changed to experiment) 518 %ImaNames: changed to ImageName 519 if exist('Record','var') && ~isempty(Record) 520 xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 521 testrecord=1; 522 else 523 xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); 524 testrecord=0; 525 end 526 if ~exist('testSubCampaign','var') 527 testSubCampaign=0; 528 end 529 if testSubCampaign 530 SubCampaign=Campaign; 531 [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 532 Campaign=[Campaign DirExt]; 533 end 534 test_mod=0; %test for the modification of the xml file 535 t_device=xmltree(xmlfullname); 536 Title=get(t_device,1,'name'); 537 uid_child=children(t_device,1); 538 Heading_old=[]; 539 uidheading=0; 540 for ilist=1:length(uid_child) 541 name=get(t_device,uid_child(ilist),'name'); 542 if isequal(name,'Heading') 543 uidheading=uid_child(ilist); 231 set(handles.ListDevices,'String',ListDevices) 232 233 234 %------------------------------------------------------------------------ 235 % --- Executes on selection in column ListDevices 236 function ListDevices_Callback(hObject, eventdata, handles) 237 %------------------------------------------------------------------------ 238 list_val=get(handles.ListExperiments,'Value'); 239 if numel(list_val)~=1 240 msgbox_uvmat('ERROR','select a single experiment') 241 return 242 end 243 ListExperiments=get(handles.ListExperiments,'String'); 244 Experiment=ListExperiments{list_val}; 245 RootPath=''; 246 if strcmp(get(handles.LinkDir,'Visible'),'on') 247 RootPath=get(handles.LinkDir,'String'); 248 end 249 if isempty(RootPath) 250 RootPath=get(handles.SourceDir,'String'); 251 end 252 ListDevices=get(handles.ListDevices,'String'); 253 Device=ListDevices{get(handles.ListDevices,'Value')}; 254 Device=regexprep(Device,'^@',''); 255 if strcmp(Device(end),'/') 256 DataDir=fullfile(RootPath,Experiment,Device(1:end-1)); 257 DirList=dir(DataDir); 258 for ilist=1:numel(DirList) 259 [tild,tild,FileExt]=fileparts(DirList(ilist).name); 260 FileExt=regexprep(FileExt,'^.',''); 261 if ~isempty(FileExt) && (~isempty(imformats(FileExt))||strcmp(lower(FileExt),'avi')||strcmp(lower(FileExt),'nc')) 262 uvmat(fullfile(DataDir,DirList(ilist).name)) 263 return 264 end 544 265 end 545 266 end 546 if uidheading 547 subt=branch(t_device,uidheading); 548 Heading_old=convert(subt); 549 else 550 return % do not edit xml files without element 'Heading' 551 end 552 if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) 553 test_mod=1; 554 end 555 Heading.Campaign=Campaign; 556 if testSubCampaign 557 if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) 558 test_mod=1; 559 end 560 Heading.SubCampaign=SubCampaign; 561 end 562 if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) 563 test_mod=1; 564 end 565 Heading.Experiment=Experiment; 566 if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) 567 test_mod=1; 568 end 569 Heading.Device=Device; 570 if testrecord 571 if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) 572 test_mod=1; 573 end 574 Heading.Record=Record; 575 end 576 if isfield(Heading_old,'ImaNames') 577 test_mod=1; 578 if ~isempty(Heading_old.ImaNames) 579 Heading.ImageName=Heading_old.ImaNames; 580 end 581 end 582 if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) 583 Heading.ImageName=Heading_old.ImageName; 584 end 585 if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) 586 Heading.DateExp=Heading_old.DateExp; 587 end 588 if test_mod && uidheading 589 uid_child=children(t_device,uidheading); 590 t_device=delete(t_device,uid_child); 591 t_device=struct2xml(Heading,t_device,uidheading); 592 backupfile=xmlfullname; 593 testexist=2; 594 while testexist==2 595 backupfile=[backupfile '~']; 596 testexist=exist(backupfile,'file'); 597 end 598 [success,message]=copyfile(xmlfullname,backupfile);%make backup 599 if isequal(success,1) 600 delete(xmlfullname) 601 else 602 return 603 end 604 save(t_device,xmlfullname) 605 end 267 % 268 % set(handles.ListRecords,'Value',1) 269 % set(handles.ListXml,'Value',1) 270 % ListDevices=get(handles.ListDevices,'String'); 271 % list_val=get(handles.ListDevices,'Value'); 272 % if isequal(list_val,1) 273 % ListDevices=ListDevices(2:end); 274 % else 275 % ListDevices=ListDevices(list_val); 276 % end 277 % [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); 278 % set(handles.ListRecords,'String',[{'*'};ListRecords']) 279 % set(handles.ListXml,'String',[{'*'};ListXml']) 280 281 282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 283 284 285 286 % %------------------------------------------------------------------------ 287 % % --- Executes on selection change in ListRecords. 288 % function ListRecords_Callback(hObject, eventdata, handles) 289 % Value=get(handles.ListRecords,'Value'); 290 % if isequal(Value(1),1) 291 % set(handles.ListRecords,'Value',1); 292 % end 293 294 % %------------------------------------------------------------------------ 295 % % --- Executes on button press in CampaignDoc. 296 % function CampaignDoc_Callback(hObject, eventdata, handles) 297 % %------------------------------------------------------------------------ 298 % 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') 299 % if ~isequal(answer{1},'OK') 300 % return 301 % end 302 % set(handles.ListExperiments,'Value',1) 303 % ListExperiments_Callback(handles)%update the overview of the experiment directories 304 % DataviewData=get(handles.datatree_browser,'UserData'); 305 % List=DataviewData.List; 306 % Currentpath=get(handles.SourceDir,'String'); 307 % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 308 % Campaign=[Campaign DirExt]; 309 % t=xmltree; 310 % t=set(t,1,'name','CampaignDoc'); 311 % t = attributes(t,'add',1,'source','directory'); 312 % SubCampaignTest=get(handles.SubCampaignTest,'Value'); 313 % root_uid=1; 314 % if SubCampaignTest 315 % %TO DO open an exoiting xml doc 316 % [t,root_uid]=add(t,1,'element','SubCampaign'); 317 % t =attributes(t,'add',root_uid,'DirName',Campaign); 318 % end 319 % for iexp=1:length(List.Experiment) 320 % set(handles.ListExperiments,'Value',iexp+1) 321 % drawnow 322 % test_mod=0; 323 % [t,uid_exp]=add(t,root_uid,'element','Experiment'); 324 % t = attributes(t,'add',uid_exp,'i',num2str(iexp)); 325 % ExpName=List.Experiment{iexp}.name; 326 % t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); 327 % 328 % if isfield(List.Experiment{iexp},'Device') 329 % for idevice=1:length(List.Experiment{iexp}.Device) 330 % [t,uid_device]=add(t,uid_exp,'element','Device'); 331 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 332 % t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); 333 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 334 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 335 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 336 % [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); 337 % if test 338 % [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] 339 % end 340 % if isequal(Title,'ImaDoc') 341 % [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); 342 % t = attributes(t,'add',uid_xml,'source','file'); 343 % [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); 344 % end 345 % end 346 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 347 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 348 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 349 % [t,uid_record]=add(t,uid_device,'element','Record'); 350 % t = attributes(t,'add',uid_record,'DirName',RecordName); 351 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 352 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 353 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 354 % [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); 355 % if test 356 % [FileName ' , Heading updated'] 357 % end 358 % [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); 359 % t = attributes(t,'add',uid_xml,'source','file'); 360 % [t]=add(t,uid_xml,'chardata',FileName); 361 % end 362 % end 363 % end 364 % end 365 % end 366 % end 367 % end 368 % set(handles.ListExperiments,'Value',1) 369 % outputdir=get(handles.SourceDir,'String'); 370 % [path,dirname]=fileparts(outputdir); 371 % outputfile=fullfile(outputdir,[dirname '.xml']); 372 % %campaigndoc(t); 373 % save(t,outputfile) 374 % 375 % %------------------------------------------------------------------------ 376 % % --- Executes on button press in CampaignDoc. 377 % function edit_xml_Callback(hObject, eventdata, handles) 378 % %------------------------------------------------------------------------ 379 % CurrentPath=get(handles.SourceDir,'String'); 380 % %[CurrentPath,Name,Ext]=fileparts(CurrentDir); 381 % ListExperiments=get(handles.ListExperiments,'String'); 382 % Value=get(handles.ListExperiments,'Value'); 383 % if ~isequal(Value,1) 384 % ListExperiments=ListExperiments(Value); 385 % end 386 % ListDevices=get(handles.ListDevices,'String'); 387 % Value=get(handles.ListDevices,'Value'); 388 % if ~isequal(Value,1) 389 % ListDevices=ListDevices(Value); 390 % end 391 % ListRecords=get(handles.ListRecords,'String'); 392 % Value=get(handles.ListRecords,'Value'); 393 % if ~isequal(Value,1) 394 % ListRecords=ListRecords(Value); 395 % end 396 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 397 % ListXml=get(handles.ListXml,'String'); 398 % Value=get(handles.ListXml,'Value'); 399 % set(handles.ListXml,'Value',Value(1)); 400 % if isequal(Value(1),1) 401 % msgbox_uvmat('ERROR','an xml file needs to be selected') 402 % return 403 % else 404 % XmlName=ListXml{Value(1)}; 405 % end 406 % for iexp=1:length(List.Experiment) 407 % ExpName=List.Experiment{iexp}.name; 408 % if isfield(List.Experiment{iexp},'Device') 409 % for idevice=1:length(List.Experiment{iexp}.Device) 410 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 411 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 412 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 413 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} 414 % if isequal(FileName,XmlName) 415 % editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); 416 % return 417 % end 418 % end 419 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 420 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 421 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 422 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 423 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 424 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 425 % if isequal(FileName,XmlName) 426 % editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); 427 % return 428 % end 429 % end 430 % end 431 % end 432 % end 433 % end 434 % end 435 % end 436 437 438 % 439 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 440 % % CurrentPath/Campaign: root directory 441 % function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) 442 % 443 % %Shema for Heading: 444 % % Campaign 445 % % (SubCampaign) 446 % % Experiment 447 % % Device 448 % % (Record) 449 % % ImageName 450 % % DateExp 451 % % old: %Project: suppressed ( changed to Campaign) 452 % %Exp: suppressed (changed to experiment) 453 % %ImaNames: changed to ImageName 454 % if exist('Record','var') && ~isempty(Record) 455 % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 456 % testrecord=1; 457 % else 458 % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); 459 % testrecord=0; 460 % end 461 % if ~exist('testSubCampaign','var') 462 % testSubCampaign=0; 463 % end 464 % if testSubCampaign 465 % SubCampaign=Campaign; 466 % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 467 % Campaign=[Campaign DirExt]; 468 % end 469 % test_mod=0; %test for the modification of the xml file 470 % t_device=xmltree(xmlfullname); 471 % Title=get(t_device,1,'name'); 472 % uid_child=children(t_device,1); 473 % Heading_old=[]; 474 % uidheading=0; 475 % for ilist=1:length(uid_child) 476 % name=get(t_device,uid_child(ilist),'name'); 477 % if isequal(name,'Heading') 478 % uidheading=uid_child(ilist); 479 % end 480 % end 481 % if uidheading 482 % subt=branch(t_device,uidheading); 483 % Heading_old=convert(subt); 484 % else 485 % return % do not edit xml files without element 'Heading' 486 % end 487 % if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) 488 % test_mod=1; 489 % end 490 % Heading.Campaign=Campaign; 491 % if testSubCampaign 492 % if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) 493 % test_mod=1; 494 % end 495 % Heading.SubCampaign=SubCampaign; 496 % end 497 % if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) 498 % test_mod=1; 499 % end 500 % Heading.Experiment=Experiment; 501 % if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) 502 % test_mod=1; 503 % end 504 % Heading.Device=Device; 505 % if testrecord 506 % if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) 507 % test_mod=1; 508 % end 509 % Heading.Record=Record; 510 % end 511 % if isfield(Heading_old,'ImaNames') 512 % test_mod=1; 513 % if ~isempty(Heading_old.ImaNames) 514 % Heading.ImageName=Heading_old.ImaNames; 515 % end 516 % end 517 % if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) 518 % Heading.ImageName=Heading_old.ImageName; 519 % end 520 % if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) 521 % Heading.DateExp=Heading_old.DateExp; 522 % end 523 % if test_mod && uidheading 524 % uid_child=children(t_device,uidheading); 525 % t_device=delete(t_device,uid_child); 526 % t_device=struct2xml(Heading,t_device,uidheading); 527 % backupfile=xmlfullname; 528 % testexist=2; 529 % while testexist==2 530 % backupfile=[backupfile '~']; 531 % testexist=exist(backupfile,'file'); 532 % end 533 % [success,message]=copyfile(xmlfullname,backupfile);%make backup 534 % if isequal(success,1) 535 % delete(xmlfullname) 536 % else 537 % return 538 % end 539 % save(t_device,xmlfullname) 540 % end 606 541 607 542 %------------------------------------------------------------------------ … … 616 551 end 617 552 618 619 620 % --- Executes on selection change in ListXml.621 function ListXml_Callback(hObject, eventdata, handles)622 Value=get(handles.ListXml,'Value');623 if isequal(Value(1),1)624 set(handles.ListXml,'Value',1);625 end553 % 554 % 555 % % --- Executes on selection change in ListXml. 556 % function ListXml_Callback(hObject, eventdata, handles) 557 % Value=get(handles.ListXml,'Value'); 558 % if isequal(Value(1),1) 559 % set(handles.ListXml,'Value',1); 560 % end 626 561 627 562 … … 634 569 end 635 570 set(handles.ListExperiments,'Value',1) 636 List Experiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories637 DataviewData=get(handles. figure,'UserData')571 ListDataDir(hObject, eventdata, handles)%update the overview of the experiment directories 572 DataviewData=get(handles.datatree_browser,'UserData') 638 573 List=DataviewData.List; 639 574 Currentpath=get(handles.SourceDir,'String'); … … 688 623 set(handles.ListExperiments,'Value',1) 689 624 690 691 % --- Executes on button press in OK. 692 function OK_Callback(hObject, eventdata, handles) 693 %------------------------------------------------------------------------ 694 CurrentPath=get(handles.SourceDir,'String'); 695 ListExperiments=get(handles.ListExperiments,'String'); 696 IndicesExp=get(handles.ListExperiments,'Value'); 697 if ~isequal(IndicesExp,1) 698 ListExperiments=ListExperiments(IndicesExp); 699 end 700 ListDevices=get(handles.ListDevices,'String'); 701 Value=get(handles.ListDevices,'Value'); 702 if isequal(Value,1) 703 msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') 704 return 705 else 706 ListDevices=ListDevices(Value); 707 end 708 ListRecords=get(handles.ListRecords,'String'); 709 Value=get(handles.ListRecords,'Value'); 710 if ~isequal(Value,1) 711 ListRecords=ListRecords(Value); 712 end 713 [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 714 ListXml=get(handles.ListXml,'String'); 715 Value=get(handles.ListXml,'Value'); 716 if isequal(Value,1) 717 msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') 718 return 719 else 720 ListXml=ListXml(Value); 721 end 722 723 %update all the selected xml files 724 DataviewData=get(handles.figure,'UserData'); 725 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... 726 % DataviewData.GeometryCalib.CalibrationType ' calibration data']) 727 % if ~isequal(answer,'Yes') 625 % 626 % % --- Executes on button press in OK. 627 % function OK_Callback(hObject, eventdata, handles) 628 % %------------------------------------------------------------------------ 629 % CurrentPath=get(handles.SourceDir,'String'); 630 % ListExperiments=get(handles.ListExperiments,'String'); 631 % IndicesExp=get(handles.ListExperiments,'Value'); 632 % if ~isequal(IndicesExp,1) 633 % ListExperiments=ListExperiments(IndicesExp); 634 % end 635 % ListDevices=get(handles.ListDevices,'String'); 636 % Value=get(handles.ListDevices,'Value'); 637 % if isequal(Value,1) 638 % msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') 728 639 % return 729 % end 730 %List.Experiment{1}.Device{1} 731 %List.Experiment{2}.Device{1} 732 for iexp=1:length(List.Experiment) 733 ExpName=List.Experiment{iexp}.name; 734 set(handles.ListExperiments,'Value',IndicesExp(iexp)); 735 if isfield(List.Experiment{iexp},'Device') 736 for idevice=1:length(List.Experiment{iexp}.Device) 737 DeviceName=List.Experiment{iexp}.Device{idevice}.name; 738 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 739 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 740 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 741 for ilistxml=1:length(ListXml) 742 if isequal(FileName,ListXml{ilistxml}) 743 set(handles.ListXml,'Value',Value(ilistxml)) 744 drawnow 745 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); 746 update_imadoc(DataviewData.GeometryCalib,xmlfullname) 747 display([xmlfullname ' updated']) 748 break 749 end 750 end 751 end 752 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 753 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 754 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 755 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 756 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 757 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 758 for ilistxml=1:length(ListXml) 759 if isequal(FileName,ListXml{ilistxml}) 760 set(handles.ListXml,'Value',Value(ilistxml)) 761 drawnow 762 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); 763 update_imadoc(DataviewData.GeometryCalib,xmlfullname) 764 display([xmlfullname ' updated']) 765 break 766 end 767 end 768 end 769 end 770 end 771 end 772 end 773 end 774 end 775 set(handles.ListXml,'Value',Value) 640 % else 641 % ListDevices=ListDevices(Value); 642 % end 643 % ListRecords=get(handles.ListRecords,'String'); 644 % Value=get(handles.ListRecords,'Value'); 645 % if ~isequal(Value,1) 646 % ListRecords=ListRecords(Value); 647 % end 648 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 649 % ListXml=get(handles.ListXml,'String'); 650 % Value=get(handles.ListXml,'Value'); 651 % if isequal(Value,1) 652 % msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') 653 % return 654 % else 655 % ListXml=ListXml(Value); 656 % end 657 % 658 % %update all the selected xml files 659 % DataviewData=get(handles.datatree_browser,'UserData'); 660 % % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... 661 % % DataviewData.GeometryCalib.CalibrationType ' calibration data']) 662 % % if ~isequal(answer,'Yes') 663 % % return 664 % % end 665 % %List.Experiment{1}.Device{1} 666 % %List.Experiment{2}.Device{1} 667 % for iexp=1:length(List.Experiment) 668 % ExpName=List.Experiment{iexp}.name; 669 % set(handles.ListExperiments,'Value',IndicesExp(iexp)); 670 % if isfield(List.Experiment{iexp},'Device') 671 % for idevice=1:length(List.Experiment{iexp}.Device) 672 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 673 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 674 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 675 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 676 % for ilistxml=1:length(ListXml) 677 % if isequal(FileName,ListXml{ilistxml}) 678 % set(handles.ListXml,'Value',Value(ilistxml)) 679 % drawnow 680 % xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); 681 % update_imadoc(DataviewData.GeometryCalib,xmlfullname) 682 % display([xmlfullname ' updated']) 683 % break 684 % end 685 % end 686 % end 687 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 688 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 689 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 690 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 691 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 692 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 693 % for ilistxml=1:length(ListXml) 694 % if isequal(FileName,ListXml{ilistxml}) 695 % set(handles.ListXml,'Value',Value(ilistxml)) 696 % drawnow 697 % xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); 698 % update_imadoc(DataviewData.GeometryCalib,xmlfullname) 699 % display([xmlfullname ' updated']) 700 % break 701 % end 702 % end 703 % end 704 % end 705 % end 706 % end 707 % end 708 % end 709 % end 710 % set(handles.ListXml,'Value',Value) 776 711 % 777 712 % … … 817 752 handles.output ='OK, Calibration replicated'; 818 753 guidata(hObject, handles);% Update handles structure 819 uiresume(handles. figure);820 821 % --- Executes on button press in Cancel.822 function Cancel_Callback(hObject, eventdata, handles)823 handles.output = get(hObject,'String');824 guidata(hObject, handles); % Update handles structure825 % Use UIRESUME instead of delete because the OutputFcn needs826 uiresume(handles.figure);827 828 % --- Executes when user attempts to close figure.829 function figure_CloseRequestFcn(hObject, eventdata, handles)830 % if isequal(get(handles. figure, 'waitstatus'), 'waiting')754 uiresume(handles.datatree_browser); 755 % 756 % % --- Executes on button press in Cancel. 757 % function Cancel_Callback(hObject, eventdata, handles) 758 % handles.output = get(hObject,'String'); 759 % guidata(hObject, handles); % Update handles structure 760 % % Use UIRESUME instead of delete because the OutputFcn needs 761 % uiresume(handles.datatree_browser); 762 763 % --- Executes when user attempts to close datatree_browser. 764 function datatree_browser_CloseRequestFcn(hObject, eventdata, handles) 765 % if isequal(get(handles.datatree_browser, 'waitstatus'), 'waiting') 831 766 % % The GUI is still in UIWAIT, us UIRESUME 832 % uiresume(handles. figure);767 % uiresume(handles.datatree_browser); 833 768 % else 834 769 % % The GUI is no longer waiting, just close it 835 % delete(handles.figure); 836 % end 837 838 % --- Executes on key press over figure1 with no controls selected. 839 function figure_KeyPressFcn(hObject, eventdata, handles) 840 % Check for "enter" or "escape" 841 if isequal(get(hObject,'CurrentKey'),'escape') 842 % User said no by hitting escape 843 handles.output = 'Cancel'; 844 845 % Update handles structure 846 guidata(hObject, handles); 847 848 uiresume(handles.figure); 849 end 850 if isequal(get(hObject,'CurrentKey'),'return') 851 uiresume(handles.figure); 852 end 770 % delete(handles.datatree_browser); 771 % end 772 delete(hObject) -
trunk/src/find_imadoc.m
r469 r507 13 13 XmlFileName=[fullfile(RootPath,SubDirBase) '.xml'];%new convention: xml at the level of the image folder 14 14 if ~exist(XmlFileName,'file') 15 if strcmp(FileExt,'.nc') 16 basexml=fullfile(RootPath,RootFile) ; % old convention: xml inside the image folder, case of civ files 17 else 18 basexml=fullfile(RootPath,SubDir,RootFile) ; % old convention: xml inside the image folder, case of images 19 end 20 XmlFileName=[basexml '.xml']; 15 XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files 21 16 if ~exist(XmlFileName,'file') 22 XmlFileName=[basexml '.civ']; % very old convention: .civ file 23 if ~exist(XmlFileName,'file') 24 XmlFileName=''; 17 XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.civ']; % very old convention: .civ file 18 if ~exist(XmlFileName,'file') && strcmp(FileExt,'.nc') 19 XmlFileName=[fullfile(RootPath,RootFile) '.xml'] ; % old convention: xml inside the image folder, old civ file opened 20 if ~exist(XmlFileName,'file') 21 XmlFileName=[fullfile(RootPath,RootFile) '.civ']; % very old convention: .civ file 22 end 25 23 end 26 24 end 27 25 end 26 if ~exist(XmlFileName,'file') 27 XmlFileName=''; 28 end -
trunk/src/geometry_calib.m
r502 r507 50 50 % Edit the above text to modify the response to help geometry_calib 51 51 52 % Last Modified by GUIDE v2.5 05-Oct-2010 13:47:0052 % Last Modified by GUIDE v2.5 29-Jul-2012 08:46:09 53 53 54 54 % Begin initialization code - DO NOT edit … … 1450 1450 1451 1451 1452 % --- Executes when user attempts to close geometry_calib. 1453 function geometry_calib_CloseRequestFcn(hObject, eventdata, handles) 1454 % hObject handle to geometry_calib (see GCBO) 1455 % eventdata reserved - to be defined in a future version of MATLAB 1456 % handles structure with handles and user data (see GUIDATA) 1457 1458 % Hint: delete(hObject) closes the figure 1459 delete(hObject); -
trunk/src/msgbox_uvmat.m
r497 r507 112 112 if exist('Position','var') 113 113 if iscell(default_answer) 114 widthstring=max( cellfun('length',default_answer),length(display_str));115 heightstring=size(default_answer,1); 114 widthstring=max(max(cellfun('length',default_answer)),length(display_str)); 115 heightstring=size(default_answer,1);%nbre of expected lines 116 116 set(handles.edit_box,'Max',2); 117 117 else -
trunk/src/transform_field/phys.m
r494 r507 16 16 % Data_1, CalibData_1: same as Data, CalibData for the second field. 17 17 18 function [DataOut,DataOut_1]=phys( varargin)18 function [DataOut,DataOut_1]=phys(DataIn,XmlData,DataIn_1,XmlData_1) 19 19 % A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'): 20 20 % chercher ListVarAttribute, for each field (cell of variables): … … 25 25 % 'D_i' if '.Role='vector_x,...', 26 26 % 'scalar', else (thenno change except scale factor) 27 %% set GUI config 28 DataOut=[]; 29 DataOut_1=[]; %default second output field 30 if strcmp(DataIn,'*') 31 if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 32 DataOut.CoordUnit=XmlData.GeometryCalib.CoordUnit; 33 end 34 return 35 end 36 27 37 %% analyse input and set default output 28 DataOut=varargin{1};%default first output field 29 DataOut_1=[]; %default second output field 38 DataOut=DataIn;%default first output field 30 39 if nargin>=2 % nargin =nbre of input variables 31 if isfield( varargin{2},'GeometryCalib')32 Calib{1}= varargin{2}.GeometryCalib;40 if isfield(XmlData,'GeometryCalib') 41 Calib{1}=XmlData.GeometryCalib; 33 42 else 34 43 Calib{1}=[]; 35 44 end 36 45 if nargin>=3 %two input fields 37 DataOut_1= varargin{3};%default second output field38 if nargin>=4 && isfield( varargin{4},'GeometryCalib')39 Calib{2}= varargin{4}.GeometryCalib;46 DataOut_1=DataIn_1;%default second output field 47 if nargin>=4 && isfield(XmlData_1,'GeometryCalib') 48 Calib{2}=XmlData_1.GeometryCalib; 40 49 else 41 50 Calib{2}=Calib{1}; … … 45 54 46 55 %% get the z index defining the section plane 47 if isfield( varargin{1},'ZIndex')&&~isempty(varargin{1}.ZIndex)&&~isnan(varargin{1}.ZIndex)48 ZIndex= varargin{1}.ZIndex;56 if isfield(DataIn,'ZIndex')&&~isempty(DataIn.ZIndex)&&~isnan(DataIn.ZIndex) 57 ZIndex=DataIn.ZIndex; 49 58 else 50 59 ZIndex=1; … … 57 66 return %bad calib parameter input 58 67 end 59 if ~(isfield( varargin{1},'CoordUnit')&& strcmp(varargin{1}.CoordUnit,'pixel'))68 if ~(isfield(DataIn,'CoordUnit')&& strcmp(DataIn.CoordUnit,'pixel')) 60 69 return % transform only fields in pixel coordinates 61 70 end 62 DataOut=phys_1( varargin{1},Calib{1},ZIndex);% transform coordiantes and velocity components71 DataOut=phys_1(DataIn,Calib{1},ZIndex);% transform coordiantes and velocity components 63 72 %case of images or scalar: in case of two input fields, we need to project the transform on the same regular grid 64 if isfield( varargin{1},'A') && isfield(varargin{1},'AX') && ~isempty(varargin{1}.AX) && isfield(varargin{1},'AY')&&...65 ~isempty( varargin{1}.AY) && length(varargin{1}.A)>173 if isfield(DataIn,'A') && isfield(DataIn,'AX') && ~isempty(DataIn.AX) && isfield(DataIn,'AY')&&... 74 ~isempty(DataIn.AY) && length(DataIn.A)>1 66 75 iscalar=1; 67 A{1}= varargin{1}.A;76 A{1}=DataIn.A; 68 77 end 69 78 end … … 83 92 %% transform second field if relevant 84 93 if ~isempty(DataOut_1) 85 if isfield( varargin{3},'ZIndex') && ~isequal(varargin{3}.ZIndex,ZIndex)94 if isfield(DataIn_1,'ZIndex') && ~isequal(DataIn_1.ZIndex,ZIndex) 86 95 DataOut_1.Txt='different plane indices for the two input fields'; 87 96 return … … 90 99 return %bad calib parameter input 91 100 end 92 if ~(isfield( varargin{3},'CoordUnit')&& strcmp(varargin{3}.CoordUnit,'pixel'))101 if ~(isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel')) 93 102 return % transform only fields in pixel coordinates 94 103 end … … 108 117 end 109 118 end 110 if isfield( varargin{3},'A')&&isfield(varargin{3},'AX')&&~isempty(varargin{3}.AX) && isfield(varargin{3},'AY')&&...111 ~isempty( varargin{3}.AY)&&length(varargin{3}.A)>1119 if isfield(DataIn_1,'A')&&isfield(DataIn_1,'AX')&&~isempty(DataIn_1.AX) && isfield(DataIn_1,'AY')&&... 120 ~isempty(DataIn_1.AY)&&length(DataIn_1.A)>1 112 121 iscalar=iscalar+1; 113 122 Calib{iscalar}=Calib{2}; 114 A{iscalar}= varargin{3}.A;123 A{iscalar}=DataIn_1.A; 115 124 end 116 125 end -
trunk/src/update_menu.m
r236 r507 12 12 function menu_str=update_menu(handle,strinput) 13 13 menu_str=get(handle,'String'); 14 nbmenu=length(menu_str);15 14 ichoice=find(strcmp(strinput,menu_str),1); 16 15 if isempty(ichoice)%the input string does not exist in the menu 17 menu_str{nbmenu+1}=menu_str{nbmenu};%shift the last item ('more...')18 menu_str {nbmenu}=strinput;16 ichoice= length(menu_str); 17 menu_str=[menu_str(1:end-1);{strinput};menu_str(end)]; 19 18 set(handle,'String',menu_str) 20 ichoice=nbmenu;21 19 end 22 20 set(handle,'Value',ichoice) -
trunk/src/uvmat.m
r503 r507 207 207 guidata(hObject, handles); 208 208 209 %% add the path to uvmat (useful if uvmat has been opened in the working directory and a working directory change occured) 210 path_uvmat=fileparts(which('uvmat')); 211 209 212 %% set the position of colorbar and ancillary GUIs: 210 213 set(hObject,'Units','Normalized') … … 237 240 238 241 %% TRANSFORM menu: builtin fcts 239 menu_str={'';'phys';'px';'phys_polar'}; 240 UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions 241 path_uvmat=fileparts(which('uvmat')); 242 addpath (path_uvmat) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) 243 addpath(fullfile(path_uvmat,'transform_field'))%add the path to transform functions, 244 fct_handle{1,1}=[]; 245 testexist=zeros(size(menu_str'));%default 246 testexist(1)=1; 247 for ilist=2:length(menu_str) 248 if exist(menu_str{ilist},'file') 249 fct_handle{ilist,1}=str2func(menu_str{ilist}); 250 testexist(ilist)=1; 251 else 252 testexist(ilist)=0; 253 end 254 end 255 rmpath(fullfile(path_uvmat,'transform_field')) 256 257 %% load the list of previously browsed files in menus Open and Open_1 242 transform_menu={'';'phys';'px';'phys_polar'}; 243 UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions 244 path_list=(num2cell(blanks(UvData.OpenParam.NbBuiltin)))';%initialize a cell array of nbvar blanks 245 transform_path=fullfile(path_uvmat,'transform_field'); 246 path_list{1}=''; 247 path_list(2:end)=regexprep(path_list(2:end),' ',transform_path); % set transform_path to the path_list 248 249 %% load the list of previously browsed files in menus Open, Open_1 and transform_fct 258 250 dir_perso=prefdir; % path to the directory .matlab for personal data 259 251 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab 260 252 if exist(profil_perso,'file') 261 262 263 264 265 266 267 268 253 h=load (profil_perso); 254 if isfield(h,'MenuFile') 255 for ifile=1:min(length(h.MenuFile),5) 256 eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) 257 eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) 258 end 259 end 260 if isfield(h,'transform_fct') && iscell(h.transform_fct) 269 261 for ilist=1:length(h.transform_fct); 270 262 if exist(h.transform_fct{ilist},'file') 271 [path,file]=fileparts(h.transform_fct{ilist}); 272 addpath(path) 273 h_func=str2func(file); 274 rmpath(path) 275 testexist=[testexist 1]; 276 else 277 file=''; 278 h_func=[]; 279 testexist=[testexist 0]; 263 [path,file]=fileparts(h.transform_fct{ilist}); 264 transform_menu=[transform_menu; {file}]; 265 path_list=[path_list; {path}]; 280 266 end 281 fct_handle=[fct_handle; {h_func}]; %concatene the list of paths282 menu_str=[menu_str; {file}];283 267 end 284 268 end 285 269 end 286 menu_str=menu_str(testexist==1);%=menu_str(testexist~=0) 287 fct_handle=fct_handle(testexist==1); 288 menu_str=[menu_str;{'more...'}]; 289 set(handles. transform_fct,'String',menu_str)290 set(handles. transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION270 transform_menu=[transform_menu;{'more...'}]; 271 set(handles.transform_fct,'String',transform_menu) 272 set(handles.transform_fct,'UserData',path_list)% store the list of path in UserData of ACTION 273 set(handles.path_transform,'String','') 274 set(handles.path_transform,'UserData',[]) 291 275 292 276 %% case of an input argument for uvmat … … 700 684 set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function 701 685 case 'xml' % edit xml files 702 if ~isempty(regexp(fileinput,'.project.xml$')) 686 t=xmltree(fileinput); 687 if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') 703 688 datatree_browser(fileinput) 704 689 else … … 1977 1962 end 1978 1963 1979 %% read the first input field if a filename has been introduced1964 %% read the first input field 1980 1965 ParamIn.ColorVar='';%default variable name for vector color 1981 1966 frame_index=1;%default 1982 if ~isempty(FileName)1983 1984 1967 % if ~isempty(FileName) 1968 FieldName='';%default 1969 VelType='';%default 1985 1970 % FileType=UvData.FileType{1}; 1986 switch UvData.FileType{1} 1987 case {'civx','civdata','netcdf'}; 1988 list_fields=get(handles.Fields,'String');% list menu fields 1989 % index_fields=get(handles.Fields,'Value');% selected string index 1990 FieldName= list_fields{get(handles.Fields,'Value')}; % selected field 1991 if ~strcmp(FieldName,'get_field...') 1992 if get(handles.FixVelType,'Value') 1993 VelTypeList=get(handles.VelType,'String'); 1994 VelType=VelTypeList{get(handles.VelType,'Value')}; 1995 end 1971 switch UvData.FileType{1} 1972 case {'civx','civdata','netcdf'}; 1973 list_fields=get(handles.Fields,'String');% list menu fields 1974 % index_fields=get(handles.Fields,'Value');% selected string index 1975 FieldName= list_fields{get(handles.Fields,'Value')}; % selected field 1976 if ~strcmp(FieldName,'get_field...') 1977 if get(handles.FixVelType,'Value') 1978 VelTypeList=get(handles.VelType,'String'); 1979 VelType=VelTypeList{get(handles.VelType,'Value')}; 1996 1980 end 1997 if strcmp(FieldName,'velocity')1998 list_code=get(handles.ColorCode,'String');% list menu fields1999 index_code=get(handles.ColorCode,'Value');% selected string index2000 if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')2001 list_code=get(handles.ColorScalar,'String');% list menu fields2002 index_code=get(handles.ColorScalar,'Value');% selected string index2003 ParamIn.ColorVar= list_code{index_code}; % selected field2004 end1981 end 1982 if strcmp(FieldName,'velocity') 1983 list_code=get(handles.ColorCode,'String');% list menu fields 1984 index_code=get(handles.ColorCode,'Value');% selected string index 1985 if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') 1986 list_code=get(handles.ColorScalar,'String');% list menu fields 1987 index_code=get(handles.ColorScalar,'Value');% selected string index 1988 ParamIn.ColorVar= list_code{index_code}; % selected field 2005 1989 end 2006 case {'video','mmreader'} 2007 ParamIn=UvData.MovieObject{1}; 2008 if ~strcmp(NomType,'*') 2009 frame_index=num_j1;%frame index for movies or multimage 2010 else 2011 frame_index=num_i1; 2012 end 2013 case 'multimage' 2014 if ~strcmp(NomType,'*') 2015 frame_index=num_j1;%frame index for movies or multimage 2016 else 2017 frame_index=num_i1; 2018 end 2019 case 'vol' %TODO: update 2020 if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') 2021 ParamIn.Npy=UvData.XmlData.Npy; 2022 ParamIn.Npx=UvData.XmlData.Npx; 2023 else 2024 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; 2025 return 2026 end 2027 end 2028 if isstruct (ParamIn) 2029 ParamIn.FieldName=FieldName; 2030 ParamIn.VelType=VelType; 2031 ParamIn.GUIName='get_field'; 2032 end 2033 [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); 2034 if ~isempty(errormsg) 2035 errormsg=['error in reading ' FileName ': ' errormsg]; 2036 return 2037 end 2038 if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') 2039 set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface 2040 set(handles.num_Npy,'String',num2str(ParamOut.Npy)); 2041 end 2042 if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field 2043 set(handles.i1,'String',num2str(ParamOut.TimeIndex)) 2044 end 2045 if isfield(ParamOut,'TimeValue') 2046 Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field 2047 end 2048 end 1990 end 1991 case {'video','mmreader'} 1992 ParamIn=UvData.MovieObject{1}; 1993 if ~strcmp(NomType,'*') 1994 frame_index=num_j1;%frame index for movies or multimage 1995 else 1996 frame_index=num_i1; 1997 end 1998 case 'multimage' 1999 if ~strcmp(NomType,'*') 2000 frame_index=num_j1;%frame index for movies or multimage 2001 else 2002 frame_index=num_i1; 2003 end 2004 case 'vol' %TODO: update 2005 if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') 2006 ParamIn.Npy=UvData.XmlData.Npy; 2007 ParamIn.Npx=UvData.XmlData.Npx; 2008 else 2009 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; 2010 return 2011 end 2012 end 2013 if isstruct (ParamIn) 2014 ParamIn.FieldName=FieldName; 2015 ParamIn.VelType=VelType; 2016 ParamIn.GUIName='get_field'; 2017 end 2018 [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); 2019 if ~isempty(errormsg) 2020 errormsg=['error in reading ' FileName ': ' errormsg]; 2021 return 2022 end 2023 if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') 2024 set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface 2025 set(handles.num_Npy,'String',num2str(ParamOut.Npy)); 2026 end 2027 if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field 2028 set(handles.i1,'String',num2str(ParamOut.TimeIndex)) 2029 end 2030 if isfield(ParamOut,'TimeValue') 2031 Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field 2032 end 2033 Field{1}.ZIndex=z_index; %used for multiplane 3D calibration 2034 % end 2049 2035 2050 2036 %% choose and read a second field FileName_1 if defined … … 2127 2113 end 2128 2114 end 2115 Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration 2129 2116 end 2130 2117 … … 2313 2300 2314 2301 %% apply coordinate transform or other user fct 2315 XmlData=[];%default 2316 XmlData_1=[];%default 2317 if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority 2318 XmlData=UvData.XmlData{1}; 2319 if numel(UvData.XmlData)==2 2320 XmlData_1=UvData.XmlData{2}; 2321 end 2322 end 2323 choice_value=get(handles.transform_fct,'Value'); 2324 transform_list=get(handles.transform_fct,'UserData'); 2325 transform=transform_list{choice_value};%selected function handles 2326 % z index 2327 if ~isempty(FileName) 2328 Field{1}.ZIndex=z_index; 2329 end 2302 transform=get(handles.path_transform,'UserData'); 2330 2303 if ~isempty(transform) 2331 if length(Field)>=2 2332 Field{2}.ZIndex=z_index; 2333 [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1); 2334 if isempty(Field{2}) 2304 XmlData=[];%default 2305 XmlData_1=[];%default 2306 if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority 2307 XmlData=UvData.XmlData{1}; 2308 if numel(UvData.XmlData)==2 2309 XmlData_1=UvData.XmlData{2}; 2310 end 2311 end 2312 transform=get(handles.path_transform,'UserData'); 2313 nbre_arg=nargin(transform); 2314 if length(Field)==2 2315 if nbre_arg==4 2316 [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1); 2317 else 2318 Field{1}=transform(Field{1},XmlData); 2335 2319 Field(2)=[]; 2336 2320 end 2337 2321 else 2338 Field{1}=transform(Field{1},XmlData); 2339 end 2340 end 2322 if nbre_arg==1 2323 Field{1}=transform(Field{1});%transform which does not need input parameter 2324 else 2325 Field{1}=transform(Field{1},XmlData); 2326 end 2327 end 2328 end 2341 2329 %% check whether tps is needed, then calculate tps coefficients if needed 2342 2330 check_proj_tps=0; … … 3100 3088 set(hhget_field.list_fig,'Value',1) 3101 3089 set(hhget_field.list_fig,'String',{'uvmat'}) 3102 set(handles.transform_fct,'Value',1)% no transform by default3103 set(handles.path_transform,'String','')3090 % set(handles.transform_fct,'Value',1)% no transform by default 3091 % set(handles.path_transform,'String','') 3104 3092 return %no action 3105 3093 end … … 3215 3203 set(hhget_field.list_fig,'Value',1) 3216 3204 set(hhget_field.list_fig,'String',{'uvmat'}) 3217 set(handles.transform_fct,'Value',1)% no transform by default3218 set(handles.path_transform,'String','')3205 % set(handles.transform_fct,'Value',1)% no transform by default 3206 % set(handles.path_transform,'String','') 3219 3207 if check_new 3220 3208 UvData.FileType{2}=UvData.FileType{1}; … … 3562 3550 UvData=get(handles.uvmat,'UserData'); 3563 3551 menu=get(handles.transform_fct,'String'); 3564 ind_coord=get(handles.transform_fct,'Value'); 3565 coord_option=menu{ind_coord}; 3566 list_transform=get(handles.transform_fct,'UserData'); 3567 ff=functions(list_transform{end}); 3568 if isequal(coord_option,'more...'); 3569 coord_fct=''; 3570 prompt = {'Enter the name of the transform function'}; 3571 dlg_title = 'user defined transform'; 3572 num_lines= 1; 3552 ichoice=get(handles.transform_fct,'Value');%item number in the menu 3553 transform_name=menu{ichoice};% choice of the transform fct 3554 list_path=get(handles.transform_fct,'UserData'); 3555 3556 %% add a new item to the menu if the option 'more...' has been selected 3557 if strcmp(transform_name,'more...'); 3573 3558 [FileName, PathName] = uigetfile( ... 3574 {'*.m', ' (*.m)';3559 {'*.m', ' (*.m)'; 3575 3560 '*.m', '.m files '; ... 3576 3561 '*.*', 'All Files (*.*)'}, ... 3577 'Pick a file', ff.file); 3578 if isequal(PathName(end),'/')||isequal(PathName(end),'\') 3579 PathName(end)=[]; 3580 end 3581 transform_selected =fullfile(PathName,FileName); 3582 if ~exist(transform_selected,'file') 3583 return 3584 end 3585 [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m 3586 if ~isequal(ext_fct,'.m') 3562 'Pick the transform function', get(handles.path_transform,'String')); 3563 path_transform_fct =fullfile(PathName,FileName); 3564 if ~exist(path_transform_fct,'file')% cancel has been activated 3565 return 3566 end 3567 if isempty(regexp(FileName,'.m$'))% detect file extension .m 3587 3568 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 3588 3569 return 3589 end 3590 menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu 3591 ind_coord=get(handles.transform_fct,'Value'); 3592 addpath(PathName) 3593 list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function 3594 set(handles.transform_fct,'UserData',list_transform) 3595 rmpath(PathName) 3596 % save the new menu in the personal file 'uvmat_perso.mat' 3597 dir_perso=prefdir;%personal Matalb directory 3598 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 3599 if exist(profil_perso,'file') 3600 nb_builtin=UvData.OpenParam.NbBuiltin; 3601 for ilist=nb_builtin+1:numel(list_transform) 3602 ff=functions(list_transform{ilist}); 3603 transform_fct{ilist-nb_builtin}=ff.file; 3604 end 3570 else 3571 transform_name=regexprep(FileName,'.m',''); 3572 end 3573 ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu 3574 if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) 3575 menu=[menu(1:end-1);{transform_name};{'more...'}]; 3576 ichoice=numel(menu)-1; 3577 end 3578 list_path{ichoice}=PathName;%update the list fo fct paths 3579 3580 % save the new menu in the personal file 'uvmat_perso.mat' 3581 dir_perso=prefdir;%personal Matalb directory 3582 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 3583 if exist(profil_perso,'file') 3584 nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat 3585 for ilist=nb_builtin+1:numel(list_path) 3586 transform_fct{ilist-nb_builtin}=fullfile(list_path{ilist},menu{ilist}); 3587 end 3605 3588 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 3606 end 3607 end 3608 3609 %% check the current path to the selected function 3610 if isa(list_transform{ind_coord},'function_handle') 3611 func=functions(list_transform{ind_coord}); 3612 set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function 3613 else 3614 set(handles.path_transform,'String','') 3589 end 3590 end 3591 3592 %% create the function handle of the selected fct 3593 if isempty(list_path{ichoice})% case of no selected fct 3594 transform_handle=[]; 3595 else 3596 if ~exist(list_path{ichoice},'dir') 3597 msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') 3598 return 3599 end 3600 current_dir=pwd;%current working dir 3601 cd(list_path{ichoice}) 3602 transform_handle=str2func(transform_name); 3603 cd(current_dir) 3604 end 3605 set(handles.path_transform,'UserData',transform_handle) 3606 3607 %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file 3608 if isempty(list_path{ichoice})% case of no selected fct 3609 set(handles.transform_fct,'ToolTipString','transform_fct:choose a transform function') 3610 else 3611 try 3612 [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); 3613 InputText=textscan(fid,'%s',1,'delimiter','\n'); 3614 fclose(fid) 3615 set(handles.transform_fct,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help 3616 end 3617 end 3618 3619 %% adapt the GUI to the input/output conditions of the selected transform fct 3620 if isempty(list_path{ichoice})% case of no selected fct 3621 DataOut=[]; 3622 else 3623 if nargin(transform_handle)>1 3624 if isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) 3625 XmlData=UvData.XmlData{1}; 3626 DataOut=feval(transform_handle,'*',XmlData); 3627 end 3628 end 3615 3629 end 3616 3630 3617 3631 set(handles.CheckFixLimits,'Value',0) 3618 3632 set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 3633 3634 %% execute the function to set input an output conditions 3635 3619 3636 3620 3637 %% delete drawn objects … … 4856 4873 end 4857 4874 4875 4876 % -------------------------------------------------------------------- 4877 function MenuSetProject_Callback(hObject, eventdata, handles) 4878 RootPath=get(handles.RootPath,'String'); 4879 ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory'); 4880 datatree_browser(ProjectDir)
Note: See TracChangeset
for help on using the changeset viewer.