Changeset 1162 for trunk


Ignore:
Timestamp:
Jul 20, 2024, 9:33:32 AM (5 months ago)
Author:
sommeria
Message:

further cleaning

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/filter_tps_3D.m

    r1161 r1162  
    4343warning off
    4444NbVec=size(Coord,1);% nbre of vectors in the field to interpolate
    45 NbCoord=size(Coord,2);% space dimension
     45NbCoord=size(Coord,2);% space dimension,Coord(:,1)= x,Coord(:,2)=  y , Coord(:,3)=  z
    4646MinCoord=min(Coord,[],1);%lower coordinate bounds
    4747MaxCoord=max(Coord,[],1);%upper coordinate bounds
    48 Range=MaxCoord-MinCoord;
    49 AspectRatio=Range(2)/Range(1);
    50 NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains
    51 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x
    52 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y
    53 NbSubDomainZ=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y
     48Range=MaxCoord-MinCoord;%along eacch coordiante x,y,z
     49Cellmesh=(prod(Range)/NbVec)^(1/3);
     50NbSubDomainX=floor(range(1)/Cellmesh);
     51NbSubDomainY=floor(range(2)/Cellmesh);
     52NbSubDomainZ=floor(range(3)/Cellmesh);
     53
     54% NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains
     55% NbSubDomainX=max(floor(sqrt(NbSubDomain/(AspectRatio(1)*AspectRatio(2))),1);% estimated number of subdomains in x
     56% NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y
     57% NbSubDomainZ=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y
    5458NbSubDomain=NbSubDomainX*NbSubDomainY;% new estimated number of subdomains in a matrix shape partition in subdomains
    5559Siz(1)=Range(1)/NbSubDomainX;%width of subdomains
    5660Siz(2)=Range(2)/NbSubDomainY;%height of subdomains
     61Siz(3)=Range(3)/NbSubDomainZ;%height of subdomains
    5762CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX);% X positions of subdomain centres
    5863CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY);% Y positions of subdomain centres
    59 [CentreX,CentreY]=meshgrid(CentreX,CentreY);
     64CentreZ=linspace(MinCoord(3)+Siz(3)/2,MaxCoord(3)-Siz(3)/2,NbSubDomainZ);% Y positions of subdomain centres
     65[CentreX,CentreY,CentreZ]=meshgrid(CentreX,CentreY,CentreZ);
    6066CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres
    6167CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres
     68CentreZ=reshape(CentreZ,1,[]);% Y positions of subdomain centres
    6269
    6370%% smoothing parameter: CHANGED 03 May 2024 TO GET RESULTS INDEPENDENT OF SUBDOMAINSIZE
  • trunk/src/get_field.m

    r1157 r1162  
    10321032% --- Executes on selection change in TimeName.
    10331033function TimeName_Callback(hObject, eventdata, handles)
     1034
    10341035Field=get(handles.get_field,'UserData');
    1035 index=get(handles.SwitchVarIndexTime,'Value');
     1036TimeMenu=get(handles.SwitchVarIndexTime,'String');
     1037TimeOption=TimeMenu{get(handles.SwitchVarIndexTime,'Value')};
    10361038MenuIndex=get(handles.TimeName,'Value');
    10371039string=get(handles.TimeName,'String');
     
    10401042TimeName=string{MenuIndex};
    10411043end
    1042 switch index
    1043     case 1
     1044switch TimeOption
     1045    case 'file index'
    10441046        set(handles.num_TimeDimension,'String','')
    10451047        set(handles.TimeUnit,'String','index')
    1046     case 2
     1048    case 'attribute'
    10471049        set(handles.num_TimeDimension,'String','')
    10481050        attr_index=find(strcmpi([TimeName 'Unit'],Field.ListGlobalAttribute));% look for time unit
     
    10531055            set(handles.TimeUnit,'String','')
    10541056        end
    1055     case {3 ,4}
    1056         if index==3  % TimeName is used to chose a variable
     1057    case 'variable' % TimeName is used to chose a variable
    10571058            VarIndex=name2index(TimeName,Field.ListVarName);
    10581059            DimName=Field.VarDimName{VarIndex};
     
    10661067            set(handles.TimeUnit,'String',unit)
    10671068            update_field(handles,TimeName)
    1068         elseif index==4% TimeName is used to chose a dimension
     1069     case 'matrix index' % TimeName is used to chose a dimension
    10691070            DimName=string{MenuIndex};
    10701071            DimIndex=name2index(DimName,Field.ListDimName);
     
    10721073            set(handles.num_TimeDimension,'String',num2str(DimValue))
    10731074            set(handles.TimeUnit,'String','index')
    1074         end
    10751075end
    10761076
  • trunk/src/get_file_info.m

    r1161 r1162  
    5555
    5656function [FileInfo,VideoObject]=get_file_info(fileinput)
     57
    5758VideoObject=[];
    5859FileInfo.FileType='';% input file does not exist
     
    6566    FileInfo.FileName=fileinput;
    6667    FileInfo.FileType='txt'; %default
    67  else
    68      return %input file does not exist.
     68else
     69    return %input file does not exist.
    6970end
    7071[tild,tild,FileExt]=fileparts(fileinput);%get the file extension FileExt
     
    8182    case '.im7'
    8283        try
    83              Input=readimx(fileinput);
    84              Image=Input.Frames{1}.Components{1}.Planes{1};
    85              FileInfo.FileType='image_DaVis';
    86              FileInfo.NumberOfFrames=numel(Input.Frames);
    87              FileInfo.Height=size(Image,2);
    88              FileInfo.Width=size(Image,1);
    89              FileInfo.TimeName='timestamp';
    90              for ilist=1:numel(Input.Attributes)
    91                  % if strcmp(Input.Attributes{ilist}.Name,'_Date')
    92                  %     DateString=Input.Attributes{ilist}.Value;
    93                  % end
    94                  % if strcmp(Input.Attributes{ilist}.Name,'_Time')
    95                  %     TimeString=Input.Attributes{ilist}.Value;
    96                  % end
    97              end
     84            Input=readimx(fileinput);
     85            Image=Input.Frames{1}.Components{1}.Planes{1};
     86            FileInfo.FileType='image_DaVis';
     87            FileInfo.NumberOfFrames=numel(Input.Frames);
     88            FileInfo.Height=size(Image,2);
     89            FileInfo.Width=size(Image,1);
     90            FileInfo.TimeName='timestamp';
     91            for ilist=1:numel(Input.Attributes)
     92                % if strcmp(Input.Attributes{ilist}.Name,'_Date')
     93                %     DateString=Input.Attributes{ilist}.Value;
     94                % end
     95                % if strcmp(Input.Attributes{ilist}.Name,'_Time')
     96                %     TimeString=Input.Attributes{ilist}.Value;
     97                % end
     98            end
    9899        catch ME
    99100            msgbox_uvmat('ERROR',{ME.message;'reading image from DaVis is possible only with Matlab version 2013 or earlier'})
     
    124125        FileInfo.Height=BitmapInfoHeader.biHeight;
    125126        FileInfo.Width=BitmapInfoHeader.biWidth;
    126          FileInfo.BitDepth=BitmapInfoHeader.biBitCount;
    127          FileInfo.TimeName='video';
     127        FileInfo.BitDepth=BitmapInfoHeader.biBitCount;
     128        FileInfo.TimeName='video';
    128129    otherwise
    129130        if ~isempty(FileExt)% exclude empty extension
     
    134135                    try
    135136                        imainfo=imfinfo(fileinput);
    136                         if length(imainfo) >1 %case of image with multiple frames   
     137                        if length(imainfo) >1 %case of image with multiple frames
    137138                            FileInfo=imainfo(1);%take info from the first frame
    138139                            FileInfo.NumberOfFrames=length(imainfo);
     
    149150                else
    150151                    error_nc=0;
    151                     try
    152                        [Data,tild,tild,errormsg]=nc2struct(fileinput,[]);
    153                         if ~isempty(errormsg)
    154                             error_nc=1;
    155                         else
     152                    try %try netcdf file
     153                        [Data,tild,tild,errormsg]=nc2struct(fileinput,[]);
     154                        if isempty(errormsg)
    156155                            if isfield(Data,'absolut_time_T0') && isfield(Data,'hart') && ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
    157                                 FileInfo.FileType='civx';
     156                                FileInfo.FileType='civx';%old civ data from the Fortran program
    158157                                if isfield(Data,'patch2') && isequal(Data.patch2,1)
    159158                                    FileInfo.CivStage=6;
     
    175174                                FileInfo.FileType='civdata_3D'; % test for 3D volume civ velocity fields
    176175                                FileInfo.CivStage=Data.CivStage;
     176                                z_dim_index=find(strcmp(Data.ListDimName,'npz'));
     177                                FileInfo.NumberOfFrames=Data.DimValue(z_dim_index);
    177178                            else
    178179                                FileInfo.FileType='netcdf';
    179180                                FileInfo.ListVarName=Data.ListVarName;
    180                                 FileInfo.VarAttribute=Data.VarAttribute;
     181                                FileInfo.VarAttribute={};
     182                                if isfield(Data,'VarAttribute')
     183                                    FileInfo.VarAttribute=Data.VarAttribute;
     184                                end
     185                                FileInfo.ListDimName=Data.ListDimName;
     186                                FileInfo.NumberOfFrames=Data.DimValue;
    181187                            end
     188                        else
     189                            error_nc=1;
    182190                        end
    183191                    catch ME
     
    186194                    if error_nc
    187195                        try
    188                             if exist('VideoReader.m','file')%recent version of Matlab
    189                                 VideoObject=VideoReader(fileinput);
    190                                 FileInfo=get(VideoObject);
    191                                 FileInfo.FileType='video';
    192                             elseif exist('mmreader.m','file')% Matlab 2009a
    193                                 VideoObject=mmreader(fileinput);
    194                                 FileInfo=get(VideoObject);
    195                                 FileInfo.FileType='mmreader';
     196                            if exist('mmreader.m','file')% Matlab 2009a
     197                                INFO=mmfileinfo (fileinput);
     198                                if  ~isempty(INFO.Video.Format)
     199                                   
     200                                    VideoObject=mmreader(fileinput);
     201                                    FileInfo=get(VideoObject);
     202                                    FileInfo.FileType='mmreader';
     203                                end
    196204                            end
    197205                            FileInfo.BitDepth=FileInfo.BitsPerPixel/3;
     
    212220
    213221if ismember (FileInfo.FileType,{'mat','image','image_DaVis','multimage','mmreader','cine_phantom','video','netcdf','civdata'})
    214         FileInfo.FileIndexing='on'; % allow to detect file index for scanning series
     222    FileInfo.FileIndexing='on'; % allow to detect file index for scanning series
    215223else
    216224    FileInfo.FileIndexing='off';
     
    219227switch FileInfo.FileType
    220228    case {'image','multimage','video','mmreader','rdvision','image_DaVis','cine_phantom'}
    221     FileInfo.FieldType='image';
     229        FileInfo.FieldType='image';
    222230    case {'civx','civdata','pivdata_fluidimage'}
    223231        FileInfo.FieldType='civdata';
  • trunk/src/nc2struct.m

    r1157 r1162  
    108108        catch ME
    109109        end
    110         eval(['Data.' varargin{ilist} '=valuestr;'])
     110        Data.(varargin{ilist})=valuestr;
    111111    end
    112112    netcdf.close(nc)
  • trunk/src/read_civdata.m

    r1161 r1162  
    5959%=======================================================================
    6060
    61 function [Field,VelTypeOut,errormsg]=read_civdata(FileName,FieldNames,VelType)
     61function [Field,VelTypeOut,errormsg]=read_civdata(FileName,FieldNames,VelType,frame_index)
    6262
    6363%% default input
     64if ~exist('frame_index','var')
     65    frame_index=1;
     66end
    6467if ~exist('VelType','var')
    6568    VelType='';
     
    7477VelTypeOut=VelType;
    7578errormsg='';
    76 if ischar(FieldNames), FieldNames={FieldNames}; end;
     79if ischar(FieldNames), FieldNames={FieldNames}; end
    7780ProjModeRequest='';
    7881for ilist=1:length(FieldNames)
     
    9093
    9194%% reading data
    92 [Data,tild,tild,errormsg]=nc2struct(FileName,'ListGlobalAttribute','CivStage');
     95[Data,tild,tild,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage');
    9396if ~isempty(errormsg)
    9497     errormsg=['read_civdata: ' errormsg];
     
    101104    return
    102105else
     106    if strcmp(Data.Conventions,'uvmat/civdata_3D')
     107        [Field,vardetect]=nc2struct(FileName,'TimeDimName','npz',frame_index,varlist);%read the variables in the netcdf file
     108    else   
    103109    [Field,vardetect]=nc2struct(FileName,varlist);%read the variables in the netcdf file
     110    end
    104111end
    105112if isfield(Field,'Txt')
  • trunk/src/read_field.m

    r1137 r1162  
    11%'read_field': read the fields from files in different formats (netcdf files, images, video)
    22%--------------------------------------------------------------------------
    3 %  function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num)
     3%  function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,frame_index)
    44%
    55% OUTPUT:
     
    2020%     .ColorVar: variable used for vector color
    2121%     .Npx, .Npy: nbre of pixels along x and y (used for .vol input files)
    22 %     .TimeDimName: name of the dimension considered as 'time', selected index value then set by input 'num'
    23 % num: frame number for movies
     22%     .TimeDimName: name of the dimension considered as 'time', selected index value then set by input 'frame_index'
     23% frame_index: frame number for movies or multidimensional netcdf files with dim >2
    2424%
    2525% see also read_image.m,read_civxdata.m,read_civdata.m,
     
    4343%=======================================================================
    4444
    45 function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num)
     45function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,frame_index)
    4646%% default output and check input
    4747Field=[];
    48 if ~exist('num','var')
    49     num=1;
    50 end
    51 if isempty(num)
    52     num=1;
     48if ~exist('frame_index','var')
     49    frame_index=1;
     50end
     51if isempty(frame_index)
     52    frame_index=1;
    5353end
    5454if ~exist('ParamIn','var')
     
    5757ParamOut=ParamIn;%default
    5858errormsg='';
    59 if isempty(regexp(FileName,'^http://'))&& ~exist(FileName,'file')
     59if isempty(regexp(FileName,'^http://', 'once'))&& ~exist(FileName,'file')
    6060    errormsg=['input file ' FileName ' does not exist'];
    6161    return
     
    8181%% distingush different input file types
    8282switch FileType
    83     case 'civdata'% new format for civ results
    84         [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType);
     83    case {'civdata','civdata_3D'}% new format for civ results
     84        [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType,frame_index);
    8585        if ~isempty(errormsg),errormsg=['read_civdata / ' errormsg];return,end
    8686        ParamOut.CivStage=Field.CivStage;
     
    102102        % scan the list InputField
    103103        Operator=cell(1,numel(InputField));
    104         InputVar=cell(1,numel(InputField));
     104        %InputVar=cell(1,numel(InputField));
    105105        for ilist=1:numel(InputField)
    106106            % look for input variables to read
     
    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,num,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
     147            [Field,var_detect,ichoice,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,num,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVarName]);
    150             if numel(num)~=1
     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
    151151                NbCoord=NbCoord+1;% adds time coordinate, except if a single time has been selected
    152152            end
     
    157157            return
    158158        end
    159         CheckStructured=1;
     159       % CheckStructured=1;
    160160        %scan all the variables
    161161        NbCoord=0;
    162162        if ~isempty(ParamIn.Coord_x)
    163             index_Coord_x=find(strcmp(ParamIn.Coord_x,Field.ListVarName));
     163            index_Coord_x=strcmp(ParamIn.Coord_x,Field.ListVarName);
    164164            Field.VarAttribute{index_Coord_x}.Role='coord_x';%
    165165            NbCoord=NbCoord+1;
     
    167167        if ~isempty(ParamIn.Coord_y)
    168168            if ischar(ParamIn.Coord_y)
    169                 index_Coord_y=find(strcmp(ParamIn.Coord_y,Field.ListVarName));
     169                index_Coord_y=strcmp(ParamIn.Coord_y,Field.ListVarName);
    170170                Field.VarAttribute{index_Coord_y}.Role='coord_y';%
    171171                NbCoord=NbCoord+1;
    172172            else
    173173                for icoord_y=1:numel(ParamIn.Coord_y)
    174                     index_Coord_y=find(strcmp(ParamIn.Coord_y{icoord_y},Field.ListVarName));
     174                    index_Coord_y=strcmp(ParamIn.Coord_y{icoord_y},Field.ListVarName);
    175175                    Field.VarAttribute{index_Coord_y}.Role='coord_y';%
    176176                    NbCoord=NbCoord+1;
     
    180180        NbDim=1;
    181181        if ~isempty(ParamIn.Coord_z)
    182             index_Coord_z=find(strcmp(ParamIn.Coord_z,Field.ListVarName));
     182            index_Coord_z=strcmp(ParamIn.Coord_z,Field.ListVarName);
    183183            Field.VarAttribute{index_Coord_z}.Role='coord_z';%
    184184            NbCoord=NbCoord+1;
     
    187187            NbDim=2;
    188188        end
    189         NormName='';
    190         UName='';
    191         VName='';
    192189        if numel(Field.ListVarName)>NbCoord % if there are variables beyond coord (exclude 1 D plots)
    193190            VarAttribute=cell(1,numel(ListVarName));
     
    236233        end 
    237234    case 'video'
    238         if strcmp(class(ParamIn),'VideoReader')
    239             A=read(ParamIn,num);
     235        if isa(ParamIn,'VideoReader')
     236            A=read(ParamIn,frame_index);
    240237        else
    241238            ParamOut=VideoReader(FileName);
    242             A=read(ParamOut,num);
     239            A=read(ParamOut,frame_index);
    243240        end
    244241    case 'mmreader'
    245         if strcmp(class(ParamIn),'mmreader')
    246             A=read(ParamIn,num);
     242        if isa(ParamIn,'mmreader')
     243            A=read(ParamIn,frame_index);
    247244        else
    248245            ParamOut=mmreader(FileName);
    249             A=read(ParamOut,num);
     246            A=read(ParamOut,frame_index);
    250247        end
    251248    case 'vol'
     
    255252        A=permute(A,[3 2 1]);
    256253    case 'multimage'
    257         %  warning 'off'
    258         A=imread(FileName,num);
     254        A=imread(FileName,frame_index);
    259255    case 'image'
    260256        A=imread(FileName);
    261257    case 'rdvision'
    262         [A,FileInfo,timestamps,errormsg]=read_rdvision(FileName,num);
     258        [A,FileInfo,timestamps,errormsg]=read_rdvision(FileName,frame_index);
    263259    case 'image_DaVis'
    264260        Input=readimx(FileName);
    265261        if numel(Input.Frames)==1
    266             num=1;
    267         end
    268         A=Input.Frames{num}.Components{1}.Planes{1}';
     262            frame_index=1;
     263        end
     264        A=Input.Frames{frame_index}.Components{1}.Planes{1}';
    269265        for ilist=1:numel(Input.Frames{1}.Attributes)
    270266            if strcmp(Input.Frames{1}.Attributes{ilist}.Name,'AcqTimeSeries')
     
    274270        end
    275271    case 'cine_phantom'
    276         [A,FileInfo] = read_cine_phantom(FileName,num );
     272        [A,FileInfo] = read_cine_phantom(FileName,frame_index );
    277273    otherwise
    278274        errormsg=[ FileType ': invalid input file type for uvmat'];
     
    299295    Field.VarAttribute{3}.Role='scalar';
    300296    if ndims(A)==3
    301         if Npz==1;%color
     297        if Npz==1%color
    302298            Field.VarDimName={'Coord_y','Coord_x',{'Coord_y','Coord_x','rgb'}}; %
    303299            Field.Coord_y=[npxy(1)-0.5 0.5];
  • trunk/src/script_delete_rdvision.m

    r1161 r1162  
    4545        ind_rdvision=[];
    4646        for isubsub=1:numel(ListNamesSubSub)
    47             if ~isempty(regexp(ListNamesSubSub{isubsub},'^2024-'))
     47            if ~isempty(regexp(ListNamesSubSub{isubsub},'^2024-', 'once'))
    4848                ind_rdvision=[ind_rdvision isubsub];%detect rdvision folders
    4949            end
     
    5353        if numel(ind_rdvision)==1%
    5454            DataFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{ind_rdvision});
    55             if isempty(regexp(DataFolder,'.extract$'))% if the detected folder is not .extract
     55            if isempty(regexp(DataFolder,'.extract$', 'once'))% if the detected folder is not .extract
    5656                %     ExtractFolder=fullfile(Param.InputTable{1},[Param.InputTable{2} '.extract']);
    5757                %     mkdir(ExtractFolder)
     
    7676        if numel(ind_rdvision)==2
    7777            for irdvision=1:2
    78                 CheckExtract(irdvision)=isempty(regexp(fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{irdvision}), '.extract$'));
     78                CheckExtract(irdvision)=isempty(regexp(fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{irdvision}), '.extract$', 'once'));
    7979            end
    8080            status='extract missing';
    8181            if numel(find(CheckExtract))==1
    82                 ExtractFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{find(CheckExtract)});
     82                ExtractFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{CheckExtract});
    8383                PngFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},'im');
    8484                status='image folder not created';
  • trunk/src/series/civ_series.m

    r1161 r1162  
    993993    shifty=shifty*ones(nbvec,1);
    994994end
     995%TODO: shift the origin by -shift/2
    995996
    996997%% Array initialisation and default output  if par_civ.CorrSmooth=0 (just the grid calculated, no civ computation)
     
    11931194   FF=false; % no error by the limited search box
    11941195    max_conv=result_conv(y,x);% max correlation
    1195     peak2noise= max(4,max_conv/std(reshape(result_conv,1,[])));% ratio of max conv to standard deviation of correlations (estiamtion of noise level), set to value 4 if it is too low
     1196    %peak2noise= max(4,max_conv/std(reshape(result_conv,1,[])));% ratio of max conv to standard deviation of correlations (estiamtion of noise level), set to value 4 if it is too low
     1197    peak2noise=100;% TODO: make this threshold more precise, depending on the image noise
    11961198    result_conv=result_conv*peak2noise/max_conv;% renormalise the correlation with respect to the noise
    11971199    result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1  (=0 by discretisation, to avoid divergence in the log)
  • trunk/src/set_field_list.m

    r1127 r1162  
    3434%=======================================================================
    3535
    36 function [FieldList,VecColorList]=set_field_list(UName,VName,CName)
    37 
     36function [FieldList,VecColorList]=set_field_list(UName,VName,CName,WName)
     37if exist('WName','var')% 3D civ case
     38    FieldList={['vec(' UName ',' VName ')'];...
     39        ['norm(' UName ',' VName ')'];...
     40        UName;...
     41        VName;...
     42        WName};
     43    VecColorList={['norm(' UName ',' VName ')'];...
     44        WName;...
     45        VName};
     46else
    3847FieldList={['vec(' UName ',' VName ')'];...
    3948    ['norm(' UName ',' VName ')'];...
     
    5059    UName;...
    5160    VName};...
     61end
    5262if exist('CName','var') && ~isempty(CName)
    5363    VecColorList=[{CName};VecColorList];
  • trunk/src/uvmat.m

    r1161 r1162  
    20182018function MenuRun1_Callback(hObject, eventdata, handles)
    20192019%------------------------------------------------------------------------
     2020MenuRun(hObject,handles);
     2021
     2022
     2023% --------------------------------------------------------------------
     2024function MenuRun2_Callback(hObject, eventdata, handles)
     2025MenuRun(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
     2035% --------------------------------------------------------------------
     2036function MenuRun3_Callback(hObject, eventdata, handles)
     2037MenuRun(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
     2047function MenuRun(hObject,handles)
    20202048Param=read_GUI(handles.uvmat);
    20212049Param.HiddenData=get(handles.uvmat,'UserData');
    2022 series(Param); %run the series interface
    2023 
    2024 % --------------------------------------------------------------------
    2025 function MenuRun2_Callback(hObject, eventdata, 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));
     2050hseries=series(Param); %run the series interface
     2051ActionName=get(hObject,'Label');
     2052if ~strcmp(ActionName,'series')
     2053    hhseries=guidata(hseries);
     2054    ActionMenu=get(hhseries.ActionName,'String');
     2055index_action=find(strcmp(ActionName,ActionMenu));
     2056if isempty(index_action) %add to the menu
     2057    NbBuiltinAction=get(hhseries.Action,'UserData');
     2058    ActionMenu(NbBuiltinAction+1)=[];
     2059    ActionMenu=[ActionMenu(1:end-1); {ActionName} ;{'more...'}];%insert the required action at the penultimate rank in the menu
     2060    index_action=numel(ActionMenu)-1;
     2061    set(hhseries.ActionName,'String',ActionMenu);
     2062end
    20322063set(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
     2064series('ActionName_Callback',hObject,[],hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
     2065end
    20342066
    20352067% %------------------------------------------------------------------------
     
    22402272        editxml(fileinput);
    22412273        return
    2242 %     case 'mat'% matlab data file
    2243 % %         global Data_uvmat
    2244 % Data_uvmat.Field=load(fileinput);
    2245 % evalin('base','global Data_uvmat')%make CurData global in the workspace
    2246 % disp('Data_uvmat.Field=')
    2247 % evalin('base','Data_uvmat.Field') %display CurData in the workspace
    2248 % commandwindow; %brings the Matlab command window to the front
    2249 % return
    22502274    otherwise
    22512275        set(handles_RootPath,'String',RootPath);
    22522276        set(handles_SubDir,'String',['/' SubDir]);
    22532277        set(handles_RootFile,'String',['/' RootFile]); %display the separator
    2254         if isempty(regexp(RootPath,'^http://'))
     2278        if isempty(regexp(RootPath,'^http://', 'once'))
    22552279            rootname=fullfile(RootPath,SubDir,RootFile);
    22562280        else
     
    24642488        if isfield(XmlDataRead, 'Slice') && ~isempty(XmlDataRead.Slice)
    24652489            XmlData.Slice=XmlDataRead.Slice;
    2466             % check whether the GUI geometry_calib is opened
    2467 %             hgeometry_calib=findobj('tag','geometry_calib');
    2468 %             if ~isempty(hgeometry_calib) % check whether the display of the GUI geometry_calib is consistent with the current calib param
    2469 %                 GUserData=get(hgeometry_calib,'UserData');
    2470 %                 if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName))
    2471 %                     answer=msgbox_uvmat('INPUT_Y-N','refresh the display of the GUI geometry_calib with the new input data?');
    2472 %                     if strcmp(answer,'Yes')
    2473 %                         geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib
    2474 %                     end
    2475 %                 end
    2476 %             end
    24772490        end
    24782491        if isfield(XmlData.Slice,'CheckVolumeScan') && isequal(XmlData.Slice.CheckVolumeScan,1)
     
    24982511elseif strcmp(FileInfo.FieldType,'civdata')% ajouter pivdata_fluidimage
    24992512    TimeName='civdata';
     2513elseif strcmp(FileInfo.FieldType,'civdata_3D')% ajouter pivdata_fluidimage
     2514    TimeName='civdata_3D';
    25002515end
    25012516if index==1
     
    25932608switch FileInfo.FieldType
    25942609    case 'civdata'
    2595         [FieldList,ColorList]=set_field_list('U','V','C');
     2610        [FieldList,VecColorList]=set_field_list('U','V','C');
    25962611        set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    25972612        set(handles_Fields,'Value',2) % set menu to 'velocity
     
    26012616        end
    26022617        set(handles.ColorScalar,'Value',1)
    2603         set(handles.ColorScalar,'String',ColorList)
     2618        set(handles.ColorScalar,'String',VecColorList)
    26042619        set(handles.Vectors,'Visible','on')
    26052620        set(handles.Coord_x,'String','X');
    26062621        set(handles.Coord_y,'String','Y');
    2607         set(handles.MenuRun3,'Label','test_filter_tps')
     2622        set(handles.MenuRun2,'Label','test_filter_tps')
     2623        set(handles.MenuRun3,'Label','civ_series')
     2624    case 'civdata_3D'
     2625        [FieldList,VecColorList]=set_field_list('U','V','C','W');
     2626        set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
     2627        set(handles_Fields,'Value',2) % set menu to 'velocity
     2628        if index==1
     2629            set(handles.FieldName_1,'Value',1);
     2630            set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field
     2631        end
     2632        set(handles.ColorScalar,'Value',1)
     2633        set(handles.ColorScalar,'String',VecColorList)
     2634        set(handles.Vectors,'Visible','on')
     2635        set(handles.Coord_x,'String','X');
     2636        set(handles.Coord_y,'String','Y');
     2637        set(handles.MenuRun2,'Label','')
     2638        set(handles.MenuRun3,'Label','')
    26082639    case {'netcdf','mat'}
    26092640        set(handles_Fields,'Value',1)
     
    26202651        set(handles.Coord_x,'String','Coord_x');
    26212652    set(handles.Coord_y,'String','Coord_y');
     2653    set(handles.MenuRun2,'Label','civ_series')
     2654    set(handles.MenuRun3,'Label','sub_background')
    26222655end
    26232656
     
    26352668end
    26362669if ~isempty(i1_series)
    2637 [ref_j,ref_i]=find(squeeze(i1_series(1,:,:)));
    2638 if ~isempty(j1_series)
     2670    [ref_j,ref_i]=find(squeeze(i1_series(1,:,:)));
     2671    if ~isempty(j1_series)
    26392672        state_j='on';
    26402673        if index==1
     
    26432676            end
    26442677        end
    2645 end
    2646 if isequal(scan_option,'i')
    2647     diff_ref_i=diff(ref_i,1);
    2648     if isempty(diff_ref_i)
    2649         diff_ref_i=1;
    2650     end
    2651     if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i)))
    2652         set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1)))
    2653     end
    2654      set(handles.scan_i,'Value',1)
    2655      scan_i_Callback([],[], handles);
    2656 else
    2657     diff_ref_j=diff(ref_j);
    2658     if isempty(diff_ref_j)
    2659         diff_ref_j=1;
    2660     end
    2661     if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j)))
    2662         set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1)))
    2663     end
    2664      set(handles.scan_j,'Value',1)
    2665      scan_j_Callback([],[], handles);
    2666 end
     2678    end
     2679    if isequal(scan_option,'i')
     2680        diff_ref_i=diff(ref_i,1);
     2681        if isempty(diff_ref_i)
     2682            diff_ref_i=1;
     2683        end
     2684        if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i)))
     2685            set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1)))
     2686        end
     2687        set(handles.scan_i,'Value',1)
     2688        scan_i_Callback([],[], handles);
     2689    else
     2690        diff_ref_j=diff(ref_j);
     2691        if isempty(diff_ref_j)
     2692            diff_ref_j=1;
     2693        end
     2694        if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j)))
     2695            set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1)))
     2696        end
     2697        set(handles.scan_j,'Value',1)
     2698        scan_j_Callback([],[], handles);
     2699    end
    26672700end
    26682701set(handles.scan_j,'Visible',state_j)
     
    31403173NomType=InputFile.NomType;
    31413174[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
    3142 if isempty(i1)
    3143     i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
     3175if isempty(i1)% no i index set by the input file name
     3176    i1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
    31443177elseif isempty(j1) && strcmp(get(handles.j1,'Visible'),'on')
    3145     j1=str2num(get(handles.j1,'String'));%case of indexed movie
     3178    j1=str2double(get(handles.j1,'String'));%case of indexed movie
    31463179end
    31473180% if movie_status% we read the second index from the edit box
     
    31713204
    31723205% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
    3173 if CheckFixPair && isnumeric(increment)
    3174     if get(handles.scan_i,'Value')==1% case of scanning along index i
     3206if isnumeric(increment)
     3207    if get(handles.scan_i,'Value')==1  % case of scanning along index i
    31753208        i1=i1+increment;
    31763209        i2=i2+increment;
     
    35533586end
    35543587switch UvData.FileInfo{1}.FieldType
    3555     case {'civdata','netcdf','mat'}
     3588    case {'civdata','civdata_3D','netcdf','mat'}
    35563589        list_fields=get(handles.FieldName,'String');% list menu fields
    35573590        FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
     
    35733606                index_code=get(handles.ColorScalar,'Value');% selected string index
    35743607                ParamIn.ColorVar= list_code{index_code}; % selected field
     3608            end
     3609        end
     3610        if strcmp(UvData.FileInfo{1}.FieldType,'civdata_3D')
     3611            if num_j1>UvData.FileInfo{1}.NumberOfFrames
     3612                errormsg='specified frame index exceeds file content';
     3613                return
     3614            else
     3615                frame_index=num_j1;% frame index from a set of indexed movies
    35753616            end
    35763617        end
     
    36633704    end
    36643705    switch UvData.FileInfo{2}.FileType
    3665         case {'civx','civdata','netcdf','pivdata_fluidimage','mat'}
     3706        case {'civx','civdata','civdata_3D','netcdf','pivdata_fluidimage','mat'}
    36663707            list_fields=get(handles.FieldName_1,'String');% list menu fields
    36673708            FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
     
    37283769%% update the display menu for the first velocity type (first menuline)
    37293770test_veltype=0;
    3730 if isfield(UvData.FileInfo{1},'FieldType') && strcmp(UvData.FileInfo{1}.FieldType,'civdata')&& ~strcmp(FieldName,'get_field...')
     3771if isfield(UvData.FileInfo{1},'FieldType') && ismember(UvData.FileInfo{1}.FieldType,{'civdata','civdata_3D'})&& ~strcmp(FieldName,'get_field...')
    37313772    test_veltype=1;
    37323773    set(handles.VelType,'Visible','on')
     
    46354676        %read selection from get_field
    46364677        [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    4637         if isempty(regexp(RootPath,'^http://'))
     4678        if isempty(regexp(RootPath,'^http://', 'once'))
    46384679        FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    46394680        else
     
    46414682        end
    46424683        GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field
     4684           
    46434685        FieldList={};
    46444686        VecColorList={''};
     
    46984740                case 'variable'
    46994741                    set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
    4700                     set(handles.NomType,'String','*')
     4742                   % set(handles.NomType,'String','*')
    47014743                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
    47024744                    set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix)
     
    49725014            imax=6;
    49735015        end
    4974     case {'civdata','pivdata_fluidimage'}
     5016    case {'civdata','civdata_3D','pivdata_fluidimage'}
    49755017        menu={'civ1';'filter1';'civ2';'filter2'};
    49765018        imax=[0 1 1 2 3 3 4 5 5 6];
     
    52555297        ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu
    52565298        if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it)
    5257             menu=[menu(1:end-1);{transform_name};{'more...'}];
     5299            if numel(menu)>12
     5300                menu(4:numel(menu)-9)=[];%remove the old items, preserving the three first ones
     5301            end
     5302            menu=[menu(1:end-1);{transform_name};{'more...'}];% insert the new fct in the menu
    52585303            ichoice=numel(menu)-1;
    52595304        end
     
    61216166
    61226167
    6123 % --------------------------------------------------------------------
    6124 function MenuRun3_Callback(hObject, eventdata, handles)
    6125 Param=read_GUI(handles.uvmat);
    6126 Param.HiddenData=get(handles.uvmat,'UserData');
    6127 hseries=series(Param);
    6128 hhseries=guidata(hseries);
    6129 ActionMenu=get(hhseries.ActionName,'String');
    6130 index_action=find(strcmp('test_filter_tps',ActionMenu));
    6131 set(hhseries.ActionName,'Value',index_action);
    6132 series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
Note: See TracChangeset for help on using the changeset viewer.