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