Changeset 1178 for trunk


Ignore:
Timestamp:
Mar 21, 2025, 10:17:07 AM (4 weeks ago)
Author:
sommeria
Message:

virtual frame indexing introduced

Location:
trunk/src
Files:
9 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_file_info.m

    r1170 r1178  
    7979        FileInfo.FileType=regexprep(FileExt,'^.','');% eliminate the dot of the extension;
    8080    case {'.seq','.sqb'}
    81         [~,FileInfo,timestamps,errormsg]=read_rdvision(fileinput,[]);
     81        [~,FileInfo]=read_rdvision(fileinput,[]);
    8282    case '.im7'
    8383        try
     
    158158                        FileInfo=orderfields(FileInfo,[nbfield nbfield-1 nbfield-2 (1:nbfield-3)]); %reorder the fields of fileInfo for clarity
    159159                    catch ME
    160                         FileInfo.error=ME.message
     160                        FileInfo.error=ME.message;
    161161                    end
    162162                else
     
    165165                        [Data,tild,tild,errormsg]=nc2struct(fileinput,[]);
    166166                        if isempty(errormsg)
    167                             %                             if isfield(Data,'absolut_time_T0') && isfield(Data,'hart') && ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
    168                             %                                 FileInfo.FileType='civx';%old civ data from the Fortran program
    169                             %                                 if isfield(Data,'patch2') && isequal(Data.patch2,1)
    170                             %                                     FileInfo.CivStage=6;
    171                             %                                 elseif isfield(Data,'fix2') && isequal(Data.fix2,1)
    172                             %                                     FileInfo.CivStage=5;
    173                             %                                 elseif  isfield(Data,'civ2')&& isequal(Data.civ2,1)
    174                             %                                     FileInfo.CivStage=4;
    175                             %                                 elseif isfield(Data,'patch')&&isequal(Data.patch,1)
    176                             %                                     FileInfo.CivStage=3;
    177                             %                                 elseif isfield(Data,'fix')&&isequal(Data.fix,1)
    178                             %                                     FileInfo.CivStage=2;
    179                             %                                 else
    180                             %                                     FileInfo.CivStage=1;
    181                             %                                 end
    182                             %                             else
    183167                            if isfield(Data,'Conventions') && strcmp(Data.Conventions,'uvmat/civdata')
    184168                                FileInfo.FileType='civdata'; % test for civ velocity fields
  • trunk/src/imadoc2struct.m

    r1150 r1178  
    4040%% opening the xml file
    4141[tild,tild,FileExt]=fileparts(ImaDoc);
    42 %% case of .civ files (obsolete)
    43 if strcmp(FileExt,'.civ')
    44     [errormsg,time,TimeUnit,mode,npx,npy,s.GeometryCalib]=read_imatext(ImaDoc);
    45     return
    46 end
    4742
    48 %% case of xml files
    4943if nargin ==1
    5044    [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
  • trunk/src/read_image.m

    r1170 r1178  
    8383         A=(reshape(A,Header(1).Width,Header(1).Height))';
    8484         A=flip(A,1);
     85    case 'rdvision'
     86         A=read_rdvision(FileName,num);
    8587end
  • trunk/src/read_rdvision.m

    r1127 r1178  
    6363s=ini2struct(filename_seq);
    6464FileInfo=s.sequenceSettings;
     65FileInfo.Width=str2double(FileInfo.width);
     66FileInfo.Height=str2double(FileInfo.height);
     67if isequal(FileInfo.bytesperpixel,'2')
     68    FileInfo.BitDepth=16;
     69else
     70    FileInfo.BitDepth=8;
     71end
    6572if isfield(s.sequenceSettings,'numberoffiles')
    6673    FileInfo.NumberOfFrames=str2double(s.sequenceSettings.numberoffiles);
     
    119126            binrepertoire=regexprep(FileInfo.bindirectory,'\\$','');%tranform Windows notation to Linux
    120127            binrepertoire=regexprep(binrepertoire,'\','/');
    121             [tild,binrepertoire,DirExt]=fileparts(binrepertoire);
     128            [~,binrepertoire,DirExt]=fileparts(binrepertoire);
    122129            binrepertoire=[binrepertoire DirExt];     
    123130        end
     
    144151    FileInfo.StartTime=regexprep(FileInfo.binrepertoire,'T',' ');
    145152    FileInfo.EndTime=datestr(datenum(FileInfo.StartTime,'yyyy-mm-dd HH.MM.SS')+timestamps(end)/86400);
    146     disp(FileInfo)
    147153end
    148154
     
    238244    if isempty(s)
    239245        continue;
    240     end;
     246    end
    241247    if (s(1)==';')                      % ';' start comment lines
    242248        continue;
    243     end;
     249    end
    244250    if (s(1)=='#')                      % '#' start comment lines
    245251        continue;
    246     end;
     252    end
    247253    if ( s(1)=='[' ) && (s(end)==']' )
    248254        % We found section
  • trunk/src/series.m

    r1171 r1178  
    553553set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
    554554set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH  button to yellow color (indicate activation)
     555set(handles.Relabel,'BackgroundColor',[0 1 0])
    555556drawnow
    556557empty_line=false(size(InputTable,1),1);
     
    876877    MinIndex_j=0;
    877878end
     879if isfield(FileInfo,'Software')&&~isempty(FileInfo.Software) && ~isempty(regexp(FileInfo.Software,'^pco.camware', 'once'))
     880    MinIndex_i=0;
     881end
     882if strcmp(FileInfo.FileType,'rdvision')
     883    set(handles.OutputSubDir,'String','/im')
     884end
    878885MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
    879886MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
     
    10351042        TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
    10361043    end
     1044end
     1045
     1046%% case of possible index relabeling from xml info
     1047if isfield(XmlData,'FileSeries')&& strcmp(FileInfo.FileType,'multimage')
     1048    set(handles.Relabel,'Visible','on')
     1049    set(handles.Relabel,'Value',0)
     1050    SeriesData.FileSeries{iview}=XmlData.FileSeries;
     1051    TimeMin=Time(2,2);
     1052    TimeMax=Time(end,end);
     1053    TimeFirst=TimeMin;
     1054    TimeLast=TimeMax;
     1055elseif iview==1
     1056    set(handles.Relabel,'Visible','off')
    10371057end
    10381058
     
    14071427if isfield(SeriesData,'ProjObject')
    14081428    Param.ProjObject=SeriesData.ProjObject;
     1429end
     1430if isfield(SeriesData,'FileSeries')
     1431    Param.FileSeries=SeriesData.FileSeries{1};
    14091432end
    14101433if ~isfield(SeriesData,'i1_series')
     
    39363959
    39373960
    3938 
    3939 
    39403961function OutputPath_Callback(hObject, eventdata, handles)
    39413962
     
    39593980
    39603981
    3961 
    39623982% --- Executes on button press in DeleteMask.
    39633983function DeleteMask_Callback(hObject, eventdata, handles)
    39643984set(handles.MaskTable,'Data',{})
     3985
     3986
     3987% --- Executes on button press in Relabel.
     3988function Relabel_Callback(hObject, eventdata, handles)
     3989if get(handles.Relabel,'Value')
     3990    SeriesData=get(handles.series,'UserData');
     3991    if isfield(SeriesData,'FileSeries')&& ~isempty(SeriesData.FileSeries{1})
     3992        [nbfield,nbfield_j]=size(SeriesData.Time{1});
     3993        nbfield=nbfield-1; %remove the possible index 0
     3994        nbfield_j=nbfield_j-1; %remove the possible index 0
     3995        MaxIndex_i=get(handles.MaxIndex_i,'Data');
     3996        MaxIndex_j=get(handles.MaxIndex_j,'Data');
     3997        MaxIndex_i(1,:)=nbfield;
     3998        MaxIndex_j(1,:)=nbfield_j;
     3999                MinIndex_i(1,:)=1;
     4000        MinIndex_j(1,:)=1;
     4001        set(handles.MaxIndex_i,'Data',MaxIndex_i)
     4002        set(handles.MaxIndex_j,'Data',MaxIndex_j)
     4003         set(handles.MinIndex_i,'Data',MinIndex_i)
     4004        set(handles.MinIndex_j,'Data',MinIndex_j)
     4005        first_i=str2double(get(handles.num_first_i,'String'));
     4006        first_j=str2double(get(handles.num_first_j,'String'));
     4007        i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     4008        if strcmp(SeriesData.TimeName,'xml')% indices i and j
     4009            j1=mod(i1-1,nbfield_j)+first_j;
     4010            i1=floor((i1-1)/nbfield_j)+1;
     4011            set(handles.num_first_j,'String',num2str(j1))
     4012        end
     4013        set(handles.num_first_i,'String',num2str(i1))
     4014%         last_i=str2double(get(handles.num_last_i,'String'));
     4015%         last_j=str2double(get(handles.num_last_j,'String'));
     4016%         i1=(last_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     4017%         if strcmp(SeriesData.TimeName,'xml')% indices i and j
     4018%             j1=mod(i1-1,nbfield_j)+1;
     4019%             i1=floor((i1-1)/nbfield_j)+1;
     4020%         end
     4021        set(handles.num_last_i,'String',num2str(nbfield))
     4022         set(handles.num_last_j,'String',num2str(nbfield_j))
     4023    end
     4024else
     4025    check_input_file_series(handles)
     4026    ActionInput_Callback([],[], handles)
     4027end
     4028
  • trunk/src/series/aver_spectral.m

    r1127 r1178  
    144144transform_fct='';%default
    145145if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    146     addpath(Param.FieldTransform.TransformPath)
     146            currentdir=pwd;
     147    cd(Param.FieldTransform.TransformPath)
    147148    transform_fct=str2func(Param.FieldTransform.TransformName);
    148     rmpath(Param.FieldTransform.TransformPath)
     149    cd (currentdir)
    149150end
    150151
  • trunk/src/series/aver_stat.m

    r1148 r1178  
    198198transform_fct='';%default
    199199if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    200     addpath(Param.FieldTransform.TransformPath)
     200            currentdir=pwd;
     201    cd(Param.FieldTransform.TransformPath)
    201202    transform_fct=str2func(Param.FieldTransform.TransformName);
    202     rmpath(Param.FieldTransform.TransformPath)
     203    cd (currentdir)
    203204    if isfield(Param,'TransformInput')
    204205        XmlData{1}.TransformInput=Param.TransformInput;
  • trunk/src/series/civ_series.m

    r1177 r1178  
    254254    end
    255255end
     256CheckRelabel=isfield(Param,'FileSeries' );%=true for index relabeling (PCO)
    256257
    257258%% introduce input image transform
    258259transform_fct=[];%default, no transform
    259260if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    260        % addpath(Param.FieldTransform.TransformPath)
    261261        currentdir=pwd;
    262262    cd(Param.FieldTransform.TransformPath)
    263263    transform_fct=str2func(Param.FieldTransform.TransformName);
    264264    cd (currentdir)
    265     %rmpath(Param.FieldTransform.TransformPath)
    266265end
    267266
     
    289288    end
    290289    OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
    291 
     290    if CheckRelabel
     291         RootFileOut=index2filename(Param.FileSeries,1,1,MaxIndex_j);
     292    else
     293        RootFileOut=RootFile_A;
     294    end
    292295    if strcmp(Param.ActionInput.ListCompareMode,'PIV')
    293         ncfile=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...
     296        ncfile=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...
    294297            j1_series_Civ1(ifield),j2_series_Civ1(ifield));
    295298    else
    296         ncfile=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],...
     299        ncfile=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],...
    297300            j1_series_Civ1(ifield),j2_series_Civ1(ifield));
    298301    end
     
    314317        end
    315318        if strcmp(Param.ActionInput.ListCompareMode,'PIV')
    316             ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
     319            ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
    317320        else % displacement
    318             ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
     321            ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
    319322        end
    320323    end
     
    336339            if strcmp(Param.ActionInput.ListCompareMode,'displacement')
    337340                ImageName_A=Param.ActionInput.RefFile;
     341            elseif CheckRelabel
     342            [RootFile,FileIndexString,FrameIndex_A]=index2filename(Param.FileSeries,i1_series_Civ1(ifield),j1_series_Civ1(ifield),MaxIndex_j);
     343            ImageName_A=fullfile(RootPath_A,SubDir_A,[RootFile FileIndexString FileExt_A]);
    338344            else
    339345                ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
     346                FrameIndex_A=FrameIndex_A_Civ1(ifield);
    340347            end
    341348            if strcmp(FileExt_A,'.nc')% case of input images in format netcdf
     
    368375                end
    369376                tsart_input=tic;
    370                 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield));
     377                [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A);
    371378                time_input=toc(tsart_input);
    372379            end
     380if CheckRelabel
     381            [RootFile,FileIndexString,FrameIndex_B]=index2filename(Param.FileSeries,i1_series_Civ1(ifield),j1_series_Civ1(ifield),MaxIndex_j);
     382            ImageName_B=fullfile(RootPath_B,SubDir_B,[RootFile FileIndexString FileExt_B]);
     383else
    373384            ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));
     385            FrameIndex_B=FrameIndex_B_Civ1(ifield);
     386end
    374387            if isempty(FileType_B)% determine the image type for the first field
    375388                [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
     
    380393                continue
    381394            end
    382             [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield));
     395            [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B);
    383396           
    384397        catch ME % display errors in reading input images
     
    613626        if strcmp(Param.ActionInput.ListCompareMode,'displacement')
    614627            ImageName_A_Civ2=Param.ActionInput.RefFile;
    615         else
     628        elseif CheckRelabel
     629              [RootFile,FileIndexString,FrameIndex_A_2]=index2filename(Param.FileSeries,i1_series_Civ2(ifield),j1_series_Civ2(ifield),MaxIndex_j);
     630            ImageName_A_Civ2=fullfile(RootPath_A,SubDir_A,[RootFile FileIndexString FileExt_A]);
     631            else
    616632            ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
    617         end
    618         if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
     633            FrameIndex_A_2=FrameIndex_A_Civ2(ifield);
     634        end
     635        if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A,FrameIndex_A_2)
    619636            par_civ2.ImageA=par_civ1.ImageA;
    620637        else
    621             [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield));
    622         end
     638            [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_2);
     639        end
     640        if CheckRelabel
     641              [RootFile,FileIndexString,FrameIndex_B_2]=index2filename(Param.FileSeries,i2_civ2,j2_civ2,MaxIndex_j);
     642            ImageName_B_Civ2=fullfile(RootPath_B,SubDir_B,[RootFile FileIndexString FileExt_B]);
     643            else
     644
     645
    623646        ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2);
    624         if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2)
     647        FrameIndex_B_2=FrameIndex_B_Civ2(ifield);
     648        end
     649        if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_2,FrameIndex_B)
    625650            par_civ2.ImageB=par_civ1.ImageB;
    626651        else
    627             [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
     652            [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_2);
    628653        end
    629654        %  [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A_Civ2);
  • trunk/src/series/sub_background.m

    r1175 r1178  
    1010% Organization of image indices:
    1111    % The program is working on a series of images,
    12     % In the mode 'volume', nbfield2=1 (1 image at each level)and NbSlice (=nbfield_j)
    13     % Else nbfield2=nbfield_j =nbre of images in a burst (j index)
     12    % In the mode 'volume', nbfield2=1 (1 image at each level)and NbSlice (=NbField_j)
     13    % Else nbfield2=NbField_j =nbre of images in a burst (j index)
    1414   
    1515% function GUI_config=sub_background(Param)
     
    8383    ParamOut.OutputDirExt='.sback';%set the output dir extension
    8484    ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
    85    
    86     %% root input file(s) and type
    87     % check the existence of the first file in the series
    88         first_j=[];% note that the function will propose to cover the whole range of indices
    89     if isfield(Param.IndexRange,'MinIndex_j'); first_j=Param.IndexRange.MinIndex_j; end
    90     last_j=[];
    91     if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
    92     PairString='';
    93     if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
    94     [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
    95     FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
    96         Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
    97     if ~exist(FirstFileName,'file')
    98         msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist'])
    99     else
    100         [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
    101         LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
    102         Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
    103         if ~exist(FirstFileName,'file')
    104              msgbox_uvmat('WARNING',['the last input file ' LastFileName ' does not exist'])
    105         end
    106     end
    10785
    10886    %% check the validity of  input file types
    109     FileInfo=get_file_info(FirstFileName);
    110     FileType=FileInfo.FileType;
    111     CheckImage=strcmp(FileInfo.FieldType,'image');% =1 for images
    112     if ~CheckImage
    113         msgbox_uvmat('ERROR',['invalid file type input: ' FileType ' not an image'])
     87    if isfield(Param,'SeriesData')&& isfield(Param.SeriesData,'FileInfo')
     88    if ~strcmp(Param.SeriesData.FileInfo{1}.FieldType,'image')
     89        msgbox_uvmat('ERROR','invalid file type input: not an image series')
    11490        return
    11591    end
    116    
     92    end
     93
    11794    %% numbers of fields
    11895    NbSlice_i=1;%default
     
    124101        incr_j=Param.IndexRange.incr_j;
    125102    end
    126     if isempty(first_j)||isempty(last_j)
    127         nbfield_j=1;
     103    if isfield(Param.IndexRange,'first_j')&&~isempty(Param.IndexRange.first_j)
     104        NbField_j=numel(Param.IndexRange.first_j:incr_j:Param.IndexRange.last_j);%nb of fields for the j index (bursts or volume slices)
    128105    else
    129         nbfield_j=numel(first_j:incr_j:last_j);%nb of fields for the j index (bursts or volume slices)
     106        NbField_j=1;
    130107    end
    131108    first_i=1;last_i=1;incr_i=1;%default
     
    136113    end
    137114    nbfield_i=numel(first_i:incr_i:last_i);%nb of fields for the i index (bursts or volume slices)
    138     nbfield=nbfield_j*nbfield_i; %total number of fields
     115    nbfield=NbField_j*nbfield_i; %total number of fields
    139116    nbfield_i=floor(nbfield/NbSlice_i);%total number of  indexes in a slice (adjusted to an integer number of slices)
    140117   
     
    143120    nbaver_init=23; %default number of images used for the sliding background: to be adjusted later to include an integer number of bursts
    144121    SaturationValue=0;
    145      if nbfield_i~=1 && nbfield_j<=nbaver_init
    146         nbaver=floor(nbaver_init/nbfield_j); % number of bursts used for the sliding background,
     122     if nbfield_i~=1 && NbField_j<=nbaver_init
     123        nbaver=floor(nbaver_init/NbField_j); % number of bursts used for the sliding background,
    147124        if isequal(mod(nbaver,2),0)% if nbaver is even
    148125            nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
    149126        end
    150         nbaver_init=nbaver*nbfield_j;%propose by default an integer number of bursts
     127        nbaver_init=nbaver*NbField_j;%propose by default an integer number of bursts
    151128    end
    152129    BrightnessRankThreshold=0.1;
     
    161138          BrightnessRankThreshold=Param.ActionInput.BrightnessRankThreshold;
    162139        end
    163 %         if isfield(Param.ActionInput,'CheckSubmedian') && Param.ActionInput.CheckSubmedian
    164 %         CheckSubmedian='Yes';
    165 %         end
    166140        if isfield(Param.ActionInput,'SaturationValue')
    167141            SaturationValue=Param.ActionInput.SaturationValue;
     
    190164        ParamOut.NbSlice=1; %nbre of slices displayed
    191165    else
    192         step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
    193     end
    194     ParamOut.ActionInput.SlidingSequenceLength=adjust_slidinglength(str2num(answer{2}),step);
     166        step=NbField_j;%case of bursts: the sliding background is shifted by the length of one burst
     167    end
     168    ParamOut.ActionInput.SlidingSequenceLength=adjust_slidinglength(str2double(answer{2}),step);
    195169    ParamOut.ActionInput.CheckVolume=strcmp(answer{1},'Yes');
    196170    ParamOut.ActionInput.BrightnessRankThreshold=str2double(answer{3});
     
    205179
    206180%% read input parameters from an xml file if input is a file name (batch mode)
    207 checkrun=1;
     181% checkrun=1;
    208182RUNHandle=[];
    209 WaitbarHandle=[];
     183% WaitbarHandle=[];
    210184if ischar(Param)
    211185    Param=xml2struct(Param);% read Param as input file (batch case)
    212     checkrun=0;
    213 else
    214 hseries=findobj(allchild(0),'Tag','series');
     186else
     187 hseries=findobj(allchild(0),'Tag','series');
    215188RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
    216 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
     189% WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
    217190end
    218191
     
    220193NbSlice_i=Param.IndexRange.NbSlice;
    221194if ~isequal(NbSlice_i,1)
    222     display(['multi-level splitting into ' num2str(NbSlice_i) ' slices']);
    223 end
    224 RootPath=Param.InputTable(:,1);
    225 RootFile=Param.InputTable(:,3);
    226 SubDir=Param.InputTable(:,2);
    227 NomType=Param.InputTable(:,4);
    228 FileExt=Param.InputTable(:,5);
    229 [filecell,i1_series,i2_series,j1_series]=get_file_series(Param);%series of file names organised as a single array
    230 
    231 %%%%%%%%%%%%
    232     % The cell array filecell is the list of input file names, while
    233     % filecell{iview,fileindex}:
    234     %        iview: line in the table corresponding to a given file series
    235     %        fileindex: file index within  the file series,
    236     % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
    237     % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    238 %%%%%%%%%%%%
    239 [FileInfo{1},MovieObject{1}]=get_file_info(filecell{1,1});
    240 FileType{1}=FileInfo{1}.FileType;
    241     if ~isempty(j1_series{1})
    242         frame_index{1}=j1_series{1};
    243     else
    244         frame_index{1}=i1_series{1};
    245     end
    246 
    247 
    248 %% output file naming
    249 FileExtOut='.png'; % write result as .png images for image inputsFileInfo.FileType='image'
    250 if strcmp(FileInfo{1}.FileType,'image')
    251     NomTypeOut=NomType{1};
    252 elseif isempty(j1_series{1})
    253     NomTypeOut='_1';
    254 else
    255     NomTypeOut='_1_1';% caseof purely numerical indexing
    256 end
    257 OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    258 OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
     195    disp(['multi-level splitting into ' num2str(NbSlice_i) ' slices']);
     196end
     197RootPath=Param.InputTable{1,1};
     198RootFile=Param.InputTable{1,3};
     199SubDir=Param.InputTable{1,2};
     200NomType=Param.InputTable{1,4};
     201FileExt=Param.InputTable{1,5};
     202%[filecell,i1_series,i2_series,j1_series]=get_file_series(Param);%series of file names organised as a single array
     203
    259204
    260205%% file index parameters
     
    267212% nbaver_ima: nbre of the images in the sliding sequence used for the background
    268213% nbaver=nbaver_ima/step: nbre of bursts corresponding to nbaver_ima images. It has been adjusted so that nbaver is an odd integer
    269 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    270 nbfield_i=size(i1_series{1},2); %nb of fields for the i index
     214i_indices=Param.IndexRange.first_i:Param.IndexRange.incr_i:Param.IndexRange.last_i;
     215if isfield(Param.IndexRange,'first_j')
     216j_indices=Param.IndexRange.first_j:Param.IndexRange.incr_j:Param.IndexRange.last_j;
     217else
     218    j_indices=1;
     219end
     220nbfield_i=numel(i_indices); %nb of fields for the i index (bursts or volume slices)
     221NbField_j=numel(j_indices); %nb of fields for the j index
     222j_indices=j_indices'*ones(1,nbfield_i);
     223i_indices=ones(NbField_j,1)*i_indices;
    271224
    272225if Param.ActionInput.CheckVolume% case of volume scan: the background images must be determined for each index j
    273226    step=2;% we assume the burst contains only one image pair
    274     NbSlice_j=nbfield_j;
     227    NbSlice_j=NbField_j;
    275228    nbfield_series=nbfield_i;
    276229else
    277     step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
     230    if Param.ActionInput.SlidingSequenceLength<NbField_j
     231        step=1;
     232    else
     233    step=NbField_j;%case of bursts: the sliding background is shifted by the length of one burst
     234    end
    278235    NbSlice_j=1;
    279     nbfield_series=nbfield_i*nbfield_j;
    280 end
    281 nbfield=nbfield_j*nbfield_i; %total number of fields
     236    nbfield_series=nbfield_i*NbField_j;
     237end
     238nbfield=NbField_j*nbfield_i; %total number of fields
    282239[nbaver_ima,nbaver,step]=adjust_slidinglength(Param.ActionInput.SlidingSequenceLength,step);
    283240if nbaver_ima > nbfield
    284     display('number of images in a slice smaller than the proposed number of images for the sliding average')
     241    disp('number of images in a slice smaller than the proposed number of images for the sliding average')
    285242    return
    286243end
    287244halfnbaver=floor(nbaver/2); % half width (in unit of bursts) of the sliding background
     245
     246
     247%% File relabeling documented by the xml file
     248CheckRelabel=isfield(Param,'FileSeries' );
     249
     250%% Input file info
     251if CheckRelabel
     252      [RootFileOut,FileIndexString]=index2filename(Param.FileSeries,Param.IndexRange.first_i,j_indices(1),NbField_j);
     253       FirstFileName=fullfile(RootPath,SubDir,[RootFileOut FileIndexString FileExt]);
     254else
     255FirstFileName=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,Param.IndexRange.first_i,[],j_indices(1));%get first file name
     256RootFileOut=RootFile;
     257end
     258[FileInfo,MovieObject]=get_file_info(FirstFileName);
     259FileType=FileInfo.FileType;
     260if isfield(FileInfo,'NumberOfFrames') && FileInfo.NumberOfFrames >1
     261    if isempty(regexp(NomType,'1$', 'once'))% no file indexing
     262        frame_index=i_indices;% the index i denotes the frame number in a movie, no index j
     263    else
     264        frame_index=j_indices;% the index j denotes the frame number in a movie
     265        MovieObject=[]; %not a single video object
     266    end
     267else
     268    frame_index=ones(1,nbfield);
     269end
     270
     271%% output file naming
     272FileExtOut='.png'; % write result as .png images for image inputsFileInfo.FileType='image'
     273if strcmp(FileInfo.FileType,'image')
     274    NomTypeOut=NomType;
     275elseif NbField_j==1
     276    NomTypeOut='_1';
     277else
     278    NomTypeOut='_1_1';% case of purely numerical indexing
     279end
     280OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     281OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
    288282
    289283%% calculate absolute brightness rank
     
    294288
    295289%% prealocate memory for the sliding background
    296 try
    297     Afirst=read_image(filecell{1,1},FileType{1},MovieObject{1},frame_index{1}(1));
    298     [npy,npx,nbcolor]=size(Afirst);% the argument nbcolor is important to get npx right for color images
    299     if strcmp(class(Afirst),'uint8') % case of 8bit images
    300         Ak=zeros(npy,npx,nbaver_ima,'uint8'); %prealocate memory
    301         Asort=zeros(npy,npx,nbaver_ima,'uint8'); %prealocate memory
    302     else
    303         Ak=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
    304         Asort=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
    305     end
    306 catch ME
    307     msgbox_uvmat('ERROR',['sub_background/read_image/' ME.message])
    308     return
    309 end
    310 
    311 %selection of frame indices
     290Ak=zeros(FileInfo.Height,FileInfo.Width,nbaver_ima,['uint' num2str(FileInfo.BitDepth)]); %prealocate memory   
     291
     292%% selection of frame indices
    312293if Param.ActionInput.CheckVolume
    313294    nbfield=floor(nbfield/NbSlice_j)*NbSlice_j;% truncate the total number of frames in case of incomplete series
     
    326307%%%%%%%  LOOP ON SLICES %%%%%%%
    327308for j_slice=1:NbSlice
    328     %% select the series of i indices to process
    329  %   indselect=j_slice:step*NbSlice_j:nbfield;% select file indices of the slice
    330 %     for ifield=1:step-1
    331 %         indselect=[indselect;indselect(end,:)+NbSlice];
    332 %     end
    333    
     309
    334310    %% read the first series of nbaver_ima images and sort by luminosity at each pixel
    335311    for ifield = 1:nbaver_ima
    336         ifile=indselect(jslice,ifield);
    337         filename=filecell{1,ifile};
    338         Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile));
     312        ifile=indselect(j_slice,ifield);
     313        %filename=filecell{1,ifile};
     314        if CheckRelabel
     315            [RootFile,FileIndexString,FrameIndex]=index2filename(Param.FileSeries,i_indices(ifile),j_indices(ifile),NbField_j);
     316            filename=fullfile(RootPath,SubDir,[RootFile FileIndexString FileExt]);
     317        else
     318            filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i_indices(ifile),[],j_indices(ifile));
     319            FrameIndex=frame_index(ifile);
     320        end
     321        Aread=read_image(filename,FileType,MovieObject,FrameIndex);
    339322        if ndims(Aread)==3%color images
    340323            Aread=sum(double(Aread),3);% take the sum of color components
     
    344327    Asort=sort(Ak,3);%sort the luminosity of images at each point
    345328    B=Asort(:,:,rank);%background image
    346    
     329
    347330    %% substract the first background image to the first images
    348     display( 'first background image will be substracted')
     331    disp( 'first background image will be substracted')
    349332    for ifield=1:step*(halfnbaver+1)% nbre of images treated by the first background image
    350333        Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image
    351334        Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor
    352         ifile=indselect(jslice,ifield);
    353         j1=1;
    354         if ~isempty(j1_series{1})
    355             j1=j1_series{1}(ifile);
    356         end
    357         newname=fullfile_uvmat(OutputPath,OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
    358        
     335        ifile=indselect(j_slice,ifield);
     336        newname=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,FileExtOut,NomTypeOut,i_indices(ifile),[],j_indices(ifile));
     337
    359338        %write result file
    360339        if ~isequal(Param.ActionInput.SaturationValue,0)
     
    362341            imwrite(C,newname,'BitDepth',16); % save the new image
    363342        else
    364             if ~isfield(FileInfo{1},'BitDepth')
    365                 FileInfo{1}.BitDepth=16;
    366             end
    367             if isequal(FileInfo{1}.BitDepth,16)
     343            if isequal(FileInfo.BitDepth,16)
    368344                C=uint16(Acor);
    369345                imwrite(C,newname,'BitDepth',16); % save the new image
     
    373349            end
    374350        end
    375         display([newname ' written'])
    376     end
    377    
     351        disp([newname ' written'])
     352    end
     353
    378354    %% repeat the operation on a sliding series of images
    379     display('sliding background image will be substracted')
     355    disp('sliding background image will be substracted')
    380356    if nbfield_series > nbaver_ima
    381357        for ifield = step*(halfnbaver+1):step:nbfield_series-step*(halfnbaver+1)% ifield +iburst=index of the current processed image
    382             update_waitbar(WaitbarHandle,ifield/nbfield_series)
     358            %             update_waitbar(WaitbarHandle,ifield/nbfield_series)
    383359            if  ~isempty(RUNHandle)&&~strcmp(get(RUNHandle,'BusyAction'),'queue')
    384360                disp('program stopped by user')
     
    386362            end
    387363            if nbaver_ima>step
    388             Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step)
     364                Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step)
    389365            end
    390366            %incorporate next burst in the current image series
    391367            for iburst=1:step
    392                 ifile=indselect(jslice,ifield+iburst+step*halfnbaver);
    393                 j1=1;
    394                 if ~isempty(j1_series{1})
    395                     j1=j1_series{1}(ifile);
     368                ifile=indselect(j_slice,ifield+iburst+step*halfnbaver);
     369                if CheckRelabel
     370                    [RootFile,FileIndexString,FrameIndex]=index2filename(Param.FileSeries,i_indices(ifile),j_indices(ifile),NbField_j);
     371                    filename=fullfile(RootPath,SubDir,[RootFile FileIndexString FileExt]);
     372                else
     373                    filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i_indices(ifile),[],j_indices(ifile));
     374                    FrameIndex=frame_index(ifile);
    396375                end
    397                
    398                 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1);
    399                 Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile));
     376                Aread=read_image(filename,FileType,MovieObject,FrameIndex);
    400377                if ndims(Aread)==3%case of color images
    401378                    Aread=sum(double(Aread),3);% take the sum of color components
     
    409386                Acor=double(Ak(:,:,step*halfnbaver+iburst))-double(B); %the current image has been already read ans stored as index step*halfnbaver+iburst in the current series
    410387                Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor
    411                 ifile=indselect(jslice,ifield+iburst);
    412                 if ~isempty(j1_series{1})
    413                     j1=j1_series{1}(ifile);
    414                 end
    415                 newname=fullfile_uvmat(OutputPath,OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
     388                ifile=indselect(j_slice,ifield+iburst);
     389                newname=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,FileExtOut,NomTypeOut,i_indices(ifile),[],j_indices(ifile));
    416390                %write result file
    417391                if ~isequal(Param.ActionInput.SaturationValue,0)
     
    419393                    imwrite(C,newname,'BitDepth',16); % save the new image
    420394                else
    421                     if isequal(FileInfo{1}.BitDepth,16)
     395                    if isequal(FileInfo.BitDepth,16)
    422396                        C=uint16(Acor);
    423397                        imwrite(C,newname,'BitDepth',16); % save the new image
     
    427401                    end
    428402                end
    429                 display([newname ' written'])
    430             end
    431         end
    432     end
    433    
     403                disp([newname ' written'])
     404            end
     405        end
     406    end
     407
    434408    %% substract the background from the last images
    435     display('last background image will be substracted')
     409    disp('last background image will be substracted')
    436410    for  ifield=nbfield_series-step*halfnbaver+1:nbfield_series
    437411        Acor=double(Ak(:,:,ifield-nbfield_series+step*(2*halfnbaver+1)))-double(B);
    438412        Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor
    439         ifile=indselect(jslice,ifield);
    440         if ~isempty(j1_series{1})
    441             j1=j1_series{1}(ifile);
    442         end
    443         newname=fullfile_uvmat(OutputPath,OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
     413        ifile=indselect(j_slice,ifield);
     414        newname=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,FileExtOut,NomTypeOut,i_indices(ifile),[],j_indices(ifile));
    444415        %write result file
    445416        if ~isequal(Param.ActionInput.SaturationValue,0)
     
    447418            imwrite(C,newname,'BitDepth',16); % save the new image
    448419        else
    449             if isequal(FileInfo{1}.BitDepth,16)
     420            if isequal(FileInfo.BitDepth,16)
    450421                C=uint16(Acor);
    451422                imwrite(C,newname,'BitDepth',16); % save the new image
     
    455426            end
    456427        end
    457         display([newname ' written'])
     428        disp([newname ' written'])
    458429    end
    459430end
  • trunk/src/uvmat.m

    r1176 r1178  
    221221%% EXPORT menu
    222222export_menu={'as field in workspace';'in new figure';'on existing axis';'make movie';'more...'};
    223 export_path=fullfile(path_uvmat,'export_fct');
     223%export_path=fullfile(path_uvmat,'export_fct');
    224224
    225225%% load the list of previously browsed files in menus Open, Open_1 and TransformName
     
    625625        hveccolor=axes('Position',[0.93 0.1 0.02 0.5]);
    626626        ima=permute(get(handles.VecColBar,'CData'),[2 1 3]);
    627         ymin=str2num(get(handles.num_MinVec,'String'));
    628         ymax=str2num(get(handles.num_MaxVec,'String'));
     627        ymin=str2double(get(handles.num_MinVec,'String'));
     628        ymax=str2double(get(handles.num_MaxVec,'String'));
    629629        set(hveccolor,'YLim',[ymin ymax])
    630630        imagesc([0 1],[ymin ymax],ima)
     
    862862huvmat=findobj(allchild(0),'Tag','uvmat');
    863863hhuvmat=guidata(huvmat);
    864 increment=str2num(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat
     864increment=str2double(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat
    865865set(hhuvmat.STOP,'Visible','on')
    866866set(hhuvmat.speed,'Visible','on')
     
    14091409hset_slice=get(hObject, 'parent');
    14101410hZ=findobj(hset_slice,'Tag','num_Z_1');
    1411 Z_plane=str2num(get(hZ,'String'));% set of Z positions explicitly entered as a Matlab vector
     1411Z_plane=str2double(get(hZ,'String'));% set of Z positions explicitly entered as a Matlab vector
    14121412SliceData=read_GUI(hset_slice);
    14131413Slice.NbSlice=SliceData.NbSlice;
     
    20662066end
    20672067
    2068 % %------------------------------------------------------------------------
    2069 % % -- open the GUI civ.fig for PIV
    2070 % function MenuCIVx_Callback(hObject, eventdata, handles)
    2071 % %------------------------------------------------------------------------
    2072 %  [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    2073 %  FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    2074 % civ(FileName);% interface de civ(not in the uvmat file)
    2075 
    20762068%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    20772069% MenuHelp Callback
     
    20832075
    20842076
    2085 
    2086 
    2087 
    2088 
    2089 
    2090 
    2091 
    2092 
    20932077%------------------------------------------------------------------------
    20942078% --- Called by action in FileIndex edit box
     
    20962080%------------------------------------------------------------------------
    20972081[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
     2082UvData=get(handles.uvmat,'UserData');
     2083check_index=false;
     2084if isfield(UvData,'XmlData')&& ~isempty(UvData.XmlData)
     2085    if isfield(UvData.XmlData{1},'FileSeries')% case of frame indexing documented by the xml file (PCO)
     2086        if strcmp(UvData.XmlData{1}.FileSeries.Convention,'PCO')
     2087            i1_mod=i1*UvData.XmlData{1}.FileSeries.NbFramePerFile+1;
     2088            if isfield(UvData.XmlData{1},'Time')
     2089                [NbField,NbField_j]=size(UvData.XmlData{1}.Time);
     2090                j1=mod(i1_mod,NbField_j-1)+1;
     2091                i1_mod=floor(i1_mod/(NbField_j -1))+1;
     2092            end
     2093            set(handles.i1,'String',num2str(i1_mod));%update the counters
     2094            set(handles.j1,'String',num2str(j1));%update the counters
     2095            check_index=true;
     2096        end
     2097    end
     2098end
     2099if ~check_index
    20982100set(handles.i1,'String',num2str(i1));%update the counters
    20992101set(handles.i2,'String',num2str(i2));
    21002102set(handles.j1,'String',num2str(j1));
    21012103set(handles.j2,'String',num2str(j2));
    2102 
     2104end
    21032105
    21042106%------------------------------------------------------------------------
     
    21062108function NomType_Callback(hObject, eventdata, handles)
    21072109%------------------------------------------------------------------------
    2108 i1=str2num(get(handles.i1,'String'));
    2109 i2=str2num(get(handles.i2,'String'));
    2110 j1=str2num(get(handles.j1,'String'));
    2111 j2=str2num(get(handles.j2,'String'));
     2110i1=str2double(get(handles.i1,'String'));
     2111i2=str2double(get(handles.i2,'String'));
     2112j1=str2double(get(handles.j1,'String'));
     2113j2=str2double(get(handles.j2,'String'));
    21122114NomType=get(hObject,'String');
    21132115if strcmp(NomType,'level')
    2114     FileIndex=str2num(get(handles.i1,'String'));
     2116    FileIndex=str2double(get(handles.i1,'String'));
    21152117else
    21162118FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2);
     
    21242126function NomType_1_Callback(hObject, eventdata, handles)
    21252127%------------------------------------------------------------------------
    2126 i1=str2num(get(handles.i1,'String'));
    2127 i2=str2num(get(handles.i2,'String'));
    2128 j1=str2num(get(handles.j1,'String'));
    2129 j2=str2num(get(handles.j2,'String'));
     2128i1=str2double(get(handles.i1,'String'));
     2129i2=str2double(get(handles.i2,'String'));
     2130j1=str2double(get(handles.j1,'String'));
     2131j2=str2double(get(handles.j2,'String'));
    21302132NomType=get(hObject,'String');
    21312133if strcmp(NomType,'level')
    2132     FileIndex=str2num(get(handles.i1,'String'));
     2134    FileIndex=str2double(get(handles.i1,'String'));
    21332135else
    21342136FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2);
     
    21482150[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    21492151% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    2150 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     2152%[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    21512153errormsg='';
    21522154if isempty(RootFile)
     
    21652167else
    21662168    % initiate the input file series and refresh the current field view:
    2167     errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,1);
     2169    [FileInfo,VideoObject]=get_file_info(fullfile(RootPath,SubDir,[RootFile FileIndices FileExt]));
     2170    errormsg=update_rootinfo(handles,RootPath,SubDir,[RootFile FileIndices FileExt],FileInfo,VideoObject,1);
    21682171end
    21692172
     
    21882191    else
    21892192        % initiate the input file series and refresh the current field view:
    2190         errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,2);
     2193        errormsg=update_rootinfo(handles,RootPath,SubDir,FileName,FileInfo,MovieObject,2);
    21912194    end
    21922195end
     
    22002203function errormsg=display_file_name(handles,fileinput,input_line)
    22012204%------------------------------------------------------------------------
    2202 %% look for the input file existence
     2205%% look for the input file existence and properties in the structure FileInfo
    22032206errormsg='';%default
    22042207if isempty(regexp(fileinput,'^http')) && ~exist(fileinput,'file')
     
    22062209    msgbox_uvmat('ERROR',errormsg)
    22072210    return
     2211end
     2212[FileInfo,MovieObject]=get_file_info(fileinput);
     2213FieldType=FileInfo.FieldType;
     2214
     2215%% case of isolated input files without series
     2216switch FieldType
     2217    case ''
     2218        msgbox_uvmat('ERROR','invalid input file type')
     2219        return
     2220    case 'txt'
     2221        edit(fileinput)
     2222        return
     2223    case 'figure'                           %display matlab figure
     2224        hfig=open(fileinput);
     2225        set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
     2226        set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
     2227        set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
     2228        return
     2229    case 'xml'                % edit xml files
     2230        t=xmltree(fileinput);
     2231        % the xml file marks a project or project link, open datatree_browser
     2232        if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir')
     2233            datatree_browser(fileinput)
     2234        else % other xml file, open the xml editor
     2235            editxml(fileinput);
     2236        end
     2237        return
     2238    case 'xls'% Excel file opended by editxml
     2239        editxml(fileinput);
     2240        return
    22082241end
    22092242
     
    22392272drawnow
    22402273
     2274[RootPath,SubDir,RootFile,i1,i2,j1,j2,~,NomType]=fileparts_uvmat(fileinput);
     2275[~,FileName,FileExt]=fileparts(fileinput);
     2276
     2277
    22412278%% detect root name, nomenclature and indices in the input file name:
    2242 [FilePath,FileName,FileExt]=fileparts(fileinput);
     2279%[FilePath,FileName,FileExt]=fileparts(fileinput);
    22432280% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    22442281% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    2245 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=...
    2246     find_file_series(FilePath,[FileName FileExt]);
    2247 
    2248 %% open the file or fill the GUI uvmat according to the detected file type
    2249 FieldType=FileInfo.FieldType;
    2250 switch FieldType
    2251     case ''
    2252         msgbox_uvmat('ERROR','invalid input file type')
    2253         return
    2254     case 'txt'
    2255         edit(fileinput)
    2256         return
    2257     case 'figure'                           %display matlab figure
    2258         hfig=open(fileinput);
    2259         set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
    2260         set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
    2261         set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
    2262         return
    2263     case 'xml'                % edit xml files
    2264         t=xmltree(fileinput);
    2265         % the xml file marks a project or project link, open datatree_browser
    2266         if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir')
    2267             datatree_browser(fileinput)
    2268         else % other xml file, open the xml editor
    2269             editxml(fileinput);
    2270         end
    2271         return
    2272     case 'xls'% Excel file opended by editxml
    2273         editxml(fileinput);
    2274         return
    2275     otherwise
    2276         set(handles_RootPath,'String',RootPath);
    2277         set(handles_SubDir,'String',['/' SubDir]);
    2278         set(handles_RootFile,'String',['/' RootFile]); %display the separator
    2279         if isempty(regexp(RootPath,'^http://', 'once'))
    2280             rootname=fullfile(RootPath,SubDir,RootFile);
     2282
     2283set(handles_RootPath,'String',RootPath);
     2284set(handles_SubDir,'String',['/' SubDir]);
     2285set(handles_RootFile,'String',['/' RootFile]); %display the separator
     2286if isempty(regexp(RootPath,'^http://', 'once'))
     2287    rootname=fullfile(RootPath,SubDir,RootFile);
     2288else
     2289    rootname=[RootPath '/' SubDir '/' RootFile];
     2290end
     2291indices=fileinput(length(rootname)+1:end);
     2292indices(end-length(FileExt)+1:end)=[]; %remove extension
     2293set(handles_FileIndex,'String',indices);
     2294set(handles_NomType,'String',NomType);
     2295set(handles_FileExt,'String',FileExt);
     2296if input_line==1
     2297    % fill file index counters if the first file series is opened
     2298    set(handles.i1,'String',num2str(i1));
     2299    set(handles.i2,'String',num2str(i2));
     2300    set(handles.j1,'String',num2stra(j1,NomType));
     2301    set(handles.j2,'String',num2stra(j2,NomType));
     2302    if isfield(FileInfo,'MaskFile')
     2303        if exist(FileInfo.MaskFile)
     2304            set(handles.CheckMask,'Value',1)
    22812305        else
    2282             rootname=[RootPath '/' SubDir '/' RootFile];
    2283         end
    2284         indices=fileinput(length(rootname)+1:end);
    2285         indices(end-length(FileExt)+1:end)=[]; %remove extension
    2286         set(handles_FileIndex,'String',indices);
    2287         set(handles_NomType,'String',NomType);
    2288         set(handles_FileExt,'String',FileExt);
    2289         if input_line==1
    2290             % fill file index counters if the first file series is opened
    2291             set(handles.i1,'String',num2str(i1));
    2292             set(handles.i2,'String',num2str(i2));
    2293             set(handles.j1,'String',num2stra(j1,NomType));
    2294             set(handles.j2,'String',num2stra(j2,NomType));
    2295             if isfield(FileInfo,'MaskFile')
    2296                 if exist(FileInfo.MaskFile)
    2297                 set(handles.CheckMask,'Value',1)
    2298                 else
    2299                     set(handles.CheckMask,'Value',0)
    2300                 end
    2301                  Mask.File=FileInfo.MaskFile;
    2302                  if isfield(FileInfo,'MaskNbSlice')
    2303                      Mask.NbSlice=FileInfo.MaskNbSlice;
    2304                  elseif isfield(FileInfo,'VolumeScan')
    2305                      Mask.VolumeScan=FileInfo.VolumeScan;
    2306                  end 
    2307                  set(handles.CheckMask,'UserData', Mask)
    2308             else
    2309                 set(handles.CheckMask,'Value',0)
    2310                 CheckMask_Callback(handles.CheckMask, [], handles)
    2311             end                         
    2312         else %read the current field index to synchronise with the first series
    2313             i1_s=str2num(get(handles.i1,'String'));
    2314             i2_0=str2num(get(handles.i2,'String'));
    2315             if ~isempty(i2_0)
    2316                 i2_s=i2_0;
    2317             else
    2318                 i2_s=i2;
    2319             end
    2320             j1_0=stra2num(get(handles.j1,'String'));
    2321             if ~isempty(j1_0)
    2322                 j1_s=j1_0;
    2323             else
    2324                 j1_s=j1;
    2325             end
    2326             j2_0=stra2num(get(handles.j2,'String'));
    2327             if ~isempty(j2_0)
    2328                 j2_s=j2_0;
    2329             else
    2330                 j2_s=j2;
    2331             end
    2332         end
    2333        
    2334         % synchronise indices of the second  input file if it exists
    2335         if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
    2336             Input=read_GUI(handles.InputFile);
    2337             if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"')
    2338                 Input.RootPath_1=Input.RootPath;
    2339             end
    2340             if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"')
    2341                 Input.SubDir_1=Input.SubDir;
    2342             end
    2343             if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"')
    2344                 Input.RootFile_1=Input.RootFile;
    2345             end
    2346             if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"')
    2347                 Input.FileExt_1=Input.FileExt;
    2348             end
    2349             if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"')
    2350                 Input.NomType_1=Input.NomType;
    2351             end
    2352             %updtate the indices of the second field series to correspond to the newly opened one
    2353             FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1_s,i2_s,j1_s,j2_s);
    2354             if exist(FileName_1,'file')
    2355                 FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s);
    2356             else
    2357                 FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2);
    2358 %                 msgbox_uvmat('WARNING','unable to synchronise the indices of the two series')
    2359             end
    2360             set(handles.FileIndex_1,'String',FileIndex_1)
    2361         end
    2362        
    2363         %enable other menus
    2364         set(handles.MenuExport,'Enable','on')
    2365         set(handles.MenuExportFigure,'Enable','on')
    2366         set(handles.MenuExportMovie,'Enable','on')
    2367         set(handles.MenuTools,'Enable','on')
    2368        
    2369         % initiate input file series and inputfilerefresh the current field view:
    2370         update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,input_line);
    2371 end
     2306            set(handles.CheckMask,'Value',0)
     2307        end
     2308        Mask.File=FileInfo.MaskFile;
     2309        if isfield(FileInfo,'MaskNbSlice')
     2310            Mask.NbSlice=FileInfo.MaskNbSlice;
     2311        elseif isfield(FileInfo,'VolumeScan')
     2312            Mask.VolumeScan=FileInfo.VolumeScan;
     2313end
     2314set(handles.CheckMask,'UserData', Mask)
     2315    else
     2316        set(handles.CheckMask,'Value',0)
     2317        CheckMask_Callback(handles.CheckMask, [], handles)
     2318end
     2319else %read the current field index to synchronise with the first series
     2320    i1_s=str2double(get(handles.i1,'String'));
     2321    i2_0=str2double(get(handles.i2,'String'));
     2322    if ~isempty(i2_0)
     2323        i2_s=i2_0;
     2324    else
     2325        i2_s=i2;
     2326    end
     2327    j1_0=stra2num(get(handles.j1,'String'));
     2328    if ~isempty(j1_0)
     2329        j1_s=j1_0;
     2330    else
     2331        j1_s=j1;
     2332    end
     2333    j2_0=stra2num(get(handles.j2,'String'));
     2334    if ~isempty(j2_0)
     2335        j2_s=j2_0;
     2336    else
     2337        j2_s=j2;
     2338    end
     2339end
     2340
     2341% synchronise indices of the second  input file if it exists
     2342if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
     2343    Input=read_GUI(handles.InputFile);
     2344    if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"')
     2345        Input.RootPath_1=Input.RootPath;
     2346    end
     2347    if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"')
     2348        Input.SubDir_1=Input.SubDir;
     2349    end
     2350    if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"')
     2351        Input.RootFile_1=Input.RootFile;
     2352    end
     2353    if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"')
     2354        Input.FileExt_1=Input.FileExt;
     2355    end
     2356    if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"')
     2357        Input.NomType_1=Input.NomType;
     2358    end
     2359    %updtate the indices of the second field series to correspond to the newly opened one
     2360    FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1_s,i2_s,j1_s,j2_s);
     2361    if exist(FileName_1,'file')
     2362        FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s);
     2363    else
     2364        FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2);
     2365        %                 msgbox_uvmat('WARNING','unable to synchronise the indices of the two series')
     2366    end
     2367    set(handles.FileIndex_1,'String',FileIndex_1)
     2368end
     2369
     2370%enable other menus
     2371set(handles.MenuExport,'Enable','on')
     2372set(handles.MenuExportFigure,'Enable','on')
     2373set(handles.MenuExportMovie,'Enable','on')
     2374set(handles.MenuTools,'Enable','on')
     2375
     2376% initiate input file series and inputfilerefresh the current field view:
     2377update_rootinfo(handles,RootPath,SubDir,[FileName FileExt],FileInfo, MovieObject,input_line);
     2378
    23722379
    23732380%% update list of recent files in the menubar and save it for future opening
     
    23962403% --- Update information about a new field series (indices to scan, timing,
    23972404%     calibration from an xml file, then inputfilerefresh current plots
    2398 function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,input_line)
     2405%function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,input_line)
     2406function errormsg=update_rootinfo(handles,RootPath,SubDir,FileName,FileInfo,VideoObject,input_line)
    23992407%------------------------------------------------------------------------
    24002408errormsg=''; %default error msg
     
    24102418end
    24112419set(handles.FixVelType,'Value',0); %desactivate fixed veltype by default
     2420
     2421%% look for the xml file and read it
     2422XmlFileName=find_imadoc(RootPath,SubDir);
     2423[~,XmlName]=fileparts(XmlFileName);
     2424warntext='';%default warning message
     2425NbSlice=1;%default
     2426%CheckImaDoc=false;
     2427TimeUnit='';%default
     2428TimeName='';%default
     2429CheckIndexing=false;%default
     2430if isempty(XmlFileName)
     2431    set(handles.view_xml,'Visible','off')
     2432else
     2433    set(handles.view_xml,'Visible','on')
     2434    set(handles.view_xml,'BackgroundColor',[1 1 0])% paint  to yellow color to indicate reading of the xml file
     2435    set(handles.view_xml,'String','view xml')
     2436    drawnow
     2437    [XmlData,warntext]=imadoc2struct(XmlFileName);
     2438    if ~isempty(warntext)
     2439        msgbox_uvmat('WARNING',warntext)
     2440    end
     2441    if ~isempty(XmlData)
     2442        %CheckImaDoc=true;
     2443        if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
     2444            TimeUnit=XmlData.TimeUnit;
     2445        end
     2446        if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
     2447            TimeName='xml';%
     2448            if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1
     2449                sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file
     2450                ind_start=1;
     2451            else
     2452                sizDti=size(XmlData.Time,1);% case starting with index 0
     2453                ind_start=0;
     2454            end
     2455            if isfield(XmlData,'FileSeries')
     2456                if strcmp(XmlName,SubDir)% frame indexing documented from the xml file (case PCO)
     2457                    CheckIndexing=true;
     2458                else
     2459                    XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series
     2460                end
     2461            end
     2462        end
     2463    end
     2464    set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white
     2465    set(handles.view_xml,'String','view xml')% indicate that a xml file has been detected
     2466    drawnow
     2467    if isfield(XmlData,'Slice') && isfield(XmlData.Slice,'CheckVolumeScan') && isequal(XmlData.Slice.CheckVolumeScan,1)
     2468        set (handles.slices,'String','volume')
     2469    end
     2470end
     2471
     2472%% get the file series
     2473MovieObject=[];
     2474if strcmp(TimeName,'xml') && strcmp(XmlName,SubDir)% get the image series info from the xml file
     2475    [nbfield,nbfield_j]=size(XmlData.Time);
     2476    nbfield=nbfield-1; %remove the possible index 0
     2477    nbfield_j=nbfield_j-1; %remove the possible index 0
     2478        i1_series=zeros(nbfield,nbfield_j,1);
     2479    i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j);
     2480    i2_series=i1_series;
     2481    if nbfield_j==1
     2482        j1_series=[];
     2483    else
     2484    j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j);
     2485    end
     2486    j2_series=j1_series;
     2487else % scan the input folder to get the list of existing files
     2488    [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=...
     2489        find_file_series(fullfile(RootPath,SubDir),FileName);
     2490    nbfield=max(max(max(i2_series)));% total number of fields (i index)
     2491    if isempty(nbfield)
     2492        nbfield=max(max(max(i1_series)));
     2493    end
     2494    nbfield_j=max(max(max(j2_series)));% number of fields along j index
     2495    if isempty(nbfield_j)
     2496        nbfield_j=max(max(max(j1_series)));
     2497    end
     2498    if input_line==1
     2499    set(handles.NomType,'String',NomType)
     2500    else
     2501         set(handles.NomType_1,'String',NomType)
     2502    end
     2503end
     2504if CheckIndexing
     2505    i1=str2double(get(handles.FileIndex,'String'));
     2506    if isnan(i1)
     2507        i1=1;
     2508    else
     2509    i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index
     2510    end
     2511    if strcmp(TimeName,'xml')% indices i and j
     2512                j1=mod(i1-1,nbfield_j)+1;
     2513                i1=floor((i1-1)/nbfield_j)+1;
     2514                set(handles.j1,'String',num2str(j1))
     2515    end
     2516    set(handles.i1,'String',num2str(i1))
     2517end
     2518
    24122519
    24132520%% record info in UserData of the figure uvmat
     
    24172524%UvData.FileType{input_line}=FileInfo.FileType;
    24182525UvData.FileInfo{input_line}=FileInfo;
    2419 UvData.MovieObject{input_line}=VideoObject;
     2526UvData.MovieObject{input_line}=MovieObject;
    24202527UvData.i1_series{input_line}=i1_series;
    24212528UvData.i2_series{input_line}=i2_series;
    24222529UvData.j1_series{input_line}=j1_series;
    24232530UvData.j2_series{input_line}=j2_series;
    2424 nbfield=max(max(max(i2_series)));% total number of fields (i index)
    2425 if isempty(nbfield)
    2426     nbfield=max(max(max(i1_series)));
    2427 end
    2428 nbfield_j=max(max(max(j2_series)));% number of fields along j index
    2429 if isempty(nbfield_j)
    2430     nbfield_j=max(max(max(j1_series)));
    2431 end
     2531
    24322532
    24332533%% read timing and total frame number from the current file (e.g. movie files)
    2434 TimeUnit='';%default
    2435 TimeName='';%default
    2436 XmlData.Time=[];%default
    24372534ColorType='falsecolor'; %default
    24382535if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
     
    24682565else
    24692566    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
    2470 end
    2471 XmlFileName=find_imadoc(RootPath,SubDir);
    2472 [tild,tild,DocExt]=fileparts(XmlFileName);
    2473 warntext='';%default warning message
    2474 NbSlice=1;%default
    2475 ImaDoc_str='';
    2476 if ~isempty(XmlFileName)
    2477     set(handles.view_xml,'Visible','on')
    2478     set(handles.view_xml,'BackgroundColor',[1 1 0])% paint  to yellow color to indicate reading of the xml file
    2479     set(handles.view_xml,'String','view .xml')
    2480     drawnow
    2481     [XmlDataRead,warntext]=imadoc2struct(XmlFileName);
    2482     if ~isempty(warntext)
    2483         msgbox_uvmat('WARNING',warntext)
    2484     end
    2485     if ~isempty(XmlDataRead)
    2486         ImaDoc_str=['view ' DocExt];  % DocExt= '.xml' or .civ (obsolete case)
    2487         if isfield(XmlDataRead,'TimeUnit')&& ~isempty(XmlDataRead.TimeUnit)
    2488             TimeUnit=XmlDataRead.TimeUnit;
    2489         end
    2490         if isfield(XmlDataRead,'Time')&& ~isempty(XmlDataRead.Time)
    2491             XmlData.Time=XmlDataRead.Time;
    2492             if XmlDataRead.Time(1,:)==XmlDataRead.Time(2,:)% case starting with index 1
    2493                 sizDti=size(XmlDataRead.Time,1)-1;%size of the time vector explicitly defined in the xml file
    2494                 ind_start=1;
    2495             else
    2496                 sizDti=size(XmlDataRead.Time,1);% case starting with index 0
    2497                 ind_start=0;
    2498             end
    2499         end
    2500         set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white
    2501         drawnow
    2502         if isfield(XmlDataRead, 'GeometryCalib') && ~isempty(XmlDataRead.GeometryCalib)
    2503             XmlData.GeometryCalib=XmlDataRead.GeometryCalib;     
    2504         end
    2505         XmlData.Slice=XmlData.GeometryCalib;%default
    2506         if isfield(XmlDataRead, 'Slice') && ~isempty(XmlDataRead.Slice)
    2507             XmlData.Slice=XmlDataRead.Slice;
    2508         end
    2509         if isfield(XmlData.Slice,'CheckVolumeScan') && isequal(XmlData.Slice.CheckVolumeScan,1)
    2510                 set (handles.slices,'String','volume')
    2511             end
    2512         if isfield(XmlDataRead, 'LIFCalib')
    2513             XmlData.LIFCalib=XmlDataRead.LIFCalib;
    2514         end
    2515     end
    2516 end
    2517 if isempty(ImaDoc_str)
    2518     set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected
    2519 else
    2520     set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected
    25212567end
    25222568
     
    25402586
    25412587%% store last index in handles.MaxIndex_i and .MaxIndex_j
    2542 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
    2543     %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    2544     if isequal(size(XmlData.Time,1),1)
    2545         XmlData.Time=(XmlData.Time)';
    2546     end
    2547 end
    25482588last_i_cell=get(handles.MaxIndex_i,'String');
    25492589if isempty(nbfield)
     
    27942834
    27952835NomType=get(handles.NomType,'String');
     2836UvData=get(handles.uvmat,'UserData');
    27962837
    27972838if strcmp(NomType,'level')
    2798     indices=get(handles.i1,'String');
    2799 else
    2800     indices=get(handles.FileIndex,'String');
    2801     [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex
    2802     switch index_rank
    2803         case 1
    2804             indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2);
    2805         case 2
    2806             indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2);
    2807         case 3
    2808             indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2);
    2809         case 4
    2810             indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String')));
    2811     end
    2812 end
    2813 set(handles.FileIndex,'String',indices)
     2839    index_string=get(handles.i1,'String');
     2840else
     2841    index_string=get(handles.FileIndex,'String');
     2842    if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'FileSeries')
     2843        i1=str2double(get(handles.i1,'String'));
     2844        j1=str2double(get(handles.j1,'String'));
     2845        NbField_j_cell=get(handles.MaxIndex_j,'String');
     2846        NbField_j=str2double(NbField_j_cell{1});
     2847        [RootFile,index_string,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j);
     2848        set(handles.RootFile,'String',RootFile)
     2849    else
     2850        [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(index_string);% the index_string for the second series taken from FileIndex
     2851        switch index_rank
     2852            case 1
     2853                index_string=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2);
     2854            case 2
     2855                index_string=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2);
     2856            case 3
     2857                index_string=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2);
     2858            case 4
     2859                index_string=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String')));
     2860        end
     2861    end
     2862end
     2863set(handles.FileIndex,'String',index_string)
    28142864
    28152865% update the second index if relevant
    28162866if strcmp(get(handles.FileIndex_1,'Visible'),'on')
    28172867    NomType_1=get(handles.NomType_1,'String');
    2818     indices_1=get(handles.FileIndex_1,'String');
    2819     [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(indices_1);% the indices for the second series taken from FileIndex_1
     2868    index_string_1=get(handles.FileIndex_1,'String');
     2869    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(index_string_1);% the index_string for the second series taken from FileIndex_1
    28202870    switch index_rank
    28212871        case 1
    2822             indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1);
     2872            index_string_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1);
    28232873        case 2
    2824             indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1);
     2874            index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1);
    28252875        case 3
    2826             indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1);
     2876            index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1);
    28272877        case 4
    2828             indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String')));
    2829     end
    2830     set(handles.FileIndex_1,'String',indices_1)
     2878            index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String')));
     2879    end
     2880    set(handles.FileIndex_1,'String',index_string_1)
    28312881    set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
    28322882end
     
    28842934end
    28852935option=get(handles.view_xml,'String');
    2886 if isequal(option,'view .xml')
     2936if isequal(option,'view xml')
    28872937    FileXml=fullfile(RootPath,[SubDir '.xml']);
    28882938    if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir
     
    29823032    if isfield(MaskInfo,'NbSlice')&& ~isempty(MaskInfo.NbSlice)
    29833033        if isfield(MaskInfo,'VolumeScan') &&  MaskInfo.VolumeScan
    2984             MaskIndex_i=str2num(get(handles.j1,'String'));
     3034            MaskIndex_i=str2double(get(handles.j1,'String'));
    29853035        else
    2986             MaskIndex_i=mod(str2num(get(handles.i1,'String'))-1,MaskInfo.NbSlice)+1;
     3036            MaskIndex_i=mod(str2double(get(handles.i1,'String'))-1,MaskInfo.NbSlice)+1;
    29873037        end
    29883038        MaskName=[MaskInfo.File '_' num2str(MaskIndex_i) '.png'];
     
    31743224%------------------------------------------------------------------------
    31753225errormsg='';%default
    3176 %% check for movie pair status
    3177 % movie_status=get(handles.movie_pair,'Value');
    3178 % if movie_status
    3179 %     STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
    3180 % end
    31813226
    31823227%% read the current input file name(s) and field indices
     
    31863231FileExt=InputFile.FileExt;
    31873232NomType=InputFile.NomType;
    3188 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
    3189 if isempty(i1)% no i index set by the input file name
    3190     i1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
    3191 elseif isempty(j1) && strcmp(get(handles.j1,'Visible'),'on')
    3192     j1=str2double(get(handles.j1,'String'));%case of indexed movie
    3193 end
    3194 % if movie_status% we read the second index from the edit box
    3195 %     i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
    3196 %     if strcmp(get(handles.j2,'Visible'),'on')
    3197 %     j2=str2num(get(handles.j2,'String'));%
    3198 %     end
    3199 % end
     3233UvData=get(handles.uvmat,'UserData');
     3234if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')% case of indexing documented by the xml file
     3235    i1=str2double(get(handles.i1,'String'));
     3236    j1=str2double(get(handles.j1,'String'));%read the field indices (for movie, it is not given by the file name)
     3237    i2=[];j2=[];
     3238else
     3239    [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
     3240    if isempty(i1)% no i index set by the input file name
     3241        i1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
     3242    elseif isempty(j1) && strcmp(get(handles.j1,'Visible'),'on')
     3243        j1=str2double(get(handles.j1,'String'));%case of indexed movie
     3244    end
     3245end
    32003246sub_value= get(handles.SubField,'Value');
    32013247if sub_value % a second input file has been entered
     
    32033249    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1
    32043250    if isempty(i1_1)
    3205         i1_1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
     3251        i1_1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
    32063252    elseif isempty(j1_1) && strcmp(get(handles.j1,'Visible'),'on')
    3207         j1_1=str2num(get(handles.j1,'String'));%case of indexed movie
     3253        j1_1=str2double(get(handles.j1,'String'));%case of indexed movie
    32083254    end
    32093255else
     
    32343280        end
    32353281    end
    3236    
     3282
    32373283    % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
    32383284else
    3239     UvData=get(handles.uvmat,'UserData');
    32403285    ref_i=i1;
    32413286    if ~isempty(i2)
     
    32493294        end
    32503295    end
    3251     if isnumeric(increment)
    3252         if get(handles.scan_i,'Value')==1% case of scanning along index i
    3253             ref_i=ref_i+increment;% increment the current reference index i
    3254         else % case of scanning along index j (burst numbers)
    3255             ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used
    3256         end
    3257     else % free increment
    3258         if strcmp(increment,'+')% if runplus or movie is activated
    3259             step=1;
    3260         else
    3261             step=-1;
    3262         end
    3263         if get(handles.scan_i,'Value')==1% case of scanning along index i
     3296
     3297    if strcmp(increment,'+')% if runplus or movie is activated
     3298        step=1;
     3299    else
     3300        step=-1;
     3301    end
     3302    if get(handles.scan_i,'Value')==1% case of scanning along index i
     3303        ref_i=ref_i+step;
     3304        while ref_i>=0  && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0
    32643305            ref_i=ref_i+step;
    3265             while ref_i>=0  && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0
    3266                 ref_i=ref_i+step;
    3267             end
    3268         else % case of scanning along index j (burst numbers)
     3306        end
     3307    else % case of scanning along index j (burst numbers)
     3308        ref_j=ref_j+step;
     3309        while ref_j>=0  && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0
    32693310            ref_j=ref_j+step;
    3270             while ref_j>=0  && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0
    3271                 ref_j=ref_j+step;
    3272             end
    32733311        end
    32743312    end
     
    33043342        j2=UvData.j2_series{1}(ref_indices(end));
    33053343    end
    3306    
     3344
    33073345    % case of a second file series
    33083346    if sub_value
     
    33403378        elseif ref_i_1+1>size(UvData.i1_series{2},3)&&~isempty(InputFile.NomType_1)
    33413379            errormsg='maximum i index reached for the second series (reload the input file to update the index bound)';
    3342         %elseif ref_j_1+1>size(UvData.i1_series{2},2)&&~isempty(InputFile.NomType_1)
    3343          %   errormsg='maximum j index reached for the second series(reload the input file to update the index bound)';
     3380            %elseif ref_j_1+1>size(UvData.i1_series{2},2)&&~isempty(InputFile.NomType_1)
     3381            %   errormsg='maximum j index reached for the second series(reload the input file to update the index bound)';
    33443382        end
    33453383        if ~isempty(errormsg),return,end
     
    34023440    if strcmp(NomType,'level')
    34033441        indices=num2str(i1);
     3442    elseif isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')
     3443        NbField_j_cell=get(handles.MaxIndex_j,'String');
     3444        NbField_j=str2double(NbField_j_cell{1});
     3445        [RootFile,indices,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j);
     3446        set(handles.RootFile,'String',RootFile)
    34043447    else
    34053448        indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
     
    35343577
    35353578%% determine the main input file information for action
    3536 if isempty(regexp(FileName,'^http://', 'once')) &&~exist(FileName,'file')
    3537     errormsg=['input file ' FileName ' does not exist'];
    3538     return
    3539 end
     3579% if isempty(regexp(FileName,'^http://', 'once')) &&~exist(FileName,'file')
     3580%     errormsg=['input file ' FileName ' does not exist'];
     3581%     return
     3582% end
    35403583NomType=get(handles.NomType,'String');
    3541 % NomType_1='';
    3542 % if strcmp(get(handles.NomType_1,'Visible'),'on')
    3543 %     NomType_1=get(handles.NomType_1,'String');
    3544 % end
    35453584%update the z position index
    35463585mode_slice=get(handles.slices,'String');
     
    35643603    for iobj=1:numel(UvData.ProjObject)
    35653604        if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps')
    3566             check_proj_tps=1;% tps projection proposed
     3605            check_proj_tps=1;% tps projection proposedUvData.XmlData
    35673606            break
    35683607        end
     
    35983637        ParamIn=UvData.MovieObject{1};
    35993638    end
     3639end
     3640%% case of special file series (PCO)
     3641if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')
     3642    [RootName,~,Ext]=fileparts(FileName);
     3643    NbField_j_cell=get(handles.MaxIndex_j,'String');
     3644    NbField_j=str2double(NbField_j_cell{1});
     3645    if num_j1>NbField_j
     3646       errormsg=['index j exceeds upper bound ' num2str(NbField_j)];
     3647       return
     3648    elseif num_j1<1
     3649         errormsg='index j smaller that 1';
     3650        return
     3651    end
     3652    [FNameMulti,FileIndexString,frame_index]=index2filename(UvData.XmlData{1}.FileSeries,num_i1,num_j1,NbField_j);
     3653    FileName=fullfile(RootName,[FNameMulti FileIndexString Ext]);
    36003654end
    36013655switch UvData.FileInfo{1}.FieldType
     
    38853939        % TODO: look for time unit attribute
    38863940    elseif ~isempty(regexp(TimeName,'^dim:'))
    3887         abstime=str2num(get(handles.i1,'String'));
     3941        abstime=str2double(get(handles.i1,'String'));
    38883942        TimeUnit='index';
    38893943    end
     
    51115165    if ~isempty(errormsg)
    51125166        msgbox_uvmat('ERROR',errormsg);
    5113     else
    5114 %         set(handles.i1,'BackgroundColor',[1 1 1])
    5115 %         set(handles.i2,'BackgroundColor',[1 1 1])
    5116 %         set(handles.j1,'BackgroundColor',[1 1 1])
    5117 %         set(handles.j2,'BackgroundColor',[1 1 1])
    5118 %         set(handles.FileIndex,'BackgroundColor',[1 1 1])
    5119 %         set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
    51205167    end
    51215168    set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
     
    51395186function VOLUME_Callback(hObject, eventdata, handles)
    51405187%-----------------------------------------------------------------------
    5141 %errordlg('command VOL not implemented yet')
    51425188if ishandle(handles.UVMAT_title)
    51435189    delete(handles.UVMAT_title)
     
    51505196    edit_vect_Callback(hObject, eventdata, handles)
    51515197    set(handles.CheckEditObject,'Value',0)
    5152 %     set(handles.CheckEditObject,'BackgroundColor',[0.7 0.7 0.7])
    5153 %     set(handles.cal,'Value',0)
    5154 %     set(handles.cal,'BackgroundColor',[0 1 0])
    51555198    set(handles.edit_vect,'Value',0)
    51565199    edit_vect_Callback(hObject, eventdata, handles)
     
    54415484drawnow
    54425485
    5443 %% inputfilerefresh the current plot
     5486%% inputfile refresh the current plot
    54445487if isempty(list_path{ichoice}) || nargin(transform_handle)<3
    54455488    set(handles.SubField,'Value',0)
     
    56825725%------------------------------------------------------------------
    56835726slider1=get(handles.Slider1,'Value');
    5684 min_val=str2num(get(handles.num_MinVec,'String'));
    5685 max_val=str2num(get(handles.num_MaxVec,'String'));
     5727min_val=str2double(get(handles.num_MinVec,'String'));
     5728max_val=str2double(get(handles.num_MaxVec,'String'));
    56865729col=min_val+(max_val-min_val)*slider1;
    56875730set(handles.num_ColCode1,'String',num2str(col))
     
    56985741function Slider2_Callback(hObject, eventdata, handles)
    56995742slider2=get(handles.Slider2,'Value');
    5700 min_val=str2num(get(handles.num_MinVec,'String'));
    5701 max_val=str2num(get(handles.num_MaxVec,'String'));
     5743min_val=str2double(get(handles.num_MinVec,'String'));
     5744max_val=str2double(get(handles.num_MaxVec,'String'));
    57025745col=min_val+(max_val-min_val)*slider2;
    57035746set(handles.num_ColCode2,'String',num2str(col))
     
    57495792set(handles.CheckFixVecColor,'Value',1)
    57505793CheckFixVecColor_Callback(hObject, eventdata, handles)
    5751 min_val=str2num(get(handles.num_MinVec,'String'));
    5752 max_val=str2num(get(handles.num_MaxVec,'String'));
     5794min_val=str2double(get(handles.num_MinVec,'String'));
     5795max_val=str2double(get(handles.num_MaxVec,'String'));
    57535796slider1=get(handles.Slider1,'Value');
    57545797slider2=get(handles.Slider2,'Value');
     
    57745817ichoice=get(handles.ColorCode,'Value');
    57755818colcode.ColorCode=list{ichoice};
    5776 colcode.MinVec=str2num(get(handles.num_MinVec,'String'));
    5777 colcode.MaxVec=str2num(get(handles.num_MaxVec,'String'));
     5819colcode.MinVec=str2double(get(handles.num_MinVec,'String'));
     5820colcode.MaxVec=str2double(get(handles.num_MaxVec,'String'));
    57785821test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
    57795822if test3color
    5780     colcode.ColCode1=str2num(get(handles.num_ColCode1,'String'));
    5781     colcode.ColCode2=str2num(get(handles.num_ColCode2,'String'));
     5823    colcode.ColCode1=str2double(get(handles.num_ColCode1,'String'));
     5824    colcode.ColCode2=str2double(get(handles.num_ColCode2,'String'));
    57825825end
    57835826vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
Note: See TracChangeset for help on using the changeset viewer.