Changeset 456 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jun 17, 2012, 10:50:20 PM (12 years ago)
Author:
sommeria
Message:

various bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r452 r456  
    597597% read the current input file name:
    598598[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     599if ~exist(fullfile(RootPath,SubDir),'dir')
     600    msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist'])
     601    return
     602end
    599603% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    600604[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     
    608612% update_rootinfo_1(hObject,eventdata,handles)
    609613[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     614if ~exist(fullfile(RootPath,SubDir),'dir')
     615    msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist'])
     616    return
     617end
    610618% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    611619[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     
    908916SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    909917filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
     918DocExt='.xml';
    910919if ~exist(filexml,'file')
    911920    filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
     921    if ~exist(filexml,'file')
     922        filexml=fullfile(RootPath,SubDir,[RootFile '.civ']); % very old convention: .civ file
     923        if ~exist(filexml,'file')
     924            DocExt='.civ';
     925        else
     926            filexml='';
     927        end
     928    end
    912929end
    913930warntext='';%default warning message
    914931NbSlice=1;%default
    915932set(handles.RootPath,'BackgroundColor',[1 1 1])
    916 if exist(filexml,'file')
     933if ~isempty(filexml)
    917934    set(handles.view_xml,'Visible','on')
    918935    set(handles.view_xml,'BackgroundColor',[1 1 0])
    919936    set(handles.view_xml,'String','view .xml')
    920937    drawnow
    921     [XmlData,warntext]=imadoc2struct(filexml);
     938    [XmlDataRead,warntext]=imadoc2struct(filexml);
    922939    if ~isempty(warntext)
    923         display(warntext)
    924 %         msgbox_uvmat('WARNING',warntext)
    925     end
    926     if isfield(XmlData,'TimeUnit')
    927         if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
    928             TimeUnit=XmlData.TimeUnit;
    929         end
    930     end
    931     set(handles.view_xml,'BackgroundColor',[1 1 1])
    932     drawnow
    933     if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
    934         if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
    935             set (handles.nb_slice,'String','volume')
    936         end
    937         hgeometry_calib=findobj('tag','geometry_calib');
    938         if ~isempty(hgeometry_calib)
    939             GUserData=get(hgeometry_calib,'UserData');
    940             if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
    941                 answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
    942                 if strcmp(answer,'Yes')
    943                     geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
     940        msgbox_uvmat('WARNING',warntext)
     941    end
     942    if isempty(XmlDataRead)
     943        set(handles.view_xml,'Visible','off')
     944    else
     945        set(handles.view_xml,'String',['view ' DocExt])   
     946        XmlData=XmlDataRead;
     947        if isfield(XmlData,'TimeUnit')
     948            if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
     949                TimeUnit=XmlData.TimeUnit;
     950            end
     951        end
     952        set(handles.view_xml,'BackgroundColor',[1 1 1])
     953        drawnow
     954        if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
     955            if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
     956                set (handles.nb_slice,'String','volume')
     957            end
     958            hgeometry_calib=findobj('tag','geometry_calib');
     959            if ~isempty(hgeometry_calib)
     960                GUserData=get(hgeometry_calib,'UserData');
     961                if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
     962                    answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
     963                    if strcmp(answer,'Yes')
     964                        geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
     965                    end
    944966                end
    945967            end
    946968        end
    947     end 
    948 else
    949     fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']);
    950     if exist(fileciv,'file')% if .civ file found (very old convention)
    951         [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext(fileciv);
    952         GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    953         GeometryCalib.Tx=0;
    954         GeometryCalib.Ty=0;
    955         GeometryCalib.Tz=1;
    956         GeometryCalib.dpx=1;
    957         GeometryCalib.dpy=1;
    958         GeometryCalib.sx=1;
    959         GeometryCalib.Cx=0;
    960         GeometryCalib.Cy=0;
    961         GeometryCalib.f=1;
    962         GeometryCalib.kappa1=0;
    963         GeometryCalib.CoordUnit='cm';
    964         XmlData.GeometryCalib=GeometryCalib;
    965         if error==2, warntext=['no file ' fileciv];
    966         elseif error==1, warntext='inconsistent number of fields in the .civ file';
    967         end
    968         set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
    969         set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
    970         set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
    971         set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
    972         set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
    973         set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
    974         set(handles.view_xml,'Visible','on')
    975         set(handles.view_xml,'String','view .civ')
    976     else
    977         set(handles.view_xml,'Visible','off')
    978969    end
    979970end
     
    991982    %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    992983    if isequal(size(XmlData.Time,1),1)
    993 %     if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
    994984        NomType=get(handles.NomType,'String');
    995 %         if isempty(nbfield_j)
    996 %         if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
    997             XmlData.Time=(XmlData.Time)';
     985        XmlData.Time=(XmlData.Time)';
    998986    end
    999987end
     
    23272315      abstime_1=[];
    23282316end 
    2329 set(handles.abs_time,'String',num2str(abstime,4))
    2330 set(handles.abs_time_1,'String',num2str(abstime_1,4))
     2317set(handles.abs_time,'String',num2str(abstime,5))
     2318set(handles.abs_time_1,'String',num2str(abstime_1,5))
    23312319% if testimedoc && isfield(UvData,'dt')
    23322320%     dt=UvData.dt;
Note: See TracChangeset for help on using the changeset viewer.