Changeset 371 for trunk/src


Ignore:
Timestamp:
Jan 14, 2012, 1:44:13 PM (13 years ago)
Author:
sommeria
Message:

various bug fixes with file indexing. mode displacement from a fixed image introduced.
PIV stereo suppressed (todo: introduce in the GUI series).
find_file_series cleaned, with a change in the function arguments

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r370 r371  
    2323%TODO: search range
    2424
    25 % Last Modified by GUIDE v2.5 13-Jan-2012 08:01:20
     25% Last Modified by GUIDE v2.5 14-Jan-2012 00:46:29
    2626% Begin initialization code - DO NOT EDIT
    2727gui_Singleton = 1;
     
    102102%% prepare the GUI with parameters from the input file if opened from uvmat
    103103if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName)
    104     set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     104    set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    105105    errormsg=display_file_name(handles,fileinput);
    106106    if ~isempty(errormsg)
    107107        msgbox_uvmat('ERROR',errormsg)
    108108    end
    109     set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     109    set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    110110end
    111111
     
    122122%------------------------------------------------------------------------
    123123%% get the current input root file name to initiate the browser
    124 filebase=get(handles.RootName,'String');
     124filebase=get(handles.RootPath,'String');
    125125oldfile=''; %default
    126126if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name
     
    183183
    184184%% prepare the GUI with parameters from the input file
    185 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     185set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    186186errormsg=display_file_name(handles,fileinput);
    187187if ~isempty(errormsg)
    188188    msgbox_uvmat('ERROR',erromsg)
    189189end
    190 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     190set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    191191
    192192%------------------------------------------------------------------------
     
    194194function MenuFile_1_Callback(hObject, eventdata, handles)
    195195%------------------------------------------------------------------------
    196 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     196set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    197197fileinput=get(handles.MenuFile_1,'Label');
    198198errormsg=display_file_name(handles,fileinput);
     
    200200    msgbox_uvmat('ERROR',errormsg)
    201201end
    202 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     202set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    203203
    204204% -----------------------------------------------------------------------
     
    206206function MenuFile_2_Callback(hObject, eventdata, handles)
    207207%------------------------------------------------------------------------
    208 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     208set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    209209fileinput=get(handles.MenuFile_2,'Label');
    210210errormsg=display_file_name(handles,fileinput);
     
    212212    msgbox_uvmat('ERROR',errormsg)
    213213end
    214 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     214set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    215215
    216216% -----------------------------------------------------------------------
     
    218218function MenuFile_3_Callback(hObject, eventdata, handles)
    219219%------------------------------------------------------------------------
    220 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     220set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    221221fileinput=get(handles.MenuFile_3,'Label');
    222222errormsg=display_file_name(handles,fileinput);
     
    224224    msgbox_uvmat('ERROR',errormsg)
    225225end
    226 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     226set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    227227
    228228% -----------------------------------------------------------------------
     
    230230function MenuFile_4_Callback(hObject, eventdata, handles)
    231231%------------------------------------------------------------------------
    232 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     232set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    233233fileinput=get(handles.MenuFile_4,'Label');
    234234errormsg=display_file_name(handles,fileinput);
     
    236236    msgbox_uvmat('ERROR',errormsg)
    237237end
    238 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     238set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    239239
    240240% -----------------------------------------------------------------------
     
    242242function MenuFile_5_Callback(hObject, eventdata, handles)
    243243%------------------------------------------------------------------------
    244 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     244set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    245245fileinput=get(handles.MenuFile_5,'Label');
    246246errormsg=display_file_name(handles,fileinput);
     
    248248    msgbox_uvmat('ERROR',errormsg)
    249249end
    250 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     250set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    251251
    252252% -----------------------------------------------------------------------
     
    266266%------------------------------------------------------------------------
    267267% --- Function activated when a new filebase (image series) is introduced
    268 function RootName_Callback(hObject, eventdata, handles)
    269 %------------------------------------------------------------------------
    270 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    271 [RootPath,RootFile]=fileparts(get(handles.RootName,'String'));
     268function RootPath_Callback(hObject, eventdata, handles)
     269%------------------------------------------------------------------------
     270set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
     271RootPath=get(handles.RootPath,'String');
     272RootFile=get(handles.RootFile,'String');
    272273ref_i=str2num(get(handles.ref_i,'String'));
    273274ref_j=str2num(get(handles.ref_j,'String'));
     
    279280    msgbox_uvmat('ERROR',errormsg)
    280281end
    281 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     282set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    282283%------------------------------------------------------------------------
    283284% --- general function activated for an input file series
     
    311312if strcmp(ExtInput,'.nc')
    312313    NomTypeNc=NomTypeInput;
    313     Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','fix','patch','civ2','fix2');
     314    if isempty(regexp(NomTypeInput,'[ab|AB|-]'))
     315        set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs
     316        [RootPath,SubDir]=fileparts(RootPath);
     317    set(handles.RootFile_1,'Visible','On');
     318    else
     319         set(handles.ListCompareMode,'Value',1)
     320         set(handles.RootFile_1,'Visible','Off');
     321    end
     322    Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2');
    314323    if isfield(Data,'Txt')
    315324        errormsg=Data.Txt;
     
    322331            ind_opening=Data.CivStage;
    323332        end
    324         if ~isempty(Data.Civ2_ImageA)%get the corresponding input image in the netcdf file
    325             imageinput=Data.Civ1_ImageA;
    326         elseif ~isempty(Data.Civ1_ImageA)
    327             imageinput=Data.Civ1_ImageA;
    328         end
     333        if  ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file
     334            imageinput=Data.Civ2_ImageB;
     335            [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA);
     336            set(handles.RootFile_1,'String',[ImaName ImaExt])
     337        elseif ~isempty(Data.Civ1_ImageB)
     338            imageinput=Data.Civ1_ImageB;
     339            [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA);
     340            set(handles.RootFile_1,'String',[ImaName ImaExt])
     341        end
     342       
    329343    elseif ~isempty(Data.absolut_time_T0')% case of  civx data,
    330344        set(handles.ListProgram,'Value',1) %select Cix by default
     
    361375end
    362376
    363 %% scan the image series when a nc file has been opened
     377%no corresponding image found, select manually with the browser
    364378ImaExt=ExtInput;
    365379if ~isempty(NomTypeNc)
     
    377391    end   
    378392    fileinput=imageinput;
    379     [tild, tild,ImaExt]=fileparts(imageinput);
    380 end
    381 [RootPath,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object]=find_file_series(fileinput);
     393end
     394
     395%% scan the image file series
     396[RootPath,FileName,ImaExt]=fileparts(fileinput);
     397[RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object]=find_file_series(RootPath,[FileName ImaExt]);
    382398if strcmp(NomTypeInput,'*')% movies will be opened at the first frame
    383399    i1=1;
     
    392408        return
    393409end
    394 RootName=fullfile(RootPath,RootFile);
    395 set(handles.RootName,'String',RootName)
    396 browse=get(handles.RootName,'UserData');
     410% RootName=fullfile(RootPath,RootFile);
     411set(handles.RootPath,'String',RootPath)
     412set(handles.RootFile,'String',RootFile)
     413browse=get(handles.RootPath,'UserData');
    397414% browse.nom_type_nc=NomTypeNc;
    398415browse.incr_pair=[0 0];%default
     
    409426
    410427%% scan the images if a civ file has been opened
    411 if ~isempty(NomTypeNc)
    412 [RootPath,tild,i1_series,tild,j1_series,tild,NomTypeIma,ImageType,Object]=find_file_series(imageinput);
    413 end
     428% if ~isempty(NomTypeNc)
     429% [tild,i1_series,tild,j1_series,tild,NomTypeIma,ImageType,Object]=find_file_series(RootPath,RootFile);
     430% end
    414431MinIndex_i=min(i1_series(i1_series>0));
    415432MinIndex_j=min(j1_series(j1_series>0));
     
    419436%% look for an image documentation file
    420437ext_imadoc='';%default
     438RootName=fullfile(RootPath,RootFile);
    421439if exist([RootName '.xml'],'file')
    422440    ext_imadoc='.xml';
     
    543561first_i=str2num(get(handles.first_i,'String'));
    544562last_i=str2num(get(handles.last_i,'String'));
    545 if ind_opening~=0 || first_i<MinIndex_i || last_i>MaxIndex_i
     563if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)
     564    set(handles.first_i,'String',num2str(num_ref_i));
     565    set(handles.last_i,'String',num2str(num_ref_i));%
     566end
     567if ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i
    546568set(handles.first_i,'String',num2str(num_ref_i));
    547569set(handles.last_i,'String',num2str(num_ref_i));%
     
    551573first_j=str2num(get(handles.first_j,'String'));
    552574last_j=str2num(get(handles.last_i,'String'));
    553 if ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
    554 set(handles.first_j,'String',num2str(num_ref_j));
     575if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)
     576    set(handles.first_j,'String',num2str(num_ref_j));
     577    set(handles.last_j,'String',num2str(num_ref_j));%
     578elseif ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
     579    set(handles.first_j,'String',num2str(num_ref_j));
    555580set(handles.last_j,'String',num2str(num_ref_j));%
    556581end
    557582
    558583%% set the civ options depending on the input file content when a nc file has been opened
    559  ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'};
     584ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'};
    560585if ind_opening~=0
    561586    for index = 1:ind_opening
    562587        set(handles.(ListOptions{index}),'value',0)
    563588    end
    564     for index = ind_opening+2:6
    565         set(handles.(ListOptions{index}),'value',0)
    566     end
     589end
     590for index = ind_opening+2:6
     591    set(handles.(ListOptions{index}),'value',0)
    567592end
    568593set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
     
    571596%%  set the menus of image pairs and default selection for civ   %%%%%%%%%%%%%%%%%%%
    572597%check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter
    573 if  isequal(NomTypeNc,'_1-2')|| (MaxIndex_j==1)
     598if  isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1)
    574599    set(handles.ListPairMode,'Value',1)
    575600    set(handles.ListPairMode,'String',{'series(Di)'})   
     
    641666
    642667%% store info
    643 set(handles.RootName,'UserData',browse)% store the nomenclature type
     668set(handles.RootPath,'UserData',browse)% store the nomenclature type
    644669
    645670%% list the possible index pairs, depending on the option set in ListPairMode
     
    660685    end
    661686end
    662 set(handles.RootName,'BackgroundColor',[1 1 1])
     687set(handles.RootPath,'BackgroundColor',[1 1 1])
    663688
    664689%------------------------------------------------------------------------
     
    755780ind_selected=find(checkbox,1);
    756781if ~isempty(ind_selected)
    757     RootName=get(handles.RootName,'String');
    758     if isempty(RootName)
     782    RootPath=get(handles.RootPath,'String');
     783    if isempty(RootPath)
    759784        msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')
    760785        return
     
    764789set(handles.SubdirCiv1,'Visible','on')
    765790set(handles.ListSubdirCiv1,'Visible','on')
     791set(handles.TitleSubdirCiv1,'Visible','on')
    766792if ~opening
    767793    errormsg=find_netcpair_civ(handles,1); % select the available netcdf files
     
    808834set(handles.RUN,'BackgroundColor',[1 0 0])
    809835
    810 % start status callback to visualise results
     836% display errors or start status callback to visualise results
    811837if ~isempty(errormsg)
    812838    display(errormsg)
     
    828854set(handles.BATCH,'BackgroundColor',[1 0 0])
    829855
    830 % start status callback to visualise results
     856% display errors or start status callback to visualise results
    831857if ~isempty(errormsg)
    832858    display(errormsg)
     
    884910    hfig=figure('DeleteFcn',@stop_status);
    885911    set(hfig,'name','civ_status')
    886     %hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
    887912     uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
    888913    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
     
    918943            option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
    919944            if ~isempty(Data.CivStage)
    920                 option=Data.CivStage;
     945                option=Data.CivStage;%case of Matlab civ
    921946            else
    922947                if ~isempty(Data.patch2) && isequal(Data.patch2,1)
    923948                    option=6;
    924                     %                 option_str='patch2';
    925949                elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
    926950                    option=5;
    927                     %                 option_str='fix2';
    928951                elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
    929952                    option=4;
    930                     %                 option_str='civ2';
    931953                elseif ~isempty(Data.patch) && isequal(Data.patch,1);
    932954                    option=3;
    933                     %                 option_str='patch1';
    934955                elseif ~isempty(Data.fix) && isequal(Data.fix,1);
    935956                    option=2;
    936                     %                 option_str='fix1';
    937957                else
    938958                    option=1;
    939                     %                 option_str='civ1';
    940959                end
    941960            end
     
    10961115
    10971116%% check if the binaries exist
    1098 % if isequal(get(handles.ListProgram,'Value'),2)
    1099 %     CivMode='Matlab';
    1100 % else
    1101 %     CivMode='CivX';
    1102 % end
    11031117ListProgram=get(handles.ListProgram,'String');
    11041118CivMode=ListProgram{get(handles.ListProgram,'Value')};
     
    11071121    case 'CivX'
    11081122        binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'};
    1109     case 'CivAll'
     1123    case 'CivAll'% desactivated option
    11101124        binary_list={'Civ'};
    11111125    case 'Matlab'
    11121126        if batch
    1113             % vérifier MenuMatlab installé sur le cluster
     1127            % verifier MenuMatlab installe sur le cluster
    11141128            % difficile a faire a priori
    11151129        end         
     
    17061720t=struct2xml(Param);
    17071721t=set(t,1,'Name','CivDoc');% set the head label
    1708 save(t,[namedoc '.xml']); %save GUI  parameters as xml file
     1722save(t,[namedoc '.CivDoc.xml']); %save GUI  parameters as xml file
    17091723saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    17101724
     
    17601774%------------------------------------------------------------------------
    17611775% --- determine the list of filenames and indices needed for launch_job
    1762 function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2,compare]=...
     1776%------------------------------------------------------------------------
     1777% OUTPUT:
     1778% filecell: structure of cell arrays {ref_i,ref_j} containing all the filenames involved in the civ process
     1779%    the indices ref_i and ref_j correspond to the list of reference indices
     1780%       .filebase=fullfile(RootPath,RootFile) used to construct mask names, grid names, CivDoc xml file
     1781%       .ima1.civ1,.ima1.civ2: first image for civ1 and civ2 respectively (possibly different)
     1782%       .ima2.civ1,.ima2.civ2: second image for civ1 and civ2 respectively (possibly different)
     1783%       .nc.civ1,.nc.civ2: netcdf files containing civ1 and civ2 data respectively (possibly different)
     1784% i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2: arrays of files indices, needed for timing records
     1785function [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,NomType_nc,file_ref_fix1,file_ref_fix2,compare]=...
    17631786    set_civ_filenames(handles,ref_i,ref_j,checkbox)
    17641787%------------------------------------------------------------------------
    17651788filecell=[];%default
    17661789
    1767 %% get the root names nomenclature and numbers
    1768 filebase=get(handles.RootName,'String');
    1769 
    1770 if isempty(filebase)||isequal(filebase,'')
     1790%% get the root name and check dir
     1791RootPath=get(handles.RootPath,'String');
     1792RootFile=get(handles.RootFile,'String');
     1793filecell.filebase=fullfile(RootPath,RootFile);
     1794if isempty(filecell.filebase)
    17711795    msgbox_uvmat('ERROR','please open an image with the upper menu option Open/Browse...')
    17721796    return
    17731797end
    1774 
    1775 %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis
    1776 filecell.filebase=filebase;
    1777 
    1778 browse=get(handles.RootName,'UserData');
    1779 compare_list=get(handles.ListCompareMode,'String');
    1780 val=get(handles.ListCompareMode,'Value');
    1781 compare=compare_list{val};
     1798if ~exist(RootPath,'dir')
     1799    msgbox_uvmat('ERROR',['path to images ' RootPath ' not found'])
     1800    return
     1801end
     1802[xx,message]=fileattrib(RootPath);
     1803if ~isempty(message) && ~isequal(message.UserWrite,1)
     1804    msgbox_uvmat('ERROR',['No writting access to ' RootPath])
     1805    return
     1806end
     1807%check result directory
     1808subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data
     1809subdir_civ2=get(handles.SubdirCiv2,'String');
     1810if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir
     1811if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
     1812
     1813%% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV
     1814ListCompareMode=get(handles.ListCompareMode,'String');
     1815compare=ListCompareMode{get(handles.ListCompareMode,'Value')};
     1816
     1817% set the nomenclature type of the nc files depending on the pair mode
    17821818if strcmp(compare,'displacement')||strcmp(compare,'shift')
    17831819    mode='displacement';
     
    17871823    mode=mode_list{mode_value};
    17881824end
    1789 %time=get(handles.RootName,'UserData'); %get the set of times
    1790 ext_ima=get(handles.ImaExt,'String');
    1791 if strcmp(compare,'displacement')
    1792     nom_type_ima1='*';
    1793 else
    1794     nom_type_ima1=get(handles.NomType,'String');
    1795 end
    1796 nom_type_nc=nomtype2pair(nom_type_ima1,mode);
    1797 
    1798 [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
     1825NomType_ima2=get(handles.NomType,'String');
     1826NomType_nc=nomtype2pair(NomType_ima2,mode);
     1827
     1828% set the rootfile and image indexing
     1829RootFile_ima2=get(handles.RootFile,'String');%root file for the second image series
     1830ext_ima=get(handles.ImaExt,'String'); % image extension (the same for all images)
     1831switch compare
     1832    case 'PIV'
     1833       RootFile_ima1=RootFile_ima2;% root name of the two image series is the same
     1834       NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one
     1835       RootFile_nc=RootFile_ima2;
     1836    case 'displacement'
     1837       RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1
     1838       NomType_ima1='';% no indexing of the first image, a fixed reference for the whole series
     1839       RootFile_nc=RootFile_ima2;
     1840    case 'shift'
     1841       RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1
     1842       NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one
     1843       RootFile_nc=[RootFile_ima1 '-' RootFile_ima2];
     1844end
     1845
     1846%determine the list of file indices involved
     1847[i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=...
    17991848    find_pair_indices(handles,ref_i,ref_j,mode);
     1849
    18001850%determine the new filebase for 'displacement' ListPairMode (comparison of two series)
    1801 filebase_B=filebase;% root name of the second field series for stereo
    1802 if ~strcmp(compare,'PIV')
    1803     [Path2,Name2]=fileparts(filebase_B);
    1804     Path1=Path2;
    1805     Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo
    1806     filebase_A=fullfile(Path1,Name1);
    1807     if length(Name1)>6
    1808         Name1=Name1(end-5:end);
    1809     end
    1810     if length(Name2)>6
    1811         Name2=Name2(end-5:end);
    1812     end
    1813     filebase_AB=fullfile(Path2,[Name2 '-' Name1]);
    1814 else
    1815 %     test_disp=0;
    1816     filebase_A=filebase;
    1817     nom_type_ima2=nom_type_ima1;
    1818     filebase_AB=filebase;
    1819 end
    1820 if strcmp(compare,'displacement')||strcmp(compare,'shift')
    1821     filebase_ima1=filebase_A;
    1822     filebase_ima2=filebase_B;
    1823     filebase_nc=filebase_AB; %root name for the result of civ2
    1824 else
    1825     filebase_ima1=filebase_B;
    1826     filebase_ima2=filebase_B;
    1827     filebase_nc=filebase_B;
    1828 end
    1829 [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1);
    1830 [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2);
    1831 [RootPath_nc,RootFile_nc]=fileparts(filebase_nc);
    1832 [RootPath_A,RootFile_A]=fileparts(filebase_A);
    1833 [RootPath_AB,RootFile_AB]=fileparts(filebase_AB);
     1851%filebase_B=filebase;% root name of the second field series for stereo
     1852% filebase_A=filebase;%default
     1853% if strcmp(compare,'PIV')
     1854%     filebase_AB=filebase;
     1855% else
     1856%     [Path2,Name2]=fileparts(filebase_B);
     1857%     Name1=RootFile_ima1;
     1858%     filebase_AB=fullfile(Path2,[Name2 '-' Name1]);   
     1859% end
     1860% [RootPath_AB,RootFile_AB]=fileparts(filebase_AB);
     1861% % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B);
     1862% [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B);
     1863% [RootPath_nc,RootFile_nc]=fileparts(filebase_B);%default
     1864% if strcmp(compare,'displacement')
     1865% %     [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B);
     1866% %     [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B);
     1867%     [RootPath_nc,RootFile_nc]=fileparts(filebase_B);
     1868% elseif strcmp(compare,'shift')
     1869%     RootPath_nc=RootPath_AB;
     1870%     RootFile_nc=RootFile_AB;
     1871% end
     1872% else
     1873%     filebase_ima1=filebase_B;
     1874%     filebase_ima2=filebase_B;
     1875%     filebase_nc=filebase_B;
     1876% [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1);
     1877% [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2);
     1878% [RootPath_nc,RootFile_nc]=fileparts(filebase_nc);
     1879% [RootPath_A,RootFile_A]=fileparts(filebase_A);
     1880
    18341881   
    1835 %determine reference files for fix:
     1882%% determine reference files for fix:
    18361883file_ref_fix1={};%default
    18371884file_ref_fix2={};
    1838 nbfield=length(num1_civ1);
    1839 nbslice=length(num_a_civ1);
     1885nbfield=length(i1_civ1);
     1886nbslice=length(j1_civ1);
    18401887if checkbox(2)==1% fix1 performed
    18411888    ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback
     
    18511898        if isequal(mode,'displacement')
    18521899            num_i1=num_i_ref;
    1853  name_genna           num_i2=num_i_ref;
     1900            num_i2=num_i_ref;
    18541901            num_j1=num_j_ref;
    18551902            num_j2=num_j_ref;
     
    18791926        for ifile=1:nbfield
    18801927            for j=1:nbslice
    1881                 [RootPath,RootFile]=fileparts(ref.filebase);
    1882                 file_ref=fullfile_uvmat(RootPath,ref.subdir,RootFile,'.nc',ref.nom_type,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j));
    1883 %                 file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);%
     1928                [RootPathRef,RootFile]=fileparts(ref.filebase);
     1929                file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j));
    18841930                file_ref_fix1(ifile,j)={file_ref};
    18851931                if ~exist(file_ref,'file')
     
    18931939end
    18941940
    1895 %determine reference files for checkfix2:
     1941%% determine reference files for fix2:
    18961942if checkbox(5)==1% fix2 performed
    18971943    ref=get(handles.ref_fix2,'UserData');
     
    19321978        for ifile=1:nbfield
    19331979            for j=1:nbslice
    1934                 [RootPath,RootFile]=fileparts(ref.filebase);
    1935                 file_ref=fullfile_uvmat(RootPath,ref.subdir,RootFile,'.nc',ref.nom_type,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j));
    1936                 %file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);%
     1980                [RootPathRef,RootFile]=fileparts(ref.filebase);
     1981                file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j));
    19371982                file_ref_fix2(ifile,j)={file_ref};
    19381983                if ~exist(file_ref,'file')
     
    19461991end
    19471992
    1948 %check dir
    1949 subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data
    1950 subdir_civ2=get(handles.SubdirCiv2,'String');
    1951 if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir
    1952 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
    1953 % currentdir=pwd;%store the current working directory
    1954 [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ)
    1955 if ~exist(Path_ima,'dir')
    1956     msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
    1957     filecell={};
    1958     return
    1959 end
    1960 [xx,message]=fileattrib(Path_ima);
    1961 if ~isempty(message) && ~isequal(message.UserWrite,1)
    1962     msgbox_uvmat('ERROR',['No writting access to ' Path_ima])
    1963     filecell={};
    1964 %     cd(currentdir);
    1965     return
    1966 end
    1967 
    1968 %check the existence of the netcdf and image files involved
     1993%% check the existence of the netcdf and image files involved
    19691994% %%%%%%%%%%%%  case CheckCiv1 activated   %%%%%%%%%%%%%
    19701995if checkbox(1)==1;
     
    19752000        for ifile=1:nbfield
    19762001            for j=1:nbslice
    1977                 [RootPath,RootFile]=fileparts(filebase_nc);
    1978                 filename=fullfile_uvmat(RootPath_nc,subdir_civ1_new,RootFile_nc,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
    1979                % filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);
     2002                filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
    19802003                detect=exist(filename,'file')==2;
    19812004                if detect% if a netcdf file already exists
     
    19992022 
    20002023        %create the new SubdirCiv1
    2001         if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
    2002 %             cd(Path_ima);         
    2003             [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new));
     2024        if ~exist(fullfile(RootPath,subdir_civ1_new),'dir')     
     2025            [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new));
    20042026
    20052027            if ~strcmp(msg1,'')
     
    20082030                return
    20092031            elseif isunix         
    2010                 [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g)
     2032                [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g)
    20112033                if ~strcmp(msg2,'')
    2012                     msgbox_uvmat('ERROR',['pb of permission for  ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation
     2034                    msgbox_uvmat('ERROR',['pb of permission for  ' fullfile(RootPath,subdir_civ1_new) ': ' msg2])%error message for directory creation
    20132035                    filecell={};
    20142036                    return
    20152037                end
    20162038            end
    2017 %             cd(currentdir);
    20182039        end
    20192040        if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series
    20202041            for ifile=1:nbfield
    20212042                for j=1:nbslice
    2022                      filename=fullfile_uvmat(RootPath_A,subdir_civ1_new,RootFile_A,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
    2023                    % filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);%
     2043                     filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
     2044                   % filename=name_generator(filebase_A,i1_civ1(ifile),j1_civ1(j),'.nc',NomType_nc,1,i2_civ1(ifile),j2_civ1(j),subdir_civ1_new);%
    20242045                    detect=exist(filename,'file')==2;
    20252046                    if detect% if a netcdf file already exists
     
    20422063            end
    20432064            %create the new SubdirCiv1
    2044             if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
    2045 %                    cd(Path_ima);         
    2046                 [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new));
    2047 %                             cd(currentdir);
     2065            if ~exist(fullfile(RootPath,subdir_civ1_new),'dir')       
     2066                [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new));
    20482067                if ~strcmp(msg1,'')
    20492068                    msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])
    2050 %                     cd(currentdir)
    20512069                    filecell={};
    20522070                    return
    20532071                else
    2054                     [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g)
     2072                    [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g)
    20552073                    if ~strcmp(msg2,'')
    20562074                        msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation
    2057 %                         cd(currentdir)
    20582075                        filecell={};
    20592076                        return
     
    20672084    for ifile=1:nbfield
    20682085        for j=1:nbslice
    2069              filename=fullfile_uvmat(RootPath_ima1,'',RootFile_ima1,ext_ima,nom_type_ima1,num1_civ1(ifile),[],num_a_civ1(j));
    2070            % filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
     2086             filename=fullfile_uvmat(RootPath,'',RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
    20712087            idetect(j)=exist(filename,'file')==2;
    20722088            filecell.ima1.civ1(ifile,j)={filename}; %first image
    2073             filename=fullfile_uvmat(RootPath_ima2,'',RootFile_ima2,ext_ima,nom_type_ima2,num2_civ1(ifile),[],num_b_civ1(j));
    2074           %  filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
     2089            filename=fullfile_uvmat(RootPath,'',RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
    20752090            idetect_1(j)=exist(filename,'file')==2;
    20762091            filecell.ima2.civ1(ifile,j)={filename};%second image
     
    20802095            msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found'])
    20812096            filecell={};
    2082            % cd(currentdir)
    20832097            return
    20842098        end
     
    20872101            msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found'])
    20882102            filecell={};
    2089             %cd(currentdir)
    20902103            return
    20912104        end
     
    20942107        for ifile=1:nbfield
    20952108            for j=1:nbslice
    2096                 filename=fullfile_uvmat(RootPath_A,'',RootFile_A,ext_ima,nom_type_ima1,num1_civ1(ifile),[],num_a_civ1(j));
    2097                % filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
     2109                filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
    20982110                idetect(j)=exist(filename,'file')==2;
    20992111                filecell.imaA1.civ1(ifile,j)={filename} ;%first image
    2100                 filename=fullfile_uvmat(RootPath_A,'',RootFile_A,ext_ima,nom_type_ima2,num2_civ1(ifile),[],num_b_civ1(j));
    2101                % filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
     2112                filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
    21022113                idetect_1(j)=exist(filename,'file')==2;
    21032114                filecell.imaA2.civ1(ifile,j)={filename};%second image
     
    21242135    for ifile=1:nbfield
    21252136        for j=1:nbslice
    2126             filename=fullfile_uvmat(RootPath_nc,subdir_civ1,RootFile_nc,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
    2127            % filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',...
    2128            %     nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
     2137            filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
    21292138            detect=exist(filename,'file')==2;
    21302139            if detect==0
     
    21402149        for ifile=1:nbfield
    21412150            for j=1:nbslice
    2142                 filename=fullfile_uvmat(RootPath_A,subdir_civ1,RootFile_A,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
    2143               %  filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
     2151                filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
    21442152                filecell.ncA.civ1(ifile,j)={filename};
    21452153                if ~exist(filename,'file')
     
    21672175        for ifile=1:nbfield
    21682176            for j=1:nbslice
    2169                 filename=fullfile_uvmat(RootPath_nc,subdir_civ2_new,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
    2170                % filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);%
     2177                filename=fullfile_uvmat(RootPath,subdir_civ2_new,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j));
    21712178                detect=exist(filename,'file')==2;
    21722179                if detect% if a netcdf file already exists
     
    21882195        end
    21892196        %create the new subdir_civ2_new
    2190         if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
    2191             [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new));
    2192             [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g)
     2197        if ~exist(fullfile(RootPath,subdir_civ2_new),'dir')
     2198            [xx,m2]=mkdir(fullfile(RootPath,subdir_civ2_new));
     2199            [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g)
    21932200            if ~isequal(m2,'')
    2194                 msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])
     2201                msgbox_uvmat('ERROR',['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2])
    21952202                filecell={};
    2196                % cd(currentdir)
    21972203                return
    21982204            end
     
    22012207            for ifile=1:nbfield
    22022208                for j=1:nbslice
    2203                     filename=fullfile_uvmat(RootPath_A,subdir_civ2_new,RootFile_A,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
    2204                 %   filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
    2205                  %       nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);%
     2209                    filename=fullfile_uvmat(RootPath,subdir_civ2_new,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j));
    22062210                    detect=exist(filename,'file')==2;
    22072211                    if detect% if a netcdf file already exists
     
    22242228            subdir_civ2=subdir_civ2_new;
    22252229            %create the new SubdirCiv1
    2226             if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
     2230            if ~exist(fullfile(RootPath,subdir_civ2_new),'dir')
    22272231                [xx,m2]=mkdir(subdir_civ2_new);
    2228                  [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g)
     2232                 [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g)
    22292233                if ~isequal(m2,'')
    2230                     msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation
     2234                    msgbox_uvmat('ERROR', ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2])%error message for directory creation
    22312235                  %  cd(currentdir)
    22322236                    filecell={};
     
    22462250        for ifile=1:nbfield
    22472251            for j=1:nbslice
    2248                 filename=fullfile_uvmat(RootPath_nc,subdir_civ1,RootFile_nc,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
    2249                 %filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',...
    2250 %                     nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
     2252                filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));%
    22512253                filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file
    22522254                if ~exist(filename,'file')
     
    22922294            for ifile=1:nbfield
    22932295                for j=1:nbslice
    2294                     filename=fullfile_uvmat(RootPath_A,subdir_civ2,RootFile_A,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2296                    filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j));
    22952297                    filecell.ncA.civ2(ifile,j)={filename};
    22962298                    if ~exist(filename,'file')
     
    23092311    for ifile=1:nbfield
    23102312        for j=1:nbslice
    2311             filename=fullfile_uvmat(RootPath_nc,subdir_civ2,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2313            filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j));
    23122314            detect=exist(filename,'file')==2;
    23132315            filecell.nc.civ2(ifile,j)={filename};
     
    23152317    end
    23162318    %get first image names for checkciv2
    2317     if checkbox(1)==1 && isequal(num1_civ1,num1_civ2) && isequal(num_a_civ1,num_a_civ2)
     2319    if checkbox(1)==1 && isequal(i1_civ1,i1_civ2) && isequal(j1_civ1,j1_civ2)
    23182320        filecell.ima1.civ2=filecell.ima1.civ1;
    23192321    elseif checkbox(4)==1
    23202322        for ifile=1:nbfield
    23212323            for j=1:nbslice
    2322                 filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,ext_ima,nom_type_ima1,num1_civ2(ifile),[],num_a_civ2(j));
    2323                 %filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1);
     2324                filename=fullfile_uvmat(RootPath,[],RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j));
    23242325                idetect_2(j)=exist(filename,'file')==2;
    23252326                filecell.ima1.civ2(ifile,j)={filename};%first image
     
    23352336   
    23362337    %get second image names for checkciv2
    2337     if checkbox(1)==1 && isequal(num2_civ1,num2_civ2) && isequal(num_b_civ1,num_b_civ2)
     2338    if checkbox(1)==1 && isequal(i2_civ1,i2_civ2) && isequal(j2_civ1,j2_civ2)
    23382339        filecell.ima2.civ2=filecell.ima2.civ1;
    23392340    elseif checkbox(4)==1
    23402341        for ifile=1:nbfield
    23412342            for j=1:nbslice
    2342                 filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,ext_ima,nom_type_ima2,num2_civ2(ifile),[],num_b_civ2(j));
    2343                % filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2);
     2343                filename=fullfile_uvmat(RootPath,[],RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j));
    23442344                idetect_3(j)=exist(filename,'file')==2;
    23452345                filecell.ima2.civ2(ifile,j)={filename};%first image
     
    23602360        for ifile=1:nbfield
    23612361            for j=1:nbslice
    2362                  filename=fullfile_uvmat(RootPath_nc,subdir_civ2,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2362                 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j));
    23632363                filecell.nc.civ2(ifile,j)={filename};
    23642364                if ~exist(filename,'file')
     
    23882388        for ifile=1:nbfield
    23892389            for j=1:nbslice
    2390                  filename=fullfile_uvmat(RootPath_AB,subdir_civ1,RootFile_AB,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
     2390                 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_AB,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
    23912391                filecell.st(ifile,j)={filename};
    23922392            end
     
    23962396        for ifile=1:nbfield
    23972397            for j=1:nbslice
    2398                  filename=fullfile_uvmat(RootPath_AB,subdir_civ2,RootFile_AB,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
     2398                 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_AB,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j));
    23992399                filecell.st(ifile,j)={filename};
    24002400            end
     
    24042404set(handles.SubdirCiv1,'String',subdir_civ1);%update the edit box
    24052405set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box
    2406 browse.nom_type_nc=nom_type_nc;
    2407 set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat
    2408 
    24092406
    24102407%COPY IMAGES TO THE FORMAT .png IF NEEDED
    2411 if isequal(nom_type_ima1,'*')%case of movie files
    2412     nom_type_imanew1='_i';
    2413 else
    2414     nom_type_imanew1=nom_type_ima1;
    2415 end
    2416 if isequal(nom_type_ima2,'*')%case of movie files
    2417     nom_type_imanew2='_i';
    2418 else
    2419     nom_type_imanew2=nom_type_ima2;
     2408if isequal(NomType_ima1,'*')%case of movie files
     2409    NomType_imanew1='_i';
     2410else
     2411    NomType_imanew1=NomType_ima1;
     2412end
     2413if isequal(NomType_ima2,'*')%case of movie files
     2414    NomType_imanew2='_i';
     2415else
     2416    NomType_imanew2=NomType_ima2;
    24202417end
    24212418if ~isequal(ext_ima,'.png')
     
    24342431        form=imformats(ext_ima(2:end));
    24352432        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2436             if isequal(nom_type_ima1,'*');
     2433            if isequal(NomType_ima1,'*');
    24372434                type_ima1='multimage';%image series in a single image file
    24382435            else
     
    24542451        form=imformats(ext_ima(2:end));
    24552452        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2456             if isequal(nom_type_ima1,'*');
     2453            if isequal(NomType_ima1,'*');
    24572454                type_ima2='multimage';%image series in a single image file
    24582455            else
     
    24612458        end
    24622459    end
    2463     %npxy=get(handles.ImaExt,'UserData');
    2464     % %     if numel(npxy)<2
    2465     %
    2466     %         filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1);
    2467     %         A=imread(filename);
    2468     %         npxy=size(A);
    2469     % %     end
    2470     %     npy=npxy(1);
    2471     %     npx=npxy(2);
    24722460    if checkbox(1) %if civ1 is performed
    24732461        h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
     
    24752463            waitbar(ifile/nbfield);
    24762464            for j=1:nbslice
    2477                  filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ1(ifile),[],num_a_civ1(j));
    2478 %                 filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1);
     2465                filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
    24792466                if ~exist(filename,'file')
    2480                     A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1);
     2467                    A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
    24812468                    imwrite(A,filename,'BitDepth',16);
    24822469                end
    24832470                filecell.ima1.civ1(ifile,j)={filename};
    2484                 filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,'.png',nom_type_imanew2,num2_civ1(ifile),[],num_b_civ1(j));
    2485                 %filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2);
     2471                filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
    24862472                if ~exist(filename,'file')
    2487                     A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2);
     2473                    A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
    24882474                    imwrite(A,filename,'BitDepth',16);
    24892475                end
     
    24982484            waitbar(ifile/nbfield);
    24992485            for j=1:nbslice
    2500                 filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ2(ifile),[],num_a_civ2(j));
    2501                 %filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1);
     2486                filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
    25022487                if ~exist(filename,'file')
    2503                     A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile));
     2488                    A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
    25042489                    imwrite(A,filename,'BitDepth',16);
    25052490                end
    25062491                filecell.ima1.civ2(ifile,j)={filename};
    2507                 filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,'.png',nom_type_imanew2,num2_civ2(ifile),[],num_b_civ2(j));
    2508                % filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2);
     2492                filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
    25092493                if ~exist(filename,'file')
    2510                     A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile));
     2494                    A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
    25112495                    imwrite(A,filename,'BitDepth',16);
    25122496                end
     
    26202604function ListCompareMode_Callback(hObject, eventdata, handles)
    26212605%------------------------------------------------------------------------
    2622 menu=get(handles.ListCompareMode,'String');
    2623 val=get(handles.ListCompareMode,'Value');
    2624 option=menu{val};
     2606ListCompareMode=get(handles.ListCompareMode,'String');
     2607option=ListCompareMode{get(handles.ListCompareMode,'Value')};
    26252608if ~strcmp(option,'PIV') % case 'displacement' or 'stereo PIV'
    2626     filebase=get(handles.RootName,'String');
    2627     browse=get(handles.RootName,'Userdata');
    2628    % browse.nom_type_ima1=browse.nom_type_ima;
    2629     set(handles.RootName,'UserData',browse);
     2609    filebase=get(handles.RootPath,'String');
    26302610    set(handles.sub_txt,'Visible','on')
    2631     set(handles.RootName_1,'Visible','On');%mkes the second file input window visible
     2611    set(handles.RootFile_1,'Visible','On');%mkes the second file input window visible
    26322612    mode_store=get(handles.ListPairMode,'String');%get the present 'mode'
    26332613    set(handles.ListCompareMode,'UserData',mode_store);%store the mode display
    26342614    set(handles.ListPairMode,'Visible','off')
    2635     if test==2
    2636         set(handles.ListPairMode,'Visible','off')
    2637         set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
    2638     else
    2639         set(handles.ListPairMode,'Visible','on')
    2640         set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo
    2641     end
    26422615   
    2643     %% menuopen an image file with the browser
     2616    %% open an image file with the browser
    26442617    ind_opening=1;%default
    26452618    browse.incr_pair=[0 0]; %default
    2646     oldfile=get(handles.RootName,'String');
    2647      menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
    2648        '*.xml',  '.xml files '; ...
    2649         '*.civ',  '.civ files '; ...
     2619    oldfile=get(handles.RootPath,'String');
     2620    menu={'*.png;*.jpg;*.tif;*.avi;*.AVI;', ' (*.png,*.jpg ,.tif, *.avi,*.AVI)';
    26502621        '*.png','.png image files'; ...
    26512622        '*.jpg',' jpeg image files'; ...
    26522623        '*.tif','.tif image files'; ...
    26532624        '*.avi;*.AVI','.avi movie files'; ...
    2654         '*.nc','.netcdf files'; ...
    26552625        '*.*',  'All Files (*.*)'};
    2656     [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile);
     2626    if strcmp(option,'displacement')
     2627        comment='Pick the reference file for displacements';
     2628    else
     2629        comment='Pick a file of the second series';
     2630    end
     2631    [FileName, PathName] = uigetfile( menu, comment,oldfile);
    26572632    fileinput=[PathName FileName];%complete file name
    26582633    sizf=size(fileinput);
     
    26652640    end
    26662641    if ~strcmp(path1,path)
    2667         msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one')
     2642        msgbox_uvmat('ERROR','The second image or series must be in the same directory as the first one')
    26682643        return
    26692644    end
    2670     [tild,tild,RootFile,tild,tild,tild,tild,tild,nom_type]=fileparts_uvmat(name);
    2671     set(handles.RootName_1,'String',RootFile);
    2672     browse=get(handles.RootName,'UserData');
    2673     %browse.nom_type_ima_1=nom_type;
    2674     set(handles.RootName,'UserData',browse)
    2675    
    2676     %check image extension
     2645    if strcmp(option,'displacement')
     2646        [tild,RootFile_1]=fileparts(name);
     2647    else
     2648        [tild,tild,RootFile_1,tild,tild,tild,tild,tild,nom_type_1]=fileparts_uvmat(fileinput);
     2649        [RootFile_1,i1_series,tild,j1_series,tild,nom_type_1,FileType,Object]=find_file_series(PathName,FileName);
     2650        %check image nom type
     2651        if ~strcmp(nom_type_1,get(handles.NomType,'String'))
     2652        msgbox_uvmat('ERROR','The second image series must have the same indexing type as the first one, or use the option displacement for a fixed image')
     2653        return
     2654        end
     2655    end   
     2656    %check image  extension
    26772657    if ~strcmp(ext,get(handles.ImaExt,'String'))
    26782658        msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one')
    26792659        return
    2680     end
    2681 
     2660    end 
     2661    set(handles.RootFile_1,'String',RootFile_1);
    26822662else
    26832663    set(handles.ListPairMode,'Visible','on')
    2684     set(handles.RootName_1,'Visible','Off');
     2664    set(handles.RootFile_1,'Visible','Off');
    26852665    set(handles.sub_txt,'Visible','off')
    2686     set(handles.RootName_1,'String',[]);
     2666    set(handles.RootFile_1,'String',[]);
    26872667    mode_store=get(handles.ListCompareMode,'UserData');
    26882668    set(handles.ListPairMode,'Value',1)
     
    26912671    set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
    26922672end
    2693 if strcmp(option,'stereo PIV') && get(handles.CheckPatch1,'Value')
    2694     set(handles.CheckStereo,'Visible','on')
    2695 else
    2696     set(handles.CheckStereo,'Visible','off')
    2697 end
    2698 if strcmp(option,'stereo PIV') && get(handles.CheckPatch2,'Value')
    2699     set(handles.CheckStereo,'Visible','on')
    2700 else
    2701     set(handles.CheckStereo,'Visible','off')
    2702 end
     2673% if strcmp(option,'stereo PIV') && get(handles.CheckPatch1,'Value')
     2674%     set(handles.CheckStereo,'Visible','on')
     2675% else
     2676%     set(handles.CheckStereo,'Visible','off')
     2677% end
     2678% if strcmp(option,'stereo PIV') && get(handles.CheckPatch2,'Value')
     2679%     set(handles.CheckStereo,'Visible','on')
     2680% else
     2681%     set(handles.CheckStereo,'Visible','off')
     2682% end
    27032683ListPairMode_Callback(hObject, eventdata, handles)
    27042684
     
    29502930%% initialisation
    29512931errormsg='';
    2952 filebase=get(handles.RootName,'String');
    2953 [filepath,Nme,ext_dir]=fileparts(filebase);
    2954 browse=get(handles.RootName,'UserData');
     2932% filebase=get(handles.RootPath,'String');
     2933% [filepath,Nme,ext_dir]=fileparts(filebase);
     2934browse=get(handles.RootPath,'UserData');
    29552935compare_list=get(handles.ListCompareMode,'String');
    29562936val=get(handles.ListCompareMode,'Value');
    29572937compare=compare_list{val};
    2958 if strcmp(compare,'displacement')
     2938if strcmp(compare,'displacement')||strcmp(compare,'shift')
    29592939    mode='displacement';
    29602940else
     
    29772957% end
    29782958% browse.nom_type_nc=nom_type_nc;
    2979 % set(handles.RootName,'UserData',browse)
     2959% set(handles.RootPath,'UserData',browse)
    29802960
    29812961%% reads .nc subdirectoy and image numbers from the interface
     
    30112991select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
    30122992testpair=0;
    3013 [RootPath,RootFile]=fileparts(filebase);
     2993RootPath=get(handles.RootPath,'String');
     2994RootFile=get(handles.RootFile,'String');
    30142995if index==1 % case civ1
    30152996    if ~get(handles.CheckCiv1,'Value') %
    3016         if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
     2997        if ~exist(fullfile(RootPath,subdir_civ1),'dir')
    30172998            errormsg=['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist'];
    30182999            set(handles.ListPairCiv1,'String',{});
     
    31613142set(handles.ListPairCiv2,'String',displ_pair');
    31623143set(gcf,'Pointer','arrow')
    3163 
    3164 %------------------------------------------------------------------------
    3165 % determine the menu for checkciv2 pairs depending on the existing netcdf file at the
    3166 %middle of the series set by first_i, incr, last_i
    3167 % function find_netcpair_civ2(handles)
    3168 % %------------------------------------------------------------------------
    3169 % set(gcf,'Pointer','watch')
    3170 % %nomenclature types
    3171 % filebase=get(handles.RootName,'String');
    3172 % [filepath,Nme,ext_dir]=fileparts(filebase);
    3173 % browse=get(handles.RootName,'UserData');
    3174 % compare_list=get(handles.ListCompareMode,'String');
    3175 % val=get(handles.ListCompareMode,'Value');
    3176 % compare=compare_list{val};
    3177 % if strcmp(compare,'displacement')
    3178 %     mode='displacement';
    3179 % else
    3180 %     mode_list=get(handles.ListPairMode,'String');
    3181 %     if isempty(mode_list)
    3182 %         msgbox_uvmat('ERROR','please enter an input image or netcdf file')
    3183 %         return
    3184 %     end
    3185 %     mode_value=get(handles.ListPairMode,'Value');
    3186 %     mode=mode_list{mode_value};
    3187 % end
    3188 %
    3189 % % nomenclature type of the .nc files
    3190 % nom_type_ima='ima_num';%default
    3191 % NomTypeIma=get(handles.NomType,'String');
    3192 % nom_type_nc='_1-2';%default
    3193 % if isfield(browse,'nom_type_nc')
    3194 %     nom_type_nc=browse.nom_type_nc;
    3195 % end
    3196 % if isequal(nom_type_ima,'png_old') || isequal(nom_type_ima,'netc_old')|| isequal(nom_type_ima,'raw_SMD')|| isequal(nom_type_nc,'netc_old')
    3197 %     nom_type_nc='netc_old';%nom_type for the netcdf files
    3198 % elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none')
    3199 %     nom_type_nc='none';
    3200 % elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_1-2')
    3201 %     nom_type_nc='_1-2';
    3202 % else
    3203 %     if  isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)')
    3204 %         nom_type_nc='_1-2_1'; % PIV in volume
    3205 %     else
    3206 %         nom_type_nc='_1_1-2';
    3207 %     end
    3208 % end
    3209 % browse.nom_type_nc=nom_type_nc;
    3210 % set(handles.RootName,'UserData',browse)
    3211 %
    3212 % %reads .nc subdirectory and image numbers from the interface
    3213 % subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
    3214 % subdir_civ2=get(handles.SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data
    3215 % ref_i=str2double(get(handles.ref_i,'String'));
    3216 % if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
    3217 %     ref_j=0;
    3218 % else
    3219 %     ref_j=str2double(get(handles.ref_j,'String'));
    3220 % end
    3221 % time=get(handles.ImaDoc,'UserData'); %get the set of times
    3222 % TimeUnit=get(handles.TimeUnit,'String');
    3223 % checkframe=strcmp(TimeUnit,'frame');
    3224 % % if isempty(time)
    3225 % %     time=[0 1];%default
    3226 % % end
    3227 % displ_num=get(handles.ListPairCiv1,'UserData');
    3228 %
    3229 % %eliminate the first pairs inconsistent with the position
    3230 % if isempty(displ_num)
    3231 %     nbpair=0;
    3232 % else
    3233 %     nbpair=length(displ_num(1,:));%nbre of displayed pairs
    3234 %     if  isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)')
    3235 %         nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
    3236 %     elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    3237 %         nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
    3238 %     end
    3239 % end
    3240 % nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
    3241 %
    3242 % %% look for existing processed pairs at the reference indices if Civ1 will not
    3243 % % be performed, while the result is needed for next steps.
    3244 % displ_pair={''}; %default
    3245 % select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs
    3246 % [RootPath,RootFile]=fileparts(filebase);
    3247 % if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    3248 %     if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
    3249 %         errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
    3250 %         set(handles.ListPairCiv2,'Value',1);
    3251 %         set(handles.ListPairCiv2,'String',{''});
    3252 %         return
    3253 %     end
    3254 %     for ipair=1:nbpair
    3255 %         filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
    3256 %             ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
    3257 %        % filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
    3258 %         %    ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
    3259 %         select(ipair)=exist(filename,'file')==2;
    3260 %     end
    3261 %     if  isequal(select,zeros(size(1:nbpair)))
    3262 %         if isfield(browse,'incr_pair')
    3263 %             num_i1=ref_i-floor(browse.incr_pair(1)/2);
    3264 %             num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
    3265 %             num_j1=ref_j-floor(browse.incr_pair(2)/2);
    3266 %             num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
    3267 %             filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
    3268 %             %filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
    3269 %             select(1)=exist(filename,'file')==2;
    3270 %         else
    3271 %             if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    3272 %                 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
    3273 %             else
    3274 %                 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
    3275 %             end
    3276 %             set(handles.ListPairCiv2,'Value',1);
    3277 %             set(handles.ListPairCiv2,'String',{''});
    3278 %             return
    3279 %         end
    3280 %     end
    3281 % end
    3282 % if isequal(mode,'series(Di)')
    3283 %     for ipair=1:nbpair
    3284 %         if select(ipair)
    3285 %             displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    3286 %             if  ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3287 %                 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
    3288 %                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    3289 %             end
    3290 %         else
    3291 %             displ_pair{ipair}='...'; %pair not displayed in the menu
    3292 %         end
    3293 %     end
    3294 % elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index
    3295 %     for ipair=1:nbpair
    3296 %         if select(ipair)
    3297 %             displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    3298 %             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
    3299 %                 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
    3300 %             else
    3301 %                 dt=1;
    3302 %             end
    3303 %                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    3304 %         else
    3305 %             displ_pair{ipair}='...'; %pair not displayed in the menu
    3306 %         end
    3307 %     end
    3308 % elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs
    3309 %     for ipair=1:nbpair
    3310 %         if select(ipair)
    3311 %             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
    3312 %             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
    3313 %             else
    3314 %                 dt=1;
    3315 %             end
    3316 %             displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair)+1,nom_type_ima) '-' num2stra(displ_num(2,ipair)+1,nom_type_ima) ...
    3317 %                 ' :dt= ' num2str(dt*1000)];
    3318 %                 
    3319 %         else
    3320 %             displ_pair{ipair}='...'; %pair not displayed in the menu
    3321 %         end
    3322 %     end
    3323 % elseif isequal(mode,'displacement')
    3324 %     displ_pair={'Di=Dj=0'};
    3325 % end
    3326 % val=get(handles.ListPairCiv2,'Value');
    3327 % ichoice=find(select,1);
    3328 % if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
    3329 % if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0
    3330 %     val=ichoice;% first valid pair proposed by default in the menu
    3331 % end
    3332 % if val>length(displ_pair')
    3333 %     set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu
    3334 % else
    3335 %     set(handles.ListPairCiv2,'Value',val);
    3336 % end
    3337 % set(handles.ListPairCiv2,'String',displ_pair');
    3338 % set(gcf,'Pointer','arrow')
    33393144
    33403145%-------------------------------------------------------------------
     
    35053310else
    35063311    mask_displ='no mask'; %default
    3507     filebase=get(handles.RootName,'String');
     3312    filebase=get(handles.RootPath,'String');
    35083313    [nbslice, flag_mask]=get_mask(filebase,handles);
    35093314    if isequal(flag_mask,1)
    35103315        mask_displ=[num2str(nbslice) 'mask'];
    35113316    elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    3512         filebase_a=get(handles.RootName_1,'String');
     3317        filebase_a=get(handles.RootFile_1,'String');
    35133318        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    35143319        if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
     
    35493354else
    35503355    mask_displ='no mask'; %default
    3551     filebase=get(handles.RootName,'String');
     3356    filebase=get(handles.RootPath,'String');
    35523357    [nbslice, flag_mask]=get_mask(filebase,handles);
    35533358    if isequal(flag_mask,1)
    35543359        mask_displ=[num2str(nbslice) 'mask'];
    35553360    elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    3556         filebase_a=get(handles.RootName_1,'String');
     3361        filebase_a=get(handles.RootFile_1,'String');
    35573362        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    35583363        if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
     
    35903395else
    35913396    mask_displ='no mask'; %default
    3592     filebase=get(handles.RootName,'String');
     3397    filebase=get(handles.RootPath,'String');
    35933398    [nbslice, flag_mask]=get_mask(filebase,handles);
    35943399    if isequal(flag_mask,1)
    35953400        mask_displ=[num2str(nbslice) 'mask'];
    35963401    elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    3597         filebase_a=get(handles.RootName_1,'String');
     3402        filebase_a=get(handles.RootFile_1,'String');
    35983403        [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    35993404        if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
     
    37633568filegrid='';
    37643569if value
    3765     filebase=get(handles.RootName,'String');
     3570    filebase=get(handles.RootPath,'String');
    37663571    [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name
    37673572    if isequal(flag_grid,1)
     
    38433648testmask=0;
    38443649if value
    3845     filebase=get(handles.RootName,'String');
     3650    filebase=get(handles.RootPath,'String');
    38463651    [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name
    38473652    if isequal(flag_mask,1)
     
    38913696% --- Executes on button press in get_gridpatch1.
    38923697function get_gridpatch1_Callback(hObject, eventdata, handles)
    3893 % hObject    handle to get_gridpatch1 (see GCBO)
    3894 % eventdata  reserved - to be defined in a future version of MENUMATLAB
    3895 % handles    structure with handles and user data (see GUIDATA)
    3896 
    3897 filebase=get(handles.RootName,'String');
     3698filebase=get(handles.RootPath,'String');
    38983699[FileName, PathName, filterindex] = uigetfile( ...
    38993700    {'*.grid', ' (*.grid)';
     
    39033704filegrid=fullfile(PathName,FileName);
    39043705set(handles.grid_patch1,'string',filegrid);
    3905 % set(handles.grid_patch2,'string',filegrid
     3706
    39063707
    39073708%------------------------------------------------------------------------
     
    39463747function get_ref_fix1_Callback(hObject, eventdata, handles)
    39473748%------------------------------------------------------------------------
    3948 filebase=get(handles.RootName,'String');
     3749filebase=get(handles.RootPath,'String');
    39493750[FileName, PathName, filterindex] = uigetfile( ...
    39503751    {'*.nc', ' (*.nc)';
     
    39923793%------------------------------------------------------------------------
    39933794if isequal(get(handles.get_ref_fix2,'Value'),1)
    3994     filebase=get(handles.RootName,'String');
     3795    filebase=get(handles.RootPath,'String');
    39953796    [FileName, PathName, filterindex] = uigetfile( ...
    39963797        {'*.nc', ' (*.nc)';
     
    40593860
    40603861%------------------------------------------------------------------------
    4061 % --- Executes on button press in test_stereo1.
    4062 function test_stereo1_Callback(hObject, eventdata, handles)
    4063 %------------------------------------------------------------------------
    4064 if isequal(get(handles.test_stereo1,'Value'),0)
    4065     set(handles.subdomain_patch1,'Visible','on')
    4066     set(handles.rho_patch1,'Visible','on')
    4067 else
    4068     set(handles.subdomain_patch1,'Visible','off')
    4069     set(handles.rho_patch1,'Visible','off')
    4070 end
    4071 
    4072 %------------------------------------------------------------------------
    4073 % --- Executes on button press in CheckStereo.
    4074 function StereoCheck_Callback(hObject, eventdata, handles)
    4075 %------------------------------------------------------------------------
    4076 if isequal(get(handles.CheckStereo,'Value'),0)
     3862% --- TO ABANDON Executes on button press in test_stereo1.
     3863function CheckStereo_Callback(hObject, eventdata, handles)
     3864%------------------------------------------------------------------------
     3865hparent=get(hObject,'parent');
     3866parent_tag=get(hparent,'Tag');
     3867hchildren=get(hparent,'children');
     3868handle_txtbox=findobj(hchildren,'tag','txt_Mask');
     3869if isequal(get(hObject,'Value'),0)
    40773870    set(handles.num_SubdomainSize,'Visible','on')
    40783871    set(handles.num_SmoothingParam,'Visible','on')
     
    40813874    set(handles.num_SmoothingParam,'Visible','off')
    40823875end
     3876
     3877% %------------------------------------------------------------------------
     3878% % --- Executes on button press in CheckStereo.
     3879% function StereoCheck_Callback(hObject, eventdata, handles)
     3880% %------------------------------------------------------------------------
     3881% if isequal(get(handles.CheckStereo,'Value'),0)
     3882%     set(handles.num_SubdomainSize,'Visible','on')
     3883%     set(handles.num_SmoothingParam,'Visible','on')
     3884% else
     3885%     set(handles.num_SubdomainSize,'Visible','off')
     3886%     set(handles.num_SmoothingParam,'Visible','off')
     3887% end
    40833888
    40843889%------------------------------------------------------------------------
     
    45444349
    45454350%determine nom_type_nc:
    4546 NomTypeNc='';%default
     4351NomTypeNc=NomTypeIma;%default
    45474352switch mode
    45484353    case 'pair j1-j2'     
     
    46044409% --- Executes on button press in TestCiv2.
    46054410function TestCiv2_Callback(hObject, eventdata, handles)
     4411
     4412
     4413
     4414function RootFile_Callback(hObject, eventdata, handles)
     4415
     4416
     4417
  • trunk/src/find_file_series.m

    r365 r371  
    44%
    55% OUTPUT:
    6 % RootPath,RootFile: root path and root name detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
     6% RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    77% i1_series(ref_i+1, ref_j+1,pair),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
    88%  (ref_i+1 is used to deal with the image index zero sometimes used)
     
    1818%
    1919%INPUT
    20 % fileinput: name (including path)  of the input file
     20% RootPath: path to the directory to be scanned
     21% fileinput: name (without path) of the input file sample
    2122%
    2223%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    3637%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3738
    38 function [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput)
     39function [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPath,fileinput)
    3940%------------------------------------------------------------------------
    4041
    4142%% get input root name and nomenclature type
    42 [RootPath,SubDir,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput);
     43[tild,tild,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput);
     44fullfileinput=fullfile(RootPath,fileinput);
    4345
    4446%% check for particular file types: images, movies, civ data
     
    4951j1_series=zeros(1,1,1);
    5052j2_series=zeros(1,1,1);
     53
    5154switch FileExt
    5255    % ancillary files, no field indexing
     
    6467        NomType='';
    6568    otherwise
     69     
    6670        if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end)))
    6771            try
    68                 imainfo=imfinfo(fileinput);
     72                imainfo=imfinfo(fullfileinput);
    6973                FileType='image';
    7074                if length(imainfo) >1 %case of image with multiple frames
     
    7276                    FileType='multimage';
    7377                    i1_series=(1:length(imainfo))';
    74                     [RootPath,RootFile]=fileparts(fileinput);
     78                    [RootPath,RootFile]=fileparts(fullfileinput);
    7579                end
    7680            end
    7781        else
    7882            try
    79                 Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions');
     83                Data=nc2struct(fullfileinput,'ListGlobalAttribute','absolut_time_T0','Conventions');
    8084                if ~isempty(Data.absolut_time_T0')
    8185                    FileType='civx'; % test for civx velocity fields
     
    8892            try
    8993                if exist('VideoReader','file')%recent version of Matlab
    90                     Object=VideoReader(fileinput);
     94                    Object=VideoReader(fullfileinput);
    9195                else
    92                     Object=mmreader(fileinput);%older Matlab function for movies
     96                    Object=mmreader(fullfileinput);%older Matlab function for movies
    9397                end
    9498                NomType='*';
     
    100104
    101105if strcmp(NomType,'')||strcmp(NomType,'*')
    102     if exist(fileinput,'file')
    103         [RootPath,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
    104     else
    105         RootPath='';
     106    if exist(fullfileinput,'file')
     107        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
     108    else     
    106109        RootFile='';
    107110    end
     
    163166        end
    164167    end
    165     detect_string=[sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str];%string used in regexp to detect file indices
     168    detect_string=['^' RootFile sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str FileExt '$'];%string used in regexp to detect file indices
    166169    %find the string used to extract the relevant files with the command dir
    167     star_string=['*' sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];
     170    star_string=[RootFile sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];
    168171    wd=pwd;%current working directory
    169     RR=fullfile(RootPath,SubDir);
    170     cd (RR)% move to the local dir to save time in the operation dir.
    171     dirpair=dir([RootFile star_string FileExt]);% look for relevant files in the file directory
     172    %RR=fullfile(RootPath,SubDir);
     173    cd (RootPath)% move to the local dir to save time in the operation dir.
     174    dirpair=dir([star_string FileExt]);% look for relevant files in the file directory
    172175    cd(wd)
    173176    nbpair=numel(dirpair);
  • trunk/src/fullfile_uvmat.m

    r360 r371  
    115115    end
    116116end
    117 if ~isempty(i2_str)||~isempty(j2_str)
     117% if ~isempty(i2_str)||~isempty(j2_str)
    118118    filename=fullfile(RootPath,SubDir,RootFile);
    119 else
    120     filename=fullfile(RootPath,RootFile);
    121 end
     119% else
     120%     filename=fullfile(RootPath,RootFile);
     121% end
    122122filename=[filename sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str FileExt];
    123123
  • trunk/src/num2stra.m

    r332 r371  
    2525%         end
    2626    case 2
    27         if isequal(nom_type(end),'a')||isequal(nom_type(end),'b')
     27        if ~isempty(nom_type) && (isequal(nom_type(end),'a')||isequal(nom_type(end),'b'))
    2828            str=char(96+num);
    29         elseif isequal(nom_type(end),'A')|isequal(nom_type(end),'B')
     29        elseif ~isempty(nom_type) && (isequal(nom_type(end),'A')||isequal(nom_type(end),'B'))
    3030            str=char(64+num);
    31 %         elseif isequal(nom_type,'series_i')|isequal(nom_type,'netc_series')...
    32 %                 |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none')...
    33 %                 isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')
    34 %             str='';
    3531        else
    3632            str=num2str(num);
  • trunk/src/series.m

    r360 r371  
    11771177nbfield=cell2mat(Series.IndexRange.MaxIndex);
    11781178nb=min(nbfield,1);
    1179 nbfield=nb(1);
    1180 nbfield2=nb(2);
     1179% nbfield=nb(1);
     1180% nbfield2=nb(2);
    11811181
    11821182%get complementary information from the 'series' interface
     
    21942194%% look for min and max indices existing in the file series and update SeriesData
    21952195errormsg='';
    2196 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput);
     2196[RootPath,FileName,FileExt]=fileparts(fileinput);
     2197[RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPath,[FileName FileExt]);
    21972198if isempty(RootFile)&&isempty(i1_series)
    21982199    errormsg='no input file in the series';
  • trunk/src/uvmat.m

    r368 r371  
    509509
    510510%% detect root name, nomenclature and indices in the input file name:
    511 [tild,SubDir,tild,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
     511[RootPath,SubDir,tild,i1,i2,j1,j2]=fileparts_uvmat(fileinput);
     512[tild,FileName,FileExt]=fileparts(fileinput);
    512513% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    513 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput);
     514[RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[FileName FileExt]);
    514515if strcmp(NomType,'*')% movies will be opened at the first frame
    515516    i1=1;
     
    608609% read the current input file name:
    609610[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    610 fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     611%fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    611612% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    612 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fileinput);
     613[tild,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    613614% initiate the input file series and refresh the current field view:
    614615update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
     
    10991100% update_rootinfo_1(hObject,eventdata,handles)
    11001101[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
    1101 fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     1102%fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    11021103% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    1103 [tild,tild,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fileinput);
     1104[tild,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    11041105% initiate the input file series and refresh the current field view:
    11051106update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2);
Note: See TracChangeset for help on using the changeset viewer.