[12] | 1 | %'dataview': function for scanning directories in a campaign |
---|
[2] | 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function varargout = series(varargin) |
---|
| 4 | % associated with the GUI dataview.fig |
---|
[89] | 5 | |
---|
[17] | 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[2] | 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
[17] | 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[2] | 9 | % This file is part of the toolbox UVMAT. |
---|
| 10 | % |
---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published by |
---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 14 | % (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
[17] | 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[2] | 21 | |
---|
| 22 | function varargout = dataview(varargin) |
---|
| 23 | |
---|
[12] | 24 | % Last Modified by GUIDE v2.5 13-Jan-2010 07:28:19 |
---|
[2] | 25 | |
---|
| 26 | % Begin initialization code - DO NOT EDIT |
---|
| 27 | gui_Singleton = 1; |
---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @dataview_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @dataview_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
[12] | 34 | if nargin & ischar(varargin{1}) |
---|
[2] | 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
[17] | 45 | %------------------------------------------------------------------------ |
---|
[2] | 46 | % --- Executes just before dataview is made visible. |
---|
[12] | 47 | function dataview_OpeningFcn(hObject, eventdata, handles, RootDir, SubCampaignTst,GeometryCalib) |
---|
[17] | 48 | %------------------------------------------------------------------------ |
---|
[2] | 49 | % Choose default command line output for dataview |
---|
[12] | 50 | handles.output = 'Cancel'; |
---|
[2] | 51 | |
---|
| 52 | % Update handles structure |
---|
| 53 | guidata(hObject, handles); |
---|
[12] | 54 | testCancel=1; |
---|
| 55 | testinputstring=0; |
---|
| 56 | icontype='quest';%default question icon (text input asked) |
---|
[2] | 57 | |
---|
[12] | 58 | % Determine the position of the dialog - centered on the screen |
---|
| 59 | FigPos=get(0,'DefaultFigurePosition'); |
---|
| 60 | OldUnits = get(hObject, 'Units'); |
---|
| 61 | set(hObject, 'Units', 'pixels'); |
---|
| 62 | OldPos = get(hObject,'Position'); |
---|
| 63 | FigWidth = OldPos(3); |
---|
| 64 | FigHeight = OldPos(4); |
---|
| 65 | ScreenUnits=get(0,'Units'); |
---|
| 66 | set(0,'Units','pixels'); |
---|
| 67 | ScreenSize=get(0,'ScreenSize'); |
---|
| 68 | set(0,'Units',ScreenUnits); |
---|
| 69 | |
---|
| 70 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth); |
---|
| 71 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight); |
---|
| 72 | FigPos(3:4)=[FigWidth FigHeight]; |
---|
| 73 | set(hObject, 'Position', FigPos); |
---|
| 74 | set(hObject, 'Units', OldUnits); |
---|
| 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 exist('RootDir','var') |
---|
| 97 | set(handles.RootDirectory,'String',RootDir); |
---|
| 98 | set(handles.clean_civ_cmx,'Visible','off') |
---|
| 99 | set(handles.edit_xml,'Visible','off') |
---|
| 100 | set(handles.HELP,'Visible','off') |
---|
| 101 | set(handles.OK,'Visible','on') |
---|
| 102 | set(handles.Cancel,'Visible','on') |
---|
| 103 | set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal |
---|
| 104 | RootDirectory_Callback(hObject, eventdata, handles) |
---|
| 105 | % UIWAIT makes translate_points wait for user response (see UIRESUME) |
---|
| 106 | uiwait(handles.figure); |
---|
| 107 | end |
---|
| 108 | |
---|
| 109 | %------------------------------------------------------------------------ |
---|
[2] | 110 | % --- Outputs from this function are returned to the command line. |
---|
| 111 | function varargout = dataview_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 112 | %------------------------------------------------------------------------ |
---|
[2] | 113 | % Get default command line output from handles structure |
---|
| 114 | varargout{1} = handles.output; |
---|
[12] | 115 | delete(handles.figure) |
---|
[2] | 116 | |
---|
[12] | 117 | %------------------------------------------------------------------------ |
---|
[2] | 118 | % --- Executes on button press in browser. |
---|
| 119 | function browser_Callback(hObject, eventdata, handles) |
---|
[12] | 120 | %------------------------------------------------------------------------ |
---|
| 121 | CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String'); |
---|
[2] | 122 | set(handles.SubCampaignTest,'Value',0) |
---|
| 123 | CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser |
---|
| 124 | set(handles.RootDirectory,'String',CampaignDir) |
---|
| 125 | RootDirectory_Callback(hObject, eventdata, handles) |
---|
| 126 | |
---|
[12] | 127 | %------------------------------------------------------------------------ |
---|
[2] | 128 | % --- Executes on button press in open_SubCampaign. |
---|
| 129 | function OpenSubCampaign_Callback(hObject, eventdata, handles) |
---|
[12] | 130 | %------------------------------------------------------------------------ |
---|
[2] | 131 | CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String'); |
---|
| 132 | set(handles.SubCampaignTest,'Value',1) |
---|
| 133 | CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser |
---|
| 134 | set(handles.RootDirectory,'String',CampaignDir) |
---|
| 135 | RootDirectory_Callback(hObject, eventdata, handles) |
---|
| 136 | |
---|
| 137 | %------------------------------------------------------------------------ |
---|
| 138 | function RootDirectory_Callback(hObject, eventdata, handles) |
---|
[12] | 139 | %------------------------------------------------------------------------ |
---|
[2] | 140 | CampaignDir=get(handles.RootDirectory,'String'); |
---|
[12] | 141 | ExpName={''}; |
---|
[2] | 142 | if exist(CampaignDir,'dir') |
---|
| 143 | hdir=dir(CampaignDir); %list files and dirs |
---|
| 144 | idir=0; |
---|
| 145 | for ilist=1:length(hdir) |
---|
| 146 | if hdir(ilist).isdir |
---|
| 147 | dirname=hdir(ilist).name; |
---|
| 148 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 149 | idir=idir+1; |
---|
| 150 | ExpName{idir}=hdir(ilist).name; |
---|
| 151 | end |
---|
| 152 | % look for the list of 'devices' |
---|
| 153 | else |
---|
| 154 | %warning for isolated files |
---|
| 155 | end |
---|
| 156 | end |
---|
| 157 | set(handles.ListExperiments,'String',[{'*'};ExpName']) |
---|
| 158 | set(handles.ListExperiments,'Value',1) |
---|
| 159 | ListExperiments_Callback(hObject, eventdata, handles) |
---|
| 160 | else |
---|
[12] | 161 | msgbox_uvmat('ERROR',['The input ' CampaignDir ' is not a directory']) |
---|
[2] | 162 | end |
---|
| 163 | |
---|
| 164 | %------------------------------------------------------------------------ |
---|
| 165 | % --- Executes on selection change in ListExperiments. |
---|
| 166 | function ListExperiments_Callback(hObject, eventdata, handles) |
---|
[12] | 167 | %------------------------------------------------------------------------ |
---|
[2] | 168 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 169 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 170 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 171 | if isequal(list_val(1),1) |
---|
| 172 | ListExperiments=ListExperiments(2:end); %choose all experiments |
---|
| 173 | testList=1; |
---|
| 174 | set(handles.ListExperiments,'Value',1) |
---|
| 175 | else |
---|
| 176 | ListExperiments=ListExperiments(list_val);%choose selected experiments |
---|
| 177 | testList=0; |
---|
| 178 | end |
---|
| 179 | set(handles.ListDevices,'Value',1) |
---|
| 180 | set(handles.ListRecords,'Value',1) |
---|
| 181 | set(handles.ListXml,'Value',1) |
---|
| 182 | [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,{},{}); |
---|
| 183 | set(handles.ListRecords,'String',[{'*'};ListRecords']) |
---|
| 184 | set(handles.ListDevices,'String',[{'*'};ListDevices']) |
---|
| 185 | set(handles.ListXml,'String',[{'*'};ListXml']) |
---|
| 186 | if testList |
---|
[12] | 187 | DataviewData=get(handles.figure,'UserData'); |
---|
| 188 | DataView.List=List; |
---|
| 189 | set(handles.figure,'UserData',DataviewData) |
---|
[2] | 190 | end |
---|
| 191 | set(handles.CampaignDoc,'Visible','on') |
---|
[12] | 192 | % set(handles.edit_xml,'Visible','on') |
---|
[2] | 193 | |
---|
| 194 | %------------------------------------------------------------------------ |
---|
| 195 | % --- Executes on button press in update_headings. |
---|
| 196 | function ListDevices_Callback(hObject, eventdata, handles) |
---|
| 197 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 198 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 199 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 200 | if isequal(list_val,1) |
---|
| 201 | ListExperiments=ListExperiments(2:end); |
---|
| 202 | else |
---|
| 203 | ListExperiments=ListExperiments(list_val); |
---|
| 204 | end |
---|
| 205 | set(handles.ListRecords,'Value',1) |
---|
| 206 | set(handles.ListXml,'Value',1) |
---|
| 207 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 208 | list_val=get(handles.ListDevices,'Value'); |
---|
| 209 | if isequal(list_val,1) |
---|
| 210 | ListDevices=ListDevices(2:end); |
---|
| 211 | else |
---|
| 212 | ListDevices=ListDevices(list_val); |
---|
| 213 | end |
---|
| 214 | [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); |
---|
| 215 | set(handles.ListRecords,'String',[{'*'};ListRecords']) |
---|
| 216 | set(handles.ListXml,'String',[{'*'};ListXml']) |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 220 | |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | %------------------------------------------------------------------------ |
---|
| 224 | % --- Executes on selection change in ListRecords. |
---|
| 225 | function ListRecords_Callback(hObject, eventdata, handles) |
---|
| 226 | Value=get(handles.ListRecords,'Value'); |
---|
| 227 | if isequal(Value(1),1) |
---|
| 228 | set(handles.ListRecords,'Value',1); |
---|
| 229 | end |
---|
| 230 | |
---|
| 231 | %------------------------------------------------------------------------ |
---|
| 232 | % --- Executes on button press in CampaignDoc. |
---|
| 233 | function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
| 234 | %------------------------------------------------------------------------ |
---|
| 235 | 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') |
---|
| 236 | if ~isequal(answer{1},'OK') |
---|
| 237 | return |
---|
| 238 | end |
---|
| 239 | set(handles.ListExperiments,'Value',1) |
---|
| 240 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
[12] | 241 | DataviewData=get(handles.figure,'UserData'); |
---|
| 242 | List=DataviewData.List; |
---|
[2] | 243 | Currentpath=get(handles.RootDirectory,'String'); |
---|
| 244 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 245 | Campaign=[Campaign DirExt]; |
---|
| 246 | t=xmltree; |
---|
| 247 | t=set(t,1,'name','CampaignDoc'); |
---|
| 248 | t = attributes(t,'add',1,'source','directory'); |
---|
| 249 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 250 | root_uid=1; |
---|
| 251 | if SubCampaignTest |
---|
| 252 | %TO DO open an exoiting xml doc |
---|
| 253 | [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
| 254 | t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
| 255 | end |
---|
| 256 | for iexp=1:length(List.Experiment) |
---|
| 257 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 258 | drawnow |
---|
| 259 | test_mod=0; |
---|
| 260 | [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
| 261 | t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
| 262 | ExpName=List.Experiment{iexp}.name; |
---|
| 263 | t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
| 264 | |
---|
| 265 | if isfield(List.Experiment{iexp},'Device') |
---|
| 266 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 267 | [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
| 268 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 269 | t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
| 270 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 271 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 272 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 273 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
| 274 | if test |
---|
| 275 | [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] |
---|
| 276 | end |
---|
| 277 | if isequal(Title,'ImaDoc') |
---|
| 278 | [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
| 279 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 280 | [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
| 281 | end |
---|
| 282 | end |
---|
| 283 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 284 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 285 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 286 | [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
| 287 | t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
| 288 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 289 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 290 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 291 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
| 292 | if test |
---|
| 293 | [FileName ' , Heading updated'] |
---|
| 294 | end |
---|
| 295 | [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
| 296 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 297 | [t]=add(t,uid_xml,'chardata',FileName); |
---|
| 298 | end |
---|
| 299 | end |
---|
| 300 | end |
---|
| 301 | end |
---|
| 302 | end |
---|
| 303 | end |
---|
| 304 | end |
---|
| 305 | set(handles.ListExperiments,'Value',1) |
---|
| 306 | outputdir=get(handles.RootDirectory,'String'); |
---|
| 307 | [path,dirname]=fileparts(outputdir); |
---|
| 308 | outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
| 309 | %campaigndoc(t); |
---|
| 310 | save(t,outputfile) |
---|
| 311 | |
---|
| 312 | %------------------------------------------------------------------------ |
---|
| 313 | % --- Executes on button press in CampaignDoc. |
---|
| 314 | function edit_xml_Callback(hObject, eventdata, handles) |
---|
| 315 | %------------------------------------------------------------------------ |
---|
| 316 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 317 | %[CurrentPath,Name,Ext]=fileparts(CurrentDir); |
---|
| 318 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 319 | Value=get(handles.ListExperiments,'Value'); |
---|
| 320 | if ~isequal(Value,1) |
---|
| 321 | ListExperiments=ListExperiments(Value); |
---|
| 322 | end |
---|
| 323 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 324 | Value=get(handles.ListDevices,'Value'); |
---|
| 325 | if ~isequal(Value,1) |
---|
| 326 | ListDevices=ListDevices(Value); |
---|
| 327 | end |
---|
| 328 | ListRecords=get(handles.ListRecords,'String'); |
---|
| 329 | Value=get(handles.ListRecords,'Value'); |
---|
| 330 | if ~isequal(Value,1) |
---|
| 331 | ListRecords=ListRecords(Value); |
---|
| 332 | end |
---|
| 333 | [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 334 | ListXml=get(handles.ListXml,'String'); |
---|
| 335 | Value=get(handles.ListXml,'Value'); |
---|
| 336 | set(handles.ListXml,'Value',Value(1)); |
---|
| 337 | if isequal(Value(1),1) |
---|
[42] | 338 | msgbox_uvmat('ERROR','an xml file needs to be selected') |
---|
[2] | 339 | return |
---|
| 340 | else |
---|
| 341 | XmlName=ListXml{Value(1)}; |
---|
| 342 | end |
---|
| 343 | for iexp=1:length(List.Experiment) |
---|
| 344 | ExpName=List.Experiment{iexp}.name; |
---|
| 345 | if isfield(List.Experiment{iexp},'Device') |
---|
| 346 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 347 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 348 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 349 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 350 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} |
---|
| 351 | if isequal(FileName,XmlName) |
---|
| 352 | editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); |
---|
| 353 | return |
---|
| 354 | end |
---|
| 355 | end |
---|
| 356 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 357 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 358 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 359 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 360 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 361 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 362 | if isequal(FileName,XmlName) |
---|
| 363 | editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); |
---|
| 364 | return |
---|
| 365 | end |
---|
| 366 | end |
---|
| 367 | end |
---|
| 368 | end |
---|
| 369 | end |
---|
| 370 | end |
---|
| 371 | end |
---|
| 372 | end |
---|
| 373 | |
---|
| 374 | |
---|
| 375 | |
---|
| 376 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 377 | % CurrentPath/Campaign: root directory |
---|
| 378 | function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) |
---|
| 379 | |
---|
| 380 | %Shema for Heading: |
---|
| 381 | % Campaign |
---|
| 382 | % (SubCampaign) |
---|
| 383 | % Experiment |
---|
| 384 | % Device |
---|
| 385 | % (Record) |
---|
| 386 | % ImageName |
---|
| 387 | % DateExp |
---|
| 388 | % old: %Project: suppressed ( changed to Campaign) |
---|
| 389 | %Exp: suppressed (changed to experiment) |
---|
| 390 | %ImaNames: changed to ImageName |
---|
| 391 | if exist('Record','var') && ~isempty(Record) |
---|
| 392 | xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); |
---|
| 393 | testrecord=1; |
---|
| 394 | else |
---|
| 395 | xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); |
---|
| 396 | testrecord=0; |
---|
| 397 | end |
---|
| 398 | if ~exist('testSubCampaign','var') |
---|
| 399 | testSubCampaign=0; |
---|
| 400 | end |
---|
| 401 | if testSubCampaign |
---|
| 402 | SubCampaign=Campaign; |
---|
| 403 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 404 | Campaign=[Campaign DirExt]; |
---|
| 405 | end |
---|
| 406 | test_mod=0; %test for the modification of the xml file |
---|
| 407 | t_device=xmltree(xmlfullname); |
---|
| 408 | Title=get(t_device,1,'name'); |
---|
| 409 | uid_child=children(t_device,1); |
---|
| 410 | Heading_old=[]; |
---|
| 411 | uidheading=0; |
---|
| 412 | for ilist=1:length(uid_child) |
---|
| 413 | name=get(t_device,uid_child(ilist),'name'); |
---|
| 414 | if isequal(name,'Heading') |
---|
| 415 | uidheading=uid_child(ilist); |
---|
| 416 | end |
---|
| 417 | end |
---|
| 418 | if uidheading |
---|
| 419 | subt=branch(t_device,uidheading); |
---|
| 420 | Heading_old=convert(subt); |
---|
| 421 | else |
---|
| 422 | return % do not edit xml files without element 'Heading' |
---|
| 423 | end |
---|
| 424 | if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) |
---|
| 425 | test_mod=1; |
---|
| 426 | end |
---|
| 427 | Heading.Campaign=Campaign; |
---|
| 428 | if testSubCampaign |
---|
| 429 | if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) |
---|
| 430 | test_mod=1; |
---|
| 431 | end |
---|
| 432 | Heading.SubCampaign=SubCampaign; |
---|
| 433 | end |
---|
| 434 | if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) |
---|
| 435 | test_mod=1; |
---|
| 436 | end |
---|
| 437 | Heading.Experiment=Experiment; |
---|
| 438 | if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) |
---|
| 439 | test_mod=1; |
---|
| 440 | end |
---|
| 441 | Heading.Device=Device; |
---|
| 442 | if testrecord |
---|
| 443 | if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) |
---|
| 444 | test_mod=1; |
---|
| 445 | end |
---|
| 446 | Heading.Record=Record; |
---|
| 447 | end |
---|
| 448 | if isfield(Heading_old,'ImaNames') |
---|
| 449 | test_mod=1; |
---|
| 450 | if ~isempty(Heading_old.ImaNames) |
---|
| 451 | Heading.ImageName=Heading_old.ImaNames; |
---|
| 452 | end |
---|
| 453 | end |
---|
| 454 | if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) |
---|
| 455 | Heading.ImageName=Heading_old.ImageName; |
---|
| 456 | end |
---|
| 457 | if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) |
---|
| 458 | Heading.DateExp=Heading_old.DateExp; |
---|
| 459 | end |
---|
| 460 | if test_mod && uidheading |
---|
| 461 | uid_child=children(t_device,uidheading); |
---|
| 462 | t_device=delete(t_device,uid_child); |
---|
| 463 | t_device=struct2xml(Heading,t_device,uidheading); |
---|
| 464 | backupfile=xmlfullname; |
---|
| 465 | testexist=2; |
---|
| 466 | while testexist==2 |
---|
| 467 | backupfile=[backupfile '~']; |
---|
| 468 | testexist=exist(backupfile,'file'); |
---|
| 469 | end |
---|
| 470 | [success,message]=copyfile(xmlfullname,backupfile);%make backup |
---|
| 471 | if isequal(success,1) |
---|
| 472 | delete(xmlfullname) |
---|
| 473 | else |
---|
| 474 | return |
---|
| 475 | end |
---|
| 476 | save(t_device,xmlfullname) |
---|
| 477 | end |
---|
| 478 | |
---|
[12] | 479 | %------------------------------------------------------------------------ |
---|
[2] | 480 | % --- Executes on button press in HELP. |
---|
| 481 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 482 | path_to_uvmat=which ('uvmat')% check the path of uvmat |
---|
| 483 | pathelp=fileparts(path_to_uvmat); |
---|
| 484 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
[12] | 485 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
[2] | 486 | else |
---|
| 487 | web([helpfile '#dataview']) |
---|
| 488 | end |
---|
| 489 | |
---|
| 490 | |
---|
| 491 | |
---|
| 492 | % --- Executes on selection change in ListXml. |
---|
| 493 | function ListXml_Callback(hObject, eventdata, handles) |
---|
| 494 | Value=get(handles.ListXml,'Value'); |
---|
| 495 | if isequal(Value(1),1) |
---|
| 496 | set(handles.ListXml,'Value',1); |
---|
| 497 | end |
---|
| 498 | |
---|
| 499 | |
---|
| 500 | % --- Executes on button press in clean_civ_cmx. |
---|
| 501 | function clean_civ_cmx_Callback(hObject, eventdata, handles) |
---|
| 502 | message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)'; |
---|
| 503 | answer=msgbox_uvmat('INPUT_Y-N',message); |
---|
| 504 | if ~isequal(answer{1},'OK') |
---|
| 505 | return |
---|
| 506 | end |
---|
| 507 | set(handles.ListExperiments,'Value',1) |
---|
| 508 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
[12] | 509 | DataviewData=get(handles.figure,'UserData'); |
---|
| 510 | List=DataviewData.List; |
---|
[2] | 511 | Currentpath=get(handles.RootDirectory,'String'); |
---|
| 512 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 513 | Campaign=[Campaign DirExt]; |
---|
| 514 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 515 | nbdelete_tot=0; |
---|
| 516 | for iexp=1:length(List.Experiment) |
---|
| 517 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 518 | drawnow |
---|
| 519 | test_mod=0; |
---|
| 520 | ExpName=List.Experiment{iexp}.name; |
---|
| 521 | nbdelete=0; |
---|
| 522 | if isfield(List.Experiment{iexp},'Device') |
---|
| 523 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 524 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 525 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 526 | currentdir=fullfile(Currentpath,Campaign,ExpName,DeviceName); |
---|
| 527 | hdir=dir(currentdir); %list files and dirs |
---|
| 528 | idir=0; |
---|
| 529 | for ilist=1:length(hdir) |
---|
| 530 | if hdir(ilist).isdir |
---|
| 531 | dirname=hdir(ilist).name; |
---|
| 532 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 533 | CivDir=fullfile(currentdir,dirname) |
---|
| 534 | hCivDir=dir(CivDir); |
---|
| 535 | for ilist=1:length(hCivDir) |
---|
| 536 | FileName=hCivDir(ilist).name; |
---|
| 537 | [dd,ff,Ext]=fileparts(FileName); |
---|
| 538 | if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors') |
---|
| 539 | delete(fullfile(CivDir,FileName)) |
---|
| 540 | nbdelete=nbdelete+1; |
---|
| 541 | end |
---|
| 542 | end |
---|
| 543 | end |
---|
| 544 | end |
---|
| 545 | end |
---|
| 546 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 547 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 548 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 549 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 550 | 'look at subdirectories' |
---|
| 551 | end |
---|
| 552 | end |
---|
| 553 | end |
---|
| 554 | end |
---|
| 555 | end |
---|
| 556 | display([num2str(nbdelete) ' files deleted']) |
---|
| 557 | nbdelete_tot=nbdelete_tot+nbdelete; |
---|
| 558 | end |
---|
| 559 | msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete_tot) ' files deleted by clean_civ_cmx']) |
---|
| 560 | set(handles.ListExperiments,'Value',1) |
---|
| 561 | |
---|
| 562 | |
---|
[12] | 563 | % --- Executes on button press in OK. |
---|
| 564 | function OK_Callback(hObject, eventdata, handles) |
---|
| 565 | %------------------------------------------------------------------------ |
---|
| 566 | CurrentPath=get(handles.RootDirectory,'String'); |
---|
| 567 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 568 | IndicesExp=get(handles.ListExperiments,'Value'); |
---|
| 569 | if ~isequal(IndicesExp,1) |
---|
| 570 | ListExperiments=ListExperiments(IndicesExp); |
---|
| 571 | end |
---|
| 572 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 573 | Value=get(handles.ListDevices,'Value'); |
---|
| 574 | if isequal(Value,1) |
---|
| 575 | msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') |
---|
| 576 | return |
---|
| 577 | else |
---|
| 578 | ListDevices=ListDevices(Value); |
---|
| 579 | end |
---|
| 580 | ListRecords=get(handles.ListRecords,'String'); |
---|
| 581 | Value=get(handles.ListRecords,'Value'); |
---|
| 582 | if ~isequal(Value,1) |
---|
| 583 | ListRecords=ListRecords(Value); |
---|
| 584 | end |
---|
| 585 | [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 586 | ListXml=get(handles.ListXml,'String'); |
---|
| 587 | Value=get(handles.ListXml,'Value'); |
---|
| 588 | if isequal(Value,1) |
---|
| 589 | msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') |
---|
| 590 | return |
---|
| 591 | else |
---|
| 592 | ListXml=ListXml(Value); |
---|
| 593 | end |
---|
[2] | 594 | |
---|
[12] | 595 | %update all the selected xml files |
---|
| 596 | DataviewData=get(handles.figure,'UserData'); |
---|
| 597 | % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... |
---|
| 598 | % DataviewData.GeometryCalib.CalibrationType ' calibration data']) |
---|
| 599 | % if ~isequal(answer,'Yes') |
---|
| 600 | % return |
---|
| 601 | % end |
---|
| 602 | %List.Experiment{1}.Device{1} |
---|
| 603 | %List.Experiment{2}.Device{1} |
---|
| 604 | for iexp=1:length(List.Experiment) |
---|
| 605 | ExpName=List.Experiment{iexp}.name; |
---|
| 606 | set(handles.ListExperiments,'Value',IndicesExp(iexp)); |
---|
| 607 | if isfield(List.Experiment{iexp},'Device') |
---|
| 608 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 609 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 610 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 611 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 612 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 613 | for ilistxml=1:length(ListXml) |
---|
| 614 | if isequal(FileName,ListXml{ilistxml}) |
---|
| 615 | set(handles.ListXml,'Value',Value(ilistxml)) |
---|
| 616 | drawnow |
---|
| 617 | xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); |
---|
| 618 | update_imadoc(DataviewData.GeometryCalib,xmlfullname) |
---|
| 619 | display([xmlfullname ' updated']) |
---|
| 620 | break |
---|
| 621 | end |
---|
| 622 | end |
---|
| 623 | end |
---|
| 624 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 625 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 626 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 627 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 628 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 629 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 630 | for ilistxml=1:length(ListXml) |
---|
| 631 | if isequal(FileName,ListXml{ilistxml}) |
---|
| 632 | set(handles.ListXml,'Value',Value(ilistxml)) |
---|
| 633 | drawnow |
---|
| 634 | xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); |
---|
| 635 | update_imadoc(DataviewData.GeometryCalib,xmlfullname) |
---|
| 636 | display([xmlfullname ' updated']) |
---|
| 637 | break |
---|
| 638 | end |
---|
| 639 | end |
---|
| 640 | end |
---|
| 641 | end |
---|
| 642 | end |
---|
| 643 | end |
---|
| 644 | end |
---|
| 645 | end |
---|
| 646 | end |
---|
| 647 | set(handles.ListXml,'Value',Value) |
---|
| 648 | % |
---|
| 649 | % |
---|
| 650 | % |
---|
| 651 | % |
---|
| 652 | % |
---|
| 653 | % |
---|
| 654 | % |
---|
| 655 | % CurrentPath=get(handles.RootDirectory,'String');%= get(hObject,'String'); |
---|
| 656 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 657 | % Value=get(handles.ListExperiments,'Value'); |
---|
| 658 | % if ~isequal(Value,1) |
---|
| 659 | % ListExperiments=ListExperiments(Value); |
---|
| 660 | % end |
---|
| 661 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 662 | % Value=get(handles.ListDevices,'Value'); |
---|
| 663 | % if isequal(Value,1) |
---|
| 664 | % msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') |
---|
| 665 | % return |
---|
| 666 | % else |
---|
| 667 | % ListDevices=ListDevices(Value); |
---|
| 668 | % end |
---|
| 669 | % ListRecords=get(handles.ListRecords,'String'); |
---|
| 670 | % Value=get(handles.ListRecords,'Value'); |
---|
| 671 | % if ~isequal(Value,1) |
---|
| 672 | % ListRecords=ListRecords(Value); |
---|
| 673 | % end |
---|
| 674 | % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 675 | % ListXml=get(handles.ListXml,'String'); |
---|
| 676 | % Value=get(handles.ListXml,'Value'); |
---|
| 677 | % if isequal(Value,1) |
---|
| 678 | % msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') |
---|
| 679 | % return |
---|
| 680 | % else |
---|
| 681 | % ListXml=ListXml(Value); |
---|
| 682 | % end |
---|
| 683 | % handles.output.CurrentPath=CurrentPath; |
---|
| 684 | % handles.output.ListExperiments=ListExperiments; |
---|
| 685 | % handles.output.ListDevices=ListDevices; |
---|
| 686 | % handles.output.ListRecords=ListRecords; |
---|
| 687 | % handles.output.ListXml=ListXml; |
---|
| 688 | % handles.output.List=List; |
---|
| 689 | handles.output ='OK, Calibration replicated'; |
---|
| 690 | guidata(hObject, handles);% Update handles structure |
---|
| 691 | uiresume(handles.figure); |
---|
[2] | 692 | |
---|
[12] | 693 | % --- Executes on button press in Cancel. |
---|
| 694 | function Cancel_Callback(hObject, eventdata, handles) |
---|
| 695 | handles.output = get(hObject,'String'); |
---|
| 696 | guidata(hObject, handles); % Update handles structure |
---|
| 697 | % Use UIRESUME instead of delete because the OutputFcn needs |
---|
| 698 | uiresume(handles.figure); |
---|
| 699 | |
---|
| 700 | % --- Executes when user attempts to close figure. |
---|
| 701 | function figure_CloseRequestFcn(hObject, eventdata, handles) |
---|
| 702 | if isequal(get(handles.figure, 'waitstatus'), 'waiting') |
---|
| 703 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 704 | uiresume(handles.figure); |
---|
| 705 | else |
---|
| 706 | % The GUI is no longer waiting, just close it |
---|
| 707 | delete(handles.figure); |
---|
| 708 | end |
---|
| 709 | |
---|
| 710 | % --- Executes on key press over figure1 with no controls selected. |
---|
| 711 | function figure_KeyPressFcn(hObject, eventdata, handles) |
---|
| 712 | % Check for "enter" or "escape" |
---|
| 713 | if isequal(get(hObject,'CurrentKey'),'escape') |
---|
| 714 | % User said no by hitting escape |
---|
| 715 | handles.output = 'Cancel'; |
---|
| 716 | |
---|
| 717 | % Update handles structure |
---|
| 718 | guidata(hObject, handles); |
---|
| 719 | |
---|
| 720 | uiresume(handles.figure); |
---|
| 721 | end |
---|
| 722 | if isequal(get(hObject,'CurrentKey'),'return') |
---|
| 723 | uiresume(handles.figure); |
---|
| 724 | end |
---|