Changeset 1180


Ignore:
Timestamp:
Mar 27, 2025, 5:59:21 PM (4 weeks ago)
Author:
sommeria
Message:

various bugs repaired,Relabeling frames installed for multitif

Location:
trunk/src
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r1164 r1180  
    6363j2_series=zeros(1,1,1);
    6464checkfileindexing=1;
    65 if isempty(regexp(FilePath,'^http://')) && ~exist(FilePath,'dir')
     65if isempty(regexp(FilePath,'^http://', 'once')) && ~exist(FilePath,'dir')
    6666    return % don't go further if the dir path does not exist
    6767end
     
    7070    if isempty(NomType)||strcmp(NomType,'*')
    7171        if exist(fullfileinput,'file')
    72             [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing), get the filename without its extension
     72            [~,RootFile]=fileparts(fileinput);% case of constant name (no indexing), get the filename without its extension
    7373        else
    7474            RootFile='';
     
    159159            %             rr=regexp(dirpair(ifile).name,detect_string,'names');
    160160            if ~isempty(rr{ifile})
    161                 i1=str2num(rr{ifile}.i1);
    162                 i2=str2num(regexprep(rr{ifile}.i2,'^-',''));
     161                i1=str2double(rr{ifile}.i1);
     162                i2=str2double(regexprep(rr{ifile}.i2,'^-',''));
    163163                j1=stra2num(regexprep(rr{ifile}.j1,'^_',''));
    164164                j2=stra2num(regexprep(rr{ifile}.j2,'^-',''));
    165165                ref_i=i1;
    166166                if isempty(i2_input)
    167                     if ~isempty(i2)% invalid file name if i2 does not exist in the input file
     167                    if ~isnan(i2)% invalid file name if i2 does not exist in the input file
    168168                        break
    169169                    end
     
    173173                ref_j=1;
    174174                if isempty(j1_input)
    175                     if  ~isempty(j1)% invalid file name if j1 does not exist in the input file
     175                    if  ~isnan(j1)% invalid file name if j1 does not exist in the input file
    176176                        break
    177177                    end
    178178                else %j1_input is not empty
    179                     if isempty(j1)% the detected name does not fit with the input
     179                    if isnan(j1)% the detected name does not fit with the input
    180180                        break
    181181                    else
    182182                        ref_j=j1;
    183183                        if isempty(j2_input)
    184                             if  ~isempty(j2)% invalid file name if j2 does not exist in the input file
     184                            if  ~isnan(j2)% invalid file name if j2 does not exist in the input file
    185185                                break
    186186                            end
     
    191191                end
    192192                % update the detected index series
    193                 if ~isempty(ref_i)&&~isempty(ref_j)
     193                if ~isnan(ref_i)&&~isnan(ref_j)
     194                    if ref_i*ref_j>100000
     195                        disp('warning: inapropriate file name indexing: too large indices for scanning')
     196                        ref_i_list(ifile)=i1_input;
     197                        if isempty(j1_input)
     198                            ref_j_list(ifile)=1;
     199                        else
     200                        ref_j_list(ifile)=j1_input;
     201                        end
     202                        break
     203                    end
    194204                    ref_i_list(ifile)=ref_i;
    195205                    ref_j_list(ifile)=ref_j;
  • trunk/src/geometry_calib.m

    r1174 r1180  
    11961196Coord(:,1)=r1*x+r2*y;
    11971197Coord(:,2)=r3*x+r4*y;
     1198Coord(:,1)=Coord(:,1)+O_x;
     1199Coord(:,2)=Coord(:,2)+O_y;
    11981200set(handles.ListCoord,'Data',Coord)
    11991201set(handles.APPLY,'BackgroundColor',[1 0 1])
     
    12821284    {'*.xml;*.mat', ' (*.xml,*.mat)';
    12831285    '*.xml',  '.xml files '; ...
     1286    '*.xml~*',  'backup .xml files '; ...
    12841287    '*.mat',  '.mat matlab files '}, ...
    12851288    'Pick a file',oldfile);
     
    13101313if isfield (s,'GeometryCalib')
    13111314    GeometryCalib=s.GeometryCalib;
    1312     %fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
    1313     %CoordCell={};
    1314     %Tabchar={};%default
    13151315    val_cal=1;%default
    13161316    if ~isempty(GeometryCalib)
  • trunk/src/get_file_info.m

    r1178 r1180  
    1 %'get_file_info': determine info about a file (image, multimage, civdata,...) . 
     1%'get_file_info': determine info about a file (image, multimage, civdata,...) .
    22%------------------------------------------------------------------------
    33% [FileInfo,VideoObject]=get_file_info(fileinput)
     
    1919%               ='cine_phantom': images from fast camera Phantom
    2020%               ='bin': binary file without specific organisation
    21 %               ='netcdf': netcdf file 
     21%               ='netcdf': netcdf file
    2222%               ='civdata': netcdf files provided by civ_series
    2323%               ='civx': netcdf files provided by the obsolete program civx (in fortran)
     
    6969    return %input file does not exist.
    7070end
    71 [tild,tild,FileExt]=fileparts(fileinput);%get the file extension FileExt
     71[~,~,FileExt]=fileparts(fileinput);%get the file extension FileExt
    7272
    7373switch FileExt
     
    128128        FileInfo.TimeName='video';
    129129    case '.hcc'
    130         %cd 'TelopsToolbox_20230707(r20340)'
    131          installToolboxIRCAM
     130        installToolboxIRCAM
    132131        [~,InfoArray]=readIRCam(fileinput,'HeadersOnly',true);
    133          FileInfo.FileType='telopsIR';
    134          FileInfo.Height=InfoArray(1).Height;
    135          FileInfo.Width=InfoArray(1).Width;
    136          FileInfo.FrameRate=InfoArray(1).AcquisitionFrameRate;
    137          FileInfo.NumberOfFrames=numel(InfoArray);
    138          FileInfo.TimeName='video';
     132        FileInfo.FileType='telopsIR';
     133        FileInfo.Height=InfoArray(1).Height;
     134        FileInfo.Width=InfoArray(1).Width;
     135        FileInfo.FrameRate=InfoArray(1).AcquisitionFrameRate;
     136        FileInfo.NumberOfFrames=numel(InfoArray);
     137        FileInfo.TimeName='video';
     138        Path=fileparts(fileinput);% look for the xml file to document theb file series
     139        [RootPath,SubDir,DirExt]=fileparts(Path);
     140        if ~isempty(DirExt)
     141            disp(['ERROR: change the name of the folder containing the image files: no file extension ' DirExt])
     142            FileInfo.FileType='error';
     143            return
     144        end
     145        XmlFile=fullfile(RootPath,[SubDir '.xml']);
     146        CheckWriteImaDoc=true;
     147        if exist(XmlFile,'file')
     148            [XmlData,~,errormsg]=xml2struct(XmlFile);
     149            if ~isempty(errormsg)
     150                disp(errormsg)
     151                FileInfo.FileType='error';
     152                return
     153            elseif isfield(XmlData,'FileSeries')
     154                CheckWriteImaDoc=false;
     155            end
     156        end
     157        if CheckWriteImaDoc
     158            DirContent=dir(Path);
     159            NbFiles=0;
     160            FileSeries.Convention='telopsIR';
     161            for ilist=1:numel(DirContent)
     162                FName=DirContent(ilist).name;
     163                if ~isempty(regexp(FName,'.hcc$', 'once'))
     164                    NbFiles=NbFiles+1;
     165                    FileSeries.FileName{NbFiles,1}=FName;
     166                end
     167            end
     168            FileSeries.NbFramePerFile=FileInfo.NumberOfFrames;
     169            [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries);
     170        end
     171
    139172    otherwise
    140173        if ~isempty(FileExt)% exclude empty extension
     
    160193                        FileInfo.error=ME.message;
    161194                    end
     195
    162196                else
    163197                    error_nc=0;
     
    205239                                end
    206240                                FileInfo.ListDimName=Data.ListDimName;
    207 %                                 FileInfo.NumberOfFrames=Data.DimValue;
     241                                %                                 FileInfo.NumberOfFrames=Data.DimValue;
    208242                            end
    209243                        else
     
    218252                                INFO=mmfileinfo (fileinput);
    219253                                if  ~isempty(INFO.Video.Format)
    220                                    
    221254                                    VideoObject=mmreader(fileinput);
    222255                                    FileInfo=get(VideoObject);
  • trunk/src/index2filename.m

    r1178 r1180  
    3131%=======================================================================
    3232
    33 function [RootFile,FileIndexString,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)
    34 RootFile='';
    35 FileIndexString='';
     33function [FileName,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)
     34FileName='';
     35% FileIndexString='';
    3636FrameIndex=1;
    37 if exist('j1','var')
    38     if isempty(j1)
    39         j1=1;
     37if isfield(FileSeries,'FileName')
     38    if exist('j1','var')&&~isnan(NbField_j)
     39        if isempty(j1)
     40            j1=1;
     41        end
     42        i_vector=(i1-1)*NbField_j+j1;%frames labeld with two indices i and j
     43    else
     44        i_vector=i1;% frames labelled with a single concatenated index vector
    4045    end
    41     i_vector=(i1-1)*NbField_j+j1-1;%frames labeld with two indices i and j
    42 else
    43     i_vector=i1;% frames labelled with a single concatenated index vector
    44 end
     46    if ischar(FileSeries.FileName)
     47        FileSeries.FileName={FileSeries.FileName};
     48    end
     49    [~,~,RootFile,i1,~,~,~,FileExt,NomType]=fileparts_uvmat(FileSeries.FileName{end});
     50    FileIndex=floor((i_vector-1)/FileSeries.NbFramePerFile)+1;
     51    if FileIndex>numel(FileSeries.FileName)
     52        FileIndex=FileIndex-numel(FileSeries.FileName)+i1;
     53        FileName=fullfile_uvmat('','',RootFile,FileExt,NomType,FileIndex);
     54    else
     55        FileName=FileSeries.FileName{FileIndex};
     56    end
    4557
    46 switch FileSeries.Convention
    47     case 'PCO'
    48         RootFile=FileSeries.RootName;
    49         FileIndex=floor(i_vector/FileSeries.NbFramePerFile);
    50         if FileIndex>0
    51             RootFile=[RootFile '@'];
    52            FileIndexString=num2str(FileIndex,'%04d');
    53         end
    54         FrameIndex=mod(i_vector,FileSeries.NbFramePerFile)+1;
     58    % switch FileSeries.Convention
     59    %     case 'PCO'
     60    %         RootFile=FileSeries.RootName;
     61    %         FileIndex=floor(i_vector/FileSeries.NbFramePerFile);
     62    %         if FileIndex>0
     63    %             RootFile=[RootFile '@'];
     64    %            FileIndexString=num2str(FileIndex,'%04d');
     65    %         end
     66    FrameIndex=mod(i_vector-1,FileSeries.NbFramePerFile)+1;
    5567end
    5668
    5769
     70
  • trunk/src/mouse_up.m

    r1127 r1180  
    7171    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object
    7272    IndexObj=PlotData.IndexObj;
     73    if IndexObj<=numel(UvData.ProjObject)
    7374    ObjectData=UvData.ProjObject{IndexObj};
    7475    check_multiple=0;
     
    120121        end
    121122    end
    122    
     123
    123124    %show object coordinates in the GUI set_object
    124125    if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')
     
    127128        set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4));
    128129    end
     130
    129131   
    130132    %% stop drawing and plot the projected field if the object manipulation is finished
     
    195197    hother=findobj('Tag','deformpoint');%find all the deformpoints
    196198    set(hother,'Color','b');%reset all the deformpoints in 'blue'
     199    end
    197200end
    198201
  • trunk/src/read_field.m

    r1170 r1180  
    145145        NbCoord=~isempty(ParamIn.Coord_x)+~isempty(ParamIn.Coord_y)+~isempty(ParamIn.Coord_z);
    146146        if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array
    147             [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,frame_index,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
     147            [Field,~,~,errormsg]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,frame_index,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
    148148        elseif isfield(ParamIn,'TimeVarName')% case of reading of a single time  in a multidimensional array
    149             [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeVarName',ParamIn.TimeVarName,frame_index,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
    150             if numel(frame_index)~=1
    151                 NbCoord=NbCoord+1;% adds time coordinate, except if a single time has been selected
    152             end
    153         else
    154             [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
     149            [Field,~,~,errormsg]=nc2struct(FileName,'TimeVarName',ParamIn.TimeVarName,frame_index,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
     150%             if numel(frame_index)~=1
     151%                 NbCoord=NbCoord+1;% adds time coordinate, except if a single time has been selected
     152%             end
     153        else
     154            [Field,~,~,errormsg]=nc2struct(FileName,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
    155155        end
    156156        if ~isempty(errormsg)
     
    241241    case 'telopsIR'
    242242         [A,Header]=readIRCam(FileName,'Frames',frame_index);
     243         A=flip(A);
    243244         A=(reshape(A,Header(1).Width,Header(1).Height))';
    244          A=flip(A,1);
    245245    case 'mmreader'
    246246        if isa(ParamIn,'mmreader')
  • trunk/src/read_image.m

    r1178 r1180  
    8181    case 'telopsIR'     
    8282        [A,Header]=readIRCam(FileName,'Frames',num);
     83        A=flip(A);
    8384         A=(reshape(A,Header(1).Width,Header(1).Height))';
    84          A=flip(A,1);
    8585    case 'rdvision'
    8686         A=read_rdvision(FileName,num);
  • trunk/src/rotate_points.m

    r1127 r1180  
    120120    y_shift=str2num(get(handles.x_0,'String'));
    121121    z_shift=str2num(get(handles.y_0,'String'));
    122     if ~isempty(x_shift)
     122    if ~isnan(x_shift)
    123123        varargout{1}(1)=x_shift;
    124124    end
    125     if ~isempty(y_shift)
     125    if ~isnan(y_shift)
    126126        varargout{1}(2)=y_shift;
    127127    end
    128     if ~isempty(z_shift)
     128    if ~isnan(z_shift)
    129129        varargout{1}(3)=z_shift;
    130130    end
  • trunk/src/series.m

    r1179 r1180  
    40054005        first_i=str2double(get(handles.num_first_i,'String'));
    40064006        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
     4007        %i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
     4008        i1=1;
    40084009        if strcmp(SeriesData.TimeName,'xml')% indices i and j
    40094010            j1=mod(i1-1,nbfield_j)+first_j;
  • trunk/src/series/civ_3D.m

    r1165 r1180  
    11521152    end
    11531153    if isempty(r)
    1154         display('wrong pair mode input option')
     1154        disp('wrong pair mode input option')
    11551155    else
    11561156        ind1=stra2num(r.num1);
  • trunk/src/series/civ_input.m

    r1177 r1180  
    13781378[Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput);
    13791379ref.filebase=fullfile(Path,File);
    1380 % ref.num_a=stra2num(str_a);
    1381 % ref.num_b=stra2num(str_b);
    1382 % ref.num1=str2double(field_count);
    1383 % ref.num2=str2double(str2);
    1384 browse=[];%initialisation
     1380
     1381%browse=[];%initialisation
    13851382if ~isequal(ref.ext,'.nc')
    13861383    msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)')
  • trunk/src/series/civ_series.m

    r1178 r1180  
    254254    end
    255255end
     256
     257%% File relabeling documented by the xml file (e.g. PCO)
    256258CheckRelabel=isfield(Param,'FileSeries' );%=true for index relabeling (PCO)
    257259
     
    340342                ImageName_A=Param.ActionInput.RefFile;
    341343            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]);
     344            [RootFile,FrameIndex_A]=index2filename(Param.FileSeries,i1_series_Civ1(ifield),j1_series_Civ1(ifield),MaxIndex_j);
     345            ImageName_A=fullfile(RootPath_A,SubDir_A,RootFile);
    344346            else
    345347                ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
     
    355357                    FileType_A=FileInfo_A.FileType;
    356358                    if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom','telopsIR'}), 1))% case of video input
    357                         Time=zeros(FileInfo_A.NumberOfFrames+1,2);                 
     359                        Time=zeros(FileInfo_A.NumberOfFrames+1,2);
    358360                        Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)';
    359                            if ~isempty(j1_series_Civ1) && j1_series_Civ1~=1
    360                                Time=Time';
    361                            end
     361                        if ~isempty(j1_series_Civ1) && j1_series_Civ1~=1
     362                            Time=Time';
     363                        end
    362364                    end
    363365                    if ~isempty(FileType_A) && isempty(Time)% Time = index i +0.001 index j by default
     
    378380                time_input=toc(tsart_input);
    379381            end
    380 if 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]);
    383 else
    384             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);
    386 end
     382            if CheckRelabel
     383                [RootFile,FrameIndex_B]=index2filename(Param.FileSeries,i2_series_Civ1(ifield),j2_series_Civ1(ifield),MaxIndex_j);
     384                ImageName_B=fullfile(RootPath_B,SubDir_B,RootFile);
     385            else
     386                ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));
     387                FrameIndex_B=FrameIndex_B_Civ1(ifield);
     388            end
    387389            if isempty(FileType_B)% determine the image type for the first field
    388390                [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B);
     
    394396            end
    395397            [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B);
    396            
     398
    397399        catch ME % display errors in reading input images
    398400            if ~isempty(ME.message)
     
    627629            ImageName_A_Civ2=Param.ActionInput.RefFile;
    628630        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
     631            [RootFile,FrameIndex_A_2]=index2filename(Param.FileSeries,i1_series_Civ2(ifield),j1_series_Civ2(ifield),MaxIndex_j);
     632            ImageName_A_Civ2=fullfile(RootPath_A,SubDir_A,RootFile);
     633        else
    632634            ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
    633635            FrameIndex_A_2=FrameIndex_A_Civ2(ifield);
     
    639641        end
    640642        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 
    646         ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2);
    647         FrameIndex_B_2=FrameIndex_B_Civ2(ifield);
     643            [RootFile,FrameIndex_B_2]=index2filename(Param.FileSeries,i2_civ2,j2_civ2,MaxIndex_j);
     644            ImageName_B_Civ2=fullfile(RootPath_B,SubDir_B,RootFile);
     645        else
     646            ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2);
     647            FrameIndex_B_2=FrameIndex_B_Civ2(ifield);
    648648        end
    649649        if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_2,FrameIndex_B)
  • trunk/src/series/sub_background.m

    r1179 r1180  
    7878    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    7979    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    80     ParamOut.FieldTransform = 'off';%can use a transform function
    81     ParamOut.ProjObject='off';%cannot use projection object(option 'off'/'on',
    82     ParamOut.Mask='on';%can use mask option   (option 'off'/'on', 'off' by default)
     80    ParamOut.FieldTransform = 'off';%can use a transform function (option 'off'/'on','off' by default)
     81    ParamOut.ProjObject='off';%cannot use projection object(option 'off'/'on','off' by default)
     82    ParamOut.Mask='off';%cannot use mask option   (option 'off'/'on', 'off' by default)
    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
     
    250250%% Input file info
    251251if CheckRelabel
    252       [RootFileOut,FileIndexString]=index2filename(Param.FileSeries,Param.IndexRange.first_i,j_indices(1),NbField_j);
    253        FirstFileName=fullfile(RootPath,SubDir,[RootFileOut FileIndexString FileExt]);
    254 else
    255 FirstFileName=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,Param.IndexRange.first_i,[],j_indices(1));%get first file name
    256 RootFileOut=RootFile;
     252    [RootFileOut,frame_index]=index2filename(Param.FileSeries,Param.IndexRange.first_i,j_indices(1),NbField_j);
     253    FirstFileName=fullfile(RootPath,SubDir,RootFileOut);
     254else
     255    FirstFileName=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,Param.IndexRange.first_i,[],j_indices(1));%get first file name
     256    RootFileOut=RootFile;
    257257end
    258258[FileInfo,MovieObject]=get_file_info(FirstFileName);
    259259FileType=FileInfo.FileType;
    260 if 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
     260if ~CheckRelabel
     261    if isfield(FileInfo,'NumberOfFrames') && FileInfo.NumberOfFrames >1
     262        if isempty(regexp(NomType,'1$', 'once'))% no file indexing
     263            frame_index=i_indices;% the index i denotes the frame number in a movie, no index j
     264        else
     265            frame_index=j_indices;% the index j denotes the frame number in a movie
     266            MovieObject=[]; %not a single video object
     267        end
    263268    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
    267 else
    268     frame_index=ones(1,nbfield);
     269        frame_index=ones(1,nbfield);
     270    end
    269271end
    270272
     
    288290
    289291%% prealocate memory for the sliding background
    290 Ak=zeros(FileInfo.Height,FileInfo.Width,nbaver_ima,['uint' num2str(FileInfo.BitDepth)]); %prealocate memory   
     292Ak=zeros(FileInfo.Height,FileInfo.Width,nbaver_ima,['uint' num2str(FileInfo.BitDepth)]); %prealocate memory
    291293
    292294%% selection of frame indices
    293 if Param.ActionInput.CheckVolume 
     295if Param.ActionInput.CheckVolume
    294296    nbfield=floor(nbfield/NbSlice_j)*NbSlice_j;% truncate the total number of frames in case of incomplete series
    295297    indselect=1:nbfield;
    296      indselect=reshape(indselect,NbSlice_j,[]);
    297       NbSlice=NbSlice_j;
    298 else
    299        NbSlice=NbSlice_i;
     298    indselect=reshape(indselect,NbSlice_j,[]);
     299    NbSlice=NbSlice_j;
     300else
     301    NbSlice=NbSlice_i;
    300302    nbfield=floor(nbfield/NbSlice)*NbSlice;% truncate the total number of frames in case of incomplete series
    301303    indselect=reshape(1:nbfield,NbSlice,[]);
    302304    for j_slice=1:NbSlice
    303     indselect(j_slice,:)=j_slice:NbSlice:nbfield;% select file indices of the slice
     305        indselect(j_slice,:)=j_slice:NbSlice:nbfield;% select file indices of the slice
    304306    end
    305307end
     
    313315        %filename=filecell{1,ifile};
    314316        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            [filename,FrameIndex]=index2filename(Param.FileSeries,i_indices(ifile),j_indices(ifile),NbField_j);
     318             filename=fullfile(RootPath,SubDir,filename);
    317319        else
    318320            filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i_indices(ifile),[],j_indices(ifile));
     
    368370                ifile=indselect(j_slice,ifield+iburst+step*halfnbaver);
    369371                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                    [filename,FrameIndex]=index2filename(Param.FileSeries,i_indices(ifile),j_indices(ifile),NbField_j);
     373                    filename=fullfile(RootPath,SubDir,filename);
    372374                else
    373375                    filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i_indices(ifile),[],j_indices(ifile));
  • trunk/src/stra2num.m

    r1127 r1180  
    3030
    3131function numres=stra2num(str)
    32 numres=[]; %default
    33 if double(str) >= 48 & double(str) <= 57 % = test for number strings
    34     numres=str2double(str);
    35 elseif double(str) >= 65 & double(str) <= 90 % test on ascii code for capital letters
     32numres=str2double(str); %default
     33if isnan(numres)
     34   if double(str) >= 65 & double(str) <= 90 % test on ascii code for capital letters
    3635    numres=double(str)-64; %change capital letters to corresponding number in the alphabet
    37 elseif double(str) >= 97 & double(str) <= 122 % test on ascii code for small letters
     36  elseif double(str) >= 97 & double(str) <= 122 % test on ascii code for small letters
    3837    numres=double(str)-96; %change small letters to corresponding number in the alphabet
     38   end
    3939end
  • trunk/src/struct2xml.m

    r1127 r1180  
    5151      [t,branch_uid]=add(t,root_uid,'element',fieldnames{ilist});
    5252       t=struct2xml(val,t,branch_uid);
    53      
    54 %       fieldnames_sub=fields(val)
    55 %       for ilist_sub=1:length(fieldnames_sub)
    56 %           if isstruct(fieldnames_sub{ilist_sub})
    57 %                 t=struct2xml(fieldnames_sub{ilist_sub},t,uid);
    58 % %                 save(t)
    59 %           else
    60 %               val_sub=val.(fieldnames_sub{ilist_sub});
    61 %               t=add_element(t,uid,fieldnames_sub{ilist_sub},val_sub);
    62 %           end
    63 %       end
    6453   else
    6554       t=add_element(t,root_uid,fieldnames{ilist},val);
  • trunk/src/uvmat.m

    r1179 r1180  
    517517    end
    518518end
    519 
    520 
    521 
    522 % -----------------------------------------------------------------------
    523 % --- Executes on the menu Open/Browse campaign...
    524 % --- search the file inside a campaign, using the GUI browse_data
    525 % -----------------------------------------------------------------------
    526 function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
    527 % set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
    528 % drawnow
    529 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    530 DataSeries=fullfile(RootPath,SubDir);
    531 if isempty(DataSeries) %loads the previously stored file name and set it as default in the file_input box
    532     DataSeries=get(handles.RootPath,'UserData');
    533 end
    534 OutPut=browse_data(DataSeries,'on');% open the GUI browse_data to get select a campaign dir, experiment and device
    535 if ~isfield(OutPut,'Campaign')
    536     return
    537 end
    538 DataSeries=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
    539 fileinput=uigetfile_uvmat('pick an input file',DataSeries);
    540 hh=dir(fileinput);
    541 if numel(hh)>1
    542     msgbox_uvmat('ERROR','invalid input, probably a broken link');
    543     return
    544 end
    545 
    546 %% update the list of campaigns in the menubar
    547 MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
    548     {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
    549 check_dir=isempty(find(strcmp(DataSeries,MenuCampaign)));
    550 if check_dir %insert the new campaign in the list if it is not found
    551     MenuCampaign(end)=[]; %suppress the last item
    552     MenuCampaign=[{DataSeries};MenuCampaign];%insert the new campaign
    553     for ilist=1:numel(MenuCampaign)
    554         set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
    555     end
    556     % save the list for future opening:
    557     dir_perso=prefdir;
    558     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    559     if exist(profil_perso,'file')
    560         save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat
    561     else
    562         save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat
    563     end
    564 end
    565 
    566 %% display the selected field and related information
    567 %display_file_name( handles,fullfile(DirName,FileName))
    568 display_file_name( handles,fileinput)
    569 set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    570 
    571 % -----------------------------------------------------------------------
    572 % --- Open again as second field the file whose name has been recorded in MenuFile_1
    573 % -----------------------------------------------------------------------
    574 function MenuCampaign_Callback(hObject, eventdata, handles)
    575 
    576 set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
    577 OutPut=browse_data(get(hObject,'Label'),'on');% open the GUI browse_data to get select a campaign dir, experiment and device
    578 if isfield(OutPut,'Campaign')
    579     fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}));
    580     hh=dir(fileinput);
    581     if numel(hh)>1
    582         msgbox_uvmat('ERROR','invalid input, probably a broken link');
    583     else
    584         display_file_name(handles,fileinput)
    585     end
    586 end
    587 set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    588 
    589519
    590520%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    11691099%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    11701100%------------------------------------------------------------------------
     1101function MenuRuler_Callback(hObject, eventdata, handles)
     1102%------------------------------------------------------------------------
     1103if strcmp(get(handles.MenuRuler,'checked'),'on')
     1104    set(handles.MenuRuler,'checked','off')%desactivate if activated
     1105else
     1106    set(handles.MenuRuler,'checked','on')%activate if selected
     1107    set(handles.CheckZoom,'Value',0)
     1108    CheckZoom_Callback(handles.uvmat, [], handles)
     1109    UvData=get(handles.uvmat,'UserData');
     1110    UvData.MouseAction='ruler';
     1111    set(handles.uvmat,'UserData',UvData);
     1112end
     1113
     1114%------------------------------------------------------------------------
    11711115function MenuCalib_Callback(hObject, eventdata, handles)
    11721116%------------------------------------------------------------------------
     
    19951939set_grid(FileName,UvData.Field);% call the set_object interface
    19961940
    1997 
    1998 %------------------------------------------------------------------------
    1999 function MenuRuler_Callback(hObject, eventdata, handles)
    2000 %------------------------------------------------------------------------
    2001 if strcmp(get(handles.MenuRuler,'checked'),'on')
    2002     set(handles.MenuRuler,'checked','off')%desactivate if activated
    2003 else
    2004     set(handles.MenuRuler,'checked','on')%activate if selected
    2005     set(handles.CheckZoom,'Value',0)
    2006     CheckZoom_Callback(handles.uvmat, [], handles)
    2007     UvData=get(handles.uvmat,'UserData');
    2008     UvData.MouseAction='ruler';
    2009     set(handles.uvmat,'UserData',UvData);
     1941%------------------------------------------------------------------------
     1942%-- introduce a section FileSeries in the xml file ImaDoc to virtually relabel frames
     1943% --------------------------------------------------------------------
     1944function MenuRelabelFrames_Callback(hObject, eventdata, handles)
     1945
     1946[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     1947FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     1948CheckAbort=false;
     1949if strcmp(get(handles.MenuRelabelFrames,'checked'),'off')% if the option is selected
     1950    if strcmp(FileExt,'.tif') && ~isempty(regexp(RootFile,'^im', 'once'))% case of PCO images, document <FileSeries> in the xml file
     1951        FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     1952        FileInfo=get_file_info(FileName);
     1953        XmlFile=fullfile(RootPath,[SubDir '.xml']);
     1954        [XmlData,errormsg]=imadoc2struct(XmlFile);
     1955        if ~isempty(errormsg)
     1956            disp(['a file ' XmlFile ' is needed to document the timing'])
     1957            CheckAbort=true;
     1958        elseif ~isfield(XmlData,'FileSeries')% fill the FleSeries if does not exist
     1959            FileSeries.Convention='PCO';
     1960            FileSeries.FileName{1,1}='im.tif';
     1961            FileSeries.FileName{2,1}='im@0001.tif';
     1962            FileSeries.NbFramePerFile=FileInfo.NumberOfFrames;
     1963            [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries);
     1964            if isempty(errormsg)
     1965                disp([xmlfile 'updated with FileSeries'])
     1966            else
     1967                disp(errormsg)
     1968                CheckAbort=true;
     1969            end
     1970        end
     1971    end
     1972    if ~CheckAbort
     1973    set(handles.MenuRelabelFrames,'checked','on')
     1974    end
     1975else
     1976    set(handles.MenuRelabelFrames,'checked','off')%if the option was chcked, uncheck it
     1977end
     1978if ~CheckAbort
     1979    errormsg=display_file_name(handles,FileName,1);
     1980    if ~isempty(errormsg)
     1981        disp(errormsg)
     1982    end
    20101983end
    20111984
     
    20151988
    20161989%------------------------------------------------------------------------
    2017 % open the GUI 'series'
     1990% open the GUI 'series' with the current file series as input
    20181991function MenuRun1_Callback(hObject, eventdata, handles)
    20191992%------------------------------------------------------------------------
    20201993MenuRun(hObject,handles);
    20211994
    2022 
     1995%------------------------------------------------------------------------
     1996% open the GUI 'series' with the current file series as input
    20231997% --------------------------------------------------------------------
    20241998function MenuRun2_Callback(hObject, eventdata, handles)
    20251999MenuRun(hObject,handles);
    2026 % Param=read_GUI(handles.uvmat);
    2027 % Param.HiddenData=get(handles.uvmat,'UserData');
    2028 % hseries=series(Param);
    2029 % hhseries=guidata(hseries);
    2030 % ActionMenu=get(hhseries.ActionName,'String');
    2031 % index_action=find(strcmp('civ_series',ActionMenu));
    2032 % set(hhseries.ActionName,'Value',index_action);
    2033 % series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
    2034 
     2000
     2001%------------------------------------------------------------------------
     2002% open the GUI 'series' with the current file series as input
    20352003% --------------------------------------------------------------------
    20362004function MenuRun3_Callback(hObject, eventdata, handles)
    20372005MenuRun(hObject,handles);
    2038 % Param=read_GUI(handles.uvmat);
    2039 % Param.HiddenData=get(handles.uvmat,'UserData');
    2040 % hseries=series(Param);
    2041 % hhseries=guidata(hseries);
    2042 % ActionMenu=get(hhseries.ActionName,'String');
    2043 % index_action=find(strcmp('test_filter_tps',ActionMenu));
    2044 % set(hhseries.ActionName,'Value',index_action);
    2045 % series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
    2046 
     2006
     2007%------------------------------------------------------------------------
     2008% open the GUI 'series' with the current file series as input
     2009% --------------------------------------------------------------------
    20472010function MenuRun(hObject,handles)
    20482011Param=read_GUI(handles.uvmat);
     
    23112274        elseif isfield(FileInfo,'VolumeScan')
    23122275            Mask.VolumeScan=FileInfo.VolumeScan;
    2313 end
    2314 set(handles.CheckMask,'UserData', Mask)
     2276        end
     2277        set(handles.CheckMask,'UserData', Mask)
    23152278    else
    23162279        set(handles.CheckMask,'Value',0)
    23172280        CheckMask_Callback(handles.CheckMask, [], handles)
    2318 end
     2281    end
    23192282else %read the current field index to synchronise with the first series
    23202283    i1_s=str2double(get(handles.i1,'String'));
     
    24192382set(handles.FixVelType,'Value',0); %desactivate fixed veltype by default
    24202383
    2421 %% look for the xml file and read it
    2422 XmlFileName=find_imadoc(RootPath,SubDir);
     2384%% look for the ImaDoc xml file and read it
     2385XmlFileName=find_imadoc(RootPath,SubDir);% search the appropriate ImaDoc xml file
    24232386[~,XmlName]=fileparts(XmlFileName);
    24242387warntext='';%default warning message
    24252388NbSlice=1;%default
    2426 %CheckImaDoc=false;
    24272389TimeUnit='';%default
    24282390TimeName='';%default
    2429 CheckIndexing=false;%default
    24302391XmlData=[];
    2431 if isempty(XmlFileName)
     2392if isempty(XmlFileName) %no ImaDoc xml file detected
    24322393    set(handles.view_xml,'Visible','off')
    24332394else
     
    24412402    end
    24422403    if ~isempty(XmlData)
    2443         %CheckImaDoc=true;
    24442404        if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
    24452405            TimeUnit=XmlData.TimeUnit;
    24462406        end
    24472407        if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
    2448             TimeName='xml';%
    2449             if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1
    2450                 sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file
    2451                 ind_start=1;
    2452             else
    2453                 sizDti=size(XmlData.Time,1);% case starting with index 0
    2454                 ind_start=0;
    2455             end
    2456             if isfield(XmlData,'FileSeries')
    2457                 if strcmp(XmlName,SubDir)% frame indexing documented from the xml file (case PCO)
    2458                     CheckIndexing=true;
    2459                 else
    2460                     XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series
    2461                 end
     2408            TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available)
     2409%             if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1
     2410%                 sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file
     2411%                 ind_start=1;
     2412%             else
     2413%                 sizDti=size(XmlData.Time,1);% case starting with index 0
     2414%                 ind_start=0;
     2415%             end
     2416            if isfield(XmlData,'FileSeries')&& ~strcmp(XmlName,SubDir)
     2417                  XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series (e.g. images.png)
    24622418            end
    24632419        end
     
    24702426    end
    24712427end
     2428XmlData.FileInfo=FileInfo;
    24722429
    24732430%% get the file series
    24742431MovieObject=[];
    2475 if strcmp(TimeName,'xml') && strcmp(XmlName,SubDir)% get the image series info from the xml file
    2476     [nbfield,nbfield_j]=size(XmlData.Time);
    2477     nbfield=nbfield-1; %remove the possible index 0
    2478     nbfield_j=nbfield_j-1; %remove the possible index 0
     2432if strcmp(get(handles.MenuRelabelFrames,'checked'),'on') && isfield(XmlData,'FileSeries') && isfield(XmlData.FileSeries,'FileName')
     2433    CheckIndexing=true;
     2434    NomType='*';
     2435    i1_series=[];
     2436    i2_series=[];
     2437    j1_series=[];
     2438    j2_series=[];
     2439    nbfield=[];
     2440    nbfield_j=[];
     2441
     2442    %     if iscell(XmlData.FileSeries.FileName)
     2443    %         [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName{1});
     2444    %     else
     2445    %     [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName);
     2446    %     end
     2447    if strcmp(TimeName,'xml') %&& CheckIndexing% get the image series info from the xml file
     2448        [nbfield,nbfield_j]=size(XmlData.Time);
     2449        nbfield=nbfield-1; %remove the possible index 0
     2450        nbfield_j=nbfield_j-1; %remove the possible index 0
    24792451        i1_series=zeros(nbfield,nbfield_j,1);
    2480     i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j);
    2481     i2_series=i1_series;
    2482     if nbfield_j==1
    2483         j1_series=[];
    2484     else
    2485     j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j);
    2486     end
    2487     j2_series=j1_series;
    2488 else % scan the input folder to get the list of existing files
    2489     [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=...
     2452        i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j);
     2453        i2_series=i1_series;
     2454        if nbfield_j==1
     2455            j1_series=[];
     2456        else
     2457            j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j);
     2458        end
     2459        j2_series=j1_series;
     2460    end
     2461    set(handles.i1,'String','1')
     2462    set(handles.j1,'String','1')
     2463else % scan the input folder to get the list of existing files and NomType
     2464    CheckIndexing=false;
     2465    [~,~,~,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject]=...
    24902466        find_file_series(fullfile(RootPath,SubDir),FileName);
    24912467    nbfield=max(max(max(i2_series)));% total number of fields (i index)
     
    24972473        nbfield_j=max(max(max(j1_series)));
    24982474    end
    2499     if input_line==1
     2475    if ~isempty(j1_series)&& ~strcmp(NomType,'*')% the j index is used to label the frame in multimage series
     2476        set(handles.j1,'String','1')
     2477    end
     2478end
     2479if input_line==1
    25002480    set(handles.NomType,'String',NomType)
    2501     else
    2502          set(handles.NomType_1,'String',NomType)
    2503     end
    2504 end
    2505 if CheckIndexing
    2506     i1=str2double(get(handles.FileIndex,'String'));
    2507     if isnan(i1)
    2508         i1=1;
    2509     else
    2510     i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index
    2511     end
    2512     if strcmp(TimeName,'xml')% indices i and j
    2513                 j1=mod(i1-1,nbfield_j)+1;
    2514                 i1=floor((i1-1)/nbfield_j)+1;
    2515                 set(handles.j1,'String',num2str(j1))
    2516     end
    2517     set(handles.i1,'String',num2str(i1))
    2518 end
     2481else
     2482    set(handles.NomType_1,'String',NomType)
     2483end
     2484% if CheckIndexing
     2485% %     i1=str2double(get(handles.FileIndex,'String'));
     2486% %     if isnan(i1)
     2487% %         i1=1;
     2488% %     else
     2489% %         i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index
     2490% %     end
     2491% %     if strcmp(TimeName,'xml')% indices i and j
     2492% %         j1=mod(i1-1,nbfield_j)+1;
     2493% %         i1=floor((i1-1)/nbfield_j)+1;
     2494% %         set(handles.j1,'String',num2str(j1))
     2495% %     end
     2496% %     set(handles.i1,'String',num2str(i1))
     2497%
     2498% end
    25192499
    25202500
     
    25342514%% read timing and total frame number from the current file (e.g. movie files)
    25352515ColorType='falsecolor'; %default
    2536 if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
     2516if ~CheckIndexing && isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
    25372517    TimeUnit='s';
    25382518    if isempty(j1_series) %frame index along i
     
    25622542%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
    25632543%XmlData.GeometryCalib=[];%default
    2564 if input_line==1
    2565     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    2566 else
    2567     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
    2568 end
     2544% if input_line==1
     2545%     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     2546% else
     2547%     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     2548% end
    25692549
    25702550%% Define timing
     
    26292609            set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off
    26302610        end
    2631         if isfield(XmlData.Slice,'SliceCoord')
     2611        if isfield(XmlData,'Slice') && isfield(XmlData.Slice,'SliceCoord')
    26322612           siz=size(XmlData.Slice.SliceCoord);
    26332613           if siz(1)>1
     
    32623242    set(handles.CheckFixPair,'Value',0)
    32633243end
    3264 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));
     3244%CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));
    32653245
    32663246% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
     
    34413421    if strcmp(NomType,'level')
    34423422        indices=num2str(i1);
    3443     elseif isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')
     3423    elseif strcmp(get(handles.MenuRelabelFrames,'Checked'),'on') && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')
    34443424        NbField_j_cell=get(handles.MaxIndex_j,'String');
    34453425        NbField_j=str2double(NbField_j_cell{1});
    3446         [RootFile,indices,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j);
     3426        [RootFile,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j);
     3427        [~,RootFile]=fileparts(RootFile);%suppress the file extension
    34473428        set(handles.RootFile,'String',RootFile)
     3429        indices='';
    34483430    else
    34493431        indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
     
    36513633        return
    36523634    end
    3653     [FNameMulti,FileIndexString,frame_index]=index2filename(UvData.XmlData{1}.FileSeries,num_i1,num_j1,NbField_j);
    3654     FileName=fullfile(RootName,[FNameMulti FileIndexString Ext]);
     3635    [FileName,frame_index]=index2filename(UvData.XmlData{1}.FileSeries,num_i1,num_j1,NbField_j);
     3636    FileName=fullfile(RootName,FileName);
    36553637end
    36563638switch UvData.FileInfo{1}.FieldType
     
    38713853        set(handles.VelType_1,'String',[{''};menu])
    38723854    else
    3873          set(handles.VelType_1,'Visible','off')
     3855        set(handles.VelType_1,'Visible','off')
    38743856    end
    38753857    % update the second field menu: the same quantity
     
    38943876end
    38953877
    3896 %% display time value of the current file
     3878%% display time value of the current field
    38973879abstime=[];%default inputs
    38983880dt=[];
     
    39033885TimeName=get(handles.TimeName,'String');
    39043886
    3905 % time from xml file or video movie
    3906 if strcmp(TimeName,'xml')||strcmp(TimeName,'video')
    3907     if isempty(num_i2)||isnan(num_i2)
    3908         num_i2=num_i1;
    3909     end
    3910     if isempty(num_j1)||isnan(num_j1)
    3911         num_j1=1;
    3912     end
    3913     if isempty(num_j2)||isnan(num_j2)
    3914         num_j2=num_j1;
    3915     end
    3916     siz=size(UvData.XmlData{1}.Time);
    3917     if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1)
    3918         abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files
    3919         dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
    3920         Field{1}.Dt=dt;
    3921         if isfield(UvData.XmlData{1},'TimeUnit')
    3922             TimeUnit=UvData.XmlData{1}.TimeUnit;
    3923         end
    3924     end
    3925 end
    3926 
    3927 % time in the input file, not defined in a xml file or movie
    3928 if isempty(abstime)
    3929     if (strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')||strcmp(TimeName,'timestamp'))&&isfield(Field{1},'Time')
    3930         abstime=Field{1}.Time;
    3931     elseif ~isempty(regexp(TimeName,'^att:', 'once'))
    3932         abstime=Field{1}.(TimeName(5:end));%the time is an attribute  selected by get_file
    3933         if isfield(Field{1},[TimeName(5:end) 'Unit'])
    3934             TimeUnit=Field{1}.([TimeName(5:end) 'Unit']);
     3887switch TimeName
     3888    case 'xml'   % time from ImaDoc xml file
     3889        if isempty(num_i2)||isnan(num_i2)
     3890            num_i2=num_i1;
     3891        end
     3892        if isempty(num_j1)||isnan(num_j1)
     3893            num_j1=1;
     3894        end
     3895        if isempty(num_j2)||isnan(num_j2)
     3896            num_j2=num_j1;
     3897        end
     3898        siz=size(UvData.XmlData{1}.Time);
     3899        if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1)
     3900            abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files
     3901            dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     3902            Field{1}.Dt=dt;
     3903            if isfield(UvData.XmlData{1},'TimeUnit')
     3904                TimeUnit=UvData.XmlData{1}.TimeUnit;
     3905            end
     3906        end
     3907
     3908    case 'video'% time  obtained from the frame rate in video file
     3909        if isempty(num_i2)% single video record with frame index num_i1
     3910            abstime=num_i1/UvData.XmlData{1}.FileInfo.FrameRate;
    39353911        else
    3936             TimeUnit='';
    3937         end
    3938     elseif  ~isempty(regexp(TimeName,'^var:', 'once'))
    3939         abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file
    3940         % TODO: look for time unit attribute
    3941     elseif ~isempty(regexp(TimeName,'^dim:'))
    3942         abstime=str2double(get(handles.i1,'String'));
    3943         TimeUnit='index';
    3944     end
    3945     if isfield(Field{1},'Dt')
    3946         dt=Field{1}.Dt;%dt read from the netcdf input file
    3947     elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first
    3948         dt=Field{2}.Dt;%dt read from the netcdf input file
    3949     end
     3912            abstime=num_i2/UvData.XmlData{1}.FileInfo.FrameRate;% set of video records with frame index num_i2
     3913        end
     3914        TimeUnit='s';
     3915
     3916    otherwise  % time sought  in the input file
     3917        if (strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')||strcmp(TimeName,'timestamp'))&&isfield(Field{1},'Time')
     3918            abstime=Field{1}.Time;
     3919        elseif ~isempty(regexp(TimeName,'^att:', 'once'))
     3920            abstime=Field{1}.(TimeName(5:end));%the time is an attribute  selected by get_file
     3921            if isfield(Field{1},[TimeName(5:end) 'Unit'])
     3922                TimeUnit=Field{1}.([TimeName(5:end) 'Unit']);
     3923            else
     3924                TimeUnit='';
     3925            end
     3926        elseif  ~isempty(regexp(TimeName,'^var:', 'once'))
     3927            abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file
     3928            % TODO: look for time unit attribute
     3929        elseif ~isempty(regexp(TimeName,'^dim:', 'once'))
     3930            abstime=str2double(get(handles.i1,'String'));
     3931            TimeUnit='index';
     3932        end
     3933        if isfield(Field{1},'Dt')
     3934            dt=Field{1}.Dt;%dt read from the netcdf input file
     3935        elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first
     3936            dt=Field{2}.Dt;%dt read from the netcdf input file
     3937        end
    39503938end
    39513939set(handles.TimeValue,'String',num2str(abstime))
     
    62496237
    62506238
     6239
     6240
Note: See TracChangeset for help on using the changeset viewer.