Changeset 1076 for trunk


Ignore:
Timestamp:
Jan 24, 2020, 8:26:09 PM (4 years ago)
Author:
sommeria
Message:

LIF calibration with mode replicate

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r1071 r1076  
    7676set(hObject, 'Position', FigPos);
    7777set(hObject, 'Units', OldUnits);
    78 % if exist('MultiDevices','var') && strcmp(MultiDevices,'on')
    79 %     set(handles.DataSeries,'Max',2)
    80 % else
    81 %     set(handles.DataSeries,'Max',1)
    82 % end
    8378if exist('EnableMirror','var') && strcmp(EnableMirror,'on')
    8479    set(handles.CreateMirror,'Visible','on')
     
    113108end
    114109s=[];
    115 % if exist(RootXml,'file')
    116 %     [s,Heading]=xml2struct(RootXml);%read the xml file
    117 %     if isfield(s,'SourceDir')
    118 %         set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened
    119 %         set(handles.MirrorDir,'Visible','on');%  mirror dir display
    120 %         set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir
    121 %         set(handles.CreateMirror,'String','update_mirror')
    122 %     end
    123 % end
    124110if isempty(s) %a source dir has been opened
    125111    set(handles.SourceDir,'String',SourceDir{1});
     
    355341    ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    356342    ListFiles=ListCells(1,:);
    357     check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     343    index_isdir=find(strcmp('isdir',fieldnames(ListStruct)));
     344    check_dir=cell2mat(ListCells(index_isdir,:));% =1 for directories, =0 for files
    358345    ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    359346    cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     
    383370    ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    384371    ListFiles=ListCells(1,:);
    385     check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     372    index_isdir=find(strcmp('isdir',fieldnames(ListStruct)));
     373    check_dir=cell2mat(ListCells(index_isdir,:));% =1 for directories, =0 for files
    386374    ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    387375    cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     
    430418                ListFiles=ListCells(1,:);
    431419                check_xml=~cellfun('isempty',regexp(ListFiles,'(\.xml|~)$'));% detect non xml files and files not marked by ~
    432                 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     420                index_isdir=find(strcmp('isdir',fieldnames(ListStruct)));
     421                check_dir=cell2mat(ListCells(index_isdir,:));% =1 for directories, =0 for files
    433422                nbfiles=numel(find(~check_xml & ~check_dir));% number of non xml files
    434423                check_dir=check_dir & cellfun('isempty', regexp(ListFiles,'^(-|\.|\+/\.)'));% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     
    481470        cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
    482471        check_keep=cellfun('isempty', cell_remove);
    483         check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     472        index_isdir=find(strcmp('isdir',fieldnames(ListStruct)));
     473        check_dir=cell2mat(ListCells(index_isdir,:));% =1 for directories, =0 for files
    484474        for ilist=1:numel(ListFiles)
    485475            if check_keep(ilist)% loop on eligible DataSeries folders
  • trunk/src/geometry_calib.m

    r1071 r1076  
    269269    %%%%% use of the option 'replicate'
    270270    if get(handles.Replicate,'Value')% if the option replicate is activated
    271         nbcalib=0;
     271        %nbcalib=0;
    272272        %% open the GUI browse_data
    273273        hbrowse=findobj(allchild(0),'Tag','browse_data');
    274         if ~isempty(hbrowse)% look for the GUI 'replicate'
     274        if ~isempty(hbrowse)% look for the GUI browse_data
    275275            BrowseData=guidata(hbrowse);
    276276            SourceDir=get(BrowseData.SourceDir,'String');
     
    322322                        display([XmlName ' created with calibration parameters'])
    323323                    end
    324                     nbcalib=nbcalib+1;
     324                    %nbcalib=nbcalib+1;
    325325                end
    326326            end
  • trunk/src/update_imadoc.m

    r1071 r1076  
    3131testappend=0;
    3232%% backup the output file if it already exist, and read it
    33 if exist(outputfile,'file');%=1 if the output file already exists, 0 else
     33if exist(outputfile,'file')%=1 if the output file already exists, 0 else
    3434    testappend=1;
    3535    backupfile=outputfile;
  • trunk/src/uvmat.m

    r1075 r1076  
    12881288    'TEST'
    12891289else
    1290 
    1291 %% store the result in the xml file used for calibration
    1292 errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
    1293 if strcmp(errormsg,'')
    1294     msgbox_uvmat('CONFIRMATION',['slice positions saved in ' XmlFile]);
    1295 else
    1296     msgbox_uvmat('ERROR',errormsg);
    1297 end
    1298 
    1299 %% display image with new calibration in the currently opened uvmat interface
    1300 %set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
    1301 uvmat('InputFileREFRESH_Callback',huvmat,[],hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    1302 set(hObject,'BackgroundColor',[1 0 0]);% paint button back to red
     1290   
     1291    %% store the result in the xml file used for calibration
     1292    errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
     1293    if strcmp(errormsg,'')
     1294        msgbox_uvmat('CONFIRMATION',['slice positions saved in ' XmlFile]);
     1295    else
     1296        msgbox_uvmat('ERROR',errormsg);
     1297    end
     1298   
     1299    %% display image with new calibration in the currently opened uvmat interface
     1300    %set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
     1301    uvmat('InputFileREFRESH_Callback',huvmat,[],hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     1302    set(hObject,'BackgroundColor',[1 0 0]);% paint button back to red
    13031303end
    13041304
     
    13231323end
    13241324
    1325 %
    1326 % set(hObject,'BackgroundColor',[1 1 0])
    1327 % drawnow
    1328 %
    1329 % %% read the GUI set_slice
    1330 % SliceData=read_GUI(get(hObject,'parent'));
    1331 %
    1332 % %% get info on the GUI uvmat
    1333 % huvmat=findobj(allchild(0),'Tag','uvmat');
    1334 % hhuvmat=guidata(huvmat);
    1335 % RootPath=read_file_boxes(hhuvmat);
    1336 %
    1337 % OutPutDir=uigetfile_uvmat('choose an image folder to document with slice position?',fileparts(RootPath),'uigetdir');
    1338 % OutPut=browse_data(OutPutDir,'off','on');
    1339 % nbcalib=0;
    1340 % for ilist=1:numel(OutPut.Experiment)
    1341 %     for idevice=1:numel(OutPut.DataSeries)
    1342 %         SubDirBase=regexprep(OutPut.DataSeries{idevice},'\..+$','');
    1343 %         XmlFile=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']);
    1344 %
    1345 %         % read the current xml file
    1346 %         if  exist(XmlFile,'file')
    1347 %             [s,errormsg]=imadoc2struct(XmlFile,'GeometryCalib');
    1348 %             if ~isempty(errormsg)
    1349 %                 msgbox_uvmat('ERROR',['error in reading ' XmlFile ': ' errormsg])
    1350 %                 return
    1351 %             end
    1352 %             GeometryCalib=s.GeometryCalib;
    1353 %             GeometryCalib.NbSlice=SliceData.NbSlice;
    1354 %             GeometryCalib.CheckVolumeScan=SliceData.CheckVolumeScan;
    1355 %             Z_plane=linspace(SliceData.Z(1),SliceData.Z(2),SliceData.NbSlice);
    1356 %             GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
    1357 %             GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3);
    1358 %             Angle_1=linspace(SliceData.SliceAngle_1(1),SliceData.SliceAngle_1(2),SliceData.NbSlice);
    1359 %             Angle_2=linspace(SliceData.SliceAngle_2(1),SliceData.SliceAngle_2(2),SliceData.NbSlice);
    1360 %             GeometryCalib.SliceAngle(:,1)=Angle_1';%rotation around x axis (to generalise)
    1361 %             GeometryCalib.SliceAngle(:,2)=Angle_2';%rotation around y axis (to generalise)
    1362 %             GeometryCalib.SliceAngle(:,3)=0;
    1363 %             if SliceData.CheckRefraction
    1364 %                 GeometryCalib.InterfaceCoord=[0 0 SliceData.H];
    1365 %                 GeometryCalib.RefractionIndex=SliceData.RefractionIndex;
    1366 %             elseif isfield(GeometryCalib,'RefractionIndex')
    1367 %                 GeometryCalib=rmfield(GeometryCalib,'RefractionIndex');
    1368 %                 GeometryCalib=rmfield(GeometryCalib,'InterfaceCoord');
    1369 %             end
    1370 %
    1371 %             % update the current xml file
    1372 %             errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
    1373 %             if ~strcmp(errormsg,'')
    1374 %                 msgbox_uvmat('ERROR',errormsg);
    1375 %             else
    1376 %                 display([XmlFile ' updated with slice positions'])
    1377 %                 nbcalib=nbcalib+1;
    1378 %             end
    1379 %         end
    1380 %     end
    1381 % end
    1382 % set(hObject,'BackgroundColor',[1 0 0])
    1383 % msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated with slice positions for ' num2str(nbcalib) ' experiments']);
    1384 %
    13851325
    13861326%------------------------------------------------------------------------
     
    14311371        UvData.ProjObject{5}=data;
    14321372        UvData.ProjObject{5}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{5},UvData.ProjObject{1},handles.PlotAxes,'b');
    1433     end     
    1434 end
    1435 set(handles.ListObject,'String',ListObjectName)
    1436 set(handles.ListObject,'Value',1)
    1437 set(handles.uvmat,'UserData',UvData);
    1438 
     1373    end
     1374    set(handles.ListObject,'String',ListObjectName)
     1375    set(handles.ListObject,'Value',1)
     1376    set(handles.uvmat,'UserData',UvData);
     1377    answer=msgbox_uvmat('INPUT_Y-N', 'keep calibration lines'); 
     1378    if ~strcmp(answer,'Yes')
     1379        return
     1380    end
     1381end
    14391382%% read lines currently drawn
    14401383ListObj=UvData.ProjObject;% get the current list of projection objects
     
    14421385select_mask=zeros(1,numel(ListObj));
    14431386for iobj=1:numel(ListObj)
    1444     if isfield(ListObj{iobj},'Type') && strcmp(ListObj{iobj}.Type,'line')&& ~strcmp(ListObj{iobj}.Name,'MaskPolygon')
     1387    if isfield(ListObj{iobj},'Type') && strcmp(ListObj{iobj}.Type,'line')
    14451388        select_line(iobj)=1;% select the lines among the projection objects
    14461389    end
     
    14551398else
    14561399    LineData=UvData.ProjObject(find(select_line));
    1457     for iobj=1:length(LineData)
     1400    for iobj=1:2
    14581401            xA(iobj)=LineData{iobj}.Coord(1,1);
    14591402            yA(iobj)=LineData{iobj}.Coord(1,2);
     
    14651408
    14661409%% set the image offset
    1467 blackoffset=0;
     1410BlackOffset=0;
     1411RefLineWidth=20;
    14681412if isfield(XmlData,'LIFCalib')&& isfield(XmlData.LIFCalib,'BlackOffset')
    1469     blackoffset=XmlData.LIFCalib.BlackOffset ;% image value for black background, to be determined by taking images with a cover on the objective lens
    1470 end
    1471 
    1472 prompt = {'offset luminosity value in the absence of illumination';'smoothing length for the reference line (in pixels)'};
     1413    BlackOffset=XmlData.LIFCalib.BlackOffset ;% image value for black background, to be determined by taking images with a cover on the objective lens
     1414    RefLineWidth=XmlData.LIFCalib.RefLineWidth;
     1415end
     1416
     1417prompt = {'offset luminosity value in the absence of illumination';'smoothing width for the reference line (in pixels)'};
    14731418    dlg_title = 'set the parameters for LIF';
    14741419    num_lines= 2;
    1475     def     = { '0';'20'};
     1420    def     = { num2str(BlackOffset);num2str(RefLineWidth)};
    14761421    answer = inputdlg(prompt,dlg_title,num_lines,def);
    1477 
    1478 if strcmp(answer,'Cancel')
     1422if isempty(answer)
    14791423    return
    14801424else
    1481     XmlData.LIFCalib.BlackOffset=str2num(answer{1}) ;% image value for black background, to be determined by taking images with a cover on the objective lens
    1482     XmlData.LIFCalib.SmoothingLength=str2num(answer{2}) ;% smoothing length used for the reference line
     1425    XmlData.LIFCalib.BlackOffset=str2double(answer{1}) ;% image value for black background, to be determined by taking images with a cover on the objective lens
     1426    XmlData.LIFCalib.RefLineWidth=str2double(answer{2}) ;% smoothing width used for the reference line
    14831427end
    14841428
     
    15101454
    15111455%% use the third line for reference luminosity, renormalize the image intensity along each ray to get a uniform brightness along this line
    1512 %UvData.Field.CoordMesh
    15131456if numel(find(select_line))==3
    15141457    x_ref=linspace(LineData{3}.Coord(1,1),LineData{3}.Coord(2,1),10);
     
    15281471    line_nan= isnan(dist_source);
    15291472    dist_source_pixel(line_nan)=1;
    1530     width=XmlData.LIFCalib.SmoothingLength; %number of pixels used for reference
    15311473    DataPol.A=double(DataPol.A)-XmlData.LIFCalib.BlackOffset;% black background substracted
    15321474    Anorm=zeros(size(DataPol.A));
    15331475    for iline=1:size(DataPol.A,1)
    1534         lum(iline)=mean(DataPol.A(iline,dist_source_pixel(iline):dist_source_pixel(iline)+width));% average the luminosity on a band width lying on the reference line
     1476        lum(iline)=mean(DataPol.A(iline,dist_source_pixel(iline):dist_source_pixel(iline)+XmlData.LIFCalib.RefLineWidth));% average the luminosity on a band width lying on the reference line
    15351477        Anorm(iline,:)=DataPol.A(iline,:)/lum(iline);% for each ray (iline), renormalise the image by the brightness at the reference line
    15361478    end
     
    15691511end
    15701512
    1571 %loop on lines iY (angle in polar coordiantes)
    1572 gamma_coeff=zeros(1,npy);
    1573 for iY=1:npy
    1574     ALine=A(iY,:);
    1575     RLine=R(iY,:);
     1513%% loop on lines iY (angle in polar coordiantes)
     1514gamma_coeff=NaN(1,npy);
     1515fitlength=NaN(1,npy);
     1516for iY=1:npy% loop on the y index of the image in polar coordinate
     1517    ALine=A(iY,:);%profile of image luminosity log (vs radial index)
     1518    RLine=R(iY,:);%radius of the reference line (vs radial index)
    15761519    ThetaLine=Theta(iY,:)*pi/180;
    15771520    [XLine,YLine] = pol2cart(ThetaLine,RLine);
     
    15791522    YLine=YLine+y0;
    15801523    if ~isempty(index_mask)
    1581         ind_good=inpolygon(XLine,YLine,MaskData.Coord(:,1),MaskData.Coord(:,2));
    1582         if numel(find(ind_good))>100
    1583             ALine=ALine(ind_good);
    1584             RLine=RLine(ind_good);
     1524        check_good=inpolygon(XLine,YLine,MaskData.Coord(:,1),MaskData.Coord(:,2));
     1525        if numel(find(check_good))>npx/4;% keep only lines with reasonable length
     1526            ALine=ALine(check_good);
     1527            RLine=RLine(check_good);
    15851528        else
    15861529            continue
     
    15891532    p = polyfit(RLine,ALine,1);
    15901533    gamma_coeff(iY)=-p(1);
     1534    fitlength(iY)=numel(find(check_good));
    15911535end
    15921536
     
    16051549
    16061550%% record the calibration data in the xml file
    1607 XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String'));
    1608 answer=msgbox_uvmat('INPUT_Y-N','save the LIF parameters in the current xml file?');
    1609 if strcmp(answer,'Yes')
    1610     t=xmltree(XmlFileName); %read the file
    1611     title_str=get(t,1,'name');
    1612     if ~strcmp(title_str,'ImaDoc')
    1613         msgbox_uvmat('ERROR','wrong xml file');
    1614         return
    1615     end
    1616     % backup the output file if it already exist, and read it
    1617     backupfile=XmlFileName;
    1618     testexist=2;
    1619     while testexist==2
    1620         backupfile=[backupfile '~'];
    1621         testexist=exist(backupfile,'file');
    1622     end
    1623     [success,message]=copyfile(XmlFileName,backupfile);%make backup
    1624     if success~=1
    1625         errormsg=['errror in xml file backup: ' message];
    1626         return
    1627     end
    1628     uid_illumination=find(t,'ImaDoc/LIFCalib');
    1629     if isempty(uid_illumination)  %if GeometryCalib does not already exists, create it
    1630         [t,uid_illumination]=add(t,1,'element','LIFCalib');
    1631     end
    1632     uid_origin=find(t,'ImaDoc/LIFCalib/LightOrigin');
    1633     if ~isempty(uid_origin)  %if LightOrigin already exists, delete it
    1634         t=delete(t,uid_origin);
    1635     end
    1636     uid_line=find(t,'ImaDoc/LIFCalib/Ray1Coord');
    1637     if ~isempty(uid_line)  %if Ray1Coord already exists, delete it
    1638         t=delete(t,uid_line);
    1639     end
    1640     uid_line=find(t,'ImaDoc/LIFCalib/Ray2Coord');
    1641     if ~isempty(uid_line)  %if Ray2Coord already exists, delete it
    1642         t=delete(t,uid_line);
    1643     end
    1644     uid_line=find(t,'ImaDoc/LIFCalib/RefLineCoord');
    1645     if ~isempty(uid_line)  %if RefLineCoord already exists, delete it
    1646         t=delete(t,uid_line);
    1647     end
    1648     uid_mask=find(t,'ImaDoc/LIFCalib/MaskPolygonCoord');
    1649     if ~isempty(uid_mask) %if MaskPolygonCoord already exists, delete it
    1650         t=delete(t,uid_mask);
    1651     end
    1652     uid_BlackOffset=find(t,'ImaDoc/LIFCalib/BlackOffset');
    1653     if ~isempty(uid_BlackOffset)  %if BlackOffset already exists, delete it
    1654         t=delete(t,uid_BlackOffset);
    1655     end
    1656     uid_DecayRate=find(t,'ImaDoc/LIFCalib/DecayRate');
    1657     if ~isempty(uid_DecayRate)  %if DecayRate already exists, delete it
    1658         t=delete(t,uid_DecayRate);
    1659     end
    1660     uid_RefLineRadius=find(t,'ImaDoc/LIFCalib/RefLineRadius');
    1661     if ~isempty(uid_RefLineRadius)  %if RefLineLum already exists, delete it
    1662         t=delete(t,uid_RefLineRadius);
    1663     end
    1664     uid_RefLineLum=find(t,'ImaDoc/LIFCalib/RefLineLum');
    1665     if ~isempty(uid_RefLineLum)  %if RefLineLum already exists, delete it
    1666         t=delete(t,uid_RefLineLum);
    1667     end
    1668     uid_RefLineAzimuth=find(t,'ImaDoc/LIFCalib/RefLineAzimuth');
    1669     if ~isempty(uid_RefLineAzimuth)  %if RefLineLum already exists, delete it
    1670         t=delete(t,uid_RefLineAzimuth);
    1671     end
    1672    
    1673     % save the LIF calibration data
    1674     t=struct2xml(XmlData.LIFCalib,t,uid_illumination);
    1675     save(t,XmlFileName);
    1676    
     1551hbrowse=browse_data(fullfile(get(handles.RootPath,'String'),get(handles.SubDir,'String')));
     1552answer = questdlg('Where','record the LIF parameters','Current series', 'Replicate', 'Cancel', 'Cancel');
     1553if strcmp(answer,'Current series')
     1554    XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String'));
     1555    update_imadoc(XmlData.LIFCalib,XmlFileName,'LIFCalib');% introduce the calibration data in the xml file
    16771556    % display the concentration in uvmat
    16781557    InputFileREFRESH_Callback(hObject, eventdata, handles);% refresh the current xml file to apply 'ima2concentration'
     
    16851564    set(handles.TransformName,'Value',ichoice)
    16861565    TransformName_Callback(hObject, eventdata, handles)
    1687 end
     1566elseif strcmp(answer,'Replicate')
     1567   
     1568    BrowseData=guidata(hbrowse);
     1569    SourceDir=get(BrowseData.SourceDir,'String');
     1570    ListExp=get(BrowseData.ListExperiments,'String');
     1571    ExpIndices=get(BrowseData.ListExperiments,'Value');
     1572    ListExp=ListExp(ExpIndices);
     1573    ListDevices=get(BrowseData.ListDevices,'String');
     1574    DeviceIndices=get(BrowseData.ListDevices,'Value');
     1575    ListDevices=ListDevices(DeviceIndices);
     1576    ListDataSeries=get(BrowseData.DataSeries,'String');
     1577    DataSeriesIndices=get(BrowseData.DataSeries,'Value');
     1578    ListDataSeries=ListDataSeries(DataSeriesIndices);
     1579    NbExp=0; % counter of the number of experiments set by the GUI browse_data
     1580    for iexp=1:numel(ListExp)
     1581        if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
     1582            for idevice=1:numel(ListDevices)
     1583                if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
     1584                    for isubdir=1:numel(ListDataSeries)
     1585                        if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
     1586                            lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
     1587                                regexprep(ListDevices{idevice},'^\+/',''));
     1588                            ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
     1589                            if exist(fullfile(lpath,ldir),'dir')
     1590                                NbExp=NbExp+1;
     1591                                ListPath{NbExp}=lpath;
     1592                                ListSubdir{NbExp}=ldir;
     1593                                ExpIndex{NbExp}=iexp;
     1594                            end
     1595                        end
     1596                    end
     1597                end
     1598            end
     1599        end
     1600    end
     1601    for iexp=1:NbExp
     1602        XmlName=fullfile(ListPath{iexp},[ListSubdir{iexp} '.xml']);
     1603        if exist(XmlName,'file')
     1604            check_update=1;
     1605        else
     1606            check_update=0;
     1607        end
     1608        errormsg=update_imadoc(XmlData.LIFCalib,XmlName,'LIFCalib');% introduce the calibration data in the xml file
     1609        if ~strcmp(errormsg,'')
     1610            msgbox_uvmat('ERROR',errormsg);
     1611        else
     1612            if check_update
     1613                display([XmlName ' updated with calibration parameters'])
     1614            else
     1615                display([XmlName ' created with calibration parameters'])
     1616            end
     1617        end
     1618    end
     1619    msgbox_uvmat('CONFIMATION',['LIF calibration replicated for ' num2str(NbExp) ' experiments']);
     1620end
     1621
     1622
     1623
     1624%     
     1625%     
     1626%     t=xmltree(XmlFileName); %read the file
     1627%     title_str=get(t,1,'name');
     1628%     if ~strcmp(title_str,'ImaDoc')
     1629%         msgbox_uvmat('ERROR','wrong xml file');
     1630%         return
     1631%     end
     1632%     % backup the output file if it already exist, and read it
     1633%     backupfile=XmlFileName;
     1634%     testexist=2;
     1635%     while testexist==2
     1636%         backupfile=[backupfile '~'];
     1637%         testexist=exist(backupfile,'file');
     1638%     end
     1639%     [success,message]=copyfile(XmlFileName,backupfile);%make backup
     1640%     if success~=1
     1641%         errormsg=['errror in xml file backup: ' message];
     1642%         return
     1643%     end
     1644%     uid_illumination=find(t,'ImaDoc/LIFCalib');
     1645%     if isempty(uid_illumination)  %if GeometryCalib does not already exists, create it
     1646%         [t,uid_illumination]=add(t,1,'element','LIFCalib');
     1647%     end
     1648%     uid_origin=find(t,'ImaDoc/LIFCalib/LightOrigin');
     1649%     if ~isempty(uid_origin)  %if LightOrigin already exists, delete it
     1650%         t=delete(t,uid_origin);
     1651%     end
     1652%     uid_line=find(t,'ImaDoc/LIFCalib/Ray1Coord');
     1653%     if ~isempty(uid_line)  %if Ray1Coord already exists, delete it
     1654%         t=delete(t,uid_line);
     1655%     end
     1656%     uid_line=find(t,'ImaDoc/LIFCalib/Ray2Coord');
     1657%     if ~isempty(uid_line)  %if Ray2Coord already exists, delete it
     1658%         t=delete(t,uid_line);
     1659%     end
     1660%     uid_line=find(t,'ImaDoc/LIFCalib/RefLineCoord');
     1661%     if ~isempty(uid_line)  %if RefLineCoord already exists, delete it
     1662%         t=delete(t,uid_line);
     1663%     end
     1664%     uid_mask=find(t,'ImaDoc/LIFCalib/MaskPolygonCoord');
     1665%     if ~isempty(uid_mask) %if MaskPolygonCoord already exists, delete it
     1666%         t=delete(t,uid_mask);
     1667%     end
     1668%     uid_BlackOffset=find(t,'ImaDoc/LIFCalib/BlackOffset');
     1669%     if ~isempty(uid_BlackOffset)  %if BlackOffset already exists, delete it
     1670%         t=delete(t,uid_BlackOffset);
     1671%     end
     1672%     uid_RefLineWidth=find(t,'ImaDoc/LIFCalib/RefLineWidth');
     1673%     if ~isempty(uid_RefLineWidth)  %if RefLineWidth already exists, delete it
     1674%         t=delete(t,uid_RefLineWidth);
     1675%     end
     1676%     uid_DecayRate=find(t,'ImaDoc/LIFCalib/DecayRate');
     1677%     if ~isempty(uid_DecayRate)  %if DecayRate already exists, delete it
     1678%         t=delete(t,uid_DecayRate);
     1679%     end
     1680%     uid_RefLineRadius=find(t,'ImaDoc/LIFCalib/RefLineRadius');
     1681%     if ~isempty(uid_RefLineRadius)  %if RefLineLum already exists, delete it
     1682%         t=delete(t,uid_RefLineRadius);
     1683%     end
     1684%     uid_RefLineLum=find(t,'ImaDoc/LIFCalib/RefLineLum');
     1685%     if ~isempty(uid_RefLineLum)  %if RefLineLum already exists, delete it
     1686%         t=delete(t,uid_RefLineLum);
     1687%     end
     1688%     uid_RefLineAzimuth=find(t,'ImaDoc/LIFCalib/RefLineAzimuth');
     1689%     if ~isempty(uid_RefLineAzimuth)  %if RefLineLum already exists, delete it
     1690%         t=delete(t,uid_RefLineAzimuth);
     1691%     end
     1692%     
     1693%     % save the LIF calibration data
     1694%     t=struct2xml(XmlData.LIFCalib,t,uid_illumination);
     1695%     save(t,XmlFileName);
     1696   
     1697
     1698
    16881699
    16891700
Note: See TracChangeset for help on using the changeset viewer.