Changeset 408 for trunk


Ignore:
Timestamp:
May 5, 2012, 6:34:46 PM (13 years ago)
Author:
sommeria
Message:

various bugs corrected in series and uvmat.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r406 r408  
    7171        case{'vort','div','strain'}% needs spatial derivatives spatial derivatives
    7272            check_der=1;
    73         case {'velocity','norm_vel'};
     73        case {'velocity','norm_vel','ima_cor'};
    7474        otherwise
    7575            check_calc(ilist)=0;
  • trunk/src/get_file_series.m

    r400 r408  
    2626end
    2727% Pairs=Param.Pairs;
    28 r.mode='';
    29 if isfield(Param,'Pairs') && isfield (Param.Pairs,'list_pair_civ')
    30     r=regexp(Param.Pairs.list_pair_civ,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
    31     if isempty(r)
    32         r=regexp(Param.Pairs.list_pair_civ,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
    33     end
    3428
    35     % TODO case of free pairs:
    36     %r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names');
    37 end
    38     if isempty(r.mode)
    39         r.num1='';
    40         r.num2='';
    41     end
    4229
    4330%% determine the list of input file names
     
    4532
    4633for iview=1:size(InputTable,1)
     34    r.mode='';
     35    if isfield (Param.IndexRange,'PairString')
     36        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
     37        if isempty(r)
     38            r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
     39        end       
     40        % TODO case of free pairs:
     41        %r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names');
     42    end
     43    if isempty(r.mode)
     44        r.num1='';
     45        r.num2='';
     46    end
    4747    [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode);
    4848    %case of pairs (.nc files)
  • trunk/src/proj_field.m

    r402 r408  
    8282function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
    8383errormsg='';%default
    84 % if ~exist('FieldName','var')
    85 %     FieldName='';
    86 % end
     84ProjData=[];
     85
    8786%% case of no projection (object is used only as graph display)
    8887if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'))
    89     ProjData=[];
    9088    return
    9189end
    9290
     91%% check coincidence of coordinate units
     92if isfield(FieldData,'CoordUnit') && isfield(ObjectData,'CoordUnit')&&~strcmp(FieldData.CoordUnit,ObjectData.CoordUnit)
     93    errormsg='inconsistent coord units for field and projection object';
     94    return
     95end
     96   
    9397%% in the absence of object Type or projection mode, or object coordinaes, the input field is just tranfered without change
    9498if ~isfield(ObjectData,'Type')||~isfield(ObjectData,'ProjMode')
     
    10911095            if testbound
    10921096                indcut=find(testin);
     1097                if isempty(indcut)
     1098                    errormsg='data outside the bounds of the projection object';
     1099                    return
     1100                end
    10931101                for ivar=VarIndex
    10941102                    VarName=FieldData.ListVarName{ivar};
     
    11051113        switch ObjectData.ProjMode
    11061114            case 'projection'
    1107                 %the list of dimension
    1108                 %ProjData.ListDimName=[ProjData.ListDimName FieldData.VarDimName(VarIndex(1))];%add the point index to the list of dimensions
    1109                 %ProjData.DimValue=[ProjData.
    1110                 %length(coord_X)];
    1111                
    11121115                for ivar=VarIndex %transfer variables to the projection plane
    11131116                    VarName=FieldData.ListVarName{ivar};
     
    11471150                if ~isequal(ivar_FF,0)
    11481151                    VarName_FF=FieldData.ListVarName{ivar_FF};
    1149                     eval(['indsel=find(FieldData.' VarName_FF '==0);'])
     1152                    indsel=find(FieldData.(VarName_FF)==0);
    11501153                    coord_X=coord_X(indsel);
    11511154                    coord_Y=coord_Y(indsel);
  • trunk/src/series.m

    r399 r408  
    3030%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3131
     32%------------------------------------------------------------------------
     33%------------------------------------------------------------------------
     34%  I - MAIN FUNCTION series
     35%------------------------------------------------------------------------
     36%------------------------------------------------------------------------
    3237function varargout = series(varargin)
    3338
     
    6368drawnow
    6469set(hObject,'Units','pixels')
     70set(handles.PairString,'ColumnEditable',logical(0))
     71set(handles.PairString,'ColumnFormat',{'char'})
     72set(handles.PairString,'ColumnWidth',{60})
     73set(handles.PairString,'Data',{''})
    6574% set(0,'Units','pixels')
    6675% screensize=get(0,'ScreenSize'); %screen size in pixels
     
    112121if isfield(param,'FileName')
    113122    if isfield(param,'FileName_1')
    114         update_rootfile(handles,param.FileName_1,0)
    115         update_rootfile(handles,param.FileName,1)
     123        display_file_name(handles,param.FileName_1,0)
     124        display_file_name(handles,param.FileName,1)
    116125    else
    117         update_rootfile(handles,param.FileName,0)
     126        display_file_name(handles,param.FileName,0)
    118127    end
    119128end 
     
    126135end
    127136
    128 %REFRESH_INDICES_Callback(hObject, eventdata, handles)
    129137%loads the information stored in prefdir to initiate  the list of ACTION functions
    130138fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
     
    195203ACTION_Callback(hObject, eventdata, handles)
    196204
    197 %--------------------------------------------------------------
     205%------------------------------------------------------------------------
    198206% --- Outputs from this function are returned to the command line.
    199 %-----------------------------------------------------------------
    200207function varargout = series_OutputFcn(hObject, eventdata, handles)
     208%------------------------------------------------------------------------
    201209% varargout  cell array for returning output args (see VARARGOUT);
    202210% hObject    handle to figure
     
    206214varargout{1} = handles.output;
    207215
    208 % --------------------------------------------------------------------
     216%------------------------------------------------------------------------
     217%------------------------------------------------------------------------
     218%  II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
     219% automatically sets the global properties when the rootfile name is introduced
     220% then activate the view-field action if selected
     221% it is activated either by clicking on the RootPath window or by the
     222% browser
     223%------------------------------------------------------------------------
     224%------------------------------------------------------------------------
    209225function MenuBrowse_Callback(hObject, eventdata, handles)
     226%------------------------------------------------------------------------   
    210227InputTable=get(handles.InputTable,'Data');
    211228RootPathCell=InputTable(:,1);
    212229SubDirCell=InputTable(:,2);
    213230RootFileCell=InputTable(:,3);
    214 %RootPathCell=get(handles.RootPath,'String');
    215 %SubDirCell=get(handles.SubDir,'String'); 
    216 %RootFileCell=get(handles.RootFile,'String');
    217231oldfile=''; %default
    218232if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
     
    242256        'Pick a file',oldfile);
    243257fileinput=[PathName FileName];%complete file name
    244 %testblank=findstr(fileinput,' ');%look for blanks
    245 % if ~isempty(testblank)
    246 %     errordlg('forbidden input file name: contain blanks')
    247 %     return
    248 % end
    249258sizf=size(fileinput);
    250259if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
     
    252261SeriesData=[];%dfault
    253262if isequal(ext,'.xml')
    254     warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
     263    msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    255264elseif isequal(ext,'.xls')
    256     warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
     265    msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    257266else
    258     update_rootfile(handles,fileinput,0)
     267    display_file_name(handles,fileinput,0)
    259268     %update list of recent files in the menubar
    260269    MenuFile_1=fileinput;
     
    289298end
    290299
    291 
    292300% --------------------------------------------------------------------
    293301function MenuFile_1_Callback(hObject, eventdata, handles)
    294302fileinput=get(handles.MenuFile_1,'Label');
    295 update_rootfile(handles,fileinput,0)
     303display_file_name(handles,fileinput,0)
    296304
    297305% --------------------------------------------------------------------
    298306function MenuFile_2_Callback(hObject, eventdata, handles)
    299307fileinput=get(handles.MenuFile_2,'Label');
    300 update_rootfile(handles,fileinput,0)
     308display_file_name(handles,fileinput,0)
    301309
    302310% --------------------------------------------------------------------
    303311function MenuFile_3_Callback(hObject, eventdata, handles)
    304312fileinput=get(handles.MenuFile_3,'Label');
    305 update_rootfile( handles,fileinput,0)
     313display_file_name( handles,fileinput,0)
    306314
    307315% --------------------------------------------------------------------
    308316function MenuFile_4_Callback(hObject, eventdata, handles)
    309317fileinput=get(handles.MenuFile_4,'Label');
    310 update_rootfile(handles,fileinput,0)
     318display_file_name(handles,fileinput,0)
    311319
    312320% --------------------------------------------------------------------
    313321function MenuFile_5_Callback(hObject, eventdata, handles)
    314322fileinput=get(handles.MenuFile_5,'Label');
    315 update_rootfile(handles,fileinput,0)
     323display_file_name(handles,fileinput,0)
    316324
    317325% --------------------------------------------------------------------
     
    349357        'Pick a file',oldfile);
    350358fileinput=[PathName FileName];%complete file name
    351 % testblank=findstr(fileinput,' ');%look for blanks
    352 % if ~isempty(testblank)
    353 %     errordlg('forbidden input file name: contain blanks')
    354 %     return
    355 % end
    356359sizf=size(fileinput);
    357360if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
    358361[path,name,ext]=fileparts(fileinput);
    359 SeriesData=[];%dfault
    360362if isequal(ext,'.xml')
    361363    msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
     
    363365    msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    364366else
    365     update_rootfile(handles,fileinput,1)
    366     %update list of recent files in the menubar
    367     MenuFile_1=fileinput;
    368     MenuFile_2=get(handles.MenuFile_1,'Label');
    369     MenuFile_3=get(handles.MenuFile_2,'Label');
    370     MenuFile_4=get(handles.MenuFile_3,'Label');
    371     MenuFile_5=get(handles.MenuFile_4,'Label');
    372     set(handles.MenuFile_1,'Label',MenuFile_1)
    373     set(handles.MenuFile_2,'Label',MenuFile_2)
    374     set(handles.MenuFile_3,'Label',MenuFile_3)
    375     set(handles.MenuFile_4,'Label',MenuFile_4)
    376     set(handles.MenuFile_5,'Label',MenuFile_5)
    377     set(handles.MenuFile_insert_1,'Label',MenuFile_1)
    378     set(handles.MenuFile_insert_2,'Label',MenuFile_2)
    379     set(handles.MenuFile_insert_3,'Label',MenuFile_3)
    380     set(handles.MenuFile_insert_4,'Label',MenuFile_4)
    381     set(handles.MenuFile_insert_5,'Label',MenuFile_5)
    382     dir_perso=prefdir;
    383     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    384     if exist(profil_perso,'file')
    385         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    386     else
    387     txt=ver('MATLAB');
    388     Release=txt.Release;
    389         relnumb=str2num(Release(3:4));
    390         if relnumb >= 14
    391             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    392         else
    393             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    394         end
    395     end
    396 end
    397 %------------------------------------------------
     367    display_file_name(handles,fileinput,1)
     368end
    398369
    399370% --------------------------------------------------------------------
    400371function MenuFile_insert_1_Callback(hObject, eventdata, handles)
     372% --------------------------------------------------------------------   
    401373fileinput=get(handles.MenuFile_insert_1,'Label');
    402 update_rootfile(handles,fileinput,1)
     374display_file_name(handles,fileinput,1)
    403375
    404376% --------------------------------------------------------------------
    405377function MenuFile_insert_2_Callback(hObject, eventdata, handles)
     378% --------------------------------------------------------------------   
    406379fileinput=get(handles.MenuFile_insert_2,'Label');
    407 update_rootfile(handles,fileinput,1)
     380display_file_name(handles,fileinput,1)
    408381
    409382% --------------------------------------------------------------------
    410383function MenuFile_insert_3_Callback(hObject, eventdata, handles)
     384% --------------------------------------------------------------------   
    411385fileinput=get(handles.MenuFile_insert_3,'Label');
    412 update_rootfile( handles,fileinput,1)
     386display_file_name( handles,fileinput,1)
    413387
    414388% --------------------------------------------------------------------
    415389function MenuFile_insert_4_Callback(hObject, eventdata, handles)
     390% --------------------------------------------------------------------   
    416391fileinput=get(handles.MenuFile_insert_4,'Label');
    417 update_rootfile( handles,fileinput,1)
     392display_file_name( handles,fileinput,1)
    418393
    419394% --------------------------------------------------------------------
    420395function MenuFile_insert_5_Callback(hObject, eventdata, handles)
     396% --------------------------------------------------------------------   
    421397fileinput=get(handles.MenuFile_insert_5,'Label');
    422 update_rootfile(handles,fileinput,1)
    423 
    424 %------------------------------------------------------------------------
    425 % ---  refresh the GUI data after introduction of a new file series
     398display_file_name(handles,fileinput,1)
     399
     400%------------------------------------------------------------------------
     401% --- Executes when entered data in editable cell(s) in InputTable.
     402function InputTable_CellEditCallback(hObject, eventdata, handles)
     403%------------------------------------------------------------------------
     404iview=eventdata.Indices(1);
     405InputTable=get(handles.InputTable,'Data');
     406filename=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}])
     407display_file_name(handles,fileinput,0)
     408
     409% hObject    handle to InputTable (see GCBO)
     410% eventdata  structure with the following fields (see UITABLE)
     411%       Indices: row and column indices of the cell(s) edited
     412%       PreviousData: previous data for the cell(s) edited
     413%       EditData: string(s) entered by the user
     414%       NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
     415%       Error: error string when failed to convert EditData to appropriate value for Data
     416% handles    structure with handles and user data (see GUIDATA)
     417% check_lines=get(handles.REFRESH_INDICES,'UserData');
     418% check_lines(eventdata.Indices(1))=1; %select the edited line for refresh
     419% set(handles.REFRESH_INDICES,'UserData',check_lines);
     420% set(handles.REFRESH_INDICES,'Visible','on')
     421%InputTable=get(handles.InputTable,'Data')
     422
     423%------------------------------------------------------------------------
     424% ---  refresh the GUI data after introduction of a new file
    426425% INPUT:
    427 % handles:
     426% handles: handles of the elements in the GUI series
    428427% fileinput: name of the input file
    429 % addtest: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert')
    430 function update_rootfile(handles,fileinput,addtest)
     428% append: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert')
     429function display_file_name(handles,fileinput,append)
    431430%------------------------------------------------------------------------ 
     431
     432%% get the input root name, indices, file extension and nomenclature NomType
     433if ~exist(fileinput,'file')
     434    msgbox_uvmat('ERROR',['input file ' fileinput  ' does not exist'])
     435    return
     436end
    432437
    433438%% enable other menus and uicontrols
     
    444449drawnow
    445450
    446 %% get the input root name, indices, file extension and nomenclature NomType
    447 if ~exist(fileinput,'file')
    448     msgbox_uvmat('ERROR',['input file ' fileinput  ' does not exist'])
     451
     452%% detect root name, nomenclature and indices in the input file name:
     453[FilePath,FileName,FileExt]=fileparts(fileinput);
     454% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     455% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
     456[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
     457if isempty(RootFile)&&isempty(i1_series)
     458    errormsg='no input file in the series';
    449459    return
    450460end
    451 [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput);
    452461
    453462%% fill the list of file series
    454463InputTable=get(handles.InputTable,'Data');
    455 if addtest % display the input data as a new line in the table
    456      val=size(InputTable,1)+1;
    457      InputTable(val,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    458     check_lines=get(handles.REFRESH_INDICES,'UserData');
     464if append % display the input data as a new line in the table
     465     lastview=size(InputTable,1)+1;
     466     InputTable(lastview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     467    set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}])
     468    set(handles.ListView,'Value',lastview)
     469%     check_lines=get(handles.REFRESH_INDICES,'UserData');
    459470else % or re-initialise the list of  input  file series
    460     val=1;
     471    lastview=1;
    461472    InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    462473    set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
    463474    set(handles.MinIndex,'Data',[{[]},{[]}])
    464475    set(handles.MaxIndex,'Data',[{[]},{[]}])
     476    set(handles.ListView,'Value',1)
     477    set(handles.ListView,'String',{'1'})
    465478end
    466479set(handles.InputTable,'Data',InputTable)
    467 check_lines(val)=1; %select the edited line for refresh
    468 set(handles.REFRESH_INDICES,'UserData',check_lines);
    469 
    470 %% refresh menus with info from the new series
    471 REFRESH_INDICES_Callback([],[], handles)
    472 
    473 %% determine the selected reference field indices for pair dispaly
     480% check_lines(lastview)=1; %select the edited line for refresh
     481% set(handles.REFRESH_INDICES,'UserData',check_lines);
     482
     483%% refresh menus with info from the new series: TODO:check
     484%REFRESH_INDICES_Callback([],[], handles)
     485
     486%% determine the selected reference field indices for pair display
    474487ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV
    475488if ~isempty(i1)
     
    479492    end
    480493end
    481 set(handles.ref_i,'String',num2str(ref_i));
     494set(handles.num_ref_i,'String',num2str(ref_i));
    482495ref_j=1; %default  ref_j is a reference frame index used to find existing pairs from PIV
    483496if ~isempty(j1)
     
    487500    end         
    488501end
    489 set(handles.ref_j,'String',num2str(ref_j));
    490 ref_i_Callback([],[], handles)
    491 ref_j_Callback([],[], handles)
    492 
    493 %% update the first and last reference indices if empty
    494 first_i=str2num(get(handles.num_first_i,'String'));
    495 if isempty(first_i)
    496 set(handles.num_first_i,'String',num2str(ref_i));
    497 set(handles.num_last_i,'String',num2str(ref_i));
    498 set(handles.num_first_j,'String',num2str(ref_j))
    499 set(handles.num_last_j,'String',num2str(ref_j));
    500 end
    501 
    502 %% store the root name for future opening of uvmat
     502set(handles.num_ref_j,'String',num2str(ref_j));
     503
     504%% update list of recent files in the menubar and save it for future opening
     505MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
     506    {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
     507str_find=strcmp(FileName,MenuFile);
     508if isempty(find(str_find,1))
     509    MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list
     510end
     511for ifile=1:min(length(MenuFile),5)
     512    eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
     513    eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
     514end
    503515dir_perso=prefdir;
    504516profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    505517if exist(profil_perso,'file')
    506     save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append'); %store the root name for future opening of uvmat
     518    save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
    507519else
    508     txt=ver('MATLAB');
    509     Release=txt.Release;
    510     relnumb=str2num(Release(3:4));
    511     if relnumb >= 14
    512         save (profil_perso,'RootPath','SubDir','RootFile','NomType','-V6') %store the root name for future opening of uvmat
     520    save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
     521end
     522
     523set(handles.InputTable,'BackgroundColor',[1 1 1])
     524
     525%% initiate input file series and refresh the current field view:     
     526update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,lastview);
     527
     528%------------------------------------------------------------------------
     529% --- Update information about a new field series (indices to scan, timing,
     530%     calibration from an xml file, then refresh current plots
     531function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview)
     532%------------------------------------------------------------------------
     533
     534%% enable j index visibility
     535if isempty(j1_series)
     536    state='off';
     537else
     538    state='on';
     539end
     540enable_j(handles,state)
     541
     542%% display the min and max indices for all the file series
     543MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
     544MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
     545% MinIndex_i=min(i1_series(i1_series>0));
     546% if ~isempty(i2_series)
     547%     MaxIndex_i=max(i2_series(i2_series>0));
     548% else
     549%     MaxIndex_i=max(i1_series(i1_series>0));
     550% end
     551% MinIndex_j=min(j1_series(j1_series>0));
     552% if ~isempty(j2_series)
     553%     MaxIndex_j=max(j2_series(j2_series>0));
     554% else
     555%     MaxIndex_j=max(j1_series(j1_series>0));
     556% end
     557i_sum=sum(sum(i1_series,2),3);
     558MaxIndex_i=max(find(i_sum>0))-1;
     559MinIndex_i=min(find(i_sum>0))-1;
     560j_sum=sum(sum(i1_series,1),3);
     561MaxIndex_j=max(find(j_sum>0))-1;
     562MinIndex_j=min(find(j_sum>0))-1;
     563MinIndex{iview,1}=MinIndex_i;
     564MinIndex{iview,2}=MinIndex_j;
     565MaxIndex{iview,1}=MaxIndex_i;
     566MaxIndex{iview,2}=MaxIndex_j;
     567set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex
     568set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex
     569
     570%% adjust the first and last indices if requested by the bounds
     571first_i=str2num(get(handles.num_first_i,'String'));
     572ref_i=str2num(get(handles.num_ref_i,'String'));
     573ref_j=str2num(get(handles.num_ref_j,'String'));
     574if isempty(first_i)
     575    first_i=ref_i;
     576elseif first_i < MinIndex_i
     577    first_i=MinIndex_i;
     578end
     579first_j=str2num(get(handles.num_first_j,'String'));
     580if isempty(first_j)
     581    first_j=ref_j;
     582elseif first_j<MinIndex_j
     583    first_j=MinIndex_j;
     584end
     585last_i=str2num(get(handles.num_last_i,'String'));
     586if isempty(last_i)
     587    last_i=ref_i;
     588elseif last_i > MaxIndex_i
     589    last_i=MaxIndex_i;
     590end
     591last_j=str2num(get(handles.num_first_j,'String'));
     592if isempty(last_j)
     593    last_j=ref_j;
     594elseif last_j>MaxIndex_j
     595    last_j=MaxIndex_j;
     596end
     597set(handles.num_first_i,'String',num2str(first_i));
     598set(handles.num_first_j,'String',num2str(first_j));
     599set(handles.num_last_i,'String',num2str(last_i));
     600set(handles.num_last_j,'String',num2str(last_j));
     601
     602%% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     603InputTable=get(handles.InputTable,'Data');
     604FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
     605time=[];%default
     606% case of movies
     607if strcmp(InputTable{iview,4},'*')
     608    if ~isempty(VideoObject)
     609        imainfo=get(VideoObject);
     610        time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)';
     611        set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     612        ColorType='truecolor';
     613    elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
     614        if ~isempty(InputTable{iview,2})
     615            imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}]));
     616        else
     617            imainfo=imfinfo([FileBase InputTable{iview,5}]);
     618        end
     619        ColorType=imainfo.ColorType;%='truecolor' for color images
     620        if length(imainfo) >1 %case of image with multiple frames
     621            nbfield=length(imainfo);
     622            nbfield_j=1;
     623        end
     624    end
     625end
     626
     627%%  read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
     628
     629ext_imadoc='';
     630if exist([FileBase '.xml'],'file')
     631    ext_imadoc='.xml';
     632elseif exist([FileBase '.civ'],'file')
     633    ext_imadoc='.civ';
     634end
     635%read the ImaDoc file
     636XmlData=[];
     637NbSlice_calib={};
     638if isequal(ext_imadoc,'.xml')
     639        [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
     640        if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName)
     641            [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
     642        end
     643        if isfield(XmlData,'Time')
     644            time=XmlData.Time;
     645        end
     646        if isfield(XmlData,'Camera')
     647            if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
     648                NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform
     649                if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
     650                    msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
     651                end
     652            end
     653            if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
     654                TimeUnit=XmlData.Camera.TimeUnit;
     655            end
     656        end
     657        if ~isempty(warntext)
     658            msgbox_uvmat('WARNING',warntext)
     659        end 
     660elseif isequal(ext_imadoc,'.civ')
     661    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
     662    time=XmlData.Time;
     663    if error==2, warntext=['no file ' FileBase '.civ'];
     664    elseif error==1, warntext='inconsistent number of fields in the .civ file';
     665    end 
     666end
     667
     668%% update time table
     669TimeTable=get(handles.TimeTable,'Data');
     670if isempty(MinIndex_j)
     671    TimeTable{iview,1}=time(MinIndex_i);
     672    TimeTable{iview,2}=time(first_i);
     673    TimeTable{iview,3}=time(last_i);
     674    TimeTable{iview,4}=time(MaxIndex_i);
     675else
     676    TimeTable{iview,1}=time(MinIndex_i,MinIndex_j);
     677    TimeTable{iview,2}=time(first_i,first_j);
     678    TimeTable{iview,3}=time(last_i,last_j);
     679    TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j);
     680end
     681set(handles.TimeTable,'Data',TimeTable)
     682
     683%% number of slices
     684if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord')
     685    siz=size(XmlData.GeometryCalib.SliceCoord);
     686    if siz(1)>1
     687        NbSlice=siz(1);
    513688    else
    514         save(profil_perso,'RootPath','SubDir','RootFile','NomType')
    515     end         
    516 end
    517 set(handles.InputTable,'BackgroundColor',[1 1 1])
    518 % set(handles.PathCampaign,'String',SeriesData.PathCampaign)
    519 %num_last_j_Callback([], [], handles)% TODO:update
    520 %num_last_i_Callback([], [], handles)
    521 
    522 
    523 % --- Executes when entered data in editable cell(s) in InputTable.
    524 function InputTable_CellEditCallback(hObject, eventdata, handles)
    525 % hObject    handle to InputTable (see GCBO)
    526 % eventdata  structure with the following fields (see UITABLE)
    527 %       Indices: row and column indices of the cell(s) edited
    528 %       PreviousData: previous data for the cell(s) edited
    529 %       EditData: string(s) entered by the user
    530 %       NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
    531 %       Error: error string when failed to convert EditData to appropriate value for Data
    532 % handles    structure with handles and user data (see GUIDATA)
     689        NbSlice=1;
     690    end
     691    set(handles.num_NbSlice,'String',num2str(NbSlice))
     692end
     693
     694%% update pair menus
     695ListView=get(handles.ListView,'String');
     696ListView{iview}=num2str(iview);
     697set(handles.ListView,'String');
     698set(handles.ListView,'Value',iview)
     699update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
     700
     701%% display the set of existing files as an image
     702set(handles.waitbar_frame,'Units','pixels')
     703pos=get(handles.waitbar_frame,'Position');
     704xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
     705yima=0.5:pos(4)-0.5;
     706[XIma,YIma]=meshgrid(xima,yima);
     707nb_i=size(i1_series,1);
     708nb_j=size(i1_series,2);
     709ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
     710ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
     711[Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
     712CData=zeros([size(XIma) 3]);
     713file_ima=double((i1_series(:,:,1)>0)');
     714if numel(file_ima)>=2
     715if size(file_ima,1)==1
     716    CLine=interp1(ind_i,file_ima,xima,'nearest');
     717    CData(:,:,2)=ones(size(yima'))*CLine;
     718else
     719    CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
     720end
     721set(handles.waitbar_frame,'CData',CData)
     722end
     723set(handles.waitbar_frame,'Units','normalized')
     724
     725%% enable field and veltype menus
     726SeriesData=get(handles.series,'UserData');
     727SeriesData.FileType{iview}=FileType;
     728check_civ=0;
     729check_netcdf=0;
     730for iview=1:length(SeriesData.FileType)
     731    switch SeriesData.FileType{iview}
     732        case {'civx','civdata'}
     733            check_civ=check_civ+1;
     734        case 'netcdf'
     735            check_netcdf=check_netcdf+1;
     736    end
     737end
     738if check_civ
     739    enable='on';
     740else
     741    enable='off';
     742end
     743set(handles.VelTypeMenu,'Visible',enable)
     744set(handles.VelType_text,'Visible',enable)
     745if check_civ>=2
     746    enable='on';
     747else
     748    enable='off';
     749end
     750set(handles.VelTypeMenu_1,'Visible',enable)
     751set(handles.VelType_text_1,'Visible',enable)
     752if check_civ || check_netcdf
     753    enable='on';
     754else
     755    enable='off';
     756end
     757set(handles.FieldMenu,'Visible',enable)
     758set(handles.Field_text,'Visible',enable)
     759if check_civ+ check_netcdf>=2
     760    enable='on';
     761else
     762    enable='off';
     763end
     764set(handles.FieldMenu_1,'Visible',enable)
     765set(handles.Field_text_1,'Visible',enable)
     766FieldString={''};
     767if check_civ
     768    FieldString=[calc_field;{'get_field...'}];
     769elseif check_netcdf
     770    FieldString={'get_field...'};
     771end
     772set(handles.FieldMenu,'String',FieldString)
     773FieldString={''};
     774if check_civ>=2
     775    FieldString=[calc_field;{'get_field...'}];
     776elseif check_civ+check_netcdf>=2
     777    FieldString={'get_field...'};
     778end
     779set(handles.FieldMenu_1,'String',{'get_field...'})
     780% testfield=isequal(get(handles.FieldMenu,'enable'),'on');
     781% testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
     782% testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
     783% testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
     784% testtransform=isequal(get(handles.transform_fct,'Enable'),'on');
     785% testnc=0;
     786% testnc_1=0;
     787% testcivx=0;
     788% testcivx_1=0;
     789% testima=0; %test for image input
     790% if isequal(lower(FileExt),'.avi') %.avi file
     791%     testima=1;
     792% elseif ~isempty(imformats(FileExt(2:end)))
     793%     testima=1;
     794% elseif isequal(FileExt,'.vol')
     795%      testima=1;
     796% end
     797%TODO: update
     798% if length(FileExtCell)==1 || length(FileExtCell)>2
     799%     for iview=1:length(FileExtCell)
     800%         if isequal(FileExtCell{iview},'.nc')
     801%             testnc=1;
     802%         end
     803%         if isequal(FileTypeCell{iview},'civx')
     804%             testcivx=1;
     805%         end
     806%     end
     807% elseif length(FileExtCell)==2
     808%     testnc=isequal(FileExtCell{1},'.nc');
     809%     testnc_1=isequal(FileExtCell{2},'.nc');
     810%     testcivx=isequal(FileTypeCell{1},'civx');
     811%     testcivx_1=isequal(FileTypeCell{2},'civx');
     812% end
     813% switch FileType
     814%     case {'civx','civdata'}
     815%     view_FieldMenu(handles,'on')
     816%     menustr=get(handles.FieldMenu,'String');
     817%     if isequal(menustr,{'get_field...'})
     818%         set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
     819%     end
     820%     set(handles.VelTypeMenu,'Visible','on')
     821%     set(handles.FieldTransform,'Visible','on')
     822%     %      view_TRANSFORM(handles,'on')
     823%     %     TODO: second menu
     824%     %           view_FieldMenu_1(handles,'on')
     825%     %     if testcivx_1
     826%     %         menustr=get(handles.FieldMenu_1,'String');
     827%     %         if isequal(menustr,{'get_field...'})
     828%     %             set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
     829%     %         end
     830%     %     else
     831%     %         set(handles.FieldMenu_1,'Value',1)
     832%     %         set(handles.FieldMenu_1,'String',{'get_field...'})
     833%     %     set(handles.VelTypeMenu_1,'Visible','on')
     834%     %     set(handles.VelType_text_1,'Visible','on');
     835%     %     end
     836%     %     view_FieldMenu_1(handles,'off')
     837%     case 'netcdf'
     838%     view_FieldMenu(handles,'on')
     839%     set(handles.FieldMenu,'Value',1)
     840%     set(handles.FieldMenu,'String',{'get_field...'})
     841%     set(handles.FieldTransform,'Visible','off')
     842%     %     view_TRANSFORM(handles,'off')
     843%     case {'image','multimage','video'}
     844%     view_FieldMenu(handles,'off')
     845%     view_FieldMenu_1(handles,'off')
     846%     set(handles.VelTypeMenu,'Visible','off')
     847%     set(handles.VelType_text,'Visible','off');
     848% end
     849
     850
     851
     852%% store the series info in 'UserData'
     853
     854SeriesData.i1_series{iview}=i1_series;
     855SeriesData.i2_series{iview}=i2_series;
     856SeriesData.j1_series{iview}=j1_series;
     857SeriesData.j2_series{iview}=j2_series;
     858SeriesData.FileType{iview}=FileType;
     859SeriesData.Time{iview}=time;
     860set(handles.series,'UserData',SeriesData)
     861
     862
     863
     864return
     865
     866%% set default options in menu 'Fields'%% TODO: check VelType
     867if ~testima
     868    testcivx=0;
     869    if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
     870        set(handles_Fields,'Value',1)
     871        set(handles_Fields,'String',{'get_field...'})
     872        UvData=rmfield(UvData,'FieldsString');
     873    else
     874        Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
     875        if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
     876            FieldList=calc_field;
     877            set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
     878            set(handles_Fields,'Value',2) % set menu to 'velocity'
     879            col_vec=FieldList;
     880            col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
     881            testcivx=1;
     882        end
     883        if ~testcivx
     884            set(handles_Fields,'Value',1) % set menu to 'get_field...
     885            set(handles_Fields,'String',{'get_field...'})
     886            col_vec={'get_field...'};
     887        end
     888        set(handles.ColorScalar,'String',col_vec)
     889    end
     890end
     891set(handles.uvmat,'UserData',UvData)
     892
     893%% set index navigation options and refresh plots
     894scan_option='i';%default
     895state_j='off'; %default
     896if index==2
     897    if get(handles.scan_j,'Value')
     898        scan_option='j'; %keep the scan option for the second fiel series
     899    end
     900    if strcmp(get(handles.j1,'Visible'),'on')
     901        state_j='on';
     902    end
     903end
     904if ~isempty(j1_series)
     905        state_j='on';
     906        if isequal(nbfield,1) &&index==1
     907            scan_option='j'; %scan j index by default if nbfield=1               
     908        end
     909end
     910if isequal(scan_option,'i')
     911     set(handles.scan_i,'Value',1)
     912     scan_i_Callback([],[], handles);
     913else
     914     set(handles.scan_j,'Value',1)
     915     scan_j_Callback([],[], handles);
     916end
     917set(handles.scan_j,'Visible',state_j)
     918set(handles.j1,'Visible',state_j)
     919set(handles.j2,'Visible',state_j)
     920set(handles.last_j,'Visible',state_j);
     921set(handles.frame_j,'Visible',state_j);
     922set(handles.j_text,'Visible',state_j);
     923if ~isempty(i2_series)||~isempty(j2_series)
     924    set(handles.CheckFixPair,'Visible','on')
     925elseif index==1
     926    set(handles.CheckFixPair,'Visible','off')
     927end
     928
     929
     930mode_Callback(hObject, eventdata, handles)
     931
     932set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
     933InputTable=get(handles.InputTable,'Data');
    533934check_lines=get(handles.REFRESH_INDICES,'UserData');
    534 check_lines(eventdata.Indices(1))=1; %select the edited line for refresh
    535 set(handles.REFRESH_INDICES,'UserData',check_lines);
    536 set(handles.REFRESH_INDICES,'Visible','on')
    537 
    538 
    539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%????????????
     935
     936%% check the indices and FileTypes for each series (limited to the new ones to save time)
     937for ind_list=1:length(check_lines)
     938    if  check_lines(ind_list)
     939        InputLine=InputTable(ind_list,:);
     940        detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
     941        detect_idem=detect_idem(detect_idem>0);
     942        if ~isempty (detect_idem)
     943            InputLine(detect_idem)=InputTable(ind_list-1,detect_idem);
     944            set(handles.InputTable,'Data',InputTable)
     945        end
     946        fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2);
     947        %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2})
     948        %update file series defined by the selected line
     949        [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list);
     950        if ~isempty(errormsg)
     951                msgbox_uvmat('ERROR',errormsg)
     952                return
     953        end
     954    end
     955end
     956set(handles.InputTable,'Data',InputTable)
     957SeriesData=get(handles.series,'UserData');
     958
     959state_j='off';
     960state_Pairs='off';
     961state_InputFields='off';
     962val=get(handles.ListView,'Value');
     963ListViewString={''};
     964if ~isempty(SeriesData)
     965%     ListViewString={};
     966    for iview=1:size(InputTable,1)
     967        if ~isempty(SeriesData.j1_series{iview})
     968            state_j='on';
     969        end
     970        if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
     971            state_Pairs='on';
     972            ListViewString{iview}=num2str(iview);
     973            if check_lines(iview)
     974                val=iview;%select the last pair if it is a new entry
     975            end
     976        end
     977        if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata')
     978            state_InputFields='on';
     979        end
     980    end
     981end
     982set(handles.ListView,'Value',val)
     983set(handles.ListView,'String',ListViewString)
     984if strcmp(state_Pairs,'on')
     985    ListView_Callback(hObject,eventdata,handles)
     986end
     987set(handles.PairString,'Visible',state_Pairs)
     988enable_j(handles,state_j)
     989
     990
     991%------------------------------------------------------------------------
     992% --- Executes when selected cell(s) is changed in PairString.
     993function PairString_CellSelectionCallback(hObject, eventdata, handles)
     994%------------------------------------------------------------------------   
     995set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index
     996ListView_Callback ([],[],handles) % update the list of available pairs
     997
     998%------------------------------------------------------------------------
     999%------------------------------------------------------------------------
     1000%  III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS
     1001%------------------------------------------------------------------------
     1002%------------------------------------------------------------------------
     1003% --- Executes on selection change in ListView.
     1004function ListView_Callback(hObject, eventdata, handles)
     1005%------------------------------------------------------------------------   
     1006SeriesData=get(handles.series,'UserData');
     1007i2_series=[];
     1008j2_series=[];
     1009iview=get(handles.ListView,'Value');
     1010if ~isempty(SeriesData.i2_series{iview})
     1011    i2_series=SeriesData.i2_series{iview};
     1012end
     1013if ~isempty(SeriesData.j2_series{iview})
     1014    j2_series=SeriesData.j2_series{iview};
     1015end
     1016update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},...
     1017    SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview})
     1018
     1019%------------------------------------------------------------------------
    5401020% --- Executes on button press in mode.
    541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    5421021function mode_Callback(hObject, eventdata, handles)
    543         
     1022%------------------------------------------------------------------------       
    5441023SeriesData=get(handles.series,'UserData');
     1024iview=get(handles.ListView,'Value');
    5451025mode_list=get(handles.mode,'String');
    546 mode_value=get(handles.mode,'Value');
    547 mode=mode_list{mode_value};
    548 time=[];
    549 if isfield(SeriesData,'Time')
    550     time=SeriesData.Time{1}; %get the set of times
    551 end
     1026mode=mode_list{get(handles.mode,'Value')};
    5521027if isequal(mode,'bursts')
    5531028    enable_i(handles,'On')
     
    5571032    enable_j(handles,'Off')
    5581033end
    559 find_netcpair_civ(handles)
    560 
    561 %-------------------------------------
    562 function enable_i(handles,state)
    563 set(handles.i_txt,'Visible',state)
    564 set(handles.num_first_i,'Visible',state)
    565 set(handles.num_last_i,'Visible',state)
    566 set(handles.num_incr_i,'Visible',state)
    567 % set(handles.num_MaxIndex_i,'Visible',state)
    568 set(handles.ref_i,'Visible',state)
    569 set(handles.ref_i_text,'Visible',state)
    570 
    571 %-----------------------------------
    572 function enable_j(handles,state)
    573 set(handles.j_txt,'Visible',state)
    574 % set(handles.num_MinIndex_j,'Visible',state)
    575 set(handles.num_first_j,'Visible',state)
    576 set(handles.num_last_j,'Visible',state)
    577 set(handles.num_incr_j,'Visible',state)
    578 % set(handles.num_MaxIndex_j,'Visible',state)
    579 set(handles.ref_j,'Visible',state)
    580 set(handles.ref_j_text,'Visible',state)
    581 
    582 %-----------------------------------
    583 function view_FieldMenu(handles,state)
    584 % set(handles.FieldMenu,'Visible',state)
    585 % set(handles.Field_text,'Visible',state)
    586 set(handles.InputFields,'Visible',state)
    587 
    588 %-----------------------------------
    589 function view_FieldMenu_1(handles,state)
    590 set(handles.FieldMenu_1,'Visible',state)
    591 set(handles.Field_text_1,'Visible',state)
    592 
    593 % %-----------------------------------
    594 % function view_TRANSFORM(handles,state)
    595 % set(handles.TRANSFORM_frame,'Visible',state)
    596 % set(handles.transform_fct,'Visible',state);
    597 % set(handles.TRANSFORM_title,'Visible',state)
     1034fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},...
     1035    SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview})
     1036ListPairs_Callback([],[],handles)
     1037
     1038%-------------------------------------------------------------
     1039% --- Executes on selection in ListPairs.
     1040function ListPairs_Callback(hObject,eventdata,handles)
     1041%------------------------------------------------------------
     1042list_pair=get(handles.ListPairs,'String');%get the menu of image pairs
     1043string=list_pair{get(handles.ListPairs,'Value')};
     1044string=regexprep(string,',.*','');%removes time indication (after ',')
     1045PairString=get(handles.PairString,'Data');
     1046iview=get(handles.ListView,'Value');
     1047PairString{iview,1}=string;
     1048% report the selected pair string to the table PairString
     1049set(handles.PairString,'Data',PairString)
     1050
     1051%------------------------------------------------------------------------
     1052function num_ref_i_Callback(hObject, eventdata, handles)
     1053%------------------------------------------------------------------------
     1054mode_list=get(handles.mode,'String');
     1055mode=mode_list{get(handles.mode,'Value')};
     1056SeriesData=get(handles.series,'UserData');
     1057iview=get(handles.ListView,'Value');
     1058fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},...
     1059    SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.time{iview});% update the menu of pairs depending on the available netcdf files
     1060ListPairs_Callback([],[],handles)
     1061
     1062%------------------------------------------------------------------------
     1063function num_ref_j_Callback(hObject, eventdata, handles)
     1064%------------------------------------------------------------------------
     1065num_ref_i_Callback(hObject, eventdata, handles)
     1066
     1067%------------------------------------------------------------------------
     1068function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
     1069%------------------------------------------------------------------------   
     1070check_burst=1;
     1071if isempty(j2_series)% no pair menu to display
     1072    if isempty(i2_series)
     1073        set(handles.mode,'String',{''})
     1074    else
     1075        set(handles.mode,'Value',1)
     1076        set(handles.mode,'String',{'series(Di)'})
     1077    end
     1078else
     1079    nbfield=size(j2_series{View},1);
     1080    nbfield2=size(j2_series{View},2);
     1081    set(handles.mode,'String',{'bursts';'series(Dj)'})
     1082    if nbfield2>10 || nbfield==1
     1083        set(handles.mode,'Value',2);
     1084    else
     1085        set(handles.mode,'Value',1);
     1086        check_burst=1;
     1087    end
     1088end
     1089if check_burst
     1090    enable_i(handles,'On')
     1091    enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice)
     1092else
     1093    enable_i(handles,'On')
     1094    enable_j(handles,'Off')
     1095end
     1096fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time)
     1097ListPairs_Callback([],[],handles)
    5981098
    5991099%--------------------------------------------------------------
    600 % determine the menu for civ1 pairs depending on existing netcdf files
    601 % with the reference indices ref_i and ref_j
     1100% determine the menu for civ1 pairstring depending on existing netcdf files
     1101% with the reference indices num_ref_i and num_ref_j
    6021102%----------------------------------------------------------------
    603 function find_netcpair_civ(handles)
    604 SeriesData=get(handles.series,'UserData');
    605 set(handles.Pairs,'Visible','on')% makes the panel "Pairs' visible
     1103function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time)
     1104
    6061105mode_list=get(handles.mode,'String');
    607 mode_value=get(handles.mode,'Value');
    608 mode=mode_list{mode_value};
    609 
    610 %reads image numbers from the interface
    611 % ref_i=str2num(get(handles.ref_i,'String'));
    612 % ref_j=str2num(get(handles.ref_j,'String'));
    613 % ref_time=0;
    614 % nbfield=50;
    615 % nbfield2=50;%default max number of pairs
    616 
    617 %look for existing processed pairs involving the field at the middle of the series if civ1 will not
    618 % be performed, while the result is needed for next steps.
    619 
    620 % ind_exist=0;
     1106mode=mode_list{get(handles.mode,'Value')};
     1107ref_i=str2num(get(handles.num_ref_i,'String'));
     1108ref_j=str2num(get(handles.num_ref_j,'String'));
     1109if isempty(ref_i)
     1110    ref_i=1;
     1111end
     1112if isempty(ref_j)
     1113    ref_j=1;
     1114end
    6211115TimeUnit=get(handles.TimeUnit,'String');
    6221116if length(TimeUnit)>=1
     
    6261120end
    6271121
    628 %% NEW
    629 for Val=1:numel(SeriesData.i1_series)
    630    
    631 i1_series=SeriesData.i1_series{Val};
    632 i2_series=SeriesData.i2_series{Val};
    633 j1_series=SeriesData.j1_series{Val};
    634 j2_series=SeriesData.j2_series{Val};
    6351122displ_pair={};
    6361123if strcmp(mode,'series(Di)')
     
    6441131    for ipair=min_diff:max_diff
    6451132        if numel(diff_i(diff_i==ipair))>0
    646             displ_pair=[displ_pair;{['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]}];
     1133            pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
     1134            if ~isempty(time)
     1135                Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j);
     1136                pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
     1137            end
     1138            displ_pair=[displ_pair;{pair_string}];
    6471139        end
    6481140    end
     
    6601152    for ipair=min_diff:max_diff
    6611153        if numel(diff_j(diff_j==ipair))>0
    662             displ_pair=[displ_pair;{['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]}];
     1154            pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
     1155            if ~isempty(time)
     1156                Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2));
     1157                pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
     1158            end
     1159            displ_pair=[displ_pair;{pair_string}];
    6631160        end
    6641161    end
     
    6871184    end
    6881185end
    689 end
    690 %% display list of pairs
    691 displ_pair_list=get(handles.list_pair_civ,'String');
     1186
     1187%% display list of pairstring
     1188displ_pair_list=get(handles.ListPairs,'String');
    6921189NewVal=[];
    6931190if ~isempty(displ_pair_list)
    694 Val=get(handles.list_pair_civ,'Value');
     1191Val=get(handles.ListPairs,'Value');
    6951192NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pâir
    6961193end
    6971194if ~isempty(NewVal)
    698     set(handles.list_pair_civ,'Value',NewVal)
     1195    set(handles.ListPairs,'Value',NewVal)
    6991196else
    700     set(handles.list_pair_civ,'Value',1)
    701 end
    702 set(handles.list_pair_civ,'String',displ_pair)
     1197    set(handles.ListPairs,'Value',1)
     1198end
     1199set(handles.ListPairs,'String',displ_pair)
    7031200if isempty(displ_pair)
    7041201    msgbox_uvmat('ERROR',['no file available for the selected subdirectory ' subdir])
    7051202end
    706 return
    707 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END FUNCTION
    708 
    709 
    710 if ind_exist==0
    711          if  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
    712             msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir])
    713         else
    714             msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir])
    715         end
    716         if isequal(mode,'bursts') %case of bursts
    717             set(handles.list_pair_civ,'String',{'j=*-*'});
    718         elseif isequal(mode,'series(Di)') %case of bursts
    719             set(handles.list_pair_civ,'String',{'Di=*|*'});
    720         elseif isequal(mode,'series(Dj)') %case of bursts
    721             set(handles.list_pair_civ,'String',{'Dj=*|*'});
    722         end
    723 end
    724 return
    725 %TO update
    726 val=get(handles.list_pair_civ,'Value');
    727 if val > length(displ_pair)
    728     set(handles.list_pair_civ,'Value',1);% first pair proposed by default in the menu
    729     val=1;
    730 end
    731 iview=get(handles.NomType,'Value');
    732 SeriesData.displ_num(iview,:)=(displ_num(:,val))';
    733 SeriesData.ref_time=ref_time;
    734 set(handles.series,'UserData',SeriesData)
    735 list_pair_civ_Callback([],[],handles)
    736 
    737 %-------------------------------------------------------------
    738 % --- Executes on selection in list_pair_civ.
    739 function list_pair_civ_Callback(hObject,eventdata,handles)
    740 %------------------------------------------------------------
    741 return
    742 %%%%%%%%
    743 %update num_first_i and num_last_i according to the chosen image pairs
    744 testupdate=0;
    745 Val=get(handles.RootPath,'Value');
    746 IndexCell=get(handles.NomType,'String');
    747 SeriesData=get(handles.series,'UserData');
    748 NomType=SeriesData.NomType{Val};
    749 list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs
    750 index_pair=get(handles.list_pair_civ,'Value');
    751 str_pair=list_pair{index_pair};
    752 ind_equ=strfind(str_pair,'=');%find '='
    753 ind_sep=strfind(str_pair,'|');%find pair separator '|'
    754 ind_com=strfind(str_pair,':');%find ':'
    755 test_bursts=0;
    756 if isempty(ind_sep)
    757     ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|'
    758     test_bursts=1;% we are in the case of bursts
    759 end
    760 displ_num=[0 0 0 0]; %default
    761 if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-')
    762     num1_str=str_pair(ind_equ(1)+1:ind_sep-1);
    763     num2_str=str_pair(ind_sep+1:ind_com-1);
    764     num1=str2double(num1_str);
    765     num2=str2double(num2_str);
    766     if isequal(num1_str(1),' ')
    767         num1_str(1)=[];
    768     end   
    769     if isequal(num2_str(end),' ')
    770         num2_str(end)=[];
    771     end
    772     switch NomType
    773        case {'_1-2_1'}
    774            if isequal(num1_str(1),'0')
    775                IndexCell{Val}=['_(i-(i+' num2_str ')_j'];
    776            else
    777                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j'];
    778            end
    779            displ_num(3)=num1;
    780            displ_num(4)=num2;
    781        case {'_1-2'}
    782            if isequal(num1_str(1),'0')
    783                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
    784            else
    785                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
    786            end
    787            displ_num(3)=num1;
    788            displ_num(4)=num2;
    789        case '_1_1-2'
    790           if test_bursts
    791               IndexCell{Val}=['_i_' num1_str '-' num2_str ];
    792           else
    793               if isequal(num1_str(1),'0')
    794                  IndexCell{Val}=['_i_j-(j+' num2_str ')'];
    795               else
    796                  IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')'];
    797               end
    798           end
    799           displ_num(1)=num1;
    800           displ_num(2)=num2;
    801        case {'#_ab'} %TO COMPLETE
    802            IndexCell{Val}=['_i_' num1_str '-' num2_str ];
    803 
    804     end
    805 end
    806 set(handles.NomType,'String',IndexCell)
    807 SeriesData.displ_num(Val,:)=displ_num;
    808 set(handles.series,'UserData',SeriesData)
    809 % set(handles.NomType,'Value',Val)
    810 
    811 if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*')
    812         mode_list=get(handles.mode,'String');
    813     mode_value=get(handles.mode,'Value');
    814     mode=mode_list{mode_value};
    815         if isequal(mode,'series(Di)')
    816         first_i=str2num(get(handles.num_first_i,'String'));
    817         last_i=str2num(get(handles.num_last_i,'String'));
    818         incr_i=str2num(get(handles.num_incr_i,'String'));
    819         num1=first_i:incr_i:last_i;
    820         lastfieldCell=get(handles.num_MaxIndex_i,'String');
    821         lastfield=str2num(lastfieldCell{1});
    822         if ~isempty(lastfield)
    823             ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
    824             num1=num1(ind);       
    825         end
    826         if ~isempty(num1)
    827             set(handles.num_first_i,'String',num2str(num1(1)));
    828             set(handles.num_last_i,'String',num2str(num1(end)));
    829         end
    830         testupdate=1;
    831         elseif isequal(mode,'series(Dj)')
    832         first_j=str2num(get(handles.num_first_j,'String'));
    833         last_j=str2num(get(handles.num_last_j,'String'));
    834         incr_j=str2num(get(handles.num_incr_j,'String'));
    835         num_j=first_j:incr_j:last_j;
    836         lastfieldCell=get(handles.num_MaxIndex_j,'String');
    837         if ~isempty(lastfieldCell)
    838             lastfield2=lastfieldCell{1};
    839             ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    840                  (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
    841         end
    842         testupdate=1;
    843         end
    844        
    845         %update the first and last times of the series
    846         if testupdate && isfield(SeriesData,'Time')
    847         if ~isempty(SeriesData.Time{1})
    848             displ_time(handles);
    849         end
    850         end
    851 end
     1203
     1204
     1205
     1206% return
     1207% %%%%%%%%
     1208% %update num_first_i and num_last_i according to the chosen image pairstring
     1209% testupdate=0;
     1210%
     1211% SeriesData=get(handles.series,'UserData');
     1212% NomType=SeriesData.NomType{Val};
     1213% list_pair=get(handles.ListPairs,'String');%get the menu of image pairs
     1214% index_pair=get(handles.ListPairs,'Value');
     1215% str_pair=list_pair{index_pair};
     1216% ind_equ=strfind(str_pair,'=');%find '='
     1217% ind_sep=strfind(str_pair,'|');%find pair separator '|'
     1218% ind_com=strfind(str_pair,':');%find ':'
     1219% test_bursts=0;
     1220% if isempty(ind_sep)
     1221%     ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|'
     1222%     test_bursts=1;% we are in the case of bursts
     1223% end
     1224% displ_num=[0 0 0 0]; %default
     1225% if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-')
     1226%     num1_str=str_pair(ind_equ(1)+1:ind_sep-1);
     1227%     num2_str=str_pair(ind_sep+1:ind_com-1);
     1228%     num1=str2double(num1_str);
     1229%     num2=str2double(num2_str);
     1230%     if isequal(num1_str(1),' ')
     1231%         num1_str(1)=[];
     1232%     end   
     1233%     if isequal(num2_str(end),' ')
     1234%         num2_str(end)=[];
     1235%     end
     1236%     switch NomType
     1237%        case {'_1-2_1'}
     1238%            if isequal(num1_str(1),'0')
     1239%                IndexCell{Val}=['_(i-(i+' num2_str ')_j'];
     1240%            else
     1241%                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j'];
     1242%            end
     1243%            displ_num(3)=num1;
     1244%            displ_num(4)=num2;
     1245%        case {'_1-2'}
     1246%            if isequal(num1_str(1),'0')
     1247%                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
     1248%            else
     1249%                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
     1250%            end
     1251%            displ_num(3)=num1;
     1252%            displ_num(4)=num2;
     1253%        case '_1_1-2'
     1254%           if test_bursts
     1255%               IndexCell{Val}=['_i_' num1_str '-' num2_str ];
     1256%           else
     1257%               if isequal(num1_str(1),'0')
     1258%                  IndexCell{Val}=['_i_j-(j+' num2_str ')'];
     1259%               else
     1260%                  IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')'];
     1261%               end
     1262%           end
     1263%           displ_num(1)=num1;
     1264%           displ_num(2)=num2;
     1265%        case {'#_ab'} %TO COMPLETE
     1266%            IndexCell{Val}=['_i_' num1_str '-' num2_str ];
     1267%
     1268%     end
     1269% end
     1270% set(handles.NomType,'String',IndexCell)
     1271% SeriesData.displ_num(Val,:)=displ_num;
     1272% set(handles.series,'UserData',SeriesData)
     1273% % set(handles.NomType,'Value',Val)
     1274%
     1275% if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*')
     1276%       mode_list=get(handles.mode,'String');
     1277%     mode_value=get(handles.mode,'Value');
     1278%     mode=mode_list{mode_value};
     1279%       if isequal(mode,'series(Di)')
     1280%         first_i=str2num(get(handles.num_first_i,'String'));
     1281%         last_i=str2num(get(handles.num_last_i,'String'));
     1282%         incr_i=str2num(get(handles.num_incr_i,'String'));
     1283%         num1=first_i:incr_i:last_i;
     1284%         lastfieldCell=get(handles.num_MaxIndex_i,'String');
     1285%         lastfield=str2num(lastfieldCell{1});
     1286%         if ~isempty(lastfield)
     1287%             ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
     1288%             num1=num1(ind);       
     1289%         end
     1290%         if ~isempty(num1)
     1291%             set(handles.num_first_i,'String',num2str(num1(1)));
     1292%             set(handles.num_last_i,'String',num2str(num1(end)));
     1293%         end
     1294%         testupdate=1;
     1295%       elseif isequal(mode,'series(Dj)')
     1296%         first_j=str2num(get(handles.num_first_j,'String'));
     1297%         last_j=str2num(get(handles.num_last_j,'String'));
     1298%         incr_j=str2num(get(handles.num_incr_j,'String'));
     1299%         num_j=first_j:incr_j:last_j;
     1300%         lastfieldCell=get(handles.num_MaxIndex_j,'String');
     1301%         if ~isempty(lastfieldCell)
     1302%             lastfield2=lastfieldCell{1};
     1303%             ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
     1304%                  (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
     1305%         end
     1306%         testupdate=1;
     1307%       end
     1308%       
     1309%       %update the first and last times of the series
     1310%       if testupdate && isfield(SeriesData,'Time')
     1311%         if ~isempty(SeriesData.Time{1})
     1312%             displ_time(handles);
     1313%         end
     1314%       end
     1315% end
     1316
     1317%-------------------------------------
     1318function enable_i(handles,state)
     1319set(handles.i_txt,'Visible',state)
     1320set(handles.num_first_i,'Visible',state)
     1321set(handles.num_last_i,'Visible',state)
     1322set(handles.num_incr_i,'Visible',state)
     1323% set(handles.num_MaxIndex_i,'Visible',state)
     1324set(handles.num_ref_i,'Visible',state)
     1325set(handles.ref_i_text,'Visible',state)
     1326
     1327%-----------------------------------
     1328function enable_j(handles,state)
     1329set(handles.j_txt,'Visible',state)
     1330% set(handles.num_MinIndex_j,'Visible',state)
     1331set(handles.num_first_j,'Visible',state)
     1332set(handles.num_last_j,'Visible',state)
     1333set(handles.num_incr_j,'Visible',state)
     1334% set(handles.num_MaxIndex_j,'Visible',state)
     1335set(handles.num_ref_j,'Visible',state)
     1336set(handles.ref_j_text,'Visible',state)
     1337
     1338%-----------------------------------
     1339function view_FieldMenu(handles,state)
     1340% set(handles.FieldMenu,'Visible',state)
     1341% set(handles.Field_text,'Visible',state)
     1342set(handles.InputFields,'Visible',state)
     1343
     1344%-----------------------------------
     1345function view_FieldMenu_1(handles,state)
     1346set(handles.FieldMenu_1,'Visible',state)
     1347set(handles.Field_text_1,'Visible',state)
     1348
     1349% %-----------------------------------
     1350% function view_TRANSFORM(handles,state)
     1351% set(handles.TRANSFORM_frame,'Visible',state)
     1352% set(handles.transform_fct,'Visible',state);
     1353% set(handles.TRANSFORM_title,'Visible',state)
     1354
     1355
     1356%list_pair_civ_Callback([],[],handles)
     1357
     1358
    8521359
    8531360%------------------------------------------------------------------------
     
    10351542last_j=str2num(get(handles.num_last_j,'String'));
    10361543ref_j=ceil((first_j+last_j)/2);
    1037 set(handles.ref_j,'String', num2str(ref_j))
     1544set(handles.num_ref_j,'String', num2str(ref_j))
    10381545ref_j_Callback(hObject, eventdata, handles)
    10391546SeriesData=get(handles.series,'UserData');
     
    10441551
    10451552
    1046 %------------------------------------------------------------------------
    1047 function ref_i_Callback(hObject, eventdata, handles)
    1048 %------------------------------------------------------------------------
    1049 mode_list=get(handles.mode,'String');
    1050 mode_value=get(handles.mode,'Value');
    1051 mode=mode_list{mode_value};
    1052 SeriesData=get(handles.series,'UserData');
    1053 % if ~isempty(SeriesData)
    1054 if ~isempty(SeriesData.i2_series)||~isempty(SeriesData.j2_series)
    1055     if isequal(mode,'series(Di)')
    1056         find_netcpair_civ(handles);% update the menu of pairs depending on the available netcdf files
    1057     end
    1058 end
    1059 % end
    1060 
    1061 %------------------------------------------------------------------------
    1062 function ref_j_Callback(hObject, eventdata, handles)
    1063 %------------------------------------------------------------------------
    1064 mode_list=get(handles.mode,'String');
    1065 mode_value=get(handles.mode,'Value');
    1066 mode=mode_list{mode_value};
    1067 SeriesData=get(handles.series,'UserData');
    1068 if ~isempty(SeriesData)
    1069 if ~isempty(SeriesData.i2_series)||~isempty(SeriesData.j2_series)
    1070     if isequal(mode,'series(Di)')
    1071         find_netcpair_civ(handles);% update the menu of pairs depending on the available netcdf files
    1072     end
    1073 end
    1074 end
    10751553% NomTypeCell=SeriesData.NomType;
    10761554% if ~isempty(NomTypeCell)
     
    10791557%     if isequal(NomType,'_1_1-2')|| isequal(NomType,'_1-2_1')|| isequal(NomType,'_1-2')
    10801558%         if isequal(mode,'series(Dj)')
    1081 %             find_netcpair_civ(handles,Val);% update the menu of pairs depending on the available netcdf files
     1559%             fill_ListPair(handles,Val);% update the menu of pairstring depending on the available netcdf files
    10821560%         end
    10831561%     end
    10841562% end
     1563%------------------------------------------------------------------------
     1564% ---- find the times corresponding to the first and last indices of a series
     1565function displ_time(handles)
     1566%------------------------------------------------------------------------
     1567SeriesData=get(handles.series,'UserData');%
     1568ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))];
     1569ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))];
     1570% last_i=str2num(get(handles.num_last_i,'String'));
     1571% last_j=str2num(get(handles.num_last_j,'String'));
     1572TimeTable=get(handles.TimeTable,'Data');
     1573
     1574for iview=1:size(TimeTable,1)
     1575    Pairs=get(handles.PairString,'Data');
     1576    i1=ref_i;
     1577    j1=ref_j;
     1578    i2=ref_i;
     1579    j2=ref_j;
     1580    if ~isempty(Pairs{iview,1})
     1581        r=regexp(Param.Pairs.list_pair_civ,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
     1582        if isempty(r)
     1583            r=regexp(Param.Pairs.list_pair_civ,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
     1584        end
     1585        switch r.mode
     1586            case 'Di='  %  case 'series(Di)')
     1587                i1=ref_i-str2num(r.num1);
     1588                i2=ref_i+str2num(r.num2);
     1589            case 'Dj='  %  case 'series(Dj)'
     1590                j1=ref_j-str2num(r.num1);
     1591                j2=ref_j+str2num(r.num2);
     1592            case '-'  % case 'bursts'
     1593                j1=str2num(r.num1)*ones(size(ref_i));
     1594                j2=str2num(r.num2)*ones(size(ref_i));
     1595        end
     1596    end
     1597    if isempty(ref_j)
     1598    time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2;
     1599    time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2;
     1600    else
     1601        time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;
     1602        time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;
     1603    end
     1604    TimeTable{iview,2}=time_first; %TODO: take into account pairs
     1605    TimeTable{iview,3}=time_last; %TODO: take into account pairs
     1606end
     1607set(handles.TimeTable,'Data',TimeTable)
     1608return
     1609
     1610
     1611NomType=InputTable(:,4);
     1612mode_list=get(handles.mode,'String');
     1613index_mode=get(handles.mode,'Value');
     1614
     1615mode=mode_list{index_mode};
     1616
     1617time_first=[];
     1618time_last=[];
     1619if ~isfield(SeriesData,'Time')
     1620    SeriesData.Time{1}=[];
     1621end
     1622TimeTable=get(handles.TimeTable,'Data');
     1623for iview=1:size(TimeTable,1)
     1624    time_first_cell{iview}='?';
     1625    time_last_cell{iview}='?';%default
     1626    time=SeriesData.Time{iview};
     1627    if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2')
     1628        if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
     1629            ind_shift=SeriesData.displ_num(iview,:);
     1630            if isequal(mode,'bursts')
     1631                first_j=0;
     1632                last_j=0;
     1633            end
     1634            first_i1=first_i +ind_shift(3);
     1635            first_i2 =first_i +ind_shift(4);
     1636            first_j1 =first_j +ind_shift(1);
     1637            first_j2 =first_j +ind_shift(2);
     1638            last_i1=last_i +ind_shift(3);
     1639            last_i2 =last_i +ind_shift(4);   
     1640            last_j1 =last_j +ind_shift(1);
     1641            last_j2 =last_j +ind_shift(2);
     1642            siz=size(SeriesData.Time{1});
     1643            if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2
     1644                time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
     1645                time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
     1646            else%read the time in the nc files
     1647                RootPath=get(handles.RootPath,'String');
     1648                RootFile=get(handles.RootFile,'String');
     1649                SubDir=get(handles.SubDir,'String');
     1650                %VelType=get(handles.VelType,'String');
     1651                VelType_str=get(handles.VelTypeMenu,'String');
     1652                VelType_val=get(handles.VelTypeMenu,'Value');
     1653                VelType=VelType_str{VelType_val};
     1654                filebase=fullfile(RootPath{1},RootFile{1});
     1655                [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
     1656                if  exist(filefirst,'file')
     1657                    Attrib=nc2struct(filefirst,[]);
     1658                    if isfield(Attrib,'Time')
     1659                        time_first=Attrib.Time;
     1660                    else
     1661                        if isfield(Attrib,'absolut_time_T0')
     1662                            time_first=Attrib.absolut_time_T0;
     1663                        end
     1664                        if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
     1665                            time_first=Attrib.absolut_time_T0_2;
     1666                        end
     1667                    end
     1668                end
     1669                [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
     1670                if exist(filelast,'file')
     1671                   Attrib=nc2struct(filelast,[]);
     1672                    if isfield(Attrib,'Time')
     1673                        time_last=Attrib.Time;
     1674                    else
     1675                        if isfield(Attrib,'absolut_time_T0')
     1676                            time_last=Attrib.absolut_time_T0;
     1677                        end
     1678                        if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
     1679                            time_last=Attrib.absolut_time_T0_2;
     1680                        end
     1681                    end
     1682                end
     1683            end
     1684        end
     1685    else
     1686        siz=size(time);
     1687        if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
     1688            time_first=times(first_i,first_j);
     1689            time_last=times(last_i,last_j);
     1690        end
     1691    end
     1692    time_first_cell{iview}=num2str(time_first,4);
     1693    time_last_cell{iview}=num2str(time_last,4);
     1694end
     1695
    10851696
    10861697%------------------------------------------------------------------------
     
    14052016
    14062017%------------------------------------------------------------------------
    1407 % --- determine the list of index pairs of processing file
     2018% --- determine the list of index pairstring of processing file
    14082019function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
    14092020%------------------------------------------------------------------------
     
    14442055end
    14452056
    1446 %------------------------------------------------------------------------
    1447 % ---- find the times corresponding to the first and last indices of a series
    1448 function displ_time(handles)
    1449 %------------------------------------------------------------------------
    1450 SeriesData=get(handles.series,'UserData');%
    1451 first_i=str2num(get(handles.num_first_i,'String'));
    1452 first_j=str2num(get(handles.num_first_j,'String'));
    1453 last_i=str2num(get(handles.num_last_i,'String'));
    1454 last_j=str2num(get(handles.num_last_j,'String'));
    1455 InputTable=get(handles.InputTable,'Data');
    1456 NomType=InputTable(:,4);
    1457 % NomType=SeriesData.NomType;
    1458 mode_list=get(handles.mode,'String');
    1459 index_mode=get(handles.mode,'Value');
    1460 mode=mode_list{index_mode};
    1461 
    1462 time_first=[];
    1463 time_last=[];
    1464 if ~isfield(SeriesData,'Time')
    1465     SeriesData.Time{1}=[];
    1466 end
    1467 for iview=1:length(NomType)
    1468     time_first_cell{iview}='?';
    1469     time_last_cell{iview}='?';%default
    1470     time=SeriesData.Time{iview};
    1471     if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2')
    1472         if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
    1473             ind_shift=SeriesData.displ_num(iview,:);
    1474             if isequal(mode,'bursts')
    1475                 first_j=0;
    1476                 last_j=0;
    1477             end
    1478             first_i1=first_i +ind_shift(3);
    1479             first_i2 =first_i +ind_shift(4);
    1480             first_j1 =first_j +ind_shift(1);
    1481             first_j2 =first_j +ind_shift(2);
    1482             last_i1=last_i +ind_shift(3);
    1483             last_i2 =last_i +ind_shift(4);   
    1484             last_j1 =last_j +ind_shift(1);
    1485             last_j2 =last_j +ind_shift(2);
    1486             siz=size(SeriesData.Time{1});
    1487             if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2
    1488                 time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
    1489                 time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
    1490             else%read the time in the nc files
    1491                 RootPath=get(handles.RootPath,'String');
    1492                 RootFile=get(handles.RootFile,'String');
    1493                 SubDir=get(handles.SubDir,'String');
    1494                 %VelType=get(handles.VelType,'String');
    1495                 VelType_str=get(handles.VelTypeMenu,'String');
    1496                 VelType_val=get(handles.VelTypeMenu,'Value');
    1497                 VelType=VelType_str{VelType_val};
    1498                 filebase=fullfile(RootPath{1},RootFile{1});
    1499                 [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
    1500                 if  exist(filefirst,'file')
    1501                     Attrib=nc2struct(filefirst,[]);
    1502                     if isfield(Attrib,'Time')
    1503                         time_first=Attrib.Time;
    1504                     else
    1505                         if isfield(Attrib,'absolut_time_T0')
    1506                             time_first=Attrib.absolut_time_T0;
    1507                         end
    1508                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
    1509                             time_first=Attrib.absolut_time_T0_2;
    1510                         end
    1511                     end
    1512                 end
    1513                 [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
    1514                 if exist(filelast,'file')
    1515                    Attrib=nc2struct(filelast,[]);
    1516                     if isfield(Attrib,'Time')
    1517                         time_last=Attrib.Time;
    1518                     else
    1519                         if isfield(Attrib,'absolut_time_T0')
    1520                             time_last=Attrib.absolut_time_T0;
    1521                         end
    1522                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
    1523                             time_last=Attrib.absolut_time_T0_2;
    1524                         end
    1525                     end
    1526                 end
    1527             end
    1528         end
    1529     else
    1530         siz=size(time);
    1531         if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
    1532             time_first=times(first_i,first_j);
    1533             time_last=times(last_i,last_j);
    1534         end
    1535     end
    1536     time_first_cell{iview}=num2str(time_first,4);
    1537     time_last_cell{iview}=num2str(time_last,4);
    1538 end
     2057
    15392058% set(handles.time_first,'Value',1)
    15402059% set(handles.time_last,'Value',1)
     
    16932212end
    16942213
     2214%------------------------------------------------------------------------
    16952215% --- Executes on button press in REFRESH_INDICES.
    16962216    function REFRESH_INDICES_Callback(hObject, eventdata, handles)
     2217%------------------------------------------------------------------------       
    16972218% hObject    handle to REFRESH_INDICES (see GCBO)
    16982219% eventdata  reserved - to be defined in a future version of MATLAB
     
    17532274    ListView_Callback(hObject,eventdata,handles)
    17542275end
    1755 set(handles.Pairs,'Visible',state_Pairs)
     2276set(handles.PairString,'Visible',state_Pairs)
    17562277enable_j(handles,state_j)
    17572278set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0])
     
    17732294% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    17742295[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
    1775 
    1776 %
    1777 % [RootPathSub,FileName,FileExt]=fileparts(fileinput);
    1778 % [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPathSub,[FileName FileExt]);
    17792296if isempty(RootFile)&&isempty(i1_series)
    17802297    errormsg='no input file in the series';
    17812298    return
    17822299end
    1783 % [tild,tild,FileExt]=fileparts(fileinput);
    1784 
     2300
     2301%% adjust the min and max indices common to all the file series
    17852302MinIndex=get(handles.MinIndex,'Data');
    17862303MaxIndex=get(handles.MaxIndex,'Data');
     
    19312448        end
    19322449        if isfield(XmlData,'Time')
    1933             time=XmlData.Time;
     2450            time{iview}=XmlData.Time;
    19342451        end
    19352452        if isfield(XmlData,'Camera')
     
    19492466elseif isequal(ext_imadoc,'.civ')
    19502467    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
    1951     time=XmlData.Time;
     2468    time{iview}=XmlData.Time;
    19522469    if error==2, warntext=['no file ' FileBase '.civ'];
    19532470    elseif error==1, warntext='inconsistent number of fields in the .civ file';
    19542471    end 
    1955 end 
    1956 
     2472end
     2473
     2474%% update time table
     2475TimeTable=get(handles.TimeTable,'Data')
     2476TimeTable{iview,1}=time(MinIndex_i,MinIndex_j);
     2477TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j);
     2478set(handles.TimeTable,'Data',TimeTable)
    19572479
    19582480%% number of slices
     
    19662488       set(handles.num_NbSlice,'String',num2str(NbSlice))
    19672489end
    1968 % set(handles.mode,'Visible','off') % do not show index pairs by default
    1969 set(handles.Pairs,'Visible','off')
    1970 % set(handles.ref_i,'Visible','off')
     2490% set(handles.mode,'Visible','off') % do not show index pairstring by default
     2491set(handles.PairString,'Visible','off')
     2492% set(handles.num_ref_i,'Visible','off')
    19712493% set(handles.ref_i_text,'Visible','off')
    19722494testpair=0;
    1973 %set the menus of image pairs and default selection for series
    1974 %list pairs if relevant
     2495%set the menus of image pairstring and default selection for series
     2496%list pairstring if relevant
    19752497% Val=get(handles.NomType,'Value');
    19762498% synchronise_view(handles,Val)
     
    19812503%     state_j='on'; %case of j index
    19822504% end
    1983 % show index pairs if files exist
     2505% show index pairstring if files exist
    19842506set(handles.series,'UserData',SeriesData)
    19852507
     
    20202542
    20212543h_fun('BATCH');% TODO modify the called function to read the xml file as input parameter
    2022 
    2023 
    2024 % --- Executes on selection change in txt_Pairs
    2025 function txt_Pairs_Callback(hObject, eventdata, handles)
    2026 
    2027 %------------------------------------------------------------------------
    2028 % --- Executes on selection change in ListView.
    2029 function ListView_Callback(hObject, eventdata, handles)
    2030 %------------------------------------------------------------------------   
    2031 ListViewString=get(handles.ListView,'String');
    2032 if isempty(ListViewString)
    2033     ListViewString={''};
    2034 end
    2035 ListViewValue=get(handles.ListView,'Value');
    2036 View=str2double(ListViewString{ListViewValue});
    2037 if isnan(View)
    2038     set(handles.Pairs,'Visible','off')
    2039 else
    2040     set(handles.Pairs,'Visible','on')
    2041     SeriesData=get(handles.series,'UserData');
    2042     if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{View})||~isempty(SeriesData.j2_series{View}))
    2043         if ~isempty(SeriesData.i2_series{View}) %pairs with i View
    2044             set(handles.mode,'Value',1)
    2045             set(handles.mode,'String',{'series(Di)'})
    2046         else  %pairs with j View
    2047             nbfield=size(SeriesData.j2_series{View},1);
    2048             nbfield2=size(SeriesData.j2_series{View},2);
    2049             set(handles.mode,'Value',1)
    2050             set(handles.mode,'String',{'bursts';'series(Dj)'})
    2051             if nbfield2>10 || nbfield==1
    2052                 set(handles.mode,'Value',2);
    2053             else
    2054                 set(handles.mode,'Value',1);
    2055             end
    2056         end
    2057     end
    2058     mode_Callback([],[], handles)
    2059 end
    2060 
    2061    
  • trunk/src/uvmat.m

    r407 r408  
    783783                set(handles.FileIndex_1,'String',FileIndex_1)
    784784            else
    785                 set(handles.SubField,'Value',0)
    786                 SubField_Callback([], [], handles)
     785                msgbox_uvmat('WARNING','unable to synchronise the indices of the two series')
     786%                 set(handles.SubField,'Value',0)
     787%                 SubField_Callback([], [], handles)
    787788            end
    788789        end
  • trunk/src/view_field.m

    r406 r408  
    788788% Hints: contents = cellstr(get(hObject,'String')) returns ColorScalar contents as cell array
    789789%        contents{get(hObject,'Value')} returns selected item from ColorScalar
     790
     791
     792
     793function num_ColCode2_Callback(hObject, eventdata, handles)
     794% hObject    handle to num_colcode2 (see GCBO)
     795% eventdata  reserved - to be defined in a future version of MATLAB
     796% handles    structure with handles and user data (see GUIDATA)
     797
     798% Hints: get(hObject,'String') returns contents of num_colcode2 as text
     799%        str2double(get(hObject,'String')) returns contents of num_colcode2 as a double
Note: See TracChangeset for help on using the changeset viewer.