Changeset 343 for trunk/src/civ.m


Ignore:
Timestamp:
Dec 21, 2011, 10:12:13 AM (13 years ago)
Author:
sommeria
Message:

-bugs repaired in civ
-change in find_file_series to account for possible file index 0
-name2display suppressed in all functions, replaced by fileparts_uvmat (except incorporated in civ_3D)
-open_uvmat introduced to open files from a list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r339 r343  
    2323%TODO: search range
    2424
    25 % Last Modified by GUIDE v2.5 04-Dec-2011 18:52:13
     25% Last Modified by GUIDE v2.5 21-Dec-2011 00:34:49
    2626% Begin initialization code - DO NOT EDIT
    2727gui_Singleton = 1;
     
    119119function MenuBrowse_Callback(hObject, eventdata, handles)
    120120%------------------------------------------------------------------------
    121 %get the current input root file name to initiate the browser
     121%% get the current input root file name to initiate the browser
    122122filebase=get(handles.RootName,'String');
    123123oldfile=''; %default
     
    137137    oldfile=filebase;
    138138end
    139 ind_opening=1;%default
    140 browse.incr_pair=[0 0]; %default
     139% ind_opening=1;%default
     140% browse.incr_pair=[0 0]; %default
     141%% get the new input fiel with the browser
    141142menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
    142143    '*.xml',  '.xml files '; ...
     
    153154if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    154155
    155 %% prepare the GUI with parameters from the input file if opened from uvmat
    156 errormsg=display_file_name(handles,fileinput);
    157 if ~isempty(errormsg)
    158     msgbox_uvmat('ERROR',erromsg)
    159 end
    160 
     156%% case of the xml file opened as input (TODO: check and see whether it is useful)
    161157[path,name,ext]=fileparts(fileinput);
    162158testeditxml=0;
     
    186182[~,~,~,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput);
    187183% filebase=fullfile(RootPath,RootFile);
    188 if isempty(i1),i1=1;end
    189 if isempty(i2),i2=i1;end
    190 if isempty(j1),j1=1;end
    191 if isempty(j2),j2=j1;end
    192 if isequal(get(handles.ListCompareMode,'Value'),1)
    193     browse=[];%initialisation
    194 else
    195     browse=get(handles.RootName,'UserData');
    196 end
    197 browse.num_i1=i1;
    198 browse.num_i2=i2;
    199 browse.num_j1=j1;
    200 browse.num_j2=j2;
    201 if length(FileExt)>1 && (~isempty(imformats(FileExt(2:end)))||strcmpi(FileExt,'.avi'));%if an image file has been opened by uvmat
    202     browse.nom_type_ima=NomType;
    203     browse.ext_ima=FileExt;
    204     set(handles.ImaExt,'String',FileExt)
    205 end
    206 set(handles.ImaDoc,'String',FileExt);
    207 
    208 set(handles.RootName,'UserData',browse);% store information from browser
     184
     185%% record the information obtained from the input file
     186% if isempty(i1),i1=1;end
     187% if isempty(i2),i2=i1;end
     188% if isempty(j1),j1=1;end
     189% if isempty(j2),j2=j1;end
     190% if isequal(get(handles.ListCompareMode,'Value'),1)
     191%     browse=[];%initialisation
     192% else
     193%     browse=get(handles.RootName,'UserData');
     194% end
     195% browse.num_i1=i1;
     196% browse.num_i2=i2;
     197% browse.num_j1=j1;
     198% browse.num_j2=j2;
     199% if length(FileExt)>1 && (~isempty(imformats(FileExt(2:end)))||strcmpi(FileExt,'.avi'));%if an image file has been opened by uvmat
     200%     browse.nom_type_ima=NomType;
     201%     browse.ext_ima=FileExt;
     202%     set(handles.ImaExt,'String',FileExt)
     203% end
     204% set(handles.RootName,'UserData',browse);% store information from browser
     205
     206%% prepare the GUI with parameters from the input file
     207errormsg=display_file_name(handles,fileinput);
     208if ~isempty(errormsg)
     209    msgbox_uvmat('ERROR',erromsg)
     210end
     211
    209212
    210213%------------------------------------------------------------------------
     
    332335nom_type_ima='';%default
    333336nom_type_nc='';
    334 [RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,subdir]=name2display(fileinput);
    335 %[RootPath,subdir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput);TODO: use to replace name2display
     337%[RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,SubDir]=name2display(fileinput);
     338[RootPath,SubDir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput);
    336339RootName=fullfile(RootPath,RootFile);
    337340set(handles.RootName,'String',RootName)
    338341set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    339 i1=str2double(i1_str);
    340 i2=str2double(i2_str);
    341 j1=str2double(j1_str);
    342 j2=str2double(j2_str);
     342% i1=str2double(i1_str);
     343% i2=str2double(i2_str);
     344% j1=str2double(j1_str);
     345% j2=str2double(j2_str);
    343346num_ref_i=i1;%efaulmt ref index
    344347num_ref_j=j1;
     
    350353    ext_ima=ext_input;
    351354    nom_type_ima=nom_type_input;
     355    imagename=fileinput;
    352356else %case of netcdf input file, look for corresponding images
    353357    nom_type_nc=nom_type_input;
     358    imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima);
     359    i1_str='';
     360    j1_str='';
    354361    if ~isnan(i2)
    355362        num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file
     
    359366    %TODO: read the image name in the netcdf file (if documented)
    360367    %look for double image series '_i_j'
     368    check_letter=regexp(nom_type_nc,'[ab|AB]$');%detect pair label by letter
     369    if ~isempty(check_letter)
     370        j1_str=nom_type_nc(end-1);
     371        r=regexp(nom_type_nc,'_(?<num1>\d+)','names');
     372        if ~isempty(r)
     373            i1_str=r.num1;
     374        end
     375    else
     376        NomTypeIma=regexprep(nom_type_nc,'-\d','');%
     377        r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names');
     378        if ~isempty(r_end)
     379            j1_str=r.num2
     380        end
     381    end
     382    r=regexp(NomTypeIma,'_(?<num1>\d+)','names');
     383    if ~isempty(r)
     384        i1_str=r.num1;
     385    end 
    361386    dirima=dir([RootName '_' i1_str '_' j1_str '.*']);
    362387    if isempty(dirima)
     
    374399    end
    375400    for ilist=1:numel(dirima)
    376         [pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);
     401        %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);
     402        [~,~,~,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name);
    377403        form=imformats(ext_list(2:end));
    378404        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    379405            ext_ima=ext_list;
    380406            nom_type_ima=nom_type_list;
    381             i1=str2double(i1_str);
    382             j1=str2double(j1_str);
    383             i2=str2double(i2_str);
    384             j2=str2double(j2_str);         
     407%             i1=str2double(i1_str);
     408%             j1=str2double(j1_str);
     409%             i2=str2double(i2_str);
     410%             j2=str2double(j2_str);         
    385411            % set the range of fields (1:1 by default) and selected pair
    386             if isequal(i2,i1)||isnan(i2)
     412            if isempty(i2)
    387413                num_ref_i=i1;
    388414            else
     
    391417                browse.incr_pair(2)=0;
    392418            end
    393             if isequal(j1,j2)||isnan(j2)
    394                 if isnan(j1)
     419            if isempty(j2)
     420                if isempty(j1)
    395421                    num_ref_j=1;
    396422                else
     
    405431    end
    406432end
     433[RootPath,RootFile,i1_series,~,j1_series,~,NomType,FileType,Object]=find_file_series(imagename);
     434MaxIndex_i=max(i1_series(i1_series>0));
     435MaxIndex_j=max(j1_series(j1_series>0));
    407436
    408437%% look for an image documentation file
     
    420449end
    421450set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used
    422 set(handles.ImaDoc,'BackgroundColor',[1 1 0])
    423 drawnow
    424 %%%%%%%%   read image documentation file  %%%%%%%%%%%%%%%%%%%%%%%%%%%
     451
     452
     453%%  read the time in the image documentation file 
    425454mode=''; %default
    426455time=[];
    427 TimeUnit='frame'; %default
    428 CoordUnit='px';%default
     456TimeUnit=''; %default
     457CoordUnit='';%default
    429458pxcmx_search=[];%default
    430459pxcmy_search=[];%default
    431 if isequal(ext_imadoc,'.civxml')%TO ABANDON
    432     [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']);
    433     mode='pair j1-j2';
    434     if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
    435         nom_type_ima='_i_j';
    436     end
    437 elseif isequal(ext_imadoc,'.xml')
    438     [XmlData,warntext]=imadoc2struct([RootName '.xml']);
    439     ext_ima_read=[];
    440     nom_type_read=[];
    441     if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    442         [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
    443         fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    444         if ~exist(fullname,'file')
    445             msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
    446         end
    447     end
    448     if isfield(XmlData,'Time')
    449         time=XmlData.Time;
    450         nbfield=size(time,1);
    451         nbfield2=size(time,2);
    452         %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
    453         if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector
    454             if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
    455                 time=time';
    456                 nbfield=nbfield2;
    457                 nbfield2=1;
    458             end
    459         end
    460     end
    461     if isfield(XmlData,'TimeUnit')
    462         TimeUnit=XmlData.TimeUnit;
    463     end
    464     pxcmx_search=1;
    465     pxcmy_search=1;
    466     if isfield(XmlData,'GeometryCalib')
    467         tsai=XmlData.GeometryCalib;
    468         if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R')
    469             rot2D=tsai.R(1:2,[1,2]);
    470             pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx);
    471             pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy);
    472         end
    473         if isfield(tsai,'CoordUnit')
    474             CoordUnit=tsai.CoordUnit;
    475         end
    476     end
    477 elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file
    478     [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']);
    479     if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']);
    480     elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    481     end
    482     nom_type_ima='001a';
    483 elseif strcmpi(ext_imadoc,'.avi')
    484     nom_type_ima='*';
    485     ext_ima=ext_imadoc;
    486     set(handles.ListPairMode,'Value',1);
    487     set(handles.ListPairMode,'String',{'series(Di)'})
    488     dt=0.04;%default
    489     if exist([RootName ext_imadoc],'file')==2
    490         info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie
    491         dt=1/info.FramesPerSecond;%time interval between successive frames
    492         nbfield=info.NumFrames;%number of frames
    493     end
    494     time=(dt*(0:nbfield-1))';%list of image times
    495 end
    496 if isempty(time)
    497     set(handles.ImaDoc,'String',''); %xml file not used for timing
    498 end
    499 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box to yellow color
    500 
     460if ~isempty(ext_imadoc)
     461    set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning
     462    drawnow
     463    switch ext_imadoc
     464        case '.civxml'%OBSOLETE
     465            [~,~,time]=read_civxml([RootName '.civxml']);
     466            mode='pair j1-j2';
     467            if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
     468                nom_type_ima='_i_j';
     469            end
     470        case '.xml'
     471            [XmlData,warntext]=imadoc2struct([RootName '.xml']);
     472            ext_ima_read=[];
     473            nom_type_read=[];
     474            if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
     475                %[PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
     476                [~,~,~,~,~,~,~,~,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
     477                fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
     478                if ~exist(fullname,'file')
     479                    msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
     480                end
     481            end
     482            if isfield(XmlData,'Time')
     483                time=XmlData.Time;
     484                %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
     485                if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector
     486                    if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
     487                        time=time';
     488                        MaxIndex_i=MaxIndex_j;
     489                        MaxIndex_j=1;
     490                    end
     491                end
     492            end
     493            if isfield(XmlData,'TimeUnit')
     494                TimeUnit=XmlData.TimeUnit;
     495            end
     496            pxcmx_search=1;
     497            pxcmy_search=1;
     498            if isfield(XmlData,'GeometryCalib')
     499                tsai=XmlData.GeometryCalib;
     500                if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R')
     501                    rot2D=tsai.R(1:2,[1,2]);
     502                    pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx);
     503                    pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy);
     504                end
     505                if isfield(tsai,'CoordUnit')
     506                    CoordUnit=tsai.CoordUnit;
     507                end
     508            end
     509        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']);
     512            elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
     513            end
     514            nom_type_ima='001a';
     515        case {'.avi','.AVI'}
     516            nom_type_ima='*';
     517            ext_ima=ext_imadoc;
     518            set(handles.ListPairMode,'Value',1);
     519            set(handles.ListPairMode,'String',{'series(Di)'})
     520            dt=0.04;%default
     521            if exist([RootName ext_imadoc],'file')==2
     522                info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie
     523                dt=1/info.FramesPerSecond;%time interval between successive frames
     524                MaxIndex_i=info.NumFrames;%number of frames
     525            end
     526            time=(dt*(0:MaxIndex_i-1))';%list of image times
     527            TimeUnit='s';
     528    end
     529    set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     530end
    501531
    502532%% timing display
    503533%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    504 if ~isempty(time)
    505     if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt
    506         nbfield=size(time,1);
    507         nbfield2=size(time,2);
    508         set(handles.ImaDoc,'UserData',time); %store the set of times
    509         set(handles.dt_unit,'String',['dt in m' TimeUnit]);
    510         set(handles.TimeUnit,'String',TimeUnit);
    511         set(handles.nb_field,'String',num2str(nbfield));
    512         set(handles.nb_field2,'String',num2str(nbfield2));
    513     end
    514 end
     534if numel(time)>=2 % if there are at least two time values to define dt
     535    MaxIndex_i=min(size(time,1),MaxIndex_i);
     536    MaxIndex_j=min(size(time,2),MaxIndex_j);
     537    time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
     538    time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros
     539    set(handles.ImaDoc,'UserData',time); %store the matrix of times
     540    set(handles.dt_unit,'String',['dt in m' TimeUnit]);
     541    set(handles.TimeUnit,'String',TimeUnit);
     542else
     543    set(handles.ImaDoc,'String',''); %xml file not used for timing
     544    time=(i1_series(:,1)+0:size(i1_series,1)-1);% time=index i
     545    time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices
     546    TimeUnit='frame';
     547end
     548set(handles.ImaDoc,'UserData',time); %store the matrix of times
     549set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms)
     550set(handles.TimeUnit,'String',TimeUnit);
     551set(handles.nb_field,'String',num2str(MaxIndex_i));
     552set(handles.nb_field2,'String',num2str(MaxIndex_j));
    515553set(handles.CoordUnit,'String',CoordUnit)
    516554set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]);
     
    545583    set(handles.(ListOptions{index}),'value',1)
    546584end
    547 update_CivOptions(handles)
     585update_CivOptions(handles,1)
    548586
    549587
    550588%%  set the menus of image pairs and default selection for civ   %%%%%%%%%%%%%%%%%%%
    551 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing
    552 if test_ima_i || isequal(nom_type_nc,'_1-2')||~(exist('nbfield2','var')&&(nbfield2~=1))
     589check_letter=~isempty(regexp(nom_type_ima,'[a|A]$'));
     590check_separator=~isempty(regexp(nom_type_ima,'_'));
     591% test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'))%=1 for images with single indexing
     592% TODO: determine MaxIndex_i and MaxIndex_j using find_file_series (in the absence of xml file)
     593if (~check_letter&&~check_separator)|| isequal(nom_type_nc,'_1-2')|| (exist('MaxIndex_j','var')&&(MaxIndex_j==1))
    553594    set(handles.ListPairMode,'Value',1)
    554595    set(handles.ListPairMode,'String',{'series(Di)'})   
    555 elseif (nbfield==1)% simple series in j
    556     set(handles.ListPairMode,'Value',1)
    557     set(handles.ListPairMode,'String',{'series(Dj)'})
     596elseif  MaxIndex_i==1 && MaxIndex_j% simple series in j
     597    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'})
     598    if  MaxIndex_j <= 10
     599        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
     600    end
    558601else
    559602    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
    560     if nbfield2 <= 10
    561         set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst
     603    if  MaxIndex_j <= 10
     604        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
    562605    end
    563606end
     
    577620    end
    578621end
    579 Value=find(strcmp(subdir,listdir));%search the index of subdir in the cell listdir
     622Value=find(strcmp(SubDir,listdir));%search the index of subdir in the cell listdir
    580623if isempty(Value)% if the input subdir is not found
    581624    ValueCiv1=get(handles.ListSubdirCiv1,'Value');%read the currrently selected dir name
     
    610653%% list the possible index pairs, depending on the option set in ListPairMode
    611654ListPairMode_Callback([], [], handles)
     655'TESTin'
     656browse=get(handles.RootName,'UserData')
    612657
    613658%% store the root input filename for future opening
     
    632677function txt_SubdirCiv1_Callback(hObject, eventdata, handles)
    633678%------------------------------------------------------------------------
    634 subdir=get(handles.txt_SubdirCiv1,'String');
     679SubDir=get(handles.txt_SubdirCiv1,'String');
    635680menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update
    636 ichoice=find(strcmp(subdir,menu_str),1);
     681ichoice=find(strcmp(SubDir,menu_str),1);
    637682if isempty(ichoice)
    638683    ilist=numel(menu_str); %select 'new...' in the menu
     
    642687set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu
    643688if get(handles.CheckCiv1,'Value')% if Civ1 is performed
    644     set(handles.txt_SubdirCiv2,'String',subdir);% set by default civ2 directory the same as civ1
     689    set(handles.txt_SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1
    645690    set(handles.ListSubdirCiv2,'Value',ilist)
    646691else % if Civ1 data already exist
     
    649694
    650695%------------------------------------------------------------------------
    651 % --- Executes on carriage return on the subdir checkciv1 edit window
     696% --- Executes on carriage return on the SubDir checkciv1 edit window
    652697function txt_SubdirCiv2_Callback(hObject, eventdata, handles)
    653698%------------------------------------------------------------------------
    654 subdir=get(handles.txt_SubdirCiv1,'String');
     699SubDir=get(handles.txt_SubdirCiv1,'String');
    655700menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update
    656 ichoice=find(strcmp(subdir,menu_str),1);
     701ichoice=find(strcmp(SubDir,menu_str),1);
    657702if isempty(ichoice)
    658703    ilist=numel(menu_str); %select 'new...' in the menu
     
    670715function CheckCiv1_Callback(hObject, eventdata, handles)
    671716%------------------------------------------------------------------------
    672 update_CivOptions(handles)
     717update_CivOptions(handles,0)
    673718
    674719%------------------------------------------------------------------------
     
    676721function CheckFix1_Callback(hObject, eventdata, handles)
    677722%------------------------------------------------------------------------
    678 update_CivOptions(handles)
     723update_CivOptions(handles,0)
    679724
    680725%------------------------------------------------------------------------
     
    682727function CheckPatch1_Callback(hObject, eventdata, handles)
    683728%------------------------------------------------------------------------
    684 update_CivOptions(handles)
     729update_CivOptions(handles,0)
    685730
    686731%------------------------------------------------------------------------
     
    688733function CheckCiv2_Callback(hObject, eventdata, handles)
    689734%------------------------------------------------------------------------
    690 update_CivOptions(handles)
     735update_CivOptions(handles,0)
    691736
    692737%------------------------------------------------------------------------
     
    694739function CheckFix2_Callback(hObject, eventdata, handles)
    695740%------------------------------------------------------------------------
    696 update_CivOptions(handles)
     741update_CivOptions(handles,0)
    697742
    698743%------------------------------------------------------------------------
     
    700745function CheckPatch2_Callback(hObject, eventdata, handles)
    701746%------------------------------------------------------------------------
    702 update_CivOptions(handles)
     747update_CivOptions(handles,0)
    703748
    704749%------------------------------------------------------------------------
    705750% --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2
    706 function update_CivOptions(handles)
     751function update_CivOptions(handles,opening)
    707752%------------------------------------------------------------------------
    708753checkbox=zeros(1,6);
     
    718763    if isempty(RootName)
    719764         msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')
    720         return
     765        returnopening
    721766    end
    722767end
     
    724769set(handles.txt_SubdirCiv1,'Visible','on')
    725770set(handles.ListSubdirCiv1,'Visible','on')
     771if ~opening
    726772find_netcpair_civ1(handles) % select the available netcdf files
     773end
    727774if max(checkbox(4:6))% case of civ2 pair choice needed
    728775    set(handles.TitlePairCiv2,'Visible','on')
     
    731778    set(handles.ListSubdirCiv2,'Visible','on')
    732779    set(handles.ListPairCiv2,'Visible','on')
     780    if ~opening
    733781    find_netcpair_civ2(handles) % select the available netcdf files
     782    end
    734783else
    735784    set(handles.TitleSubdirCiv2,'Visible','off')
     
    829878end
    830879[root,filename,ext]=fileparts(civ_files{1});
    831 [rootroot,subdir,extdir]=fileparts(root);
     880[rootroot,SubDir,extdir]=fileparts(root);
    832881hfig=findobj(allchild(0),'name','civ_status');
    833882if isempty(hfig)
    834883    hfig=figure('DeleteFcn',@stop_status);
    835884    set(hfig,'name','civ_status')
    836     hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
     885    %hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
     886     uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
    837887    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    838888    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     
    895945        end
    896946        [rr,filename,ext]=fileparts(civ_files{ifile});
    897         Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' option_str];
     947        Tabchar{ifile,1}=[fullfile([SubDir extdir],filename) ext  '...' option_str];
    898948    end
    899949    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     
    11031153%% MAIN LOOP
    11041154time=get(handles.ImaDoc,'UserData'); %get the set of times
     1155TimeUnit=get(handles.TimeUnit,'String');
     1156checkframe=strcmp(TimeUnit,'frame');
    11051157batch_file_list=[];%should be renamed file_list, can be used for xml or bash files
    11061158 
     
    11361188            Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
    11371189            Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
    1138             if size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
    1139                 Param.Civ1.Dt=(time(i2_civ1(ifile),j2_civ1(j))-time(i1_civ1(ifile),j1_civ1(j)));
    1140                 Param.Civ1.Time=((time(i2_civ1(ifile),j2_civ1(j))+time(i1_civ1(ifile),j1_civ1(j)))/2);
     1190            if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
     1191                Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1));
    11411192            else
    11421193                Param.Civ1.Dt=1;
    1143                 Param.Civ1.Time=0;
    1144             end
     1194            end
     1195            Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
    11451196            Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
    11461197            Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%   
     
    12741325            Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
    12751326            Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
    1276             if size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
    1277                 Param.Civ2.Dt=num2str(time(i2_civ2(ifile),j2_civ2(j))-time(i1_civ2(ifile),j1_civ2(j)));
    1278                 Param.Civ2.Time=num2str((time(i2_civ2(ifile),j2_civ2(j))+time(i1_civ2(ifile),j1_civ2(j)))/2);
     1327            if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
     1328                Param.Civ2.Dt=num2str(time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1));
    12791329            else
    12801330                Param.Civ2.Dt=1;
    1281                 Param.Civ2.Time=0;
    1282             end
     1331            end
     1332            Param.Civ2.Time=num2str((time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2);
    12831333            Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc);
    12841334            Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc);
     
    16201670    end
    16211671end
    1622 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu);
    1623 namedoc=fullfile(RootPath,subdir,RootFile);
     1672%[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,SubDir]=name2display(fileresu);
     1673[RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu);
     1674namedoc=fullfile(RootPath,SubDir,RootFile);
    16241675detect=1;
    16251676while detect==1
     
    25672618     end
    25682619%     set(handles.RootName_1,'String',name);
    2569     [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);
     2620    %[RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,SubDir]=name2display(name);
     2621    [~,~,RootFile,~,~,~,~,~,nom_type]=fileparts_uvmat(name);
    25702622    set(handles.RootName_1,'String',RootFile);
    25712623    browse=get(handles.RootName,'UserData');
     
    26402692% last_i=str2num(get(handles.last_i,'String'));
    26412693time=get(handles.ImaDoc,'UserData'); %get the set of times
     2694TimeUnit=get(handles.TimeUnit,'String');
     2695checkframe=strcmp(TimeUnit,'frame');
    26422696siztime=size(time);
    2643 nbfield=siztime(1);
    2644 nbfield2=siztime(2);
     2697nbfield=siztime(1)-1;
     2698nbfield2=siztime(2)-1;
    26452699indchosen=1;  %%first pair selected by default
    26462700%displ_num used to define the indices of the civ pairs
     
    26482702% are relative to the reference indices ref_i and ref_j respectively.
    26492703if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2')
     2704
    26502705    dt=1;
    26512706    displ='';
     
    26612716            numlist_a(index)=numod_a;
    26622717            numlist_b(index)=numod_b;
    2663             if ~isempty(time)
    2664                 dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt
     2718            if size(time,2)>1 && ~checkframe
     2719                dt(numod_a,numod_b)=time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt
    26652720                displ_dt(index)=dt(numod_a,numod_b);
    26662721            else
     
    26992754    set(handles.nb_field2,'Visible','On')
    27002755    set(handles.ref_j,'Visible','On')
    2701     if nbfield > 1
    2702         set(handles.itext,'Visible','On')
    2703         set(handles.first_i,'Visible','On')
    2704         set(handles.last_i,'Visible','On')
    2705         set(handles.incr_i,'Visible','On')
    2706         set(handles.nb_field,'Visible','On')
    2707         set(handles.ref_i,'Visible','On')
    2708     else
    2709         set(handles.itext,'Visible','Off')
    2710         set(handles.first_i,'Visible','Off')
    2711         set(handles.last_i,'Visible','Off')
    2712         set(handles.incr_i,'Visible','Off')
    2713         set(handles.nb_field,'Visible','Off')
    2714         set(handles.ref_i,'Visible','Off')
    2715     end
     2756%     if nbfield > 1
     2757%         set(handles.itext,'Visible','On')
     2758%         set(handles.first_i,'Visible','On')
     2759%         set(handles.last_i,'Visible','On')
     2760%         set(handles.incr_i,'Visible','On')
     2761%         set(handles.nb_field,'Visible','On')
     2762%         set(handles.ref_i,'Visible','On')
     2763%     else
     2764%         set(handles.itext,'Visible','Off')
     2765%         set(handles.first_i,'Visible','Off')
     2766%         set(handles.last_i,'Visible','Off')
     2767%         set(handles.incr_i,'Visible','Off')
     2768%         set(handles.nb_field,'Visible','Off')
     2769%         set(handles.ref_i,'Visible','Off')
     2770%     end
    27162771elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')
    27172772    index=1:200;
     
    27852840find_netcpair_civ1( handles)
    27862841find_netcpair_civ2(handles)
     2842'TESTin'
     2843browse=get(handles.RootName,'UserData')
    27872844
    27882845%------------------------------------------------------------------------
     
    29473004end
    29483005time=get(handles.ImaDoc,'UserData');%get the set of times
    2949 if isempty(time)
    2950     time=[0 1];
    2951 end
    2952 dt_unit=1000;%default
     3006% if isempty(time)
     3007%     time=[0 1];
     3008% end
     3009TimeUnit=get(handles.TimeUnit,'String');
     3010checkframe=strcmp(TimeUnit,'frame');
     3011
    29533012displ_num=get(handles.ListPairCiv1,'UserData');
    29543013
     
    30223081            if select(ipair)
    30233082                displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    3024                 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3025                     dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
    3026                     displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     3083                if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1
     3084                    dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt
     3085                else
     3086                    dt=1;
    30273087                end
     3088                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    30283089            else
    30293090                displ_pair{ipair}='...'; %pair not displayed in the menu
     
    30383099            if select(ipair)
    30393100                displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    3040                 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3041                     dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3101                if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)
     3102                    dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt
    30423103                    displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    30433104                end
     
    30503111    for ipair=1:nbpair
    30513112        if select(ipair)
    3052             dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
     3113            if ~checkframe && size(time,2)>1
     3114            dt=time(ref_i+1+displ_num(4,ipair),displ_num(2,ipair)+1)-time(ref_i+1+displ_num(3,ipair),displ_num(1,ipair)+1);%time interval dt
     3115            else % time set by default to i index
     3116                dt=1;
     3117            end
    30533118            displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
    30543119                ' :dt= ' num2str(dt*1000)];
     
    31403205end
    31413206time=get(handles.ImaDoc,'UserData'); %get the set of times
    3142 if isempty(time)
    3143     time=[0 1];%default
    3144 end
     3207TimeUnit=get(handles.TimeUnit,'String');
     3208checkframe=strcmp(TimeUnit,'frame');
     3209% if isempty(time)
     3210%     time=[0 1];%default
     3211% end
    31453212displ_num=get(handles.ListPairCiv1,'UserData');
    31463213
     
    31983265        if select(ipair)
    31993266            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    3200             if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3201                 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3267            if  ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
     3268                dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt
    32023269                displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    32033270            end
     
    32103277        if select(ipair)
    32113278            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    3212             if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3213                 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3279            if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)&& displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1
     3280                dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt
     3281            else
     3282                dt=1;
     3283            end
    32143284                displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    3215             end
    32163285        else
    32173286            displ_pair{ipair}='...'; %pair not displayed in the menu
     
    32213290    for ipair=1:nbpair
    32223291        if select(ipair)
    3223             dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
    3224             displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
     3292            if  ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) && displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1
     3293            dt=time(ref_i+displ_num(4,ipair)+1,displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,displ_num(1,ipair)+1);%time interval dt
     3294            else
     3295                dt=1;
     3296            end
     3297            displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair)+1,nom_type_ima) '-' num2stra(displ_num(2,ipair)+1,nom_type_ima) ...
    32253298                ' :dt= ' num2str(dt*1000)];
     3299               
    32263300        else
    32273301            displ_pair{ipair}='...'; %pair not displayed in the menu
     
    36233697list_subdir_civ1=get(handles.ListSubdirCiv1,'String');
    36243698val=get(handles.ListSubdirCiv1,'Value');
    3625 subdir=list_subdir_civ1{val};
    3626 if strcmp(subdir,'new...')
     3699SubDir=list_subdir_civ1{val};
     3700if strcmp(SubDir,'new...')
    36273701    if get(handles.CheckCiv1,'Value')
    3628         subdir='CIV'; %default subdirectory
     3702        SubDir='CIV'; %default subdirectory
    36293703    else
    36303704        msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation')
     
    36323706    end   
    36333707end
    3634 set(handles.txt_SubdirCiv1,'String',subdir);
     3708set(handles.txt_SubdirCiv1,'String',SubDir);
    36353709find_netcpair_civ1(handles)
    36363710
     
    36413715list_subdir_civ2=get(handles.ListSubdirCiv2,'String');
    36423716val=get(handles.ListSubdirCiv2,'Value');
    3643 subdir=list_subdir_civ2{val};
    3644 if strcmp(subdir,'new...')
     3717SubDir=list_subdir_civ2{val};
     3718if strcmp(SubDir,'new...')
    36453719    if get(handles.CheckCiv2,'Value')
    3646         subdir='CIV'; %default subdirectory
     3720        SubDir='CIV'; %default subdirectory
    36473721    else
    36483722        msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation')
     
    36503724    end
    36513725end
    3652 set(handles.txt_SubdirCiv2,'String',subdir);
     3726set(handles.txt_SubdirCiv2,'String',SubDir);
    36533727
    36543728%------------------------------------------------------------------------
     
    38603934sizf=size(fileinput);
    38613935if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    3862 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3936%[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3937[Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput);
    38633938ref.filebase=fullfile(Path,File);
    3864 ref.num_a=stra2num(str_a);
    3865 ref.num_b=stra2num(str_b);
    3866 ref.num1=str2double(field_count);
    3867 ref.num2=str2double(str2);
     3939% ref.num_a=stra2num(str_a);
     3940% ref.num_b=stra2num(str_b);
     3941% ref.num1=str2double(field_count);
     3942% ref.num2=str2double(str2);
    38683943browse=[];%initialisation
    38693944if ~isequal(ref.ext,'.nc')
     
    39043979    sizf=size(fileinput);
    39053980    if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    3906     [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3981    %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3982    [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput);
    39073983    ref.filebase=fullfile(Path,File);
    3908     ref.num_a=stra2num(str_a);
    3909     ref.num_b=stra2num(str_b);
    3910     ref.num1=str2num(field_count);
    3911     ref.num2=str2num(str2);
     3984%     ref.num_a=stra2num(str_a);
     3985%     ref.num_b=stra2num(str_b);
     3986%     ref.num1=str2num(field_count);
     3987%     ref.num2=str2num(str2);
    39123988    browse=[];%initialisation
    39133989    if ~isequal(ref.ext,'.nc')
     
    40914167errormsg=''; %default
    40924168filename=regexprep(filename,'.nc',''); %file name for the result
    4093 if isequal(Param.Civ1.Dt,'0')
    4094     Param.Civ1.Dt='1' ;%case of 'displacement' mode
     4169if isequal(Param.Civ1.Dt,0)
     4170    Param.Civ1.Dt=1 ;%case of 'displacement' mode
    40954171end
    40964172Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png','');
     
    44444520    end
    44454521end
    4446 
Note: See TracChangeset for help on using the changeset viewer.