Changeset 350 for trunk


Ignore:
Timestamp:
Dec 23, 2011, 11:56:21 PM (13 years ago)
Author:
sommeria
Message:

series modified using 'uitable'. Bugs need to be corrected.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r343 r350  
    4040
    4141%% get input root name and nomenclature type
    42 % [RootPath,RootFile,~,~,~,~,FileExt,NomType,SubDir]=name2display(fileinput);
    4342[RootPath,SubDir,RootFile,~,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput);
    4443
     
    180179    % look for the numerical string of the first files to update the NomType (take into account the 0 before the number)
    181180    max_j=max(ref_j_list);
    182     ref_ij=ref_i_list*max_j+ref_j_list; % ordered by index i, then by j for a given i.
     181    if isempty(max_j)
     182        ref_ij=ref_i_list;
     183    else
     184        ref_ij=ref_i_list*max_j+ref_j_list; % ordered by index i, then by j for a given i.
     185    end
    183186    [~,ifile]=min(ref_ij(ref_ij>0));
     187    if isempty(ifile)
     188        RootPath='';
     189        RootFile='';
     190        NomType='';
     191    else
    184192    [~,~,~,~,~,~,~,~,NomType]=fileparts_uvmat(dirpair(ifile).name);
     193    end
    185194end
    186195
  • trunk/src/read_GUI.m

    r323 r350  
    5959                  %  eval(['struct.' tag '=input;'])
    6060                end
     61            case 'uitable'
     62                 struct.(tag)=get(hchild(ichild),'Data');
    6163        end
    6264    end
  • trunk/src/series.m

    r343 r350  
    113113if isfield(param,'FileName')
    114114    if isfield(param,'FileName_1')
    115         update_file(handles,param.FileName_1,0)
    116         update_file(handles,param.FileName,1)
     115        update_rootfile(handles,param.FileName_1,0)
     116        update_rootfile(handles,param.FileName,1)
    117117    else
    118         update_file(handles,param.FileName,0)
     118        update_rootfile(handles,param.FileName,0)
    119119    end
    120120end 
     
    126126    FieldCell{1}=param.list_fields{param.index_fields};
    127127end
    128 NomType_Callback(hObject, eventdata, handles)
    129 
     128% NomType_Callback(hObject, eventdata, handles)
     129REFRESH_INDICES_Callback(hObject, eventdata, handles)
    130130%loads the information stored in prefdir to initiate  the list of ACTION functions
    131131fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
     
    211211% --------------------------------------------------------------------
    212212function MenuBrowse_Callback(hObject, eventdata, handles)
    213 
    214 RootPathCell=get(handles.RootPath,'String');
    215 SubDirCell=get(handles.SubDir,'String'); 
    216 RootFileCell=get(handles.RootFile,'String');
     213InputTable=get(handles.InputTable,'Data');
     214RootPathCell=InputTable(:,1);
     215SubDirCell=InputTable(:,1);
     216RootFileCell=InputTable(:,1);
     217%RootPathCell=get(handles.RootPath,'String');
     218%SubDirCell=get(handles.SubDir,'String'); 
     219%RootFileCell=get(handles.RootFile,'String');
    217220oldfile=''; %default
    218221if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
     
    256259    warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    257260else
    258     update_file(handles,fileinput,0)
     261    update_rootfile(handles,fileinput,0)
    259262     %update list of recent files in the menubar
    260263    MenuFile_1=fileinput;
     
    293296function MenuFile_1_Callback(hObject, eventdata, handles)
    294297fileinput=get(handles.MenuFile_1,'Label');
    295 update_file(handles,fileinput,0)
     298update_rootfile(handles,fileinput,0)
    296299
    297300% --------------------------------------------------------------------
    298301function MenuFile_2_Callback(hObject, eventdata, handles)
    299302fileinput=get(handles.MenuFile_2,'Label');
    300 update_file(handles,fileinput,0)
     303update_rootfile(handles,fileinput,0)
    301304
    302305% --------------------------------------------------------------------
    303306function MenuFile_3_Callback(hObject, eventdata, handles)
    304307fileinput=get(handles.MenuFile_3,'Label');
    305 update_file( handles,fileinput,0)
     308update_rootfile( handles,fileinput,0)
    306309
    307310% --------------------------------------------------------------------
    308311function MenuFile_4_Callback(hObject, eventdata, handles)
    309312fileinput=get(handles.MenuFile_4,'Label');
    310 update_file(handles,fileinput,0)
     313update_rootfile(handles,fileinput,0)
    311314
    312315% --------------------------------------------------------------------
    313316function MenuFile_5_Callback(hObject, eventdata, handles)
    314317fileinput=get(handles.MenuFile_5,'Label');
    315 update_file(handles,fileinput,0)
     318update_rootfile(handles,fileinput,0)
    316319
    317320% --------------------------------------------------------------------
    318321function MenuBrowse_insert_Callback(hObject, eventdata, handles)
    319 
    320 RootPathCell=get(handles.RootPath,'String');
    321 RootFileCell=get(handles.RootFile,'String');
     322InputTable=get(handles.InputTable,'Data');
     323RootPathCell=InputTable(:,1);
     324SubDirCell=InputTable(:,3);
     325RootFileCell=InputTable(:,2);
     326% RootPathCell=get(handles.RootPath,'String');
     327% RootFileCell=get(handles.RootFile,'String');
    322328oldfile=''; %default
    323329if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
     
    360366    msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    361367else
    362     update_file(handles,fileinput,1)
     368    update_rootfile(handles,fileinput,1)
    363369    %update list of recent files in the menubar
    364370    MenuFile_1=fileinput;
     
    397403function MenuFile_insert_1_Callback(hObject, eventdata, handles)
    398404fileinput=get(handles.MenuFile_insert_1,'Label');
    399 update_file(handles,fileinput,1)
     405update_rootfile(handles,fileinput,1)
    400406
    401407% --------------------------------------------------------------------
    402408function MenuFile_insert_2_Callback(hObject, eventdata, handles)
    403409fileinput=get(handles.MenuFile_insert_2,'Label');
    404 update_file(handles,fileinput,1)
     410update_rootfile(handles,fileinput,1)
    405411
    406412% --------------------------------------------------------------------
    407413function MenuFile_insert_3_Callback(hObject, eventdata, handles)
    408414fileinput=get(handles.MenuFile_insert_3,'Label');
    409 update_file( handles,fileinput,1)
     415update_rootfile( handles,fileinput,1)
    410416
    411417% --------------------------------------------------------------------
    412418function MenuFile_insert_4_Callback(hObject, eventdata, handles)
    413419fileinput=get(handles.MenuFile_insert_4,'Label');
    414 update_file( handles,fileinput,1)
     420update_rootfile( handles,fileinput,1)
    415421
    416422% --------------------------------------------------------------------
    417423function MenuFile_insert_5_Callback(hObject, eventdata, handles)
    418424fileinput=get(handles.MenuFile_insert_5,'Label');
    419 update_file(handles,fileinput,1)
     425update_rootfile(handles,fileinput,1)
    420426
    421427%------------------------------------------------------------------------
     
    425431% fileinput: name of the input file
    426432% 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')
    427 function update_file(handles,fileinput,addtest)
     433function update_rootfile(handles,fileinput,addtest)
    428434%------------------------------------------------------------------------ 
    429435
     
    437443set(handles.RUN, 'Enable','On')
    438444set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
    439 set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
     445% set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
     446set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
    440447drawnow
    441448
     
    445452    return
    446453end
    447 [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
    448 
    449 
    450 %% look for min and max indices existing in the file series and update NomType
    451 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput)
    452 MinIndex_i=min(i1_series(i1_series>0));
    453 if ~isempty(i2_series)
    454     MaxIndex_i=max(i2_series(i2_series>0));
    455 else
    456     MaxIndex_i=max(i1_series(i1_series>0));
    457 end
    458 MinIndex_j=min(j1_series(j1_series>0));
    459 if ~isempty(j2_series)
    460     MaxIndex_j=max(j2_series(j2_series>0));
    461 else
    462     MaxIndex_j=max(j1_series(j1_series>0));
    463 end
    464 if addtest% case of insertion of a new series (menu bar option Open_insert)
    465     MinIndex_i_cell=[{num2str(MinIndex_i)} ;get(handles.num_MinIndex_i,'String')];
    466     nb_field_cell=[{num2str(MaxIndex_i)} ;get(handles.num_MaxIndex_i,'String')];
    467     MinIndex_j_cell=[{num2str(MinIndex_j)} ;get(handles.num_MinIndex_j,'String')];
    468     nb_field2_cell=[{num2str(MaxIndex_j)} ;get(handles.num_MaxIndex_j,'String')];
    469 else % refresh the list (menu bar option Open)
    470     MinIndex_i_cell={num2str(MinIndex_i)};
    471     MinIndex_j_cell={num2str(MinIndex_j)};
    472     nb_field_cell={num2str(MaxIndex_i)};
    473     nb_field2_cell={num2str(MaxIndex_j)};
    474 end
    475 set(handles.num_MinIndex_i,'String',MinIndex_i_cell);
    476 set(handles.num_MinIndex_j,'String',MinIndex_j_cell);
    477 set(handles.num_MaxIndex_i,'String',nb_field_cell);
    478 set(handles.num_MaxIndex_j,'String',nb_field2_cell);
    479 
    480 set(handles.waitbar_frame,'Units','pixels')
    481 pos=get(handles.waitbar_frame,'Position');
    482 xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
    483 yima=0.5:pos(4)-0.5;
    484 [XIma,YIma]=meshgrid(xima,yima);
    485 nb_i=size(i1_series,1);
    486 nb_j=size(i1_series,2);
    487 ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
    488 ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
    489 [Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
    490 CData=zeros([size(XIma) 3]);
    491 file_ima=double((i1_series(:,:,1)>0)');
    492 if numel(file_ima)>=2
    493 if size(file_ima,1)==1
    494     CLine=interp1(ind_i,file_ima,xima,'nearest');
    495     CData(:,:,2)=ones(size(yima'))*CLine;
    496 %     file_ima=ones(pos(4),1)*file_ima;
    497 %     Ind_i=
    498 else
    499     CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
    500 end
    501 set(handles.waitbar_frame,'CData',CData)
    502 end
    503 set(handles.waitbar_frame,'Units','normalized')
    504 
    505 % CData(:,1:floor(advance_ratio*size(CData,2)),1:2)=1;
    506 % set(hwaitbar,'CData',CData)
    507 %update_waitbar(handles.waitbar_frame,[],0)
    508 
     454[RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput);
    509455
    510456%% determine reference field indices
     
    558504
    559505%% fill the list of file series
    560 % select the first line in the list
    561 set(handles.RootPath,'Value',1)
    562 set(handles.SubDir,'Value',1)
    563 set(handles.RootFile,'Value',1)
    564 set(handles.NomType,'Value',1)
    565 set(handles.FileExt,'Value',1)
    566 set(handles.num_MaxIndex_i,'Value',1)
    567 set(handles.num_MaxIndex_j,'Value',1)
    568506
    569507% insert the current file series at the head of the list
     508InputTable=get(handles.InputTable,'Data');
    570509if addtest
    571     SeriesData=get(handles.series,'UserData');
    572   %  SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num];
    573     SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile;
    574     SeriesData.i1_series=[SeriesData.i1_series;{i1_series}];
    575     SeriesData.i2_series=[SeriesData.i2_series;{i2_series}];
    576     SeriesData.j1_series=[SeriesData.j1_series;{j1_series}];
    577     SeriesData.j2_series=[SeriesData.j2_series;{j2_series}];
    578     RootPathCell=[{RootPath}; get(handles.RootPath,'String')] ;
    579     SubDirCell=[{SubDir}; get(handles.SubDir,'String')];
    580     RootFileCell=[{RootFile}; get(handles.RootFile,'String')];
    581     NomTypeCell=[{NomType}; SeriesData.NomType];
    582     FileExtCell=[{FileExt}; get(handles.FileExt,'String')];
    583     FileTypeCell=[{FileType};SeriesData.FileType];
    584     set(handles.NomType,'String',[{};get(handles.NomType,'String')])
     510%     SeriesData=get(handles.series,'UserData');
     511%   %  SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num];
     512%     SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile;
     513%     SeriesData.i1_series=[SeriesData.i1_series;{i1_series}];
     514%     SeriesData.i2_series=[SeriesData.i2_series;{i2_series}];
     515%     SeriesData.j1_series=[SeriesData.j1_series;{j1_series}];
     516%     SeriesData.j2_series=[SeriesData.j2_series;{j2_series}];
     517InputTable=get(handles.InputTable,'Data');
     518 InputTable=[{RootPath},{RootFile},{SubDir},{NomType},{FileExt};InputTable];
     519%     RootPathCell=[{RootPath}; InputTable{] ;
     520%     SubDirCell=[{SubDir}; get(handles.SubDir,'String')];
     521%     RootFileCell=[{RootFile}; get(handles.RootFile,'String')];
     522%     NomTypeCell=[{NomType}; SeriesData.NomType];
     523%     FileExtCell=[{FileExt}; get(handles.FileExt,'String')];
     524%     FileTypeCell=[{FileType};SeriesData.FileType];
     525%     set(handles.NomType,'String',[{};get(handles.NomType,'String')])
    585526   
    586527% or re-initialise the list of  input  file series   
    587528else
    588     SeriesData=[];%re-initialisation
    589  %   SeriesData.displ_num=[0 0 0 0];
    590     SeriesData.i1_series={i1_series};
    591     SeriesData.i2_series={i2_series};
    592     SeriesData.j1_series={j1_series};
    593     SeriesData.j2_series={j2_series};
    594     RootPathCell={RootPath};
    595     SubDirCell={SubDir};
    596     RootFileCell={RootFile};   
    597     NomTypeCell={NomType};
    598     FileExtCell={FileExt};   
    599     FileTypeCell={FileType};
    600 end
    601 SeriesData.NomType=NomTypeCell;
    602 SeriesData.FileType=FileTypeCell;
     529    InputTable=[{RootPath},{RootFile},{SubDir},{NomType},{FileExt}];
     530end
     531set(handles.InputTable,'Data',InputTable)
     532%     SeriesData=[];%re-initialisation
     533%  %   SeriesData.displ_num=[0 0 0 0];
     534% %     SeriesData.i1_series={i1_series};
     535% %     SeriesData.i2_series={i2_series};
     536% %     SeriesData.j1_series={j1_series};
     537% %     SeriesData.j2_series={j2_series};
     538%     RootPathCell={RootPath};
     539%     SubDirCell={SubDir};
     540%     RootFileCell={RootFile};   
     541%     NomTypeCell={NomType};
     542%     FileExtCell={FileExt};   
     543% %    FileTypeCell={FileType};
     544% end
     545% SeriesData.NomType=NomTypeCell;
     546%SeriesData.FileType=FileTypeCell;
    603547SeriesData.CurrentInputFile=fileinput;
    604 set(handles.RootPath,'String',RootPathCell);
    605 set(handles.SubDir,'String',SubDirCell);
    606 set(handles.RootFile,'String',RootFileCell);
    607 set(handles.NomType,'String',NomTypeCell);
    608 set(handles.FileExt,'String',FileExtCell);
    609 
    610 %% enable field and veltype menus
    611 testfield=isequal(get(handles.FieldMenu,'enable'),'on');
    612 testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
    613 testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
    614 testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
    615 testtransform=isequal(get(handles.transform_fct,'Enable'),'on');
    616 testnc=0;
    617 testnc_1=0;
    618 testcivx=0;
    619 testcivx_1=0;
    620 if length(FileExtCell)==1 || length(FileExtCell)>2
    621     for iview=1:length(FileExtCell)
    622         if isequal(FileExtCell{iview},'.nc')
    623             testnc=1;
    624         end
    625         if isequal(FileTypeCell{iview},'civx')
    626             testcivx=1;
    627         end
    628     end
    629 elseif length(FileExtCell)==2
    630     testnc=isequal(FileExtCell{1},'.nc');
    631     testnc_1=isequal(FileExtCell{2},'.nc');
    632     testcivx=isequal(FileTypeCell{1},'civx');
    633     testcivx_1=isequal(FileTypeCell{2},'civx');
    634 end
    635 if testfield && testnc
    636     view_FieldMenu(handles,'on')
    637     if testcivx
    638         menustr=get(handles.FieldMenu,'String');
    639         if isequal(menustr,{'get_field...'})
    640             set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
    641         end
    642     else
    643         set(handles.FieldMenu,'Value',1)
    644         set(handles.FieldMenu,'String',{'get_field...'})
    645     end
    646 else
    647     view_FieldMenu(handles,'off')
    648 end
    649 if testfield_1 && testnc_1
    650     view_FieldMenu_1(handles,'on')
    651     if testcivx_1
    652         menustr=get(handles.FieldMenu_1,'String');
    653         if isequal(menustr,{'get_field...'})
    654             set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
    655         end
    656     else
    657         set(handles.FieldMenu_1,'Value',1)
    658         set(handles.FieldMenu_1,'String',{'get_field...'})
    659     end
    660 else
    661     view_FieldMenu_1(handles,'off')
    662 end
    663 if testveltype && testcivx
    664     set(handles.VelTypeMenu,'Visible','on')
    665     set(handles.VelType_text,'Visible','on');
    666 else
    667     set(handles.VelTypeMenu,'Visible','off')
    668     set(handles.VelType_text,'Visible','off');
    669 end
    670 if testveltype_1 && testcivx_1
    671     set(handles.VelTypeMenu_1,'Visible','on')
    672     set(handles.VelType_text_1,'Visible','on');
    673 else
    674     set(handles.VelTypeMenu_1,'Visible','off')
    675     set(handles.VelType_text_1,'Visible','off');
    676 end
    677 if testtransform && (testcivx || testima)
    678     set(handles.FieldTransform,'Visible','on')
    679 %      view_TRANSFORM(handles,'on')
    680 else
    681     set(handles.FieldTransform,'Visible','off')
    682 %     view_TRANSFORM(handles,'off')
    683 end
    684 if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima
    685     msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
    686     return
    687 end 
    688 
    689 %%  read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
    690 ext_imadoc='';
    691 if isequal(FileExt,'.xml')||isequal(FileExt,'.civ')
    692     ext_imadoc=FileExt;
    693 elseif exist([FileBase '.xml'],'file')
    694     ext_imadoc='.xml';
    695 elseif exist([FileBase '.civ'],'file')
    696     ext_imadoc='.civ';
    697 end
    698 %read the ImaDoc file
    699 XmlData=[];
    700 NbSlice_calib={};
    701 if isequal(ext_imadoc,'.xml')
    702         [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
    703         if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName)
    704             [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
    705         end
    706         if isfield(XmlData,'Time')
    707             time=XmlData.Time;
    708         end
    709         if isfield(XmlData,'Camera')
    710             if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
    711                 NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform
    712                 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
    713                     msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
    714                 end
    715             end
    716             if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
    717                 TimeUnit=XmlData.Camera.TimeUnit;
    718             end
    719         end
    720         if ~isempty(warntext)
    721             msgbox_uvmat('WARNING',warntext)
    722         end 
    723 elseif isequal(ext_imadoc,'.civ')
    724     [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
    725     time=XmlData.Time;
    726     if error==2, warntext=['no file ' FileBase '.civ'];
    727     elseif error==1, warntext='inconsistent number of fields in the .civ file';
    728     end 
    729 end 
    730 
    731 %% display times
    732 if addtest
    733     SeriesData.Time=[{time} SeriesData.Time];
    734 else
    735    SeriesData.Time={time};
    736 end
    737 set(handles.TimeUnit,'String',TimeUnit)
    738 set(handles.series,'UserData',SeriesData);
    739 
    740 %% number of slices
    741 if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord')
    742        siz=size(XmlData.GeometryCalib.SliceCoord);
    743        if siz(1)>1
    744            NbSlice=siz(1);
    745        else
    746            NbSlice=1;
    747        end
    748        set(handles.num_NbSlice,'String',num2str(NbSlice))
    749 end
    750 
    751 % set menus of index pairs
    752 NomType_Callback([], [], handles)
     548% set(handles.RootPath,'String',RootPathCell);
     549% set(handles.SubDir,'String',SubDirCell);
     550% set(handles.RootFile,'String',RootFileCell);
     551% set(handles.NomType,'String',NomTypeCell);
     552% set(handles.FileExt,'String',FileExtCell);
     553%set(handles.InputTable,'Data',[RootPathCell SubDirCell RootFileCell NomTypeCell FileExtCell]) ;
     554update_indices(handles,fileinput,1)
     555
     556
     557% %% display times
     558% if addtest
     559%     SeriesData.Time=[{time} SeriesData.Time];
     560% else
     561%    SeriesData.Time={time};
     562% end
     563% set(handles.TimeUnit,'String',TimeUnit)
     564% set(handles.series,'UserData',SeriesData);
     565% time_display=[time(MinIndex_i,MinIndex_j) time(ref_i,ref_j) time(ref_i,ref_j) time(MaxIndex_i,MaxIndex_j);...
     566%     time(MinIndex_i,MinIndex_j) time(ref_i,ref_j) time(ref_i,ref_j) time(MaxIndex_i,MaxIndex_j)];
     567% set(handles.time_table,'Data',time_display)
     568
     569
    753570
    754571%store the root name for future opening of uvmat
     
    767584    end         
    768585end
    769 set(handles.RootPath,'BackgroundColor',[1 1 1])
     586set(handles.InputTable,'BackgroundColor',[1 1 1])
    770587% set(handles.PathCampaign,'String',SeriesData.PathCampaign)
    771 num_last_j_Callback([], [], handles)
    772 num_last_i_Callback([], [], handles)
    773 
    774 %------------------------------------------------------------------------
    775 function RootPath_Callback(hObject, eventdata, handles)
    776 %------------------------------------------------------------------------
    777 Val=get(handles.RootPath,'Value');
    778 synchronise_view(handles,Val)
    779 NomType_Callback(hObject, eventdata, handles)
    780 
    781 %------------------------------------------------------------------------
    782 function synchronise_view(handles,Val)
    783 %------------------------------------------------------------------------
    784 set(handles.RootPath,'Value',Val)
    785 set(handles.SubDir,'Value',Val)
    786 set(handles.RootFile,'Value',Val)
    787 set(handles.NomType,'Value',Val)
    788 set(handles.FileExt,'Value',Val)
    789 set(handles.num_MaxIndex_i,'Value',Val)
    790 set(handles.num_MaxIndex_j,'Value',Val)
    791 set(handles.time_first,'Value',Val)
    792 set(handles.time_last,'Value',Val)
    793 
    794 
    795 %------------------------------------------------------------------------
    796 % Executes on carriage return on the subdir civ1 edit window
    797 function SubDir_Callback(hObject, eventdata, handles)
    798 %------------------------------------------------------------------------
    799 Val=get(handles.SubDir,'Value');
    800 synchronise_view(handles,Val)
    801 NomType_Callback(hObject, eventdata, handles)
    802 
    803 %------------------------------------------------------------------------
    804 % --- function activated when a new filebase (image series) is introduced
    805 function RootFile_Callback(hObject, eventdata, handles)
    806 %------------------------------------------------------------------------
    807 Val=get(handles.RootFile,'Value');
    808 synchronise_view(handles,Val)
    809 NomType_Callback(hObject, eventdata, handles)
     588%num_last_j_Callback([], [], handles)% TODO:update
     589%num_last_i_Callback([], [], handles)
     590
     591% %------------------------------------------------------------------------
     592% function RootPath_Callback(hObject, eventdata, handles)
     593% %------------------------------------------------------------------------
     594% Val=get(handles.RootPath,'Value');
     595% synchronise_view(handles,Val)
     596% NomType_Callback(hObject, eventdata, handles)
     597
     598% %------------------------------------------------------------------------
     599% function synchronise_view(handles,Val)
     600% %------------------------------------------------------------------------
     601% set(handles.RootPath,'Value',Val)
     602% set(handles.SubDir,'Value',Val)
     603% set(handles.RootFile,'Value',Val)
     604% set(handles.NomType,'Value',Val)
     605% set(handles.FileExt,'Value',Val)
     606% set(handles.num_MaxIndex_i,'Value',Val)
     607% set(handles.num_MaxIndex_j,'Value',Val)
     608% % set(handles.time_first,'Value',Val)
     609% % set(handles.time_last,'Value',Val)
     610
     611
     612% %------------------------------------------------------------------------
     613% % Executes on carriage return on the subdir civ1 edit window
     614% function SubDir_Callback(hObject, eventdata, handles)
     615% %------------------------------------------------------------------------
     616% Val=get(handles.SubDir,'Value');
     617% synchronise_view(handles,Val)
     618% NomType_Callback(hObject, eventdata, handles)
     619
     620% %------------------------------------------------------------------------
     621% % --- function activated when a new filebase (image series) is introduced
     622% function RootFile_Callback(hObject, eventdata, handles)
     623% %------------------------------------------------------------------------
     624% Val=get(handles.RootFile,'Value');
     625% synchronise_view(handles,Val)
     626% NomType_Callback(hObject, eventdata, handles)
    810627
    811628%--------------------------------------------------------------
    812 %function activated when a new filebase (image series) is introduced
    813 %------------------------------------------------------------
    814 function FileExt_Callback(hObject, eventdata, handles)
    815 Val=get(handles.FileExt,'Value');
    816 synchronise_view(handles,Val)
    817 
    818 %--------------------------------------------------------------
    819 %function activated when a new filebase (image series) is introduced
    820 %------------------------------------------------------------
    821 function num_MaxIndex_i_Callback(hObject, eventdata, handles)
    822 Val=get(handles.num_MaxIndex_i,'Value');
    823 synchronise_view(handles,Val)
    824 
    825 %--------------------------------------------------------------
    826 %function activated when a new filebase (image series) is introduced
    827 %------------------------------------------------------------
    828 function num_MaxIndex_j_Callback(hObject, eventdata, handles)
    829 Val=get(handles.num_MaxIndex_j,'Value');
    830 synchronise_view(handles,Val)
    831 
    832 %--------------------------------------------------------------
    833 %function activated when a new filebase (image series) is introduced
    834 %------------------------------------------------------------
    835 function time_first_Callback(hObject, eventdata, handles)
    836 Val=get(handles.time_first,'Value');
    837 synchronise_view(handles,Val)
    838 
    839 %--------------------------------------------------------------
    840 %function activated when a new filebase (image series) is introduced
    841 %------------------------------------------------------------
    842 function time_last_Callback(hObject, eventdata, handles)
    843 Val=get(handles.time_last,'Value');
    844 synchronise_view(handles,Val)
    845 NomType_Callback(hObject, eventdata, handles)
    846 
    847 %------------------------------------------------------------------------
    848 function NomType_Callback(hObject, eventdata, handles)
    849 %------------------------------------------------------------------------
    850 
    851 SeriesData=get(handles.series,'UserData');
    852 if isfield(SeriesData,'NomType')
    853     NomTypeCell=SeriesData.NomType;
    854 else
    855     NomTypeCell={};
    856 end
    857 nbfield2_cell=get(handles.num_MaxIndex_j,'String');
    858 val=get(handles.num_MaxIndex_j,'Value');
    859 if iscell(nbfield2_cell)
    860     nbfield2=str2num(nbfield2_cell{val});
    861 else
    862     nbfield2=str2num(nbfield2_cell);
    863 end
    864 nbfield_cell=get(handles.num_MaxIndex_i,'String');
    865 if iscell(nbfield_cell)
    866     nbfield=str2num(nbfield_cell{val});
    867 else
    868    nbfield=str2num(nbfield_cell);
    869 end
    870 
    871 % set(handles.mode,'Visible','off') % do not show index pairs by default
    872 set(handles.Pairs,'Visible','off')
    873 % set(handles.ref_i,'Visible','off')
    874 % set(handles.ref_i_text,'Visible','off')
    875 testpair=0;
    876 %set the menus of image pairs and default selection for series
    877 %list pairs if relevant
    878 Val=get(handles.NomType,'Value');
    879 synchronise_view(handles,Val)
    880 if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{Val})
    881     state_j='off'; %no need for j index
    882 else
    883     state_j='on'; %case of j index
    884 end
    885 % show index pairs if files exist
    886 if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{Val})||~isempty(SeriesData.j2_series{Val}))
    887     testpair=1;
    888     if ~isempty(SeriesData.i2_series{Val}) %pairs with i index
    889         set(handles.mode,'Value',1)
    890         set(handles.mode,'String',{'series(Di)'})
    891     else  %pairs with j index
    892         set(handles.mode,'Value',1)
    893         set(handles.mode,'String',{'bursts';'series(Dj)'})
    894         if nbfield2>10 || nbfield==1
    895             set(handles.mode,'Value',2);
    896         else
    897             set(handles.mode,'Value',1);
    898         end
    899     end
    900     set(handles.mode,'Visible','on')
    901 else
    902     set(handles.mode,'Visible','off')
    903 end
    904 % if ~isempty(NomTypeCell)
    905 %     NomType=NomTypeCell{Val};
    906 %     switch NomType 
    907 %             case {'_1-2_1', '_1-2'}
    908 %                 set(handles.mode,'String',{'series(Di)'})
    909 %                 set(handles.mode,'Value',1);
    910 %                 set(handles.mode,'Visible','on')
    911 %                 testpair=1;
    912 %             case {'#_ab'}
    913 %                 set(handles.mode,'String',{'bursts'})
    914 %                 set(handles.mode,'Value',1);
    915 %                 testpair=1;
    916 %             case '_1_1-2'
    917 %                 set(handles.mode,'String',{'bursts';'series(Dj)'})%multiple choice
    918 %                 if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1))
    919 %                     set(handles.mode,'Value',2);
    920 %                 else
    921 %                     set(handles.mode,'Value',1);% advice 'bursts' for small bursts
    922 %                 end
    923 %                 set(handles.mode,'Visible','on')
    924 %                 testpair=1;
    925 %     end
    926 %     switch NomType   
    927 %             case {'_1_1','_1_1-2','_1-2_1','1_ab','01_ab'},% two navigation indices
    928 %                 state_j='on';
    929 %     end
    930 % end
    931 if testpair
    932     mode_Callback(hObject, eventdata, handles) 
    933 else
    934     set(handles.NomType,'String',NomTypeCell)
    935     set(handles.j_txt,'Visible',state_j)
    936     set(handles.num_MinIndex_j,'Visible',state_j)
    937     set(handles.num_first_j,'Visible',state_j)
    938     set(handles.num_incr_j,'Visible',state_j)
    939     set(handles.num_last_j,'Visible',state_j)
    940     set(handles.num_MaxIndex_j,'Visible',state_j)
    941 end
     629% %function activated when a new filebase (image series) is introduced
     630% %------------------------------------------------------------
     631% function FileExt_Callback(hObject, eventdata, handles)
     632% Val=get(handles.FileExt,'Value');
     633% synchronise_view(handles,Val)
     634
     635% %--------------------------------------------------------------
     636% %function activated when a new filebase (image series) is introduced
     637% %------------------------------------------------------------
     638% function num_MaxIndex_i_Callback(hObject, eventdata, handles)
     639% Val=get(handles.num_MaxIndex_i,'Value');
     640% synchronise_view(handles,Val)
     641
     642% %--------------------------------------------------------------
     643% %function activated when a new filebase (image series) is introduced
     644% %------------------------------------------------------------
     645% function num_MaxIndex_j_Callback(hObject, eventdata, handles)
     646% Val=get(handles.num_MaxIndex_j,'Value');
     647% synchronise_view(handles,Val)
     648%
     649% %--------------------------------------------------------------
     650% %function activated when a new filebase (image series) is introduced
     651% %------------------------------------------------------------
     652% function time_first_Callback(hObject, eventdata, handles)
     653% Val=get(handles.time_first,'Value');
     654% synchronise_view(handles,Val)
     655%
     656% %--------------------------------------------------------------
     657% %function activated when a new filebase (image series) is introduced
     658% %------------------------------------------------------------
     659% function time_last_Callback(hObject, eventdata, handles)
     660% Val=get(handles.time_last,'Value');
     661% synchronise_view(handles,Val)
     662% NomType_Callback(hObject, eventdata, handles)
     663
     664% %------------------------------------------------------------------------
     665% function NomType_Callback(hObject, eventdata, handles)
     666% %------------------------------------------------------------------------
     667
     668% --- Executes when entered data in editable cell(s) in InputTable.
     669function InputTable_CellEditCallback(hObject, eventdata, handles)
     670% hObject    handle to InputTable (see GCBO)
     671% eventdata  structure with the following fields (see UITABLE)
     672%       Indices: row and column indices of the cell(s) edited
     673%       PreviousData: previous data for the cell(s) edited
     674%       EditData: string(s) entered by the user
     675%       NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
     676%       Error: error string when failed to convert EditData to appropriate value for Data
     677% handles    structure with handles and user data (see GUIDATA)
     678eventdata
     679list_lines=get(handles.REFRESH_INDICES,'UserData');
     680list_lines(eventdata.Indices(1))=1; %select the edited line for refresh
     681set(handles.REFRESH_INDICES,'UserData',list_lines);
     682set(handles.REFRESH_INDICES,'Visible','on')
    942683
    943684
     
    945686% --- Executes on button press in mode.
    946687%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    947 function mode_Callback(hObject, eventdata, handles)
    948 
    949 SeriesData=get(handles.series,'UserData');
    950 mode_list=get(handles.mode,'String');
    951 mode_value=get(handles.mode,'Value');
    952 mode=mode_list{mode_value};
    953 NomType=[];
    954 % test_find_pair=0;
    955 % if isfield(SeriesData,'NomType')
    956 NomTypeCell=SeriesData.NomType;
    957 Val=get(handles.NomType,'Value');
    958 NomType=NomTypeCell{Val};
    959 check_pairs=~isempty(SeriesData.i2_series{Val})||~isempty(SeriesData.j2_series{Val});
    960 
    961 time=[];
    962 if isfield(SeriesData,'Time')
    963     time=SeriesData.Time{1}; %get the set of times
    964 end
    965 siztime=size(time);
    966 nbfield=siztime(1);
    967 nbfield2=siztime(2);
    968 % indchosen=1;  %%first pair selected by default
    969 if isequal(mode,'bursts')
    970     enable_i(handles,'On')
    971     enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) 
    972 elseif  ~isempty(SeriesData.j2_series{Val})
    973     enable_i(handles,'On')
    974     enable_j(handles,'On') % allow both i and j index scanning
    975 else
    976     enable_i(handles,'On')
    977     enable_j(handles,'Off')
    978 end   
    979 % set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1
    980 set(handles.series,'UserData',SeriesData)
    981 
    982 %list pairs if relevant
    983 if check_pairs
    984      find_netcpair_civ(handles,Val)
    985 end
     688    function mode_Callback(hObject, eventdata, handles)
     689       
     690        SeriesData=get(handles.series,'UserData');
     691        mode_list=get(handles.mode,'String');
     692        mode_value=get(handles.mode,'Value');
     693        mode=mode_list{mode_value};
     694        NomType=[];
     695        % test_find_pair=0;
     696        % if isfield(SeriesData,'NomType')
     697        NomTypeCell=SeriesData.NomType;
     698        Val=get(handles.NomType,'Value');
     699        NomType=NomTypeCell{Val};
     700        check_pairs=~isempty(SeriesData.i2_series{Val})||~isempty(SeriesData.j2_series{Val});
     701       
     702        time=[];
     703        if isfield(SeriesData,'Time')
     704            time=SeriesData.Time{1}; %get the set of times
     705        end
     706        siztime=size(time);
     707        nbfield=siztime(1);
     708        nbfield2=siztime(2);
     709        % indchosen=1;  %%first pair selected by default
     710        if isequal(mode,'bursts')
     711            enable_i(handles,'On')
     712            enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice)
     713        elseif  ~isempty(SeriesData.j2_series{Val})
     714            enable_i(handles,'On')
     715            enable_j(handles,'On') % allow both i and j index scanning
     716        else
     717            enable_i(handles,'On')
     718            enable_j(handles,'Off')
     719        end
     720        % set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1
     721        set(handles.series,'UserData',SeriesData)
     722       
     723        %list pairs if relevant
     724        if check_pairs
     725            find_netcpair_civ(handles,Val)
     726        end
    986727
    987728%-------------------------------------
     
    1008749%-----------------------------------
    1009750function view_FieldMenu(handles,state)
    1010 set(handles.FieldMenu,'Visible',state)
    1011 set(handles.Field_text,'Visible',state)
    1012 set(handles.Field_frame,'Visible',state)
     751% set(handles.FieldMenu,'Visible',state)
     752% set(handles.Field_text,'Visible',state)
     753set(handles.InputFields,'Visible',state)
    1013754
    1014755%-----------------------------------
     
    13901131        if testupdate && isfield(SeriesData,'Time')
    13911132        if ~isempty(SeriesData.Time{1})
    1392             displ_time(handles,SeriesData.Time{1});
     1133            displ_time(handles);
    13931134        end
    13941135        end
     
    16851426    SeriesData.Time{1}=[];
    16861427end
    1687 displ_time(handles,SeriesData.Time{1});
     1428displ_time(handles);
    16881429
    16891430%------------------------------------------------------------------------
     
    17041445    SeriesData.Time{1}=[];
    17051446end
    1706 displ_time(handles,SeriesData.Time{1});
     1447displ_time(handles);
    17071448
    17081449
     
    18171558
    18181559%default setting for the visibility of the GUI elements
    1819 set(handles.RootPath,'UserData','many')
    1820 set(handles.SubDir,'Visible','on')
    1821 set(handles.RootFile,'Visible','on')
    1822 set(handles.NomType,'Visible','on')
    1823 set(handles.FileExt,'Visible','on')
     1560% set(handles.RootPath,'UserData','many')
     1561% set(handles.SubDir,'Visible','on')
     1562% set(handles.RootFile,'Visible','on')
     1563% set(handles.NomType,'Visible','on')
     1564% set(handles.FileExt,'Visible','on')
    18241565set(handles.num_NbSlice,'Visible','off')
    18251566set(handles.NbSlice_title,'Visible','off')
     
    18651606
    18661607%nb_series=length(RootFile);
    1867 FileExt=get(handles.FileExt,'String');
    1868 nb_series=length(FileExt);
     1608% FileExt=get(handles.FileExt,'String');
     1609% nb_series=length(FileExt);
     1610InputFiles=get(handles.InputTable,'Data')
     1611FileExt=InputFiles(:,5);
     1612checkcell=find(cellfun('isempty',FileExt)~=0);
     1613nb_series=0;
     1614if ~isempty(checkcell)
     1615nb_series=checkcell(end);
     1616end
     1617% nb_series=size(InputFiles,1)
    18691618testima_series=1; %test for a list of images only
    18701619testima=1;
     
    18721621testciv_series=1;
    18731622for iview=1:nb_series
    1874     ext=FileExt{iview};
     1623     ext=FileExt{iview};
    18751624    if length(ext)<2
    18761625        ext='.none';
     
    18901639    switch varargout{ilist}
    18911640                       %RootFile always visible
    1892          case 'RootPath'   %visible by default
    1893             value=lower(varargout{ilist+1});
    1894             if isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
    1895                 set(handles.RootFile,'UserData',value)% for use in menu Open_insert
    1896             end
    1897         case 'SubDir' %visible by default
    1898             if isequal(lower(varargout{ilist+1}),'off')
    1899                 set(handles.SubDir,'Visible','off')
    1900             end
    1901         case 'RootFile'   %visible by default
    1902             value=lower(varargout{ilist+1});
    1903             if isequal(value,'off')
    1904                 set(handles.RootFile,'Visible','off')
    1905             elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
    1906                 set(handles.RootFile,'Visible','on')
    1907                 set(handles.RootFile,'UserData',value)% for use in menu Open_insert
    1908             end
    1909         case 'NomType'   %visible by default
    1910             if isequal(lower(varargout{ilist+1}),'off')
    1911                 set(handles.NomType,'Visible','off')
    1912             end
    1913         case 'FileExt'   %visible by default
    1914             if isequal(lower(varargout{ilist+1}),'off')
    1915                 set(handles.FileExt,'Visible','off')
    1916             end
     1641%          case 'RootPath'   %visible by default
     1642%             value=lower(varargout{ilist+1});
     1643%             if isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
     1644%                 set(handles.RootFile,'UserData',value)% for use in menu Open_insert
     1645%             end
     1646%         case 'SubDir' %visible by default
     1647%             if isequal(lower(varargout{ilist+1}),'off')
     1648%                 set(handles.SubDir,'Visible','off')
     1649%             end
     1650%         case 'RootFile'   %visible by default
     1651%             value=lower(varargout{ilist+1});
     1652%             if isequal(value,'off')
     1653%                 set(handles.RootFile,'Visible','off')
     1654%             elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
     1655%                 set(handles.RootFile,'Visible','on')
     1656%                 set(handles.RootFile,'UserData',value)% for use in menu Open_insert
     1657%             end
     1658%         case 'NomType'   %visible by default
     1659%             if isequal(lower(varargout{ilist+1}),'off')
     1660%                 set(handles.NomType,'Visible','off')
     1661%             end
     1662%         case 'FileExt'   %visible by default
     1663%             if isequal(lower(varargout{ilist+1}),'off')
     1664%                 set(handles.FileExt,'Visible','off')
     1665%             end
    19171666        case 'NbSlice'   %hidden by default
    19181667            if isequal(lower(varargout{ilist+1}),'on')
     
    21011850%------------------------------------------------------------------------
    21021851% ---- find the times corresponding to the first and last indices of a series
    2103 function displ_time(handles,times)
     1852function displ_time(handles)
    21041853%------------------------------------------------------------------------
    21051854SeriesData=get(handles.series,'UserData');%
     
    21811930        end
    21821931    else
    2183         siz=size(times);
     1932        siz=size(time);
    21841933        if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
    21851934            time_first=times(first_i,first_j);
     
    21901939    time_last_cell{iview}=num2str(time_last,4);
    21911940end
    2192 set(handles.time_first,'Value',1)
    2193 set(handles.time_last,'Value',1)
    2194 set(handles.time_first,'String',time_first_cell);
    2195 set(handles.time_last,'String',time_last_cell);
     1941% set(handles.time_first,'Value',1)
     1942% set(handles.time_last,'Value',1)
     1943% set(handles.time_first,'String',time_first_cell);
     1944% set(handles.time_last,'String',time_last_cell);
    21961945
    21971946%------------------------------------------------------------------------
     
    24802229%     nbmissing=nbline*nbcolumn-length(ind_ij);
    24812230% end
     2231
     2232
     2233% --- Executes on button press in REFRESH_INDICES.
     2234function REFRESH_INDICES_Callback(hObject, eventdata, handles)
     2235% hObject    handle to REFRESH_INDICES (see GCBO)
     2236% eventdata  reserved - to be defined in a future version of MATLAB
     2237% handles    structure with handles and user data (see GUIDATA)
     2238set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
     2239InputTable=get(handles.InputTable,'Data');
     2240list_lines=get(handles.REFRESH_INDICES,'UserData');
     2241
     2242%% check the indices and FileTypes for each series (limited to the new ones to save time)
     2243for ind_list=1:length(list_lines)
     2244    if list_lines(ind_list)
     2245        InputLine=InputTable(list_lines(ind_list),:);
     2246        detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
     2247        if ~isempty(detect_idem)&& list_lines(ind_list)>1
     2248            InputLine{detect_idem}=InputTable(list_lines(ind_list)-1,detect_idem);
     2249            set(handles.InputTable,'Data',InputTable)
     2250        end
     2251        fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2});
     2252        %update file series defined by the selected line
     2253        [InputTable{list_lines(ind_list),1},InputTable{list_lines(ind_list),2},InputTable{list_lines(ind_list),4},errormsg]=update_indices(handles,fileinput,list_lines(ind_list));
     2254        if ~isempty(errormsg)
     2255                msgbox_uvmat('ERROR',errormsg)
     2256                return
     2257        end
     2258    end
     2259end
     2260set(handles.InputTable,'Data',InputTable)
     2261SeriesData=get(handles.series,'UserData');
     2262
     2263state_j='off';
     2264state_Pairs='off';
     2265state_InputFields='off';
     2266if ~isempty(SeriesData)
     2267for ilist=1:size(InputTable,1)
     2268    if ~isempty(SeriesData.j1_series{ilist})
     2269        state_j='on';
     2270    end
     2271    if ~isempty(SeriesData.i2_series{ilist})||~isempty(SeriesData.j2_series{ilist})
     2272         state_Pairs='on';
     2273    end
     2274    if strcmp(SeriesData.FileType,'civx')||strcmp(SeriesData.FileType,'civdata')
     2275        state_InputFields='on';
     2276    end
     2277end
     2278end
     2279set(handles.num_first_j,'Visible',state_j)
     2280set(handles.num_last_j,'Visible',state_j)
     2281set(handles.num_incr_j,'Visible',state_j)
     2282set(handles.Pairs,'Visible',state_InputFields)
     2283
     2284set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0])
     2285set(handles.REFRESH_INDICES,'visible','off')
     2286
     2287% update min and max indices for a series
     2288function [RootPath,RootFile,NomType,errormsg]=update_indices(handles,fileinput,index)
     2289
     2290%% look for min and max indices existing in the file series and update SeriesData
     2291errormsg='';
     2292[RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput);
     2293if isempty(RootFile)&&isempty(i1_series)
     2294    errormsg='not input file in the series';
     2295    return
     2296end
     2297[~,~,FileExt]=fileparts(fileinput);
     2298
     2299MinIndex=get(handles.MinIndex,'Data');
     2300MaxIndex=get(handles.MaxIndex,'Data');
     2301MinIndex_i=min(i1_series(i1_series>0));
     2302if ~isempty(i2_series)
     2303    MaxIndex_i=max(i2_series(i2_series>0));
     2304else
     2305    MaxIndex_i=max(i1_series(i1_series>0));
     2306end
     2307MinIndex_j=min(j1_series(j1_series>0));
     2308if ~isempty(j2_series)
     2309    MaxIndex_j=max(j2_series(j2_series>0));
     2310else
     2311    MaxIndex_j=max(j1_series(j1_series>0));
     2312end
     2313MinIndex{index,1}=MinIndex_i;
     2314MinIndex{index,2}=MinIndex_j;
     2315MaxIndex{index,1}=MaxIndex_i;
     2316MaxIndex{index,2}=MaxIndex_j;
     2317set(handles.MinIndex,'Data',MinIndex)
     2318set(handles.MaxIndex,'Data',MaxIndex)
     2319SeriesData=get(handles.series,'UserData');
     2320SeriesData.i1_series{index}=i1_series;
     2321SeriesData.i2_series{index}=i2_series;
     2322SeriesData.j1_series{index}=j1_series;
     2323SeriesData.j2_series{index}=j2_series;
     2324SeriesData.FileType{index}=FileType;
     2325
     2326%% represents the set of existing files as an image
     2327set(handles.waitbar_frame,'Units','pixels')
     2328pos=get(handles.waitbar_frame,'Position');
     2329xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
     2330yima=0.5:pos(4)-0.5;
     2331[XIma,YIma]=meshgrid(xima,yima);
     2332nb_i=size(i1_series,1);
     2333nb_j=size(i1_series,2);
     2334ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
     2335ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
     2336[Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
     2337CData=zeros([size(XIma) 3]);
     2338file_ima=double((i1_series(:,:,1)>0)');
     2339if numel(file_ima)>=2
     2340if size(file_ima,1)==1
     2341    CLine=interp1(ind_i,file_ima,xima,'nearest');
     2342    CData(:,:,2)=ones(size(yima'))*CLine;
     2343else
     2344    CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
     2345end
     2346set(handles.waitbar_frame,'CData',CData)
     2347end
     2348set(handles.waitbar_frame,'Units','normalized')
     2349
     2350%% enable field and veltype menus
     2351testfield=isequal(get(handles.FieldMenu,'enable'),'on');
     2352testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
     2353testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
     2354testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
     2355testtransform=isequal(get(handles.transform_fct,'Enable'),'on');
     2356testnc=0;
     2357testnc_1=0;
     2358testcivx=0;
     2359testcivx_1=0;
     2360%TODO: update
     2361% if length(FileExtCell)==1 || length(FileExtCell)>2
     2362%     for iview=1:length(FileExtCell)
     2363%         if isequal(FileExtCell{iview},'.nc')
     2364%             testnc=1;
     2365%         end
     2366%         if isequal(FileTypeCell{iview},'civx')
     2367%             testcivx=1;
     2368%         end
     2369%     end
     2370% elseif length(FileExtCell)==2
     2371%     testnc=isequal(FileExtCell{1},'.nc');
     2372%     testnc_1=isequal(FileExtCell{2},'.nc');
     2373%     testcivx=isequal(FileTypeCell{1},'civx');
     2374%     testcivx_1=isequal(FileTypeCell{2},'civx');
     2375% end
     2376if testfield && testnc
     2377    view_FieldMenu(handles,'on')
     2378    if testcivx
     2379        menustr=get(handles.FieldMenu,'String');
     2380        if isequal(menustr,{'get_field...'})
     2381            set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
     2382        end
     2383    else
     2384        set(handles.FieldMenu,'Value',1)
     2385        set(handles.FieldMenu,'String',{'get_field...'})
     2386    end
     2387else
     2388    view_FieldMenu(handles,'off')
     2389end
     2390if testfield_1 && testnc_1
     2391    view_FieldMenu_1(handles,'on')
     2392    if testcivx_1
     2393        menustr=get(handles.FieldMenu_1,'String');
     2394        if isequal(menustr,{'get_field...'})
     2395            set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
     2396        end
     2397    else
     2398        set(handles.FieldMenu_1,'Value',1)
     2399        set(handles.FieldMenu_1,'String',{'get_field...'})
     2400    end
     2401else
     2402    view_FieldMenu_1(handles,'off')
     2403end
     2404if testveltype && testcivx
     2405    set(handles.VelTypeMenu,'Visible','on')
     2406    set(handles.VelType_text,'Visible','on');
     2407else
     2408    set(handles.VelTypeMenu,'Visible','off')
     2409    set(handles.VelType_text,'Visible','off');
     2410end
     2411if testveltype_1 && testcivx_1
     2412    set(handles.VelTypeMenu_1,'Visible','on')
     2413    set(handles.VelType_text_1,'Visible','on');
     2414else
     2415    set(handles.VelTypeMenu_1,'Visible','off')
     2416    set(handles.VelType_text_1,'Visible','off');
     2417end
     2418if testtransform && (testcivx || testima)
     2419    set(handles.FieldTransform,'Visible','on')
     2420%      view_TRANSFORM(handles,'on')
     2421else
     2422    set(handles.FieldTransform,'Visible','off')
     2423%     view_TRANSFORM(handles,'off')
     2424end
     2425%TODO:update
     2426% if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima
     2427%     msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
     2428%     return
     2429% end 
     2430
     2431%%  read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
     2432ext_imadoc='';
     2433FileBase=fullfile(RootPath,RootFile);
     2434if isequal(FileExt,'.xml')||isequal(FileExt,'.civ')
     2435    ext_imadoc=FileExt;
     2436elseif exist([FileBase '.xml'],'file')
     2437    ext_imadoc='.xml';
     2438elseif exist([FileBase '.civ'],'file')
     2439    ext_imadoc='.civ';
     2440end
     2441%read the ImaDoc file
     2442XmlData=[];
     2443NbSlice_calib={};
     2444if isequal(ext_imadoc,'.xml')
     2445        [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
     2446        if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName)
     2447            [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
     2448        end
     2449        if isfield(XmlData,'Time')
     2450            time=XmlData.Time;
     2451        end
     2452        if isfield(XmlData,'Camera')
     2453            if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
     2454                NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform
     2455                if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
     2456                    msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
     2457                end
     2458            end
     2459            if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
     2460                TimeUnit=XmlData.Camera.TimeUnit;
     2461            end
     2462        end
     2463        if ~isempty(warntext)
     2464            msgbox_uvmat('WARNING',warntext)
     2465        end 
     2466elseif isequal(ext_imadoc,'.civ')
     2467    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
     2468    time=XmlData.Time;
     2469    if error==2, warntext=['no file ' FileBase '.civ'];
     2470    elseif error==1, warntext='inconsistent number of fields in the .civ file';
     2471    end 
     2472end 
     2473
     2474
     2475%% number of slices
     2476if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord')
     2477       siz=size(XmlData.GeometryCalib.SliceCoord);
     2478       if siz(1)>1
     2479           NbSlice=siz(1);
     2480       else
     2481           NbSlice=1;
     2482       end
     2483       set(handles.num_NbSlice,'String',num2str(NbSlice))
     2484end
     2485% set(handles.mode,'Visible','off') % do not show index pairs by default
     2486set(handles.Pairs,'Visible','off')
     2487% set(handles.ref_i,'Visible','off')
     2488% set(handles.ref_i_text,'Visible','off')
     2489testpair=0;
     2490%set the menus of image pairs and default selection for series
     2491%list pairs if relevant
     2492% Val=get(handles.NomType,'Value');
     2493% synchronise_view(handles,Val)
     2494
     2495% if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{index})
     2496%     state_j='off'; %no need for j index
     2497% else
     2498%     state_j='on'; %case of j index
     2499% end
     2500% show index pairs if files exist
     2501if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{index})||~isempty(SeriesData.j2_series{index}))
     2502    testpair=1;
     2503    if ~isempty(SeriesData.i2_series{index}) %pairs with i index
     2504        set(handles.mode,'Value',1)
     2505        set(handles.mode,'String',{'series(Di)'})
     2506    else  %pairs with j index
     2507        set(handles.mode,'Value',1)
     2508        set(handles.mode,'String',{'bursts';'series(Dj)'})
     2509        if nbfield2>10 || nbfield==1
     2510            set(handles.mode,'Value',2);
     2511        else
     2512            set(handles.mode,'Value',1);
     2513        end
     2514    end
     2515    set(handles.mode,'Visible','on')
     2516else
     2517    set(handles.mode,'Visible','off')
     2518end
     2519% if ~isempty(NomTypeCell)
     2520%     NomType=NomTypeCell{Val};
     2521%     switch NomType 
     2522%             case {'_1-2_1', '_1-2'}
     2523%                 set(handles.mode,'String',{'series(Di)'})
     2524%                 set(handles.mode,'Value',1);
     2525%                 set(handles.mode,'Visible','on')
     2526%                 testpair=1;
     2527%             case {'#_ab'}
     2528%                 set(handles.mode,'String',{'bursts'})
     2529%                 set(handles.mode,'Value',1);
     2530%                 testpair=1;
     2531%             case '_1_1-2'
     2532%                 set(handles.mode,'String',{'bursts';'series(Dj)'})%multiple choice
     2533%                 if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1))
     2534%                     set(handles.mode,'Value',2);
     2535%                 else
     2536%                     set(handles.mode,'Value',1);% advice 'bursts' for small bursts
     2537%                 end
     2538%                 set(handles.mode,'Visible','on')
     2539%                 testpair=1;
     2540%     end
     2541%     switch NomType   
     2542%             case {'_1_1','_1_1-2','_1-2_1','1_ab','01_ab'},% two navigation indices
     2543%                 state_j='on';
     2544%     end
     2545% end
     2546set(handles.series,'UserData',SeriesData)
     2547if testpair
     2548    mode_Callback(hObject, eventdata, handles) 
     2549else
     2550%     set(handles.NomType,'String',NomTypeCell)
     2551%     set(handles.j_txt,'Visible',state_j)
     2552%     set(handles.num_MinIndex_j,'Visible',state_j)
     2553%     set(handles.num_first_j,'Visible',state_j)
     2554%     set(handles.num_incr_j,'Visible',state_j)
     2555%     set(handles.num_last_j,'Visible',state_j)
     2556%     set(handles.num_MaxIndex_j,'Visible',state_j)
     2557end
     2558
Note: See TracChangeset for help on using the changeset viewer.