Changeset 441


Ignore:
Timestamp:
Jun 6, 2012, 2:45:37 PM (9 years ago)
Author:
sommeria
Message:

many bugs corrected for the new file organisation

Location:
trunk/src
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r440 r441  
    415415set(handles.RootFile,'String',RootFile)
    416416if strcmp(ExtInput,'.nc')
    417     SubDirCiv=SubDir;
    418 else
    419     SubDirCiv=[SubDir '.civ'];
     417    SubDirCiv=regexprep(SubDir,[SuddirImages '^'],'');%suppress the root  SuddirImages;
     418else
     419    SubDirCiv= '.civ';
    420420end
    421421set(handles.SubdirCiv1,'String',SubDirCiv)
     
    442442%% look for an image documentation file
    443443ext_imadoc='';%default
     444SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     445filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
     446if ~exist(filexml,'file')
     447    filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
     448end
    444449RootName=fullfile(RootPath,RootFile);
    445 if exist([RootName '.xml'],'file')
     450if exist(filexml,'file')
    446451    ext_imadoc='.xml';
    447 elseif exist([RootName '.civxml'],'file')
    448     ext_imadoc='.civxml';
    449 elseif exist([RootName '.civ'],'file')
     452elseif exist(fullfile(RootPath,SubDir,[RootFile '.civ']),'file')
    450453    ext_imadoc='.civ';
     454    fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']);
    451455elseif exist([RootName '.avi'],'file')
    452456    ext_imadoc='.avi';
     
    465469    drawnow
    466470    switch ext_imadoc
    467         case '.civxml'%OBSOLETE
    468             [tild,tild,time]=read_civxml([RootName '.civxml']);
    469             mode='pair j1-j2';
    470             if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
    471                 nom_type_ima='_i_j';
    472             end
    473471        case '.xml'
    474             [XmlData,warntext]=imadoc2struct([RootName '.xml']);
     472            [XmlData,warntext]=imadoc2struct(filexml);
    475473            ext_ima_read=[];
    476474            nom_type_read=[];
     
    508506            end
    509507        case '.civ'% OBSOLETE: case of .civ image documentation file
    510             [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']);
    511             if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']);
     508            [error,time,TimeUnit,mode,npx,npy]=read_imatext(fileciv);
     509            if error==2, msgbox_uvmat('WARNING',['no file ' fileciv]);
    512510            elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    513511            end
     
    522520                hhh=which('videoreader');
    523521                if isempty(hhh)%use old video function of matlab
    524                     imainfo=aviinfo([RootName ext_imadoc]);%read infos on the avi movie
     522                    imainfo=aviinfo([RootName ext_imadoc]);%read infos on the avi movie TO REPLACE mmreader
    525523                    dt=1/imainfo.FramesPerSecond;%time interval between successive frames
    526524                    MaxIndex_i=imainfo.NumFrames;%number of frames
     
    681679if get(handles.CheckCiv1,'Value')% if Civ1 is performed
    682680    set(handles.SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1
    683     set(handles.ListSubdirCiv2,'Value',ilist)
     681%     set(handles.ListSubdirCiv2,'Value',ilist)
    684682else % if Civ1 data already exist
    685683    errormsg=find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory
     
    19031901end
    19041902%check result directory
    1905 subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data
    1906 subdir_civ2=get(handles.SubdirCiv2,'String');
    1907 if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir
     1903subdir_civ1=regexprep(get(handles.SubdirCiv1,'String'),'^.','');%subdirectory subdir_civ1 for the netcdf output data
     1904subdir_civ2=regexprep(get(handles.SubdirCiv2,'String'),'^.','');
     1905if isequal(subdir_civ1,''),subdir_civ1='civ'; end% put default subdir
     1906% subdir_civ1=[ '.' subdir_civ1];
     1907% subdir_civ2=[ '.' subdir_civ2];
    19081908if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
     1909subdir_civ1=[SubdirImages '.' subdir_civ1];
     1910subdir_civ2=[SubdirImages '.' subdir_civ2];
    19091911
    19101912%% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV
     
    20982100                detect=exist(filename,'file')==2;
    20992101                if detect% if a netcdf file already exists
    2100                     indstr=regexp(subdir_civ1_new,'\D');
    2101                     if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
    2102                         vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
    2103                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
    2104                     else
    2105                         vers=vers+1;
    2106                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)];       
     2102                    r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
     2103                    if isempty(r)
     2104                        r(1).root=[subdir_civ1_new '_'];
     2105                        r(1).num1='0';
    21072106                    end
     2107                    subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
     2108%                     indstr=regexp(subdir_civ1_new,'\D');
     2109%                     if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
     2110%                         vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
     2111%                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
     2112%                     else
     2113%                         vers=vers+1;
     2114%                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)];       
     2115%                     end
    21082116                    subdir_civ2=subdir_civ1_new;
    21092117                    break
     
    24672475    end
    24682476end
    2469 set(handles.SubdirCiv1,'String',subdir_civ1);%update the edit box
    2470 set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box
     2477set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubdirImages],''));%suppress the root  SuddirImages;);%update the edit box
     2478set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubdirImages],''));%update the edit box
    24712479
    24722480% For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED
     
    35633571end
    35643572
    3565 %------------------------------------------------------------------------
    3566 % --- Executes on button press in ListSubdirCiv1.
    3567 function ListSubdirCiv1_Callback(hObject, eventdata, handles)
    3568 %------------------------------------------------------------------------
    3569 list_subdir_civ1=get(handles.ListSubdirCiv1,'String');
    3570 val=get(handles.ListSubdirCiv1,'Value');
    3571 SubDir=list_subdir_civ1{val};
    3572 if strcmp(SubDir,'new...')
    3573     if get(handles.CheckCiv1,'Value')
    3574         SubDir='CIV'; %default subdirectory
    3575     else
    3576         msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation')
    3577         return
    3578     end   
    3579 end
    3580 set(handles.SubdirCiv1,'String',SubDir);
    3581 errormsg=find_netcpair_civ(handles,1);
    3582 if ~isempty(errormsg)
    3583     msgbox_uvmat('ERROR',errormsg)
    3584 end
    3585    
    3586 %------------------------------------------------------------------------
    3587 % --- Executes on button press in ListSubdirCiv2.
    3588 function ListSubdirCiv2_Callback(hObject, eventdata, handles)
    3589 %------------------------------------------------------------------------
    3590 list_subdir_civ2=get(handles.ListSubdirCiv2,'String');
    3591 val=get(handles.ListSubdirCiv2,'Value');
    3592 SubDir=list_subdir_civ2{val};
    3593 if strcmp(SubDir,'new...')
    3594     if get(handles.CheckCiv2,'Value')
    3595         SubDir='CIV'; %default subdirectory
    3596     else
    3597         msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation')
    3598         return
    3599     end
    3600 end
    3601 set(handles.SubdirCiv2,'String',SubDir);
     3573% %------------------------------------------------------------------------
     3574% % --- Executes on button press in ListSubdirCiv1.
     3575% function ListSubdirCiv1_Callback(hObject, eventdata, handles)
     3576% %------------------------------------------------------------------------
     3577% list_subdir_civ1=get(handles.ListSubdirCiv1,'String');
     3578% val=get(handles.ListSubdirCiv1,'Value');
     3579% SubDir=list_subdir_civ1{val};
     3580% if strcmp(SubDir,'new...')
     3581%     if get(handles.CheckCiv1,'Value')
     3582%         SubDir='CIV'; %default subdirectory
     3583%     else
     3584%         msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation')
     3585%         return
     3586%     end   
     3587% end
     3588% set(handles.SubdirCiv1,'String',SubDir);
     3589% errormsg=find_netcpair_civ(handles,1);
     3590% if ~isempty(errormsg)
     3591%     msgbox_uvmat('ERROR',errormsg)
     3592% end
     3593%    
     3594%------------------------------------------------------------------------
     3595% % --- Executes on button press in ListSubdirCiv2.
     3596% function ListSubdirCiv2_Callback(hObject, eventdata, handles)
     3597% %------------------------------------------------------------------------
     3598% list_subdir_civ2=get(handles.ListSubdirCiv2,'String');
     3599% val=get(handles.ListSubdirCiv2,'Value');
     3600% SubDir=list_subdir_civ2{val};
     3601% if strcmp(SubDir,'new...')
     3602%     if get(handles.CheckCiv2,'Value')
     3603%         SubDir='CIV'; %default subdirectory
     3604%     else
     3605%         msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation')
     3606%         return
     3607%     end
     3608% end
     3609% set(handles.SubdirCiv2,'String',SubDir);
    36023610
    36033611%------------------------------------------------------------------------
  • trunk/src/find_file_series.m

    r439 r441  
    8989            RootFileNew=[RootFile rr.i1];
    9090            checkpair=~isempty(regexp(NomType,'-','once'))||~isempty(regexp(NomType,'ab$','once'))||~isempty(regexp(NomType,'AB$','once'));%case of PIV results
    91             if exist(fullfile(RootPath,[RootFileNew '.xml']),'file') %|| (checkpair && exist(fullfile(fileparts(RootPath),[RootFileNew '.xml']),'file'))
     91            if exist(fullfile(RootPath,SubDir,[RootFileNew '.xml']),'file') %|| (checkpair && exist(fullfile(fileparts(RootPath),[RootFileNew '.xml']),'file'))
    9292                RootFile=RootFileNew;
    9393                NomTypePref=r.tiretnum;
  • trunk/src/mouse_motion.m

    r432 r441  
    218218                        par.ImageWidth=size(par.ImageA,2);
    219219                        Param.Civ1=par;
    220                         ibx2=floor((par.Bx-1)/2);
    221                         iby2=floor((par.By-1)/2);
    222                         isx2=floor((par.Searchx-1)/2);
    223                         isy2=floor((par.Searchy-1)/2);
    224                         shiftx=par.Shiftx;
    225                         shifty=par.Shifty;     
     220                        ibx2=floor((par.CorrBoxSize(1)-1)/2);
     221                        iby2=floor((par.CorrBoxSize(2)-1)/2);
     222                        isx2=floor((par.SearchBoxSize(1)-1)/2);
     223                        isy2=floor((par.SearchBoxSize(2)-1)/2);
     224                        shiftx=par.SearchBoxShift(1);
     225                        shifty=par.SearchBoxShift(2);     
    226226                        hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
    227227                        hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
  • trunk/src/read_field.m

    r435 r441  
    2020%     = image : usual image as recognised by Matlab
    2121%     = multimage: image series stored in a single file
    22 %     = movie: movie read with mmreader
    23 %     = avi: avi movie read with aviread (OBSOLETE, used only when mmreader is not available, old versions of Matlab)
     22%     = mmreader: movie read with mmreader
     23%     = video: movie read with VideoReader (recent versions of Matlab)
    2424%     = vol: images representing scanned volume (images concatened in the y direction)
    2525% ParamIn: Matlab structure of input parameters
  • trunk/src/series.m

    r440 r441  
    693693
    694694%% update pair menus
     695set(handles.Pairs,'Visible','on')
     696set(handles.PairString,'Visible','on')
    695697ListView=get(handles.ListView,'String');
    696698ListView{iview}=num2str(iview);
     
    698700set(handles.ListView,'Value',iview)
    699701update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
     702
    700703
    701704%% display the set of existing files as an image
     
    851854
    852855%% store the series info in 'UserData'
    853 
    854856SeriesData.i1_series{iview}=i1_series;
    855857SeriesData.i2_series{iview}=i2_series;
     
    860862set(handles.series,'UserData',SeriesData)
    861863
    862 
     864%% check for pair display
     865check_pairs=0;
     866for iview=1:numel(SeriesData.i2_series)
     867    if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
     868        check_pairs=1;
     869    end
     870end
     871if check_pairs
     872    set(handles.Pairs,'Visible','on')
     873    set(handles.PairString,'Visible','on')
     874else
     875    set(handles.Pairs,'Visible','off')
     876    set(handles.PairString,'Visible','off')
     877end
    863878
    864879return
     
    10411056%------------------------------------------------------------
    10421057list_pair=get(handles.ListPairs,'String');%get the menu of image pairs
    1043 string=list_pair{get(handles.ListPairs,'Value')};
    1044 string=regexprep(string,',.*','');%removes time indication (after ',')
     1058if isempty(list_pair)
     1059    string='';
     1060else
     1061    string=list_pair{get(handles.ListPairs,'Value')};
     1062    string=regexprep(string,',.*','');%removes time indication (after ',')
     1063end
    10451064PairString=get(handles.PairString,'Data');
    10461065iview=get(handles.ListView,'Value');
     
    11981217end
    11991218set(handles.ListPairs,'String',displ_pair)
    1200 if isempty(displ_pair)
    1201     msgbox_uvmat('ERROR',['no file available for the selected subdirectory ' SubDir])
    1202 end
     1219% if isempty(displ_pair)
     1220%     msgbox_uvmat('ERROR',['no file available for the selected subdirectory' ])
     1221% end
    12031222
    12041223
     
    15431562ref_j=ceil((first_j+last_j)/2);
    15441563set(handles.num_ref_j,'String', num2str(ref_j))
    1545 ref_j_Callback(hObject, eventdata, handles)
     1564num_ref_j_Callback(hObject, eventdata, handles)
    15461565SeriesData=get(handles.series,'UserData');
    15471566if ~isfield(SeriesData,'Time')
  • trunk/src/uvmat.m

    r439 r441  
    909909
    910910%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
    911 filexml=[FileBase '.xml'];
    912 fileciv=[FileBase '.civ'];
     911SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     912filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
     913if ~exist(filexml,'file')
     914    filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
     915end
    913916warntext='';%default warning message
    914917NbSlice=1;%default
     
    945948        end
    946949    end 
    947 elseif exist(fileciv,'file')% if .civ file found
    948     [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
    949     GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    950     GeometryCalib.Tx=0;
    951     GeometryCalib.Ty=0;
    952     GeometryCalib.Tz=1;
    953     GeometryCalib.dpx=1;
    954     GeometryCalib.dpy=1;
    955     GeometryCalib.sx=1;
    956     GeometryCalib.Cx=0;
    957     GeometryCalib.Cy=0;
    958     GeometryCalib.f=1;
    959     GeometryCalib.kappa1=0;
    960     GeometryCalib.CoordUnit='cm';
    961     XmlData.GeometryCalib=GeometryCalib;
    962     if error==2, warntext=['no file ' FileBase '.civ'];
    963     elseif error==1, warntext='inconsistent number of fields in the .civ file';
    964     end 
    965     set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
    966     set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
    967     set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
    968     set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
    969     set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
    970     set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
    971     set(handles.view_xml,'Visible','on')   
    972     set(handles.view_xml,'String','view .civ')
    973950else
    974     set(handles.view_xml,'Visible','off')
     951    fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']);
     952    if exist(fileciv,'file')% if .civ file found (very old convention)
     953        [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext(fileciv);
     954        GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
     955        GeometryCalib.Tx=0;
     956        GeometryCalib.Ty=0;
     957        GeometryCalib.Tz=1;
     958        GeometryCalib.dpx=1;
     959        GeometryCalib.dpy=1;
     960        GeometryCalib.sx=1;
     961        GeometryCalib.Cx=0;
     962        GeometryCalib.Cy=0;
     963        GeometryCalib.f=1;
     964        GeometryCalib.kappa1=0;
     965        GeometryCalib.CoordUnit='cm';
     966        XmlData.GeometryCalib=GeometryCalib;
     967        if error==2, warntext=['no file ' fileciv];
     968        elseif error==1, warntext='inconsistent number of fields in the .civ file';
     969        end
     970        set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
     971        set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
     972        set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
     973        set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
     974        set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
     975        set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
     976        set(handles.view_xml,'Visible','on')
     977        set(handles.view_xml,'String','view .civ')
     978    else
     979        set(handles.view_xml,'Visible','off')
     980    end
    975981end
    976982
     
    985991end
    986992if ~isempty(XmlData.Time)
    987 %     nbfield=size(XmlData.Time,1);
    988 %     nbfield_j=size(XmlData.Time,2);
    989993    %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    990     if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
     994    if isequal(size(XmlData.Time,1),1)
     995%     if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
    991996        NomType=get(handles.NomType,'String');
    992         if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
     997%         if isempty(nbfield_j)
     998%         if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
    993999            XmlData.Time=(XmlData.Time)';
    994 %             nbfield=nbfield_j;
    995 %             nbfield_j=1;
    996         end
    9971000    end
    9981001end
Note: See TracChangeset for help on using the changeset viewer.