Changeset 388


Ignore:
Timestamp:
Apr 6, 2012, 4:37:12 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected
file indexing, color images...

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r387 r388  
    919919    drawnow
    920920end
    921 % datnum=[];
    922921Tabchar={};
    923922nbfiles=numel(civ_files);
     
    11691168nbfield=numel(i1_civ1);
    11701169nbslice=numel(j1_civ1);
     1170if ~strcmp(CivMode,'CivX')
     1171    [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
     1172    [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
     1173end
    11711174
    11721175%% MAIN LOOP
     
    12191222            Param.Civ1.ImageHeight=ImageInfo.Height;
    12201223            Param.Civ1.ImageBitDepth=ImageInfo.BitDepth;
     1224            Param.Civ1.i1=i1_civ1;
     1225            Param.Civ1.i2=i2_civ1;
    12211226            % read mask parameters
    12221227            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
     
    12271232                    [RootPathMask,RootFileMask]=fileparts(maskbase);
    12281233                    Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask);
    1229                    % Param.Civ1.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');
    12301234                end
    12311235            end
     
    13881392            Param.Civ2.ImageHeight=ImageInfo.Height;
    13891393            Param.Civ2.ImageBitDepth=ImageInfo.BitDepth;
     1394            Param.Civ2.i1=i1_civ2;
     1395            Param.Civ2.i2=i2_civ2;
    13901396            % TODO: case of movie   
    13911397            switch CivMode
     
    17961802%------------------------------------------------------------------------
    17971803filecell=[];%default
     1804ListProgram=get(handles.ListProgram,'String');
     1805CivMode=ListProgram{get(handles.ListProgram,'Value')};%Program to use , CivX or Matlab
    17981806
    17991807%% get the root name and check dir
     
    18091817    return
    18101818end
    1811 [xx,message]=fileattrib(RootPath);
     1819[tild,message]=fileattrib(RootPath);
    18121820if ~isempty(message) && ~isequal(message.UserWrite,1)
    18131821    msgbox_uvmat('ERROR',['No writting access to ' RootPath])
     
    24142422set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box
    24152423
    2416 %COPY IMAGES TO THE FORMAT .png IF NEEDED
    2417 if isequal(NomType_ima1,'*')%case of movie files
    2418     NomType_imanew1='_i';
    2419 else
    2420     NomType_imanew1=NomType_ima1;
    2421 end
    2422 if isequal(NomType_ima2,'*')%case of movie files
    2423     NomType_imanew2='_i';
    2424 else
    2425     NomType_imanew2=NomType_ima2;
    2426 end
    2427 if ~isequal(ext_ima,'.png')
    2428     %%type of image file
    2429     type_ima1='none';%default
    2430     movieobject1=[];%default
    2431     if strcmpi(ext_ima,'.avi')
    2432         if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2433             type_ima1='movie';
    2434             movieobject1=mmreader([filecell.filebase ext_ima]);
    2435         else
    2436             type_ima1='avi';
    2437         end
    2438     elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2439         form=imformats(ext_ima(2:end));
    2440         if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2441             if isequal(NomType_ima1,'*');
    2442                 type_ima1='multimage';%image series in a single image file
     2424% For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED
     2425if strcmp(CivMode,'CivX')
     2426    if isequal(NomType_ima1,'*')%case of movie files
     2427        NomType_imanew1='_i';
     2428    else
     2429        NomType_imanew1=NomType_ima1;
     2430    end
     2431    if isequal(NomType_ima2,'*')%case of movie files
     2432        NomType_imanew2='_i';
     2433    else
     2434        NomType_imanew2=NomType_ima2;
     2435    end
     2436    if ~isequal(ext_ima,'.png')
     2437        %%type of image file
     2438        type_ima1='none';%default
     2439        movieobject1=[];%default
     2440        if strcmpi(ext_ima,'.avi')
     2441            if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
     2442                type_ima1='movie';
     2443                movieobject1=mmreader([filecell.filebase ext_ima]);
    24432444            else
    2444                 type_ima1='image';
    2445             end
    2446         end
    2447     end
    2448     type_ima2='none';%default
    2449     movieobject2=[];
    2450     if strcmpi(ext_ima,'.avi')
    2451         if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2452             type_ima2='movie';
    2453             movieobject2=mmreader([filecell.filebase ext_ima]);
    2454         else
    2455             type_ima2='avi';
    2456         end
    2457     elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2458         form=imformats(ext_ima(2:end));
    2459         if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2460             if isequal(NomType_ima1,'*');
    2461                 type_ima2='multimage';%image series in a single image file
     2445                type_ima1='avi';
     2446            end
     2447        elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
     2448            form=imformats(ext_ima(2:end));
     2449            if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     2450                if isequal(NomType_ima1,'*');
     2451                    type_ima1='multimage';%image series in a single image file
     2452                else
     2453                    type_ima1='image';
     2454                end
     2455            end
     2456        end
     2457        type_ima2='none';%default
     2458        movieobject2=[];
     2459        if strcmpi(ext_ima,'.avi')
     2460            if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
     2461                type_ima2='movie';
     2462                movieobject2=mmreader([filecell.filebase ext_ima]);
    24622463            else
    2463                 type_ima2='image';
    2464             end
    2465         end
    2466     end
    2467     if checkbox(1) %if civ1 is performed
    2468         h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
    2469         for ifile=1:nbfield
    2470             waitbar(ifile/nbfield);
    2471             for j=1:nbslice
    2472                 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
    2473                 if ~exist(filename,'file')
    2474                     A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
    2475                     imwrite(A,filename,'BitDepth',16);
     2464                type_ima2='avi';
     2465            end
     2466        elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
     2467            form=imformats(ext_ima(2:end));
     2468            if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     2469                if isequal(NomType_ima1,'*');
     2470                    type_ima2='multimage';%image series in a single image file
     2471                else
     2472                    type_ima2='image';
    24762473                end
    2477                 filecell.ima1.civ1(ifile,j)={filename};
    2478                 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
    2479                 if ~exist(filename,'file')
    2480                     A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
    2481                     imwrite(A,filename,'BitDepth',16);
     2474            end
     2475        end
     2476        if checkbox(1) %if civ1 is performed
     2477            h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
     2478            for ifile=1:nbfield
     2479                waitbar(ifile/nbfield);
     2480                for j=1:nbslice
     2481                    filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
     2482                    if ~exist(filename,'file')
     2483                        A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
     2484                        imwrite(A,filename,'BitDepth',16);
     2485                    end
     2486                    filecell.ima1.civ1(ifile,j)={filename};
     2487                    filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
     2488                    if ~exist(filename,'file')
     2489                        A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
     2490                        imwrite(A,filename,'BitDepth',16);
     2491                    end
     2492                    filecell.ima2.civ1(ifile,j)={filename};
    24822493                end
    2483                 filecell.ima2.civ1(ifile,j)={filename};
    2484             end
    2485         end
    2486         close(h)
    2487     end
    2488     if checkbox(4) %if civ2 is performed
    2489         h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
    2490         for ifile=1:nbfield
    2491             waitbar(ifile/nbfield);
    2492             for j=1:nbslice
    2493                 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
    2494                 if ~exist(filename,'file')
    2495                     A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
    2496                     imwrite(A,filename,'BitDepth',16);
     2494            end
     2495            close(h)
     2496        end
     2497        if checkbox(4) %if civ2 is performed
     2498            h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
     2499            for ifile=1:nbfield
     2500                waitbar(ifile/nbfield);
     2501                for j=1:nbslice
     2502                    filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
     2503                    if ~exist(filename,'file')
     2504                        A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
     2505                        imwrite(A,filename,'BitDepth',16);
     2506                    end
     2507                    filecell.ima1.civ2(ifile,j)={filename};
     2508                    filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
     2509                    if ~exist(filename,'file')
     2510                        A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
     2511                        imwrite(A,filename,'BitDepth',16);
     2512                    end
     2513                    filecell.ima2.civ2(ifile,j)={filename};
    24972514                end
    2498                 filecell.ima1.civ2(ifile,j)={filename};
    2499                 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
    2500                 if ~exist(filename,'file')
    2501                     A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
    2502                     imwrite(A,filename,'BitDepth',16);
    2503                 end
    2504                 filecell.ima2.civ2(ifile,j)={filename};
    2505             end
    2506         end
    2507         close(h);
     2515            end
     2516            close(h);
     2517        end
    25082518    end
    25092519end
     
    39163926    Data.nx=[1 size(Data.A,2)];
    39173927    par_civ1=read_GUI(handles.Civ1);
    3918     par_civ1.ImageWidth=size(Data.A,1);
    3919     par_civ1.ImageHeight=size(Data.A,2);
     3928    par_civ1.ImageWidth=size(Data.A,2);
     3929    par_civ1.ImageHeight=size(Data.A,1);
    39203930    par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
     3931    par_civ1.i1=i1_civ1;
     3932    par_civ1.i2=i2_civ1;
    39213933    Param.Civ1=par_civ1;
    39223934    Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV
  • trunk/src/civ_matlab.m

    r387 r388  
    6565            if ischar(par_civ1.ImageB)
    6666                temp=par_civ1.ImageA;
    67                 par_civ1.ImageA=sum(imread(par_civ1.ImageB),3);
     67                par_civ1.ImageA=imread(par_civ1.ImageB);
    6868            end
    6969            if ischar(temp)
    70                 par_civ1.ImageB=sum(imread(temp),3);
     70                par_civ1.ImageB=imread(temp);
    7171            end
    7272        end
    7373    else
    7474        if isfield(par_civ1,'ImageA') && ischar(par_civ1.ImageA) % case with no image: only the PIV grid is calculated
    75             par_civ1.ImageA=sum(imread(par_civ1.ImageA),3);
     75            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.i1);
     76            par_civ1.ImageA=Field.A;%imread(par_civ1.ImageA);%[Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num)
    7677        end
    7778        if isfield(par_civ1,'ImageB')&& ischar(par_civ1.ImageB)
    78             par_civ1.ImageB=sum(imread(par_civ1.ImageB),3);
     79            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.i2);
     80            par_civ1.ImageB=Field.A;%=imread(par_civ1.ImageB);
    7981        end
    8082    end
     
    466468%     end
    467469% end
    468 
     470par_civ.ImageA=sum(double(par_civ.ImageA),3);%sum over rgb component for color images
     471par_civ.ImageB=sum(double(par_civ.ImageB),3);
    469472[npy_ima npx_ima]=size(par_civ.ImageA);
    470473if ~isequal(size(par_civ.ImageB),[npy_ima npx_ima])
     
    472475    return
    473476end
    474 par_civ.ImageA=double(par_civ.ImageA);
    475 par_civ.ImageB=double(par_civ.ImageB);
    476 
    477477
    478478%% Apply mask
  • trunk/src/find_file_series.m

    r386 r388  
    5454[FileType,FileInfo,Object]=get_file_type(fullfileinput);
    5555if strcmp( FileType,'multimage')||strcmp( FileType,'video')
    56         NomType='*';
    57         i1_series=(1:FileInfo.NbFrame)';
     56    NomType='*';
     57    i1_series=(1:FileInfo.NbFrame)';
    5858end
    5959
     
    6161    if exist(fullfileinput,'file')
    6262        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
    63     else     
     63    else
    6464        RootFile='';
    6565    end
    66 else
    67     %% possibly include the first index in the root name, if there exists a   corresponding xml file   
     66else
     67    %% possibly include the first index in the root name, if there exists a   corresponding xml file
     68    %   RootFileNew=RootFile;
     69    %     if ~isempty(regexp(NomType,['^_']))
     70    %         NomTypePref='_';
     71    %         RootFileNew=[RootFileNew '_'];
     72    %     end       RootPath='';
    6873    NomTypePref='';
    69     RootFileNew=RootFile;
    70 %     if ~isempty(regexp(NomType,['^_']))
    71 %         NomTypePref='_';
    72 %         RootFileNew=[RootFileNew '_'];
    73 %     end       RootPath='';
    7474    r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
    75 %     r=regexp(NomType,['^' NomTypePref '(?<num1>\d+)'],'names');%look for a number at the beginning of NomTypeSt
     75    %     r=regexp(NomType,['^' NomTypePref '(?<num1>\d+)'],'names');%look for a number at the beginning of NomTypeSt
    7676    if ~isempty(r)
    77         NomTypePref=r.tiretnum;
    78         fileinput_end=regexprep(fileinput,['^' RootFileNew],'');
    79         r=regexp(fileinput_end,'^(?<num1>\d+)','names');
    80         if ~isempty(r)           
    81             RootFileNew=[RootFileNew r.num1];
    82         end
    83         if exist(fullfile(RootPath,[RootFileNew '.xml']),'file')
    84             RootFile=RootFileNew;
    85             NomType=regexprep(NomType,['^' NomTypePref],'');
    86             i2_input=j2_input;
    87             j1_input=[];
    88             j2_input=[];
    89         else
    90             NomTypePref='';
     77        fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
     78        if isempty(regexp(r.tiretnum,'^_'))% if a separator '_' is not  detected
     79            rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
     80        else% if a separator '_' is  detected
     81            rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
     82        end
     83        if ~isempty(rr)
     84            RootFileNew=[RootFile rr.i1];
     85            if exist(fullfile(RootPath,[RootFileNew '.xml']),'file')
     86                RootFile=RootFileNew;
     87                NomType=regexprep(NomType,['^'  NomTypePref],'');
     88                NomTypePref=r.tiretnum;
     89                i2_input=j2_input;
     90                j1_input=[];
     91                j2_input=[];
     92            end
    9193        end
    9294    end
    9395    %% analyse the list of existing files when relevant
    9496    sep1='';
    95     i1_str='(?<i1>)';
     97    i1_str='(?<i1>)';%will set i1=[];
    9698    i1_star='';
    97     sep2='';
    98     i2_str='(?<i2>)';
     99    %     r.sep2='';
     100    i2_str='(?<i2>)';%will set i2=[];
    99101    i2_star='';
    100     sep3='';
    101     j1_str='(?<j1>)';
     102    %     sep3='';
     103    j1_str='(?<j1>)';%will set j1=[];
    102104    j1_star='';
    103     sep4='';
    104     j2_str='(?<j2>)';
     105    %     sep4='';
     106    j2_str='(?<j2>)';%will set j2=[];
    105107    j2_star='';
    106     NomTypeStr=NomType;
    107     if ~isempty(regexp(NomTypeStr,'^_\d'))
    108         sep1='_';
    109         NomTypeStr(1)=[];%remove '_' from the beginning of NomTypeStr
    110     end
    111     r=regexp(NomTypeStr,'^(?<num1>\d+)','names');%look for a number at the beginning of NomTypeStr
     108    %   NomTypeStr=NomType;
     109    %Look for cases with letter indexing for the second index
     110    r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<j1>[a|A])(?<j2>[b|B]?)$','names');
    112111    if ~isempty(r)
    113         i1_str='(?<i1>\d+)';
    114         i1_star='*';
    115         NomTypeStr=regexprep(NomTypeStr,['^' r.num1],'');
    116         r=regexp(NomTypeStr,'^-(?<num2>\d+)','names');%look for a pair i1-i2
     112        sep1=r.sep1;
     113        if strcmp(lower(r.j1),r.j1)
     114            j1_str='(?<j1>[a-z])';
     115        else
     116           j1_str='(?<j1>[A-Z])';
     117        end
     118        j1_star='*';
     119        if ~isempty(r.j2)
     120           if strcmp(lower(r.j1),r.j1)
     121            j2_str='(?<j2>[a-z])';
     122            else
     123           j2_str='(?<j2>[A-Z])';
     124           end
     125            j2_star='*';
     126        end
     127    else %numerical indexing
     128        r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<i2>(-\d+)?)(?<j1>(_\d+)?)(?<j2>(-\d+)?)$','names');
    117129        if ~isempty(r)
    118             sep2='-';
    119             i2_str='(?<i2>\d+)';
    120             i2_star='*';
    121             NomTypeStr=regexprep(NomTypeStr,['^-' r.num2],'');
    122         end
    123         if ~isempty(regexp(NomTypeStr,'^_'));
    124             sep3='_';
    125             NomTypeStr(1)=[];%remove '_' from the beginning of NomTypeStr
    126         end
    127         if ~isempty(regexp(NomTypeStr,'^[a|A]'));
    128             j1_str='(?<j1>[a-z]|[A-Z])';
    129             j1_star='*';
    130             if ~isempty(regexp(NomTypeStr,'[b|B]$'));
    131                 j2_str='(?<j2>[a-z]|[A-Z])';
    132                 j2_star='*';
    133             end
    134         else
    135             r=regexp(NomTypeStr,'^(?<num3>\d+)','names');
    136             if ~isempty(r)
    137                 j1_str='(?<j1>\d+)';
    138                  j1_star='*';
    139                 NomTypeStr=regexprep(NomTypeStr,['^' r.num3],'');
    140             end
    141             r=regexp(NomTypeStr,'-(?<num4>\d+)','names');
    142             if ~isempty(r)
    143                 sep4='-';
    144                 j2_str='(?<j2>\d+)';
    145                  j2_star='*';
    146             end
    147         end
    148     end
    149     detect_string=['^' RootFile sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str FileExt '$'];%string used in regexp to detect file indices
     130            sep1=r.sep1;
     131            i1_str='(?<i1>\d+)';
     132            i1_star='*';
     133            if ~isempty(r.i2)
     134                i2_str='(?<i2>-\d+)';
     135                i2_star='-*';
     136            end
     137            if ~isempty(r.j1)
     138                j1_str='(?<j1>_\d+)';
     139                j1_star='_*';
     140            end
     141            if ~isempty(r.j2)
     142                j2_str='(?<j2>-\d+)';
     143                j2_star='-*';
     144            end
     145        end
     146    end
     147    detect_string=['^' RootFile sep1 i1_str i2_str j1_str j2_str FileExt '$'];%string used in regexp to detect file indices
    150148    %find the string used to extract the relevant files with the command dir
    151     star_string=[RootFile sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];
     149    star_string=[RootFile sep1 i1_star i2_star  j1_star j2_star FileExt];
    152150    wd=pwd;%current working directory
    153151    cd (RootPath)% move to the local dir to save time in the operation dir.
    154     dirpair=dir([star_string FileExt]);% look for relevant files in the file directory
     152    dirpair=dir(star_string);% look for relevant files in the file directory
    155153    cd(wd)
    156154    nbpair=numel(dirpair);
     
    158156    ref_j_list=zeros(1,nbpair);
    159157    if nbpair==0% no detected file
    160 %         RootPath='';
     158        %         RootPath='';
    161159        RootFile='';
    162160    end
     
    165163        rr=regexp(dirpair(ifile).name,detect_string,'names');
    166164        if ~isempty(rr)
    167         i1=str2num(rr.i1);
    168         i2=str2num(rr.i2);
    169         j1=stra2num(rr.j1);
    170         j2=stra2num(rr.j2);
    171         ref_i=i1;
    172         if isempty(i2_input)
    173             if ~isempty(i2)% invalid file name if i2 does not exist in the input file
    174                 break
    175             end
    176         else
    177             ref_i=floor((i1+i2)/2);
    178         end
    179         ref_j=1;
    180         if isempty(j1_input)
    181             if  ~isempty(j1)% invalid file name if j1 does not exist in the input file
    182                 break
    183             end
    184         else %j1_input is not empty
    185             if isempty(j1)% the detected name does not fit with the input
    186                 break
     165            i1=str2num(rr.i1);
     166            i2=str2num(regexprep(rr.i2,'^-',''));
     167            j1=stra2num(regexprep(rr.j1,'^_',''));
     168            j2=stra2num(regexprep(rr.j2,'^-',''));
     169            ref_i=i1;
     170            if isempty(i2_input)
     171                if ~isempty(i2)% invalid file name if i2 does not exist in the input file
     172                    break
     173                end
    187174            else
    188                 ref_j=j1;
    189                 if isempty(j2_input)
    190                     if  ~isempty(j2)% invalid file name if j2 does not exist in the input file
    191                         break
     175                ref_i=floor((i1+i2)/2);
     176            end
     177            ref_j=1;
     178            if isempty(j1_input)
     179                if  ~isempty(j1)% invalid file name if j1 does not exist in the input file
     180                    break
     181                end
     182            else %j1_input is not empty
     183                if isempty(j1)% the detected name does not fit with the input
     184                    break
     185                else
     186                    ref_j=j1;
     187                    if isempty(j2_input)
     188                        if  ~isempty(j2)% invalid file name if j2 does not exist in the input file
     189                            break
     190                        end
     191                    else
     192                        ref_j=floor((j1+j2)/2);
    192193                    end
    193                 else
    194                     ref_j=floor((j1+j2)/2);
    195                 end
    196             end
    197         end
    198         % update the detected index series
    199         ref_i_list(ifile)=ref_i;
    200         ref_j_list(ifile)=ref_j;
    201         nb_pairs=0;
    202         if ~isempty(i2_input)|| ~isempty(j2_input) %deals with  pairs
    203             if size(i1_series,1)>=ref_i+1 && size(i1_series,2)>=ref_j+1
    204                 nb_pairs=numel(find(i1_series(ref_i+1,ref_j+1,:)~=0));
    205             end
    206         end
    207         i1_series(ref_i+1,ref_j+1,nb_pairs+1)=i1;
    208         if ~isempty(i2_input)
    209             i2_series(ref_i+1,ref_j+1,nb_pairs+1)=i2;
    210         end
    211         if ~isempty(j1_input)
    212             j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1;
    213         end
    214         if ~isempty(j2_input)
    215             j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1;
    216             j2_series(ref_i+1,ref_j+1,nb_pairs+1)=j2;
    217         end
     194                end
     195            end
     196            % update the detected index series
     197            ref_i_list(ifile)=ref_i;
     198            ref_j_list(ifile)=ref_j;
     199            nb_pairs=0;
     200            if ~isempty(i2_input)|| ~isempty(j2_input) %deals with  pairs
     201                if size(i1_series,1)>=ref_i+1 && size(i1_series,2)>=ref_j+1
     202                    nb_pairs=numel(find(i1_series(ref_i+1,ref_j+1,:)~=0));
     203                end
     204            end
     205            i1_series(ref_i+1,ref_j+1,nb_pairs+1)=i1;
     206            if ~isempty(i2_input)
     207                i2_series(ref_i+1,ref_j+1,nb_pairs+1)=i2;
     208            end
     209            if ~isempty(j1_input)
     210                j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1;
     211            end
     212            if ~isempty(j2_input)
     213                j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1;
     214                j2_series(ref_i+1,ref_j+1,nb_pairs+1)=j2;
     215            end
    218216        end
    219217    end
     
    227225    [tild,ifile_min]=min(ref_ij(ref_ij>0));
    228226    if isempty(ifile_min)
    229 %         RootPath='';
     227        %         RootPath='';
    230228        RootFile='';
    231229        NomType='';
     
    239237    end
    240238end
    241 
    242 
    243239
    244240%% set to empty array the irrelevant index series
  • trunk/src/mouse_motion.m

    r387 r388  
    102102                if isfield(Field,'ListVarName')
    103103                    [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field
    104                     %                     if isfield(Field,'Mesh') && ~isempty(Field.Mesh)
    105104                    text_displ_1='';
    106105                    text_displ_2='';
     
    207206                        text_displ_1=[text_displ_1 ' z=' num2str(z,3)];
    208207                    end
    209                     %coordinate transform if proj_coord differs from menu_coord A REVOIR
    210 %                     if isfield(Field,'CoordUnit')
    211 %                         mouse.CoordUnit=Field.CoordUnit;
    212 %                     end
    213              % case of PIV correlation display
     208               % case of PIV correlation display
    214209                    if test_piv
    215210                        par=read_GUI(hhciv.Civ1);
     
    221216                        par.ImageA=Field.A;
    222217                        par.ImageB=Field.B;
    223                         [par.ImageHeight,par.ImageWidth]=size(par.ImageA);
     218                        par.ImageHeight=size(par.ImageA,1);
     219                        par.ImageWidth=size(par.ImageA,2);
    224220                        Param.Civ1=par;
    225221                        ibx2=floor((par.Bx-1)/2);
     
    287283   set(handles.text_display,'String',get(handles.text_display,'UserData'))
    288284end
    289 % set(handles.text_display_1,'String',text_displ_1);
    290 % set(handles.text_display_2,'String',text_displ_2);
    291 % set(handles.text_display_3,'String',text_displ_3);
    292 % set(handles.text_display_4,'String',text_displ_4);
    293285
    294286%%%%%%%%%%%%%
  • trunk/src/mouse_up.m

    r379 r388  
    122122%     set(hh_set_object.ZObject,'String',num2str(ObjectData.Coord(:,3),4));
    123123    if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')
    124         set(hh_set_object.XMax,'String',num2str(ObjectData.RangeX,4));
    125         set(hh_set_object.YMax,'String',num2str(ObjectData.RangeY,4));
     124        set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX,4));
     125        set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4));
    126126    end
    127127    if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||...
  • trunk/src/plot_field.m

    r379 r388  
    9494
    9595function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar)
    96 % use htext: handles of the text edit box (uicontrol)
    97 % introduce PlotParam.Hold: 'on' or 'off' (for curves)
    98 %default output
    99 
     96
     97%% default input and output
    10098if ~exist('PlotParam','var'),PlotParam=[];end;
    10199if ~exist('PosColorbar','var'),PosColorbar=[];end;
     
    107105end
    108106
    109 %% test axes and figure
    110 testnewfig=1;%test to create a new figure (default)
    111 testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes
    112 if exist('haxes','var')
    113     if ishandle(haxes)
    114         if isequal(get(haxes,'Type'),'axes')
    115             testnewfig=0;
    116             AxeData=get(haxes,'UserData');
    117             if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes)
    118                 if isequal(get(AxeData.ZoomAxes,'Type'),'axes')
    119                     testzoomaxes=1;
    120                     zoomaxes=AxeData.ZoomAxes;
    121                 end
    122             end
    123         end
    124     end
    125 end
    126 
    127 % create a new figure and axes if the plotting axes does not exist
    128 if testnewfig
    129     hfig=figure;
    130     set(hfig,'Units','normalized')
    131     haxes=axes;
    132     set(haxes,'position',[0.13,0.2,0.775,0.73])
    133      PlotParam.NextPlot='add'; %parameter for plot_profile and plot_his
    134 else
    135     hfig=get(haxes,'parent');
    136     set(0,'CurrentFigure',hfig)% the parent of haxes becomes the current figure
    137     set(hfig,'CurrentAxes',haxes)%  haxes becomes the current axes of the parent figure
    138 end
    139 
    140107%% check input structure
    141 if ~isempty(Data)
    142     [Data,errormsg]=check_field_structure(Data);
    143     if ~isempty(errormsg)
    144         msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
    145         display(['input of plot_field/check_field_structure:: ' errormsg])
    146         return
    147     end
    148 
    149     %% check the cells of fields :
    150     [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
    151     if ~isempty(errormsg)
    152         msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]);
    153         return
    154     end
    155     index_2D=find(NbDim==2,2);%find 2D fields (at most 2)
    156     index_3D=find(NbDim>2,1);
    157     if ~isempty(index_3D)
    158         if isfield(Data,'NbDim')&& isequal(Data.NbDim,2)
    159             index_2D=[index_2D index_3D];
    160         else
     108index_2D=[];
     109index_1D=[];
     110index_0D=[];
     111[Data,errormsg]=check_field_structure(Data);
     112if ~isempty(errormsg)
     113    msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
     114    display(['input of plot_field/check_field_structure: ' errormsg])
     115    return
     116end
     117% check the cells of fields :
     118[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
     119if ~isempty(errormsg)
     120    msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]);
     121    return
     122end
     123index_2D=find(NbDim==2,2);%find 2D fields (at most 2)
     124index_3D=find(NbDim>2,1);
     125if ~isempty(index_3D)
     126    if isfield(Data,'NbDim')&& isequal(Data.NbDim,2)
     127        index_2D=[index_2D index_3D];
     128    else
    161129        msgbox_uvmat('ERROR','volume plot not implemented yet');
    162130        return
    163         end
    164     end
    165    
    166     index_1D=find(NbDim==1);
    167     index_0D=find(NbDim==0);
     131    end
     132end
     133index_1D=find(NbDim==1);
     134index_0D=find(NbDim==0);
     135%remove coordinates variables from 1D plot
     136if ~isempty(index_2D)
     137    for ivar=1:length(index_1D)
     138        if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord)
     139            index_1D(ivar)=0;
     140        end
     141    end
     142    index_1D=index_1D(index_1D>0);
     143end
     144
     145%% pure text display
     146if isempty(index_2D) && isempty(index_1D)% no plot
     147    hfig=findobj(allchild(0),'Tag','fig_text_display');
     148    if isempty(hfig)
     149        hfig=figure('name','text_display','Tag','fig_text_display');
     150    end
     151    htext=findobj(hfig,'Tag','text_display');
     152    if isempty(htext)
     153        htext=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71],'Tag','text_display');
     154    end
     155    if isempty(index_0D)
     156        set(htext,'String',{''})
     157    else
     158        [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext);
     159    end
     160    haxes=[];
     161end
     162
     163%% test axes and figure
     164if ~isempty(index_2D)|| ~isempty(index_1D)%  plot
     165    testnewfig=1;%test to create a new figure (default)
     166    testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes
     167    if exist('haxes','var')
     168        if ishandle(haxes)
     169            if isequal(get(haxes,'Type'),'axes')
     170                testnewfig=0;
     171                AxeData=get(haxes,'UserData');
     172                if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes)
     173                    if isequal(get(AxeData.ZoomAxes,'Type'),'axes')
     174                        testzoomaxes=1;
     175                        zoomaxes=AxeData.ZoomAxes;
     176                    end
     177                end
     178            end
     179        end
     180    end
     181    % create a new figure and axes if the plotting axes does not exist
     182    if testnewfig
     183        hfig=figure;
     184        set(hfig,'Units','normalized')
     185        haxes=axes;
     186        set(haxes,'position',[0.13,0.2,0.775,0.73])
     187        PlotParam.NextPlot='add'; %parameter for plot_profile and plot_his
     188    else
     189        hfig=get(haxes,'parent');
     190        set(0,'CurrentFigure',hfig)% the parent of haxes becomes the current figure
     191        set(hfig,'CurrentAxes',haxes)%  haxes becomes the current axes of the parent figure
     192    end
    168193   
    169194    %% set axes properties
    170     if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1)  %adjust the graph limits*
     195    if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1)  %adjust the graph limits
    171196        set(haxes,'XLimMode', 'manual')
    172197        set(haxes,'YLimMode', 'manual')
     
    184209        set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
    185210    end
    186 else
    187     index_2D=[];
    188     index_1D=[];
    189     index_0D=[];
    190 end
    191 
    192 %% plot if the input field is valid
    193 PlotType='text';
    194 errormsg=[];
    195 AxeData=get(haxes,'UserData');
    196 if isempty(index_2D)
    197     plot_plane([],[],[],haxes);%removes images or vector plots if any
    198 else
    199     [xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar);
    200     AxeData.NbDim=2;
    201     if testzoomaxes && isempty(errormsg)
    202         [zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar);
    203         AxeData.ZoomAxes=zoomaxes;
    204     end
    205     %remove coordinates variables from 1D plot
    206     for ivar=1:length(index_1D)
    207         if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord)
    208             index_1D(ivar)=0;
    209         end
    210     end
    211     index_1D=find(index_1D);
    212 end
    213 
    214 if isempty(index_1D)
    215     plot_profile([],[],[],haxes);%
    216 else
    217     Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,Coordinates);%
    218     if testzoomaxes
    219         [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates);
    220         AxeData.ZoomAxes=zoomaxes;
    221     end
    222     if ~isempty(Coordinates)
    223         PlotParamOut.Coordinates=Coordinates;
    224     end
    225     PlotType='line';
    226 end
    227 htext=findobj(hfig,'Tag','text_display');
    228 if ~isempty(htext)
    229     if isempty(index_0D)
    230         set(htext,'String',{''})
    231     else
    232         [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext);
    233     end
    234 end
    235 
     211    errormsg='';
     212   
     213    %% plot if the input field is valid
     214    AxeData=get(haxes,'UserData');
     215    if isempty(index_2D)
     216        plot_plane([],[],[],haxes);%removes images or vector plots if any
     217    else
     218        [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar);
     219        AxeData.NbDim=2;
     220        if testzoomaxes && isempty(errormsg)
     221            [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar);
     222            AxeData.ZoomAxes=zoomaxes;
     223        end
     224    end
     225    if isempty(index_1D)
     226        if ~isempty(haxes)
     227            plot_profile([],[],[],haxes);%
     228        end
     229    else
     230        Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,Coordinates);%
     231        if testzoomaxes
     232            [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates);
     233            AxeData.ZoomAxes=zoomaxes;
     234        end
     235        if ~isempty(Coordinates)
     236            PlotParamOut.Coordinates=Coordinates;
     237        end
     238        PlotType='line';
     239    end
     240    % text display
     241    htext=findobj(hfig,'Tag','text_display');
     242    if ~isempty(htext)
     243        if isempty(index_0D)
     244            set(htext,'String',{''})
     245        else
     246            [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext);
     247        end
     248    end
     249end
     250
     251%% display error message
    236252if ~isempty(errormsg)
    237253    msgbox_uvmat('ERROR', errormsg)
    238254end
    239 if isfield(PlotParamOut,'MinX')
    240     AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];%'[PlotParamOut.MinX PlotParamOut.MaxX];
    241     AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY];%[PlotParamOut.MinY PlotParamOut.MaxY]
    242 end
    243255
    244256%% update the parameters stored in AxeData
    245 set(haxes,'UserData',AxeData)
     257if ishandle(haxes)
     258    if isfield(PlotParamOut,'MinX')
     259        AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];%'[PlotParamOut.MinX PlotParamOut.MaxX];
     260        AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY];%[PlotParamOut.MinY PlotParamOut.MaxY]
     261    end
     262    set(haxes,'UserData',AxeData)
     263end
    246264
    247265%% update the plotted field stored in parent figure
     266
    248267FigData=get(hfig,'UserData');
    249 tagaxes=get(haxes,'tag');
     268if strcmp(get(hfig,'tag'),'view_field')
     269    set(hfig,'UserData',[]); % refresh user data in view_field (set by civ/TestCiv )
     270end
     271tagaxes=get(haxes,'tag');% tag of the current plot axis
    250272if isfield(FigData,tagaxes)
    251     eval(['FigData.' tagaxes '=Data;'])
     273    FigData.(tagaxes)=Data;
    252274    set(hfig,'UserData',FigData)
    253275end
  • trunk/src/proj_field.m

    r382 r388  
    182182    end
    183183    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
    184     VarType=VarTypeCell{icell};
     184    VarType=VarTypeCell{icell};% structure defining the types of variables in the cell
    185185    ivar_X=VarType.coord_x;
    186186    ivar_Y=VarType.coord_y;
     
    211211    for ivar=VarIndex       
    212212        VarName=FieldData.ListVarName{ivar};
    213         ProjData.ListVarName=[ProjData.ListVarName {VarName}];
    214         ProjData.VarDimName=[ProjData.VarDimName {'nb_points'}];
     213        ProjData.ListVarName=[ProjData.ListVarName {VarName}];% add the current variable to the list of projected variables
     214        ProjData.VarDimName=[ProjData.VarDimName {'nb_points'}]; % projected VarName has a single dimension called 'nb_points' (set of projection points)
    215215    end
    216216    if ~test_grid
     
    236236           if isequal(length(ivar_FF),1)
    237237               FFName=FieldData.ListVarName{ivar_FF};
    238                eval(['FF=FieldData.' FFName '(indsel);'])
    239                %ind_indsel=find(~FF);
     238               FF=FieldData.(FFName)(indsel);
    240239               indsel=indsel(~FF);
    241240           end
     
    244243               VarName=FieldData.ListVarName{ivar};
    245244               if isempty(indsel)
    246                     eval(['ProjData.' VarName '(ipoint,1)=NaN;'])
     245                    ProjData.(VarName)(ipoint,1)=NaN;
    247246               else
    248                     eval(['Var=FieldData.' VarName '(indsel);'])
    249                     eval(['ProjData.' VarName '(ipoint,1)=mean(Var);'])
     247                    Var=FieldData.(VarName)(indsel);
     248                    ProjData.(VarName)(ipoint,1)=mean(Var);
    250249                    if isequal(ObjectData.ProjMode,'interp')
    251250                         ProjData.(VarName)(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2));
     
    254253            end
    255254        end
    256     else
    257         %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
    258         %case of structured coordinates
     255    else    %case of structured coordinates
    259256        if  numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
    260257            AYName=FieldData.ListVarName{VarType.coord(1)};
     
    262259            eval(['AX=FieldData.' AXName ';']);% set of x positions
    263260            eval(['AY=FieldData.' AYName ';']);% set of y positions 
    264             AName=FieldData.ListVarName{VarIndex(1)};
     261            AName=FieldData.ListVarName{VarIndex(1)};% a single variable assumed in the current cell
    265262            eval(['A=FieldData.' AName ';']);% scalar
    266             npxy=size(A);
    267 
    268 % %             nbcolor=1; %default
    269 %             for idim=1:length(ListDimName)
    270 %                 DimName=ListDimName{idim};
    271 %                 if isequal(DimName,'rgb')|isequal(DimName,'nb_coord')|isequal(DimName,'nb_coord_i')
    272 %                    nbcolor=npxy(idim);
    273 %                    DimIndices(idim)=[];
    274 %                    npxy(idim)=[];
    275 %                 end
    276 %                 if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
    277 %                     DimIndices(idim)=[];
    278 %                     npxy(idim)=[];
    279 %                 end
    280 %             end 
    281             ind_1=find(npxy==1);
    282             %DimIndices(ind_1)=[]; %suppress singleton dimensions
    283 %             indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
    284             %NbDim=length(DimIndices)%number of space dimensions
    285             NbDim=numel(VarType.coord);
    286             Coord_z=[];
    287             Coord_y=[];
    288             Coord_x=[];   
     263            npxy=size(A);       
     264            NbDim=numel(VarType.coord(VarType.coord>0));%number of space dimensions
     265            %update VarDimName in case of components (non coordinate dimensions e;g. color components)
     266            if numel(npxy)>NbDim
     267                ProjData.VarDimName{end}={'nb_points','component'};
     268            end
    289269            for idim=1:NbDim %loop on space dimensions
    290270                test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
    291271                test_coord(idim)=0;%test for defined coordinates, =0 by default
    292                 %ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension
    293272                ivar=VarType.coord(idim);
    294 %                 if ~isequal(ivar,0)%  a variable corresponds to the current dimension
    295                     eval(['Coord{idim}=FieldData.' FieldData.ListVarName{ivar} ';']) ;% position for the first index
    296                     if numel(Coord{idim})==2
    297                        DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1);
    298                     else
    299                         DCoord=diff(Coord{idim});
    300                         DCoord_min(idim)=min(DCoord);
    301                         DCoord_max=max(DCoord);
    302                         test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
    303                         test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise
    304                         if ~isequal(test_direct(idim),test_direct_min)
    305                             errormsg=['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'];
    306                                     return
    307                         end               
    308                         test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
    309                         test_coord(idim)=1;
    310                     end
    311 %                 else  % no variable associated with the first dimension, look fo variable  attributes Coord_1, _2 or _3
    312 %                     Coord_i_str=['Coord_' num2str(idim)];
    313 %                     DCoord_min(idim)=1;%default
    314 %                     Coord{idim}=[0.5 npxy(idim)];
    315 %                     test_direct(idim)=1;
    316 %                 end
     273                Coord{idim}=FieldData.(FieldData.ListVarName{ivar}); % position for the first index
     274                if numel(Coord{idim})==2
     275                    DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1);
     276                else
     277                    DCoord=diff(Coord{idim});
     278                    DCoord_min(idim)=min(DCoord);
     279                    DCoord_max=max(DCoord);
     280                    test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
     281                    test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise
     282                    if ~isequal(test_direct(idim),test_direct_min)
     283                        errormsg=['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'];
     284                        return
     285                    end
     286                    test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
     287                    test_coord(idim)=1;
     288                end
    317289            end
    318290            DX=DCoord_min(2);
     
    343315                    %[I,J]=meshgrid([1:j_int],[1:i_int]);
    344316                    for ivar=VarIndex   
    345                         eval(['Avalue=FieldData.' FieldData.ListVarName{ivar} '(j_int,i_int,:);']);
    346                         eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=mean(mean(Avalue));']);
     317                        Avalue=FieldData.(FieldData.ListVarName{ivar})(j_int,i_int,:);
     318                        ProjData.(FieldData.ListVarName{ivar})(ipoint,:)=mean(mean(Avalue));
    347319                    end
    348320                end
     
    445417        eval(['AY=FieldData.' AYName ';'])% y coordinate
    446418        VarName=FieldData.ListVarName{VarIndex(1)};
    447         eval(['DimValue=size(FieldData.' VarName ');'])
     419        DimValue=size(FieldData.(VarName));
    448420       if length(AX)==2
    449421           AX=linspace(AX(1),AX(end),DimValue(2));
     
    460432%         AX=linspace(Coord{2}(1),Coord{2}(2),DimValue(2));
    461433%         AY=linspace(Coord{1}(1),Coord{1}(2),DimValue(1));  %TODO : 3D case
    462         testcolor=find(numel(DimValue)==3);
     434%         testcolor=find(numel(DimValue)==3);
    463435        if length(DimValue)==3
    464436            testcolor=1;
     
    475447        for ivar=1:length(VarIndex)
    476448            VarName=FieldData.ListVarName{VarIndex(ivar)};
    477             eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',npxy(1)*npxy(2),npxy(3));']); % keep only non false vectors
     449            FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors
    478450        end
    479451    end
     
    526498        if testproj(ivar)
    527499            VarName=FieldData.ListVarName{ivar};
    528             eval(['ProjData.' VarName 'Mean=mean(mean(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors
    529             eval(['ProjData.' VarName 'Min=min(min(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors
    530             eval(['ProjData.' VarName 'Max=max(max(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors
     500            ProjData.([VarName 'Mean'])=mean(double(FieldData.(VarName)(indsel,:))); % take the mean in the selected region, for each color component
     501            ProjData.([VarName 'Min'])=min(double(FieldData.(VarName)(indsel,:))); % take the min in the selected region , for each color component 
     502            ProjData.([VarName 'Max'])=max(double(FieldData.(VarName)(indsel,:))); % take the max in the selected region , for each color component
    531503            if isequal(Mesh(ivar),0)
    532                 eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:)),100);']); % default histogram with 100 bins
     504                eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:,:)),100);']); % default histogram with 100 bins
    533505            else
    534506                eval(['ProjData.' VarName '=(ProjData.' VarName 'Min+Mesh(ivar)/2:Mesh(ivar):ProjData.' VarName 'Max);']); % list of bin values
     
    537509            ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}];
    538510            if test_Amat && testcolor
    539                  ProjData.VarDimName=[ProjData.VarDimName  {VarName} {{VarName,'rgb'}} {'rgb'}];%{{'nb_point','rgb'}};
     511                 ProjData.VarDimName=[ProjData.VarDimName  {VarName} {{VarName,'rgb'}} {'rgb'} {'rgb'} {'rgb'}];%{{'nb_point','rgb'}};
    540512            else
    541                ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'} {'nbpoint'} {'nbpoint'}];
     513               ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'one'} {'one'} {'one'}];
    542514            end
    543515            ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
  • trunk/src/set_object.m

    r387 r388  
    220220set(handles.ProjMode,'String',menu_proj)
    221221ProjMode_Callback(hObject, eventdata, handles)
    222 
    223 %store the current option
    224 % str=get(handles.Type,'String');
    225 % val=get(handles.Type,'Value');
    226 % set(handles.Type,'UserData',style)
    227 
    228 %------------------------------------------------------------------------
    229 function xObject_Callback(hObject, eventdata, handles)
    230 
    231 %------------------------------------------------------------------------
    232 function yObject_Callback(hObject, eventdata, handles)
    233 
    234 %------------------------------------------------------------------------
    235 % --- Executes on selection change in zObject.
    236 function zObject_Callback(hObject, eventdata, handles)
    237 %------------------------------------------------------------------------
    238222
    239223%------------------------------------------------------------------------
     
    403387
    404388%% reading the object parameters on the GUI uvmat
    405 huvmat=findobj('tag','uvmat');%find the current uvmat interface handle
     389huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle
    406390UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
    407 hhuvmat=guidata(huvmat);%handles in the uvmat GUI
    408 ListObject=get(hhuvmat.ListObject,'String');%position in the objet list
    409 IndexObj=get(hhuvmat.ListObject,'Value');
     391hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
     392ListObject=get(hhuvmat.ListObject,'String');% list of objects displyed in uvmat
     393IndexObj=get(hhuvmat.ListObject,'Value');% index(indices) of the selected object(s) in uvmat
     394                                        % (the first one is plotted in uvmat axis, the second one in view_field)
    410395
    411396%% read the object on the GUI set_object
    412 %ObjectData=read_set_object(handles.set_object);%read the input parameters defining the object in the GUI set_object
    413 ObjectData=read_GUI(handles.set_object);%read the input parameters defining the object in the GUI set_object
    414 %ObjectData.Coord=cell2mat(ObjectData.Coord);
    415 ObjectName=ObjectData.Name;%name of the current object defiend in set_object
     397ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
     398ObjectName=ObjectData.Name;%name of the current object defined in set_object
     399checknan=isnan(sum(ObjectData.Coord,2));%check for NaN lines
     400if ~isempty(checknan)
     401    ObjectData.Coord(checknan,:)=[];%remove the NaN lines
     402end
    416403if isempty(ObjectName)
    417404    if get(hhuvmat.edit_object,'Value')% edit mode
     
    449436testnew=0;
    450437if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
    451  %       PlotHandles=hhuvmat;
    452438    plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
    453439else  % if a second object is selected, the projection is in view_field, and this second object is selected
    454440    hview_field=findobj(allchild(0),'tag','view_field');
    455441    if isempty(hview_field)
    456         hview_field=view_field;
     442        hview_field=view_field;%open the GUI view_field if it is not found
    457443    end
    458444    PlotHandles=guidata(hview_field);
     
    464450set(hhuvmat.ListObject,'String',ListObject)
    465451
    466 %% update the object plot and projection field
     452%% update the object plot
    467453if testnew
    468454    set(hhuvmat.ListObject,'Value',IndexObj)
     
    488474
    489475%% plot the field projected on the object and store in the corresponding figue
    490 [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    491 if ~isempty(errormsg)
    492     msgbox_uvmat('ERROR', errormsg)
    493     return
    494 end
    495 fighandle=get(plotaxes,'parent');
    496 PlotParam=read_GUI(fighandle);
    497 [PlotType,Object_out{IndexObj(end)}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
    498 
     476if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none')
     477    PlotType='text';
     478   
     479else
     480    [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current field of uvmat on ObjectData
     481    if ~isempty(errormsg)
     482        msgbox_uvmat('ERROR', errormsg)
     483        return
     484    end
     485    fighandle=get(plotaxes,'parent');
     486    PlotParam=read_GUI(fighandle);
     487    PlotType=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
     488end
     489if strcmp(PlotType,'text')
     490    hview_field=findobj(allchild(0),'tag','view_field'); %case of no projection (pure object display)
     491    if ~isempty(hview_field)
     492        delete(hview_field)
     493    end
     494end
     495   
    499496%% update the GUI uvmat
    500497hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI
     
    603600end
    604601
    605 %set new plane position and update graph
    606 % set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4))
    607 % set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4))
    608 % set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4))
     602% update graph
    609603PLOT_Callback(hObject, eventdata, handles)
    610604
     
    616610pathelp=fileparts(path_to_uvmat);
    617611helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
    618 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    619 else
     612if ~isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    620613    addpath (fullfile(pathelp,'uvmat_doc'))
    621614    web([helpfile '#set_object'])
     
    641634    case{'points','polyline','polygon'}
    642635        Coord=get(handles.Coord,'Data');
    643         if isequal(size(Coord,2),3)
    644             Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
    645         else
    646             Coord=[Coord;{[]} {[]}]; %add a line for edition (2D case)
    647         end
    648         set(handles.Coord,'Data',Coord)
     636        if ~isnan(Coord(end,1))
     637            if isequal(size(Coord,2),3)
     638                %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
     639                Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case)
     640            else
     641                Coord=[Coord;NaN NaN]; %add a line for edition (2D case)
     642            end
     643            set(handles.Coord,'Data',Coord)
     644        end
    649645end
    650646
  • trunk/src/uvmat.m

    r387 r388  
    16311631            ref_j=ref_j+increment;
    16321632        end
    1633     else% free increment
     1633    else % free increment
    16341634        if isequal(get(handles.runplus,'BackgroundColor'),[1 1 0])% if runplus is activated
    16351635            step=1;
     
    16621662    end
    16631663    if get(handles.scan_i,'Value')==1% case of scanning along index i
    1664         i1_subseries=UvData.i1_series{1}(ref_i+1,:,:);
     1664        i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:);
    16651665    else
    1666         i1_subseries=UvData.i1_series{1}(:,ref_j+1,:);
     1666        i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:);
    16671667    end
    16681668    i1_subseries=i1_subseries(i1_subseries>0);
     
    16741674    if ~isempty(UvData.i2_series{1})
    16751675        if get(handles.scan_i,'Value')==1% case of scanning along index i
    1676             i2_subseries=UvData.i2_series{1}(ref_i+1,:,:);
     1676            i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:);
    16771677        else
    1678             i2_subseries=UvData.i2_series{1}(:,ref_j+1,:);
     1678            i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:);
    16791679        end
    16801680        i2_subseries=i2_subseries(i2_subseries>0);
     
    16831683    if ~isempty(UvData.j1_series{1})
    16841684        if get(handles.scan_i,'Value')==1% case of scanning along index i
    1685             j1_subseries=UvData.j1_series{1}(ref_i+1,:,:);
     1685            j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:);
    16861686        else
    1687             j1_subseries=UvData.j1_series{1}(:,ref_j+1,:);
     1687            j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:);
    16881688        end
    16891689        j1_subseries=j1_subseries(j1_subseries>0);
     
    16921692    if ~isempty(UvData.j2_series{1})
    16931693        if get(handles.scan_i,'Value')==1% case of scanning along index i
    1694             j2_subseries=UvData.j2_series{1}(ref_i+1,:,:);
     1694            j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:);
    16951695        else
    1696             j2_subseries=UvData.j2_series{1}(:,ref_j+1,:);
     1696            j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:);
    16971697        end
    16981698        j2_subseries=j2_subseries(j2_subseries>0);
Note: See TracChangeset for help on using the changeset viewer.