Changeset 1188


Ignore:
Timestamp:
Dec 11, 2025, 8:45:31 AM (3 days ago)
Author:
sommeria
Message:

file relabeling implemented for civ_series

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r1187 r1188  
    132132end
    133133
    134 %% Read the parameter file series.xml, or created from series.xml.default if it does not exist
     134%% Read the parameter file series.xml containing general parameters for the GUI series, or read series.xml.default if it does not exist
    135135SeriesData=[];
    136136path_series=fileparts(which('series'));% path to the GUI series
     
    279279        return
    280280    end
    281    % TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
     281    % TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
    282282    if isfield(Param.InputFile,'RootPath_1')
    283283        InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]];
    284        % TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
     284        % TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
    285285    end
    286286    set(handles.InputTable,'Data',InputTable)
     
    292292    set(handles.Experiment,'String',[Experiment ExperimentExt])
    293293    if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)','once'))
    294     set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
     294        set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
    295295    end
    296296
    297297    %update the output path if needed
    298298    if ~(isfield(SeriesData,'InputPath') && strcmp(SeriesData.InputPath,InputPath))
    299     if get(handles.OutputPathBrowse,'Value')==1  % fix the output path in manual mode
    300         OutputPathOld=get(handles.OutputPath,'String');
    301         OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
    302         set(handles.OutputPath,'String',OutputPath)
    303     else %reproduce the input path for output
    304         set(handles.OutputPath,'String',InputPath)
    305     end
     299        if get(handles.OutputPathBrowse,'Value')==1  % fix the output path in manual mode
     300            OutputPathOld=get(handles.OutputPath,'String');
     301            OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
     302            set(handles.OutputPath,'String',OutputPath)
     303        else %reproduce the input path for output
     304            set(handles.OutputPath,'String',InputPath)
     305        end
    306306    end
    307307
     
    337337    SeriesData.ref_j=ref_j;
    338338    set(handles.series,'UserData',SeriesData)
    339     update_rootinfo(handles,Param.HiddenData.i1_series{1},Param.HiddenData.i2_series{1},Param.HiddenData.j1_series{1},Param.HiddenData.j2_series{1},...
    340         Param.HiddenData.FileInfo{1},Param.HiddenData.MovieObject{1},1)
    341     if isfield(Param,'FileName_1')
    342         %         display_file_name(handles,Param,2)
    343         update_rootinfo(handles,Param.HiddenData.i1_series{2},Param.HiddenData.i2_series{2},Param.HiddenData.j1_series{2},Param.HiddenData.j2_series{2},...
    344             Param.HiddenData.FileInfo{2},Param.HiddenData.MovieObject{2},2)
    345     end
     339    Param.XmlData_1=[];XmlData_2=[];
     340    if isfield(Param.HiddenData,'XmlData')
     341            Param.XmlData=Param.HiddenData.XmlData{1};
     342    end
     343    Param.i1_series=Param.HiddenData.i1_series{1};
     344    Param.i2_series=Param.HiddenData.i2_series{1};
     345    Param.j1_series=Param.HiddenData.j1_series{1};
     346    Param.j2_series=Param.HiddenData.j2_series{1};
     347    update_rootinfo(handles,Param,Param.HiddenData.MovieObject{1},1)% update the data for the first input line
     348    if isfield(Param,'FileName_1')% if there is a second input line from uvmat
     349        if isfield(Param.HiddenData,'XmlData') && numel(Param.HiddenData.XmlData)>=2
     350            Param.XmlData=Param.HiddenData.XmlData{1};
     351        end
     352        Param.i1_series=Param.HiddenData.i1_series{2};
     353        Param.i2_series=Param.HiddenData.i2_series{2};
     354        Param.j1_series=Param.HiddenData.j1_series{2};
     355        Param.j2_series=Param.HiddenData.j2_series{2};
     356        update_rootinfo(handles,Param,Param.HiddenData.MovieObject{2},2)% update the data for the second input line
     357    end
     358
    346359    %% enable field and veltype menus, in accordance with the current action
    347360    ActionName_Callback([],[], handles)
    348361
    349     %% set length of waitbar
    350     displ_time(handles)
     362%     %% set length of waitbar
     363%     displ_time(handles)
    351364
    352365else
     
    386399
    387400%delete the bowser if detected
    388 hh=findobj(allchild(0),'tag','browser');
     401hh=findobj(allchild(0),'tag','browser');fileinput
    389402if ~isempty(hh)
    390403    delete(hh)
     
    551564function REFRESH_Callback(hObject, eventdata, handles)
    552565%------------------------------------------------------------------------
    553 check_input_file_series(handles)
     566CheckRelabel=get(handles.Relabel,'Value');
     567check_input_file_series(handles,CheckRelabel)
    554568
    555569%% enable field and veltype menus, in accordance with the current action
     
    558572%------------------------------------------------------------------------
    559573% --- check the input file series.
    560 function check_input_file_series(handles)
     574function check_input_file_series(handles,CheckRelabel)
    561575%------------------------------------------------------------------------
    562576InputTable=get(handles.InputTable,'Data');%read the table of input file series
     
    581595end
    582596nbview=size(InputTable,1);
     597CheckRelabelQuest=false;
    583598for iview=1:nbview
    584599    RootPath=fullfile(InputTable{iview,1},InputTable{iview,2});
     600    Param.Relabel=false;
     601    MovieObject=[];
     602    Param.FileInfo=[];
    585603    if ~exist(RootPath,'dir')
    586         i1_series=[];
     604        Param.i1_series=[];
    587605        RootFile='';
    588     else %scan the input folder
     606    else
     607        XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2});
     608        if ~isempty(XmlFileName)
     609            XmlData=read_imadoc(XmlFileName);
     610            if isfield(XmlData,'FileSeries')
     611                set(handles.Relabel,'Visible','on')
     612                answer='Yes';
     613                if ~CheckRelabel && ~CheckRelabelQuest% propose to relabel if not selected yet
     614                    answer=msgbox_uvmat('INPUT_Y-N','relabel the frame  indices according to the xml info?');
     615                    CheckRelabelQuest=true;
     616                end
     617                if strcmp(answer,'Yes')
     618                    set(handles.Relabel,'Value',1)
     619                    NomType='*';
     620                    i1=1;i2=[];j1=1;j2=[];
     621                    Param.i1_series=1:size(XmlData.Time,1)-1;
     622                    Param.i2_series=[];
     623                    if size(XmlData.Time,2)>2
     624                        Param.j1_series=1:size(XmlData.Time,2)-1;
     625                    else
     626                        Param.j1_series=[];
     627                    end
     628                    Param.j2_series=[];
     629                    Param.Relabel=true;
     630                    FirstFile=fullfile(InputTable{iview,1},InputTable{iview,2},XmlData.FileSeries.FileName{1});
     631                    if ~exist(FirstFile,'file')
     632                        msgbox_uvmat('ERROR',[FirstFile ' does not exist']);
     633                        return
     634                    end
     635                    [Param.FileInfo,VideoObject]=get_file_info(FirstFile);
     636                end
     637            end
     638            Param.XmlData=XmlData;
     639        else
     640            set(handles.Relabel,'Value',0)
     641        end
     642    end
     643    if ~Param.Relabel
     644        %scan the input folder
    589645        InputTable{iview,3}=regexprep(InputTable{iview,3},'^/','');%suppress '/' at the beginning of the input name
    590646        i1=str2double(get(handles.num_first_i,'String'));
     
    593649        PairString=get(handles.PairString,'Data');
    594650        if numel(PairString)>=iview
    595                 r=regexp(PairString{iview},'(?<num1>\d+)-(?<num2>\d+)' ,'names');
    596                 if ~isempty(r)
     651            r=regexp(PairString{iview},'(?<num1>\d+)-(?<num2>\d+)' ,'names');
     652            if ~isempty(r)
    597653                j1=str2double(r.num1);
    598654                j2=str2double(r.num2);
    599                 end
     655            end
    600656        end
    601657        InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2);
    602         [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,~,FileInfo,MovieObject]=...
    603                 find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
    604     end
    605     % if no file is found, open a browser
    606     if isempty(RootFile)&& isempty(i1_series)
     658        [RootPath,~,RootFile,Param.i1_series,Param.i2_series,Param.j1_series,Param.j2_series,~,Param.FileInfo,MovieObject]=...
     659            find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
     660    end
     661
     662    % if no file is found on line #ivew, open a browser
     663    if ~Param.Relabel && isempty(RootFile)&& isempty(Param.i1_series)
    607664        fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
    608665        if isempty(fileinput)
     
    613670        end
    614671    else
    615        update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview)
     672        update_rootinfo(handles,Param,MovieObject,iview)
    616673    end
    617674end
     
    632689set(handles.TimeTable,'Data',TimeTable(1:nbview,:));
    633690
    634 %% set length of waitbar
    635 displ_time(handles)
     691
    636692set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (indicate activation finished)
    637693set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch'
     
    644700% INPUT:
    645701% handles: handles of elements in the GUI
    646 % Param: structure of input parameters, including  input file name and path
     702% InputFile: (full) input file name, including path
    647703% iview: line index in the input table
    648704%       or 'one': refresh the list
    649705%         'append': add a new line to the input table
    650 function errormsg=display_file_name(handles,Param,iview)
     706function errormsg=display_file_name(handles,InputFile,iview)
    651707
    652708set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH  button to yellow color (indicate activation)
    653709drawnow
    654710errormsg=''; % default
    655 if ischar(Param)
    656     fileinput=Param;
    657 else% input set when series is opened (called by the GUI uvmat)
    658     fileinput=Param.FileName;
    659 end
     711
    660712
    661713%% get the input root name, indices, file extension and nomenclature NomType
    662 if isempty(regexp(fileinput,'^http')) && ~exist(fileinput,'file')
    663     errormsg=['input file ' fileinput  ' does not exist'];
     714if isempty(regexp(InputFile,'^http', 'once')) && ~exist(InputFile,'file')
     715    errormsg=['input file ' InputFile  ' does not exist'];
    664716    msgbox_uvmat('ERROR',errormsg)
    665717    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta color (refresh still needed)
     
    667719end
    668720
    669 %% detect root name, nomenclature and indices in the input file name:
    670 [FilePath,FileName,FileExt]=fileparts(fileinput);
    671 %%%%%%%%%%%%%%%%%%
    672 %TODO: case of input by uvmat: do not check agai the input series %%%%%%%
    673 %%%%%%%%%%%%%%%%%%%
    674 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    675 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    676 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
    677 FileType=FileInfo.FileType;
    678 if isempty(RootFile)&&isempty(i1_series)
    679     errormsg='no input file in the series';
    680     msgbox_uvmat('ERROR',errormsg)
    681     set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta color (end of activation)
     721%% Check the nature of the input file
     722[FileInfo,MovieObject]=get_file_info(InputFile);
     723CheckOpen=false;
     724switch FileInfo.FileType
     725    case 'txt'%text input file
     726        CheckOpen=true;
     727        edit(InputFile)
     728    case 'xml'%xml input file
     729        CheckOpen=true;
     730        editxml(InputFile)
     731    case 'figure'%Matlab figure
     732        CheckOpen=true;
     733        open(InputFile)
     734end
     735if CheckOpen
     736    set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta  color (end of activation)
    682737    return
    683738end
    684 if strcmp(FileType,'txt')
    685     edit(fileinput)
    686     set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to  magenta color (end of activation)
    687     return
    688 elseif strcmp(FileType,'xml')
    689     editxml(fileinput)
    690     set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta  color (end of activation)
    691      return
    692 elseif strcmp(FileType,'figure')
    693     open(fileinput)
    694     set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta  color (end of activation)
    695      return
     739Param.FileInfo=FileInfo;
     740
     741%% Look for file relabeling option
     742[FilePath,RootFile,FileExt]=fileparts(InputFile);
     743[RootPath,SubDir]=fileparts(FilePath);
     744XmlFileName=find_imadoc(RootPath,SubDir);
     745Param.Relabel=false;%no file relabeling by default
     746XmlData=[];
     747if ~isempty(XmlFileName)
     748    XmlData=read_imadoc(XmlFileName);
     749    if isfield(XmlData,'FileSeries')
     750        set(handles.Relabel,'Visible','on')
     751        answer=msgbox_uvmat('INPUT_Y-N','relabel the frame  indices according to the xml info?');
     752        if strcmp(answer,'Yes')
     753            set(handles.Relabel,'Value',1)
     754            NomType='*';
     755            i1=1;i2=[];j1=1;j2=[];
     756            Param.i1_series=1:size(XmlData.Time,1)-1;
     757            Param.i2_series=[];
     758            if size(XmlData.Time,2)>2
     759            Param.j1_series=1:size(XmlData.Time,2)-1;
     760            else
     761                Param.j1_series=[];
     762            end
     763            Param.j2_series=[];
     764            Param.Relabel=true;
     765        end
     766    end
     767end
     768Param.XmlData=XmlData;
     769
     770%% detect the list of file in the input series in the case of no relabeling
     771if ~Param.Relabel
     772            set(handles.Relabel,'Value',0)
     773    %%%%%%%%%%%%%%%%%%
     774    %TODO: case of input by uvmat: do not check again the input series %%%%%%%
     775    %%%%%%%%%%%%%%%%%%%
     776    % detect the file type, get the movie object if relevant, and look for the corresponding file series:
     777    % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
     778    [RootPath,SubDir,RootFile,Param.i1_series,Param.i2_series,Param.j1_series,Param.j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[RootFile FileExt]);
     779    if isempty(RootFile)&&isempty(Param.i1_series)
     780        errormsg='no input file in the series';
     781        msgbox_uvmat('ERROR',errormsg)
     782        set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH  button to magenta color (end of activation)
     783        return
     784    end
    696785end
    697786
     
    699788set(handles.RUN, 'Enable','On')
    700789set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
    701 set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
     790set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow to indicate that it is under modification
    702791drawnow
    703792
    704793
    705 %% fill the list of file series
     794%% refresh the list of file series according to the input option 'one' or 'append'
    706795InputTable=get(handles.InputTable,'Data');
    707796SeriesData=get(handles.series,'UserData');
    708 
    709797if strcmp(iview,'append') % display the input data as a new line in the table
    710798    iview=size(InputTable,1)+1; % the next line in InputTable becomes the current line
     
    727815    SeriesData.Time={};
    728816end
    729 if isfield(SeriesData,'i1_series')
     817if isfield(SeriesData,'i1_series')% remove the irrelevant data lines beyond iview in SeriesData
    730818    SeriesData.i1_series(iview+1:end)=[];
    731819    SeriesData.i2_series(iview+1:end)=[];
     
    736824    SeriesData.Time(iview+1:end)=[];
    737825end
    738 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     826
     827%% fill the current Intput Table line
     828InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];%fill the current Intput Table line
    739829if iview >1
    740830    set(handles.InputLine,'String',num2str(iview))
     
    761851SeriesData.ref_j=ref_j;
    762852
    763 %% update first and last indices if they do not exist
    764 Param=read_GUI(handles.series);
    765 first_j=[];
    766 if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
    767 last_j=[];
    768 if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
    769 PairString='';
    770 if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
    771 [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
    772 FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
    773     Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
    774 if ~exist(FirstFileName,'file')
    775     set(handles.num_first_i,'String',num2str(ref_i))
    776     set(handles.num_first_j,'String',num2str(ref_j))
    777 end
    778 [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
    779 LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
    780     Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
    781 if ~exist(LastFileName,'file')
    782     set(handles.num_last_i,'String',num2str(ref_i))
    783     set(handles.num_last_j,'String',num2str(ref_j))
     853%% update first and last indices to operate if the files do not exist
     854if ~Param.Relabel
     855    ParamGUI=read_GUI(handles.series);
     856    first_j=[];
     857    if isfield(ParamGUI.IndexRange,'first_j'); first_j=ParamGUI.IndexRange.first_j; end
     858    last_j=[];
     859    if isfield(ParamGUI.IndexRange,'last_j'); last_j=ParamGUI.IndexRange.last_j; end
     860    PairString='';
     861    if isfield(ParamGUI.IndexRange,'PairString'); PairString=ParamGUI.IndexRange.PairString; end
     862    [i1,i2,j1,j2] = get_file_index(ParamGUI.IndexRange.first_i,first_j,PairString);
     863    FirstFileName=fullfile_uvmat(ParamGUI.InputTable{1,1},ParamGUI.InputTable{1,2},ParamGUI.InputTable{1,3},...
     864        ParamGUI.InputTable{1,5},ParamGUI.InputTable{1,4},i1,i2,j1,j2);
     865    if ~exist(FirstFileName,'file')
     866        set(handles.num_first_i,'String',num2str(ref_i))
     867        set(handles.num_first_j,'String',num2str(ref_j))
     868    end
     869    [i1,i2,j1,j2] = get_file_index(ParamGUI.IndexRange.last_i,last_j,PairString);
     870    LastFileName=fullfile_uvmat(ParamGUI.InputTable{1,1},ParamGUI.InputTable{1,2},ParamGUI.InputTable{1,3},...
     871        ParamGUI.InputTable{1,5},ParamGUI.InputTable{1,4},i1,i2,j1,j2);
     872    if ~exist(LastFileName,'file')
     873        set(handles.num_last_i,'String',num2str(ref_i))
     874        set(handles.num_last_j,'String',num2str(ref_j))
     875    end
    784876end
    785877
     
    787879MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
    788880    {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
    789 str_find=strcmp(fileinput,MenuFile);
     881str_find=strcmp(InputFile,MenuFile);
    790882if isempty(find(str_find,1))
    791     MenuFile=[{fileinput};MenuFile]; % insert the current file if not already in the list
     883    MenuFile=[{InputFile};MenuFile]; % insert the current file if not already in the list
    792884end
    793885for ifile=1:min(length(MenuFile),5)
     
    803895end
    804896% save the opened file to initiate future opening
    805 SeriesData.RefFile{iview}=fileinput; % reference opening file for line iview
     897SeriesData.RefFile{iview}=InputFile; % reference opening file for line iview
    806898SeriesData.Ref_i1=i1;
    807899SeriesData.Ref_i2=i2;
     
    820912%update the output path if needed
    821913if ~(isfield(SeriesData,'InputPath') && strcmp(SeriesData.InputPath,InputPath))
    822     if get(handles.OutputPathBrowse,'Value')==1  % fix the output path in manual mode
     914    if get(handles.OutputPathBrowse,'Value')==1  % fix the output path in manual modei1_series
    823915        OutputPathOld=get(handles.OutputPath,'String');
    824916        OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
     
    830922end
    831923
     924
    832925set(handles.series,'UserData',SeriesData)
    833926
    834927set(handles.InputTable,'BackgroundColor',[1 1 1])
    835928
     929
     930
    836931%% initiate input file series and refresh the current field view:
    837 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview);
     932update_rootinfo(handles,Param,MovieObject,iview);
    838933
    839934%% enable field and veltype menus, in accordance with the current action
    840935ActionName_Callback([],[], handles)
    841936
    842 %% set length of waitbar
    843 displ_time(handles)
     937% %% set length of waitbar
     938% displ_time(handles)
    844939
    845940set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to red color (end of activation)
     941
     942%------------------------------------------------------------------------
     943% --- get info from the xml file XmlFileName
     944function XmlData=read_imadoc(XmlFileName)
     945
     946[XmlData,errormsg]=imadoc2struct(XmlFileName);
     947if ~isempty(errormsg)
     948    msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
     949end
     950% read time if available
     951if ~isfield(XmlData,'Time')
     952    XmlData.Time=[];
     953end
     954XmlData.TimeUnit=[];
     955if isfield(XmlData,'Camera') && isfield(XmlData.Camera,'TimeUnit')
     956    XmlData.TimeUnit=XmlData.Camera.TimeUnit;
     957end
     958% number of slices
     959XmlData.NbSlice=[];
     960if isfield(XmlData,'TranslationMotor')&& isfield(XmlData.TranslationMotor,'NbSlice')
     961    XmlData.NbSlice=XmlData.TranslationMotor.NbSlice;
     962end
     963if ~isfield(XmlData,'FileSeries')
     964    XmlData.FileSeries=[];
     965end
    846966
    847967%------------------------------------------------------------------------
    848968% --- Update information about a new field series (indices to scan, timing,
    849969%     calibration from an xml file
    850 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,iview)
    851 %------------------------------------------------------------------------
    852 InputTable=get(handles.InputTable,'Data');
     970function update_rootinfo(handles,Param,VideoObject,iview)
     971
     972%% default time settings
     973TimeUnit='';
     974% read  value set by the first series for the append mode (iwiew >1)
     975if iview>1
     976    TimeUnit=get(handles.TimeUnit,'String');
     977end
     978TimeName='';
     979Time=[]; % default
     980TimeMin=[];
     981TimeFirst=[];
     982TimeLast=[];
     983TimeMax=[];
     984
     985%% determine the min and max indices for the whole file series
     986i1_series=Param.i1_series;
     987i2_series=Param.i2_series;
     988j1_series=Param.j1_series;
     989j2_series=Param.j2_series;
     990 MaxIndex_j=1;
     991if Param.Relabel
     992    MinIndex_i=1;
     993    MinIndex_j=1;
     994    set(handles.num_incr_j,'String','1')
     995    MaxIndex_i=numel(i1_series);
     996    set(handles.num_incr_i,'String','1')
     997    if ~isempty(j1_series)
     998        MaxIndex_j=numel(j1_series);
     999    end
     1000    Time=Param.XmlData.Time;
     1001    TimeMin=Time(2,2);
     1002    TimeMax=Time(end,end);
     1003    TimeFirst=TimeMin;
     1004    TimeLast=TimeMin;
     1005    TimeName='xml';
     1006else
     1007    if isempty(i1_series)
     1008        MinIndex_j=1;MaxIndex_j=1;MinIndex_i=1;MaxIndex_i=1;
     1009    elseif size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
     1010        MinIndex_j=1; % index j set to 1 by default
     1011        MaxIndex_j=1;
     1012        MinIndex_i=find(i1_series(1,2,:), 1 )-1; % min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
     1013        MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1; % max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
     1014    else
     1015        ref_i=squeeze(max(i1_series(1,:,:),[],2)); % select ref_j index for each ref_i
     1016        ref_j=squeeze(max(j1_series(1,:,:),[],3)); % select ref_i index for each ref_j
     1017        MinIndex_i=find(ref_i, 1 )-1;
     1018        MaxIndex_i=find(ref_i, 1, 'last' )-1;
     1019        MaxIndex_j=find(ref_j, 1, 'last' )-1;
     1020        MinIndex_j=find(ref_j, 1 )-1;
     1021        diff_j_max=diff(ref_j);
     1022        diff_i_max=diff(ref_i);
     1023        if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
     1024            set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
     1025        end
     1026        if ~isempty(diff_j_max) && isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
     1027            set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
     1028        end
     1029    end
     1030    if isequal(MinIndex_i,-1)
     1031        MinIndex_i=0;
     1032    end
     1033    if isequal(MinIndex_j,-1)
     1034        MinIndex_j=0;
     1035    end
     1036    if isfield(Param.FileInfo,'Software')&&~isempty(Param.FileInfo.Software) && ~isempty(regexp(Param.FileInfo.Software,'^pco.camware', 'once'))
     1037        MinIndex_i=0;
     1038    end
     1039end
    8531040
    8541041%% make the j indices visible if relevant
     
    8561043    enable_j(handles,'off');
    8571044else
    858    enable_j(handles,'on')%%%%remark: put series with j index at the end in the case of a list
    859 end
    860 
    861 %% display the min and max indices for the whole file series
    862 if isempty(i1_series)
    863     MinIndex_j=1;MaxIndex_j=1;MinIndex_i=1;MaxIndex_i=1;
    864 elseif size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
    865     MinIndex_j=1; % index j set to 1 by default
    866     MaxIndex_j=1;
    867     MinIndex_i=find(i1_series(1,2,:), 1 )-1; % min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
    868     MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1; % max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
    869 else
    870     ref_i=squeeze(max(i1_series(1,:,:),[],2)); % select ref_j index for each ref_i
    871     ref_j=squeeze(max(j1_series(1,:,:),[],3)); % select ref_i index for each ref_j
    872      MinIndex_i=find(ref_i, 1 )-1;
    873      MaxIndex_i=find(ref_i, 1, 'last' )-1;
    874      MaxIndex_j=find(ref_j, 1, 'last' )-1;
    875      MinIndex_j=find(ref_j, 1 )-1;
    876     diff_j_max=diff(ref_j);
    877     diff_i_max=diff(ref_i);
    878     if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
    879         set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
    880     end
    881     if ~isempty(diff_j_max) && isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
    882         set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
    883     end
    884 end
    885 if isequal(MinIndex_i,-1)
    886     MinIndex_i=0;
    887 end
    888 if isequal(MinIndex_j,-1)
    889     MinIndex_j=0;
    890 end
    891 if isfield(FileInfo,'Software')&&~isempty(FileInfo.Software) && ~isempty(regexp(FileInfo.Software,'^pco.camware', 'once'))
    892     MinIndex_i=0;
    893 end
    894 if strcmp(FileInfo.FileType,'rdvision')
     1045    enable_j(handles,'on')%%%%remark: put series with j index at the end in the case of a list
     1046end
     1047
     1048SeriesData=get(handles.series,'UserData');
     1049if ~Param.Relabel
     1050    %% read timing  from the current file (prioritary)
     1051    if ~isempty(VideoObject)% case of movies
     1052        imainfo=get(VideoObject);
     1053        if isfield(imainfo,'NumFrames')
     1054            imainfo.NumberOfFrames=imainfo.NumFrames;
     1055        end
     1056        if isempty(j1_series) % frame index along i
     1057            Time=zeros(imainfo.NumberOfFrames+1,2);
     1058            Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     1059        else
     1060            Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     1061        end
     1062        TimeName='video';
     1063    end
     1064
     1065    %% get index range in case of relabeling
     1066    if ~isempty(Param.XmlData.Time)
     1067        Time=Param.XmlData.Time;
     1068        MinIndex_i=1;
     1069        MaxIndex_i=size(Time,1)-1;
     1070        MinIndex_j=1;
     1071        MaxIndex_j=size(Time,2)-1;
     1072        TimeName='xml';
     1073    else
     1074        [nbfield,nbfield_j]=size(XmlData.Time);
     1075        nbfield=nbfield-1; %remove the possible index 0
     1076        nbfield_j=nbfield_j-1; %remove the possible index 0
     1077        MaxIndex_i=get(handles.MaxIndex_i,'Data');
     1078        MaxIndex_j=get(handles.MaxIndex_j,'Data');
     1079        MaxIndex_i(1,:)=nbfield;
     1080        MaxIndex_j(1,:)=nbfield_j;
     1081        MinIndex_i(1,:)=1;
     1082        MinIndex_j(1,:)=1;
     1083
     1084        first_i=str2double(get(handles.num_first_i,'String'));
     1085        first_j=str2double(get(handles.num_first_j,'String'));
     1086        %i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     1087        i1=1;
     1088        if strcmp(SeriesData.TimeName,'xml')% indices i and j
     1089            j1=mod(i1-1,nbfield_j)+first_j;
     1090            i1=floor((i1-1)/nbfield_j)+1;
     1091            set(handles.num_first_j,'String',num2str(j1))
     1092        end
     1093    end
     1094end
     1095%     set(handles.num_first_i,'String',num2str(i1))
     1096%     %         last_i=str2double(get(handles.num_last_i,'String'));
     1097%     %         last_j=str2double(get(handles.num_last_j,'String'));
     1098%     %         i1=(last_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     1099%     %         if strcmp(SeriesData.TimeName,'xml')% indices i and j
     1100%     %             j1=mod(i1-1,nbfield_j)+1;
     1101%     %             i1=floor((i1-1)/nbfield_j)+1;
     1102%     %         end
     1103%     set(handles.num_last_i,'String',num2str(nbfield))
     1104%     set(handles.num_last_j,'String',num2str(nbfield_j))
     1105% % else
     1106
     1107
     1108
     1109
     1110%     %% case of possible index relabeling from xml info
     1111%     if isfield(XmlData,'FileSeries')&& strcmp(FileInfo.FileType,'multimage')
     1112%         answer=msgbox_uvmat('INPUT_Y-N','relabel the frame  indices according to the xml info?');
     1113%         if strcmp(answer,'Yes')
     1114%             set(handles.Relabel,'Visible','on')
     1115%             set(handles.Relabel,'Value',1)
     1116%             SeriesData.FileSeries{iview}=XmlData.FileSeries;
     1117%             TimeMin=Time(2,2);
     1118%             TimeMax=Time(end,end);
     1119%             TimeFirst=TimeMin;
     1120%             TimeLast=TimeMax;
     1121%         end
     1122%     elseif iview==1
     1123%         set(handles.Relabel,'Visible','off')
     1124%     end
     1125
     1126if ~isempty(Param.FileInfo) && strcmp(Param.FileInfo.FileType,'rdvision')
    8951127    set(handles.OutputSubDir,'String','/im')
    8961128end
     1129
     1130%% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback
     1131if ~isempty(TimeName)
     1132    if size(Time)<[MaxIndex_i+1 MaxIndex_j+1]
     1133        msgbox_uvmat('WARNING',['incomplete time info in xml file']);
     1134    end
     1135    TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
     1136%     if size(Time)>=[first_i+1 first_j+1]
     1137%         TimeFirst=Time(first_i+1,first_j+1);
     1138%     end
     1139%     if size(Time)>=[last_i+1 last_j+1]
     1140%         TimeLast=Time(last_i+1,last_j+1);
     1141%     end
     1142    if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]
     1143        TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
     1144    end
     1145end
     1146
     1147%% update the tables of Min and Max indices
    8971148MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
    8981149MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
     
    9121163set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex
    9131164
    914 
    915 SeriesData=get(handles.series,'UserData');
     1165if isfield(Param.XmlData,'NbSlice') && ~isempty(Param.XmlData.NbSlice)
     1166    set(handles.num_NbSlice,'String',num2str(Param.XmlData.NbSlice))
     1167    set(handles.num_NbSlice,'Visible','on')
     1168end
     1169
    9161170
    9171171%% adjust the first and last indices for the selected series, only if requested by the bounds
     
    9201174% ref_i=str2num(get(handles.num_ref_i,'String')); % index i given by the input field
    9211175ref_i=1;
     1176
    9221177if isfield(SeriesData,'ref_i')
    9231178    ref_i=SeriesData.ref_i;
     
    9731228end
    9741229
    975 %% default time settings
    976 TimeUnit='';
    977 % read  value set by the first series for the append mode (iwiew >1)
    978 if iview>1
    979     TimeUnit=get(handles.TimeUnit,'String');
    980 end
    981 TimeName='';
    982 Time=[]; % default
    983 TimeMin=[];
    984 TimeFirst=[];
    985 TimeLast=[];
    986 TimeMax=[];
    987 
    988 %%  read image documentation file if found
    989 XmlData=[];
    990 check_calib=0;
    991 XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2});
    992 if ~isempty(XmlFileName)
    993     [XmlData,errormsg]=imadoc2struct(XmlFileName);
    994     if ~isempty(errormsg)
    995         msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
    996     end
    997     % read time if available
    998     if isfield(XmlData,'Time')
    999         Time=XmlData.Time;
    1000         TimeName='xml';
    1001     end
    1002     if isfield(XmlData,'Camera')
    1003         if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
    1004             if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit)
    1005                 msgbox_uvmat('WARNING','inconsistent time unit with the first field series');
    1006             end
    1007             TimeUnit=XmlData.Camera.TimeUnit;
    1008         end
    1009     end
    1010     % number of slices
    1011     if isfield(XmlData,'TranslationMotor')&& isfield(XmlData.TranslationMotor,'NbSlice')
    1012         NbSlice_motor=XmlData.TranslationMotor.NbSlice;
    1013         if ~isempty(NbSlice) && ~isequal(NbSlice_motor,NbSlice)
    1014                 msgbox_uvmat('WARNING','inconsistent Z numbers of Z indices');
    1015         else
    1016             NbSlice=NbSlice_motor;
    1017         end
    1018     end
    1019 end
    1020 if ~isempty(NbSlice)
    1021 set(handles.num_NbSlice,'String',num2str(NbSlice))
    1022 set(handles.num_NbSlice,'Visible','on')
    1023 end
    1024 
    1025 %% read timing  from the current file (prioritary)
    1026 if ~isempty(VideoObject)% case of movies
    1027     imainfo=get(VideoObject);
    1028     if isfield(imainfo,'NumFrames')
    1029         imainfo.NumberOfFrames=imainfo.NumFrames;
    1030     end
    1031     if isempty(j1_series) % frame index along i
    1032         Time=zeros(imainfo.NumberOfFrames+1,2);
    1033         Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    1034     else
    1035         Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    1036     end
    1037     TimeName='video';
    1038 end
    1039 
    1040 
    1041 %% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback
    1042 if ~isempty(TimeName)
    1043     if size(Time)<[MaxIndex_i+1 MaxIndex_j+1]
    1044        msgbox_uvmat('WARNING',['incomplete time info in ' XmlFileName]);
    1045     end
    1046     TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
    1047     if size(Time)>=[first_i+1 first_j+1]
    1048         TimeFirst=Time(first_i+1,first_j+1);
    1049     end
    1050     if size(Time)>=[last_i+1 last_j+1]
    1051         TimeLast=Time(last_i+1,last_j+1);
    1052     end
    1053     if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]
    1054         TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
    1055     end
    1056 end
    1057 
    1058 %% case of possible index relabeling from xml info
    1059 if isfield(XmlData,'FileSeries')&& strcmp(FileInfo.FileType,'multimage')
    1060     set(handles.Relabel,'Visible','on')
    1061     set(handles.Relabel,'Value',1)
    1062     SeriesData.FileSeries{iview}=XmlData.FileSeries;
    1063     TimeMin=Time(2,2);
    1064     TimeMax=Time(end,end);
    1065     TimeFirst=TimeMin;
    1066     TimeLast=TimeMax;
    1067 elseif iview==1
    1068     set(handles.Relabel,'Visible','off')
    1069 end
    10701230
    10711231%% update the time table
     
    10831243SeriesData.j1_series{iview}=j1_series;
    10841244SeriesData.j2_series{iview}=j2_series;
    1085 SeriesData.FileType{iview}=FileInfo.FileType;
    1086 SeriesData.FileInfo{iview}=FileInfo;
     1245%     SeriesData.FileType{iview}=FileInfo.FileType;
     1246SeriesData.FileInfo{iview}=Param.FileInfo;
    10871247SeriesData.Time{iview}=Time;
    1088 
    10891248SeriesData.TimeName=TimeName;
    1090 
    1091 if check_calib
    1092     SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
    1093 end
    10941249set(handles.series,'UserData',SeriesData)
    10951250
     1251%% updtate the time info
     1252displ_time(handles);
     1253
    10961254%% update pair menus
     1255InputTable=get(handles.InputTable,'Data');
    10971256hset_pair=findobj(allchild(0),'Tag','set_pairs');
    10981257if ~isempty(hset_pair), delete(hset_pair); end % delete the GUI set_pair if opened
     
    11291288    j_max{iline}=max(pair_max,[],1); % max on j index
    11301289    if ~isempty(j_max{iline})
    1131     MaxIndex_i(iline)=find(j_max{iline}, 1, 'last' )-1; % max ref index i
    1132     MinIndex_i(iline)=find(j_max{iline}, 1 )-1; % min ref index i
     1290        MaxIndex_i(iline)=find(j_max{iline}, 1, 'last' )-1; % max ref index i
     1291        MinIndex_i(iline)=find(j_max{iline}, 1 )-1; % min ref index i
    11331292    end
    11341293end
     
    13121471ref_i_1=str2double(get(handles.num_first_i,'String')); % first reference index
    13131472if isnan(ref_i_1)
    1314 ref_i_1=1;
     1473    ref_i_1=1;
    13151474end
    13161475ref_i_2=str2double(get(handles.num_last_i,'String')); % last reference index
    13171476if isnan(ref_i_2)
    1318 ref_i_2=1;
     1477    ref_i_2=1;
    13191478end
    13201479ref_j_1=NaN;ref_j_2=NaN;
     
    13361495    TimeTable{iview,3}=[];
    13371496    TimeTable{iview,4}=[];
    1338     if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1)
    1339         if isempty(ref_j_1)
    1340             time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2;
     1497    if size(SeriesData.Time{iview},1)>=i2_2+1 && (isnan(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1)
     1498        if isnan(ref_j_1)
     1499            time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2;% take  the average between index i1 and i2
    13411500            time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2;
    13421501        else
     
    40054164% --- Executes on button press in Relabel.
    40064165function Relabel_Callback(hObject, eventdata, handles)
    4007 if get(handles.Relabel,'Value')
    4008     SeriesData=get(handles.series,'UserData');
    4009     if isfield(SeriesData,'FileSeries')&& ~isempty(SeriesData.FileSeries{1})
    4010         [nbfield,nbfield_j]=size(SeriesData.Time{1});
    4011         nbfield=nbfield-1; %remove the possible index 0
    4012         nbfield_j=nbfield_j-1; %remove the possible index 0
    4013         MaxIndex_i=get(handles.MaxIndex_i,'Data');
    4014         MaxIndex_j=get(handles.MaxIndex_j,'Data');
    4015         MaxIndex_i(1,:)=nbfield;
    4016         MaxIndex_j(1,:)=nbfield_j;
    4017                 MinIndex_i(1,:)=1;
    4018         MinIndex_j(1,:)=1;
    4019         set(handles.MaxIndex_i,'Data',MaxIndex_i)
    4020         set(handles.MaxIndex_j,'Data',MaxIndex_j)
    4021          set(handles.MinIndex_i,'Data',MinIndex_i)
    4022         set(handles.MinIndex_j,'Data',MinIndex_j)
    4023         first_i=str2double(get(handles.num_first_i,'String'));
    4024         first_j=str2double(get(handles.num_first_j,'String'));
    4025         %i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
    4026         i1=1;
    4027         if strcmp(SeriesData.TimeName,'xml')% indices i and j
    4028             j1=mod(i1-1,nbfield_j)+first_j;
    4029             i1=floor((i1-1)/nbfield_j)+1;
    4030             set(handles.num_first_j,'String',num2str(j1))
    4031         end
    4032         set(handles.num_first_i,'String',num2str(i1))
    4033 %         last_i=str2double(get(handles.num_last_i,'String'));
    4034 %         last_j=str2double(get(handles.num_last_j,'String'));
    4035 %         i1=(last_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     4166CheckRelabel=get(hObject,'Value');
     4167check_input_file_series(handles,CheckRelabel)
     4168 ActionInput_Callback([],[], handles)
     4169% if get(handles.Relabel,'Value')
     4170%             NomType='*';
     4171%             i1=1;i2=[];j1=1;j2=[];
     4172%             i1_series=1:size(XmlData.Time,1)-1;   
     4173%             i2_series=[];
     4174%             j1_series=1:size(XmlData.Time,2)-1;
     4175%             j2_series=[];
     4176%
     4177%
     4178%
     4179%     SeriesData=get(handles.series,'UserData');
     4180%     if isfield(SeriesData,'FileSeries')&& ~isempty(SeriesData.FileSeries{1})
     4181%         [nbfield,nbfield_j]=size(SeriesData.Time{1});
     4182%         nbfield=nbfield-1; %remove the possible index 0
     4183%         nbfield_j=nbfield_j-1; %remove the possible index 0
     4184%         MaxIndex_i=get(handles.MaxIndex_i,'Data');
     4185%         MaxIndex_j=get(handles.MaxIndex_j,'Data');
     4186%         MaxIndex_i(1,:)=nbfield;
     4187%         MaxIndex_j(1,:)=nbfield_j;
     4188%                 MinIndex_i(1,:)=1;
     4189%         MinIndex_j(1,:)=1;
     4190%         set(handles.MaxIndex_i,'Data',MaxIndex_i)
     4191%         set(handles.MaxIndex_j,'Data',MaxIndex_j)
     4192%          set(handles.MinIndex_i,'Data',MinIndex_i)
     4193%         set(handles.MinIndex_j,'Data',MinIndex_j)
     4194%         first_i=str2double(get(handles.num_first_i,'String'));
     4195%         first_j=str2double(get(handles.num_first_j,'String'));
     4196%         %i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     4197%         i1=1;
    40364198%         if strcmp(SeriesData.TimeName,'xml')% indices i and j
    4037 %             j1=mod(i1-1,nbfield_j)+1;
     4199%             j1=mod(i1-1,nbfield_j)+first_j;
    40384200%             i1=floor((i1-1)/nbfield_j)+1;
     4201%             set(handles.num_first_j,'String',num2str(j1))
    40394202%         end
    4040         set(handles.num_last_i,'String',num2str(nbfield))
    4041          set(handles.num_last_j,'String',num2str(nbfield_j))
    4042     end
    4043 else
    4044     check_input_file_series(handles)
    4045     ActionInput_Callback([],[], handles)
    4046 end
    4047 
     4203%         set(handles.num_first_i,'String',num2str(i1))
     4204% %         last_i=str2double(get(handles.num_last_i,'String'));
     4205% %         last_j=str2double(get(handles.num_last_j,'String'));
     4206% %         i1=(last_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     4207% %         if strcmp(SeriesData.TimeName,'xml')% indices i and j
     4208% %             j1=mod(i1-1,nbfield_j)+1;
     4209% %             i1=floor((i1-1)/nbfield_j)+1;
     4210% %         end
     4211%         set(handles.num_last_i,'String',num2str(nbfield))
     4212%          set(handles.num_last_j,'String',num2str(nbfield_j))
     4213%     end
     4214% else
     4215%     check_input_file_series(handles)
     4216%     ActionInput_Callback([],[], handles)
     4217% end
     4218
  • trunk/src/series/civ_input.m

    r1187 r1188  
    163163        MaxIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
    164164    else
    165         ref_i=squeeze(max(SeriesData.i1_series{iview_image}(1,:,:),[],2));% select ref_j index for each ref_i
    166         ref_j=squeeze(max(SeriesData.j1_series{iview_image}(1,:,:),[],3));% select ref_i index for each ref_j
    167         MinIndex_i=min(find(ref_i))-1;
    168         MaxIndex_i=max(find(ref_i))-1;
    169         MaxIndex_j=max(find(ref_j))-1;
    170         MinIndex_j=min(find(ref_j))-1;
     165       
     166        if ndims(SeriesData.j1_series{iview_image})==3% usuual file series input
     167            ref_i=squeeze(max(SeriesData.i1_series{iview_image}(1,:,:),[],2));% select ref_j index for each ref_i
     168            ref_j=squeeze(max(SeriesData.j1_series{iview_image}(1,:,:),[],3));% select ref_i index for each ref_j
     169            MinIndex_i=min(find(ref_i))-1;
     170            MaxIndex_i=max(find(ref_i))-1;
     171            MaxIndex_j=max(find(ref_j))-1;
     172            MinIndex_j=min(find(ref_j))-1;
     173        else %case with relabeling
     174            MinIndex_i=1;
     175            MaxIndex_i=numel(SeriesData.i1_series{iview_image});% case relabel
     176            MinIndex_j=1;
     177            MaxIndex_j=max(1,numel(SeriesData.j1_series{iview_image}));% =1 if j1_series empty
     178        end
    171179    end
    172180end
     
    176184time=[];
    177185TimeUnit='frame'; %default
    178 CoordUnit='';%default
    179 pxcm_search=1;
     186% CoordUnit='';%default
     187% pxcm_search=1;
    180188if isfield(SeriesData,'Time') &&numel(SeriesData.Time')>=1 && ~isempty(SeriesData.Time{1})
    181189    time=SeriesData.Time{1};
     
    184192    TimeUnit=Param.IndexRange.TimeUnit;
    185193end
    186 if isfield(SeriesData,'GeometryCalib')
    187     tsai=SeriesData.GeometryCalib;
    188     if isfield(tsai,'fx_fy')
    189         pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range
    190     end
    191     if isfield(tsai,'CoordUnit')
    192         CoordUnit=tsai.CoordUnit;
    193     end
    194 end
     194% if isfield(SeriesData,'GeometryCalib')
     195%     tsai=SeriesData.GeometryCalib;
     196%     if isfield(tsai,'fx_fy')
     197%         pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range
     198%     end
     199%     if isfield(tsai,'CoordUnit')
     200%         CoordUnit=tsai.CoordUnit;
     201%     end
     202% end
    195203
    196204%% timing display
     
    824832%reproduce by default the chosen pair in the checkciv2 menu
    825833set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ1 by default
    826 %ListPairCiv2_Callback(hObject, eventdata, handles)
    827834
    828835% %------------------------------------------------------------------------
     
    978985        end
    979986        if index_pair ~=0
    980         [tild,indsort]=sort(dt);
     987        [~,indsort]=sort(dt);
    981988        displ_pair=displ_pair(indsort);
    982989        displ_pair_dt=displ_pair_dt(indsort);
  • trunk/src/series/civ_series.m

    r1187 r1188  
    256256
    257257%% File relabeling documented by the xml file (e.g. PCO)
    258 CheckRelabel=isfield(Param,'FileSeries' );%=true for index relabeling (PCO)
    259 
    260 % %% introduce input image transform
    261 % transform_fct=[];%default, no transform
    262 % if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    263 %         currentdir=pwd;
    264 %     cd(Param.FieldTransform.TransformPath)
    265 %     transform_fct=str2func(Param.FieldTransform.TransformName);
    266 %     cd (currentdir)
    267 % end
     258CheckRelabel=isfield(Param.IndexRange,'Relabel' )&& Param.IndexRange.Relabel;%=true for index relabeling (PCO)
    268259
    269260%%%%% MAIN LOOP %%%%%%
     
    291282    OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
    292283    if CheckRelabel
    293          RootFileOut=index2filename(Param.FileSeries,1,1,MaxIndex_j);
     284         RootFileOut=index2filename(XmlData.FileSeries,1,1,MaxIndex_j);
    294285    else
    295286        RootFileOut=RootFile_A;
     
    343334                FrameIndex_A=1;
    344335            elseif CheckRelabel
    345             [RootFile,FrameIndex_A]=index2filename(Param.FileSeries,i1_series_Civ1(ifield),j1_series_Civ1(ifield),MaxIndex_j);
    346             ImageName_A=fullfile(RootPath_A,SubDir_A,RootFile);
     336                [RootFile,FrameIndex_A]=index2filename(XmlData.FileSeries,i1_series_Civ1(ifield),j1_series_Civ1(ifield),MaxIndex_j);
     337                ImageName_A=fullfile(RootPath_A,SubDir_A,RootFile);
    347338            else
    348339                ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
     
    382373            end
    383374            if CheckRelabel
    384                 [RootFile,FrameIndex_B]=index2filename(Param.FileSeries,i2_series_Civ1(ifield),j2_series_Civ1(ifield),MaxIndex_j);
     375                [RootFile,FrameIndex_B]=index2filename(XmlData.FileSeries,i2_series_Civ1(ifield),j2_series_Civ1(ifield),MaxIndex_j);
    385376                ImageName_B=fullfile(RootPath_B,SubDir_B,RootFile);
    386377            else
     
    632623            ImageName_A_Civ2=Param.ActionInput.RefFile;
    633624        elseif CheckRelabel
    634             [RootFile,FrameIndex_A_2]=index2filename(Param.FileSeries,i1_series_Civ2(ifield),j1_series_Civ2(ifield),MaxIndex_j);
     625            [RootFile,FrameIndex_A_2]=index2filename(XmlData.FileSeries,i1_series_Civ2(ifield),j1_series_Civ2(ifield),MaxIndex_j);
    635626            ImageName_A_Civ2=fullfile(RootPath_A,SubDir_A,RootFile);
    636627        else
     
    644635        end
    645636        if CheckRelabel
    646             [RootFile,FrameIndex_B_2]=index2filename(Param.FileSeries,i2_civ2,j2_civ2,MaxIndex_j);
     637            [RootFile,FrameIndex_B_2]=index2filename(XmlData.FileSeries,i2_civ2,j2_civ2,MaxIndex_j);
    647638            ImageName_B_Civ2=fullfile(RootPath_B,SubDir_B,RootFile);
    648639        else
Note: See TracChangeset for help on using the changeset viewer.