Changeset 1184


Ignore:
Timestamp:
Nov 6, 2025, 7:03:02 PM (4 weeks ago)
Author:
sommeria
Message:

bed-scan updated and many updates

Location:
trunk/src
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/command_launch_matlab.m

    r1179 r1184  
    3636    'matlab -nodisplay -nosplash -nojvm ''' ThreadOption ''' -logfile ''' filelog ''' <<END_MATLAB\n'...%launch the new Matlab session  without display
    3737    'addpath(''' path_uvmat ''');\n'...
    38     'addpath(''' ActionPath ''');\n'];
     38    'current_dir=pwd;\n'... % current working dir
     39    'cd(''' ActionPath ''');\n'...
     40'h_fun=str2func(''' ActionName ''');\n'...% create the function handle for the function ActionName
     41'cd(current_dir);\n'];
     42 %   'addpath(''' ActionPath ''');\n'];
    3943for iprocess=1:numel(inputxml)
    40     cmd=[cmd '' ActionName  '(''' inputxml{iprocess} ''');\n'];
     44%    cmd=[cmd '' ActionName  '(''' inputxml{iprocess} ''');\n'];
     45cmd=[cmd ' h_fun  (''' inputxml{iprocess} ''');\n'];
    4146end
    4247cmd=[cmd  'exit\n' 'END_MATLAB\n'];
  • trunk/src/get_file_index.m

    r1172 r1184  
    4646    switch r.mode
    4747        case 'Di='  %  case 'series(Di)')
    48             i1=ref_i-str2num(r.num1);
    49             i2=ref_i+str2num(r.num2);
     48            i1=ref_i-str2double(r.num1);
     49            i2=ref_i+str2double(r.num2);
    5050        case 'Dj='  %  case 'series(Dj)'
    51             j1=ref_j-str2num(r.num1);
    52             j2=ref_j+str2num(r.num2);
     51            j1=ref_j-str2double(r.num1);
     52            j2=ref_j+str2double(r.num2);
    5353        case '-'  % case 'bursts'
    54             j1=str2num(r.num1)*ones(size(ref_i));
    55             j2=str2num(r.num2)*ones(size(ref_i));
     54            j1=str2double(r.num1)*ones(size(ref_i));
     55            j2=str2double(r.num2)*ones(size(ref_i));
    5656    end
    5757end
  • trunk/src/imadoc2struct.m

    r1183 r1184  
    3434
    3535function [s,errormsg]=imadoc2struct(ImaDoc,varargin)
    36 %% default input and output
    37 errormsg='';%default
    38 s=[];
     36
     37s=[]; %default output
    3938
    4039%% opening the xml file
    41 [tild,tild,FileExt]=fileparts(ImaDoc);
    42 
    4340if nargin ==1% no additional input variable beyond 'ImaDoc'
    4441    [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
     
    5653    return
    5754end
     55
    5856%% reading timing
    5957if isfield(s,'Camera')
     
    6765end
    6866
    69 
    70 function [s,errormsg]=read_subtree(subt,Data,NbOccur,NumTest)
    71 %--------------------------------------------------
    72 s=[];%default
    73 errormsg='';
    74 head_element=get(subt,1,'name');
    75     cont=get(subt,1,'contents');
    76     if ~isempty(cont)
    77         for ilist=1:length(Data)
    78             uid_key=find(subt,[head_element '/' Data{ilist}]);
    79             if ~isequal(length(uid_key),NbOccur(ilist))
    80                 errormsg=['wrong number of occurence for ' Data{ilist}];
    81                 return
    82             end
    83             for ival=1:length(uid_key)
    84                 val=get(subt,children(subt,uid_key(ival)),'value');
    85                 if ~NumTest(ilist)
    86                     eval(['s.' Data{ilist} '=val;']);
    87                 else
    88                     eval(['s.' Data{ilist} '=str2double(val);'])
    89                 end
    90             end
    91         end
    92     end
    93 
    94 
    95 %--------------------------------------------------
    96 %  read an xml element
    97 function val=get_value(t,label,default)
    98 %--------------------------------------------------
    99 val=default;
    100 uid=find(t,label);%find the element iud(s)
    101 if ~isempty(uid) %if the element named label exists
    102    uid_child=children(t,uid);%find the children
    103    if ~isempty(uid_child)
    104        data=get(t,uid_child,'type');%get the type of child
    105        if iscell(data)% case of multiple element
    106            for icell=1:numel(data)
    107                val_read=str2num(get(t,uid_child(icell),'value'));
    108                if ~isempty(val_read)
    109                    val(icell,:)=val_read;
    110                end
    111            end
    112 %           val=val';
    113        else % case of unique element value
    114            val_read=str2num(get(t,uid_child,'value'));
    115            if ~isempty(val_read)
    116                val=val_read;
    117            else
    118               val=get(t,uid_child,'value');%char string data
    119            end
    120        end
    121    end
    122 end
    123 
    124 %------------------------------------------------------------------------
    125 %'read_imatext': reads the .civ file for image documentation (obsolete)
    126 % fileinput: name of the documentation file
    127 % time: matrix of times for the set of images
    128 %pxcmx: scale along x in pixels/cm
    129 %pxcmy: scale along y in pixels/cm
    130 function [error,time,TimeUnit,mode,npx,npy,GeometryCalib]=read_imatext(fileinput)
    131 %------------------------------------------------------------------------
    132 error='';%default
    133 time=[]; %default
    134 TimeUnit='s';
    135 mode='pairs';
    136 npx=[]; %default
    137 npy=[]; %default
    138 GeometryCalib=[];
    139 if ~exist(fileinput,'file'), error=['image doc file ' fileinput ' does not exist']; return;end;%input file does not exist
    140 dotciv=textread(fileinput);
    141 sizdot=size(dotciv);
    142 if ~isequal(sizdot(1)-8,dotciv(1,1));
    143     error=1; %inconsistent number of bursts
    144 end
    145 nbfield=sizdot(1)-8;
    146 npx=(dotciv(2,1));
    147 npy=(dotciv(2,2));
    148 pxcmx=(dotciv(6,1));% pixels/cm in the .civ file
    149 pxcmy=(dotciv(6,2));
    150 % nburst=dotciv(3,1); % nbre of bursts
    151 abs_time1=dotciv([9:nbfield+8],2);
    152 dtime=dotciv(5,1)*(dotciv([9:nbfield+8],[3:end-1])+1);
    153 timeshift=[abs_time1 dtime];
    154 time=cumsum(timeshift,2);
    155 GeometryCalib.CalibrationType='rescale';
    156 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    157 GeometryCalib.Tx=0;
    158 GeometryCalib.Ty=0;
    159 GeometryCalib.Tz=1;
    160 GeometryCalib.dpx=1;
    161 GeometryCalib.dpy=1;
    162 GeometryCalib.sx=1;
    163 GeometryCalib.Cx=0;
    164 GeometryCalib.Cy=0;
    165 GeometryCalib.f=1;
    166 GeometryCalib.kappa1=0;
    167 GeometryCalib.CoordUnit='cm';
  • trunk/src/index2filename.m

    r1180 r1184  
    1 % get the file name and frame index from a set of multimage files (e.g. from PCO camera)
     1% translate logical indices i1, j1, into file name and frame index in a set of multimage files (e.g. from PCO camera)
    22%------------------------------------------------------------------------
    3 % [RootFile,FileIndexString,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)
     3% [RootFile,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)
    44%
    55% OUTPUT:
    6 % RootFile, FileIndexString: name of the multimage file = [RootFile FileIndexString FileExt]
    7 % FrameIndex: index in the multimage file    
     6% FileName: name of the multimage file = [RootFile FileIndexString FileExt]
     7% FrameIndex: index in the multimage file FileName   
    88%
    99% INPUT:
    10 % FileSeries: structure read from the xml file, defining the the multifile organisation of images 
    11 % i1: global frame index i, or  single concatenated index vector (then no further input j1 and NbField_j
     10% FileSeries: structure read from the xml file, defining the multifile organisation of images 
     11% i1: global frame index i, or  single concatenated index vector (then no input j1 and NbField_j
    1212% j1: j index
    1313% NbField_j: nbre of j indices in the index matrix
     
    5555        FileName=FileSeries.FileName{FileIndex};
    5656    end
    57 
    58     % switch FileSeries.Convention
    59     %     case 'PCO'
    60     %         RootFile=FileSeries.RootName;
    61     %         FileIndex=floor(i_vector/FileSeries.NbFramePerFile);
    62     %         if FileIndex>0
    63     %             RootFile=[RootFile '@'];
    64     %            FileIndexString=num2str(FileIndex,'%04d');
    65     %         end
    6657    FrameIndex=mod(i_vector-1,FileSeries.NbFramePerFile)+1;
    6758end
  • trunk/src/keyboard_callback.m

    r1183 r1184  
    9090                                set(handleshaxes.movie_pair,'value',0);
    9191                                set(handleshaxes.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
    92                                 set(handleshaxes.i2,'String','')% the second i index display is suppressed
    93                                 set(handleshaxes.j2,'String','')% the second j index display is suppressed
     92                                set(handleshaxes.num_i2,'String','')% the second i index display is suppressed
     93                                set(handleshaxes.num_j2,'String','')% the second j index display is suppressed
    9494                                set(handleshaxes.Dt_txt,'String','')% the time interval indication is suppressed
    9595                            end
  • trunk/src/phys_XYZ.m

    r1127 r1184  
    11%------------------------------------------------------------------------
    22%'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters
    3 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Zindex)
     3% function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,Slice,X,Y,Zindex)
    44%
    55%OUTPUT:
     
    77%INPUT:
    88% Calib: Matlab structure containing the calibration parameters (pinhole camera model, see
    9 % http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#GeometryCalib) and the
    10 %    parameters describing the illumination plane(s)
     9% http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#GeometryCalib)
    1110%    .Tx_Ty_Tz: translation (3 phys coordinates) defining the origine of the camera frame
    1211%    .R : rotation matrix from phys to camera frame
    1312%    .fx_fy: focal length along each direction of the image
     13% Slice: Matlab structure containing the parameters describing the position and inclination of the illumination plane
    1414% X, Y: vectors of X and Y image coordinates
    15 % ZIndex: index defining the current illumination plane in a volume scan
     15% ZIndex (if needed): index defining the current illumination plane in a volume scan,=1 by default
    1616
    1717%=======================================================================
     
    3737testangle=0;% =1 if the illumination plane is tilted with respect to the horizontal plane Xphys Yphys
    3838test_refraction=0;% =1 if the considered points are viewed through an horizontal interface (located at z=Calib.InterfaceCoord(3)')
     39if ~exist('X','var')||~exist('Y','var')
     40    Xphys=[];
     41    Yphys=[];%default
     42    return
     43end
    3944Zphys=0; %default output
     45
    4046if isempty(Slice)
    4147    Slice=Calib;%old convention < 2022
     48elseif ~isfield(Slice,'SliceCoord')% bad input
     49    Xphys=[];
     50    Yphys=[];% bad input
     51    return
    4252end
    4353if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Slice,'SliceCoord')&&size(Slice.SliceCoord,1)>=Zindex
     
    5969    Z0virt=0;
    6070end
    61 if ~exist('X','var')||~exist('Y','var')
    62     Xphys=[];
    63     Yphys=[];%default
    64     return
    65 end
     71
    6672%coordinate transform
    6773if ~isfield(Calib,'fx_fy')
  • trunk/src/read_GUI.m

    r1127 r1184  
    4343        switch object_type
    4444            case 'uipanel'
    45                 eval(['struct.' tag '=read_GUI(hchild(ichild));'])
     45                struct.(tag)= read_GUI(hchild(ichild));
    4646            case 'uicontrol'
    4747                object_style=get(hchild(ichild),'Style');
  • trunk/src/read_field.m

    r1180 r1184  
    5858errormsg='';
    5959if isempty(regexp(FileName,'^http://', 'once'))&& ~exist(FileName,'file')
    60     errormsg=['input file ' FileName ' does not exist'];
     60    errormsg='input file does not exist';
    6161    return
    6262end
  • trunk/src/read_multimadoc.m

    r1152 r1184  
    3535warnmsg='';
    3636if ischar(RootPath)
    37     RootPath={RootPath};SubDir={SubDir};RootFile={RootFile};FileExt={FileExt};
     37    RootPath={RootPath};SubDir={SubDir};%RootFile={RootFile};FileExt={FileExt};
    3838end
    3939nbview=numel(RootPath);
  • trunk/src/rename_indexing.m

    r1078 r1184  
    1111            NewName=[NewName '_1'];%add the index 1
    1212        else
    13             newindex=str2num(NewName(rr:end))+1; %increment the index by 1
     13            newindex=str2double(NewName(rr:end))+1; %increment the index by 1
    1414            NewName=[NewName(1:rr-1) num2str(newindex)];
    1515        end
  • trunk/src/series.m

    r1183 r1184  
    134134%% Read the parameter file series.xml, or created from series.xml.default if it does not exist
    135135SeriesData=[];
    136 [path_series,name,ext]=fileparts(which('series'));% path to the GUI series
     136path_series=fileparts(which('series'));% path to the GUI series
    137137xmlfile=fullfile(path_series,'series.xml');
    138138if ~exist(xmlfile,'file')
     
    157157NbBuiltinAction=numel(ActionList);
    158158set(handles.Action,'UserData',NbBuiltinAction)
    159 path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
    160 [path_series,name,ext]=fileparts(which('series')); % path to the GUI series
     159%path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
     160[path_series]=fileparts(which('series')); % path to the GUI series
    161161path_series_fct=fullfile(path_series,'series'); % path of the functions in subdirectroy 'series'
    162162ActionExtList={'.m';'.sh';'fluidimage'}; % default choice of extensions (Matlab fct .m or compiled version .sh
     
    166166if isfield(SeriesData.ClusterParam, 'ExistenceTest')
    167167    oarcommand=SeriesData.ClusterParam.ExistenceTest;
    168     [s,w]=system(oarcommand); % look for cluster system presence
     168    s=system(oarcommand); % look for cluster system presence
    169169    if isequal(s,0)% cluster detected
    170170        RunModeList=[RunModeList;{'cluster'}];
     
    275275    %% fill the list of input file series
    276276    InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}];
    277     if isempty(find(cellfun('isempty',InputTable)==0)) % if there is no input file, do not introduce input info
     277    if isempty(find(cellfun('isempty',InputTable)==0,1)) % if there is no input file, do not introduce input info
    278278        set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
    279279        return
    280280    end
    281     TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
     281   % TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
    282282    if isfield(Param.InputFile,'RootPath_1')
    283283        InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]];
    284         TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
     284       % TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
    285285    end
    286286    set(handles.InputTable,'Data',InputTable)
     
    291291    set(handles.Device,'String',[Device DeviceExt])
    292292    set(handles.Experiment,'String',[Experiment ExperimentExt])
    293     if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)'))
     293    if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)','once'))
    294294    set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
    295295    end
     
    308308    %% determine the selected reference field indices for pair display
    309309
    310     [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex);
    311     if isempty(i1)
    312         i1=1;
    313     end
    314     if isempty(i2)
    315         i2=i1;
    316     end
     310  %  [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex);
     311  i1=1;j1=1;%default
     312    if isfield(Param,'i1')
     313        i1=Param.i1;
     314    end
     315    if isfield(Param,'j1')
     316        j1=Param.j1;
     317    end
     318    if isfield(Param,'i2')
     319        i2=Param.i2;
     320    end
     321    if isfield(Param,'j2')
     322        j2=Param.j2;
     323    end
     324   
    317325    ref_i=floor((i1+i2)/2); % reference image number corresponding to the file
    318326    % set(handles.num_ref_i,'String',num2str(ref_i));
     
    609617%% update MinIndex_i and MaxIndex_i if the input table content has been reduced in line nbre
    610618MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
    611 if ~isempty(MinIndex_i_table)
    612619set(handles.MinIndex_i,'Data',MinIndex_i_table(1:nbview,:));
    613 end
    614620MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
    615 if ~isempty(MinIndex_j_table)
    616621set(handles.MinIndex_j,'Data',MinIndex_j_table(1:nbview,:));
    617 end
    618622MaxIndex_i_table=get(handles.MaxIndex_i,'Data'); % retrieve the min indices in the table MinIndex
    619 if ~isempty(MaxIndex_i_table)
     623
    620624set(handles.MaxIndex_i,'Data',MaxIndex_i_table(1:nbview,:));
    621 end
    622625MaxIndex_j_table=get(handles.MaxIndex_j,'Data'); % retrieve the min indices in the table MinIndex
    623 if ~isempty(MaxIndex_j_table)
    624626set(handles.MaxIndex_j,'Data',MaxIndex_j_table(1:nbview,:));
    625 end
    626627PairString=get(handles.PairString,'Data'); % retrieve the min indices in the table MinIndex
    627 if ~isempty(PairString)
    628628set(handles.PairString,'Data',PairString(1:nbview,:));
    629 end
    630629TimeTable=get(handles.TimeTable,'Data'); % retrieve the min indices in the table MinIndex
    631 if ~isempty(TimeTable)
    632630set(handles.TimeTable,'Data',TimeTable(1:nbview,:));
    633 end
    634631
    635632%% set length of waitbar
     
    861858
    862859%% display the min and max indices for the whole file series
    863 if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
     860if isempty(i1_series)
     861    MinIndex_j=1;MaxIndex_j=1;MinIndex_i=1;MaxIndex_i=1;
     862elseif size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
    864863    MinIndex_j=1; % index j set to 1 by default
    865864    MaxIndex_j=1;
     
    988987XmlData=[];
    989988check_calib=0;
    990 
    991989XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2});
    992990if ~isempty(XmlFileName)
     
    996994    end
    997995    % read time if available
    998     if isfield(XmlData,'Time') && strcmp(FileInfo.FieldType,'image')
     996    if isfield(XmlData,'Time')
    999997        Time=XmlData.Time;
    1000998        TimeName='xml';
     
    13101308end
    13111309PairString=get(handles.PairString,'Data');
    1312 ref_i_1=str2num(get(handles.num_first_i,'String')); % first reference index
    1313 ref_i_2=str2num(get(handles.num_last_i,'String')); % last reference index
    1314 ref_j_1=[];ref_j_2=[];
     1310ref_i_1=str2double(get(handles.num_first_i,'String')); % first reference index
     1311if isnan(ref_i_1)
     1312ref_i_1=1;
     1313end
     1314ref_i_2=str2double(get(handles.num_last_i,'String')); % last reference index
     1315if isnan(ref_i_2)
     1316ref_i_2=1;
     1317end
     1318ref_j_1=NaN;ref_j_2=NaN;
    13151319if strcmp(get(handles.num_first_j,'Visible'),'on')
    1316 ref_j_1=str2num(get(handles.num_first_j,'String'));
    1317 ref_j_2=str2num(get(handles.num_last_j,'String'));
     1320    ref_j_1=str2double(get(handles.num_first_j,'String'));
     1321    ref_j_2=str2double(get(handles.num_last_j,'String'));
    13181322end
    13191323[i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString);
     
    14291433
    14301434function errormsg=launch_action(handles)
    1431 errormsg=''; % default
     1435%errormsg=''; % default
    14321436
    14331437%% read the data on the GUI series
     
    16371641        end
    16381642    end
    1639     [xx,ExpName]=fileparts(Param.InputTable{1,1});
    1640     Param.IndexRange.first_i=str2num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess
    1641     Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String'));
     1643    [~,ExpName]=fileparts(Param.InputTable{1,1});
     1644    Param.IndexRange.first_i=str2double(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess
     1645    Param.IndexRange.last_i=str2double(get(handles.num_last_i,'String'));
    16421646
    16431647    %% create the output data directory if needed, after checking its existence
     
    16551659        else
    16561660            PathExpOut=fullfile(PathOut,get(handles.Experiment,'String'));
    1657             PathExpDeviceOut=fullfile(PathExpOut,get(handles.Device,'String'))
     1661            PathExpDeviceOut=fullfile(PathExpOut,get(handles.Device,'String'));
    16581662        end
    16591663        if ~exist(PathExpOut,'dir')
    1660             [tild,msg1]=mkdir(PathExpOut);
     1664            [~,msg1]=mkdir(PathExpOut);
    16611665            if ~strcmp(msg1,'')
    16621666                errormsg=['cannot create ' PathExpOut ': ' msg1]; % error message for directory creation
     
    16651669        end
    16661670        if ~exist(PathExpDeviceOut,'dir')
    1667             [tild,msg1]=mkdir(PathExpDeviceOut);
     1671            [~,msg1]=mkdir(PathExpDeviceOut);
    16681672            if ~strcmp(msg1,'')
    16691673                errormsg=['cannot create ' PathExpDeviceOut ': ' msg1]; % error message for directory creation
     
    17101714        OutputDir=fullfile(PathExpDeviceOut,[Param.OutputSubDir Param.OutputDirExt]); % full name (with path) of output directory
    17111715        if check_create    % create output directory if it does not exist
    1712             [tild,msg1]=mkdir(OutputDir);
     1716            [~,msg1]=mkdir(OutputDir);
    17131717            if ~strcmp(msg1,'')
    17141718                errormsg=['cannot create ' OutputDir ': ' msg1]; % error message for directory creation
     
    17841788        else
    17851789            ref_j=first_j:incr_j:last_j;
    1786             [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
     1790            [~,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
    17871791            ref_i=ref_i-1;
    17881792            ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
     
    17921796        ref_i=first_i:incr_i:last_i;
    17931797        if isempty(incr_j)% automatic finding of the existing j indices
    1794             [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
     1798            ref_j=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
    17951799            ref_j=ref_j-1;
    17961800            ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
     
    18091813            else
    18101814                answer=msgbox_uvmat('INPUT_TXT','estimate the CPU time(in minutes) for each value of index i:' ,'');
    1811                 CPUTime=str2num(answer);
     1815                CPUTime=str2double(answer);
    18121816                set(handles.num_CPUTime,'String',answer)
    18131817                Param.Action.CPUTime=CPUTime;
     
    20912095                cd(curdir)
    20922096            else
    2093                 [tild,msg1]=mkdir(DIR_CLUSTER);
     2097                [~,msg1]=mkdir(DIR_CLUSTER);
    20942098                if ~strcmp(msg1,'')
    20952099                    errormsg=['cannot create ' DIR_CLUSTER ': ' msg1]; % error message for directory creation
     
    21862190                cd(curdir)
    21872191            else
    2188                 [tild,msg1]=mkdir(DirSGE);
     2192                [~,msg1]=mkdir(DirSGE);
    21892193                if ~strcmp(msg1,'')
    21902194                    errormsg=['cannot create ' DirSGE ': ' msg1]; % error message for directory creation
     
    22112215                        cmd=[cmd ActionFullName ' /softs/matlab ' filexml{imgsInJob(ii)} '\n'];
    22122216                    end
    2213                     [fid, message] = fopen([DirSGE '/job' num2str(currJobIndex) '.sh'], 'w');
     2217                    fid = fopen([DirSGE '/job' num2str(currJobIndex) '.sh'], 'w');
    22142218                    fprintf(fid, cmd);
    22152219                    fclose(fid);
     
    22212225                        fullfile([DirSGE '/job' num2str(currJobIndex) '.sh'])];
    22222226                    fprintf(sge_command); % display in command line
    2223                     [status, result] = system(sge_command);
     2227                    [~, result] = system(sge_command);
    22242228                    fprintf(result);
    22252229                    currJobIndex = currJobIndex + 1;
     
    22352239            command = ['python -m fluidimage.run_from_xml ' filexml{iprocess}];
    22362240            fprintf(['command:\n' command '\n\n'])
    2237             [status, result] = call_command_clean(command);
     2241          %  [status, result] = call_command_clean(command);
    22382242    end
    22392243    if exist(OutputDir,'dir')
    2240         [SUCCESS,MESSAGE,MESSAGEID] = fileattrib (OutputDir);
     2244        [~,MESSAGE] = fileattrib (OutputDir);
    22412245        if MESSAGE.GroupWrite~=1
    22422246            [success,msg] = fileattrib(OutputDir,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
     
    23932397%% Put the first line of the selected Action fct as tooltip help
    23942398try
    2395     [fid,errormsg] =fopen([fullfile(ActionPath,ActionName) '.m']);
     2399    fid=fopen([fullfile(ActionPath,ActionName) '.m']);
    23962400    InputText=textscan(fid,'%s',1,'delimiter','\n');
    23972401    fclose(fid);
     
    28772881        set(handles.FieldName,'String',[FieldListInit; FieldList; {'add_field...'}]);
    28782882        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    2879            if ~isempty(regexp(FieldList{1},'^vec'))
     2883           if ~isempty(regexp(FieldList{1},'^vec', 'once'))
    28802884                set(handles.FieldName,'Value',1)
    28812885           else
     
    30313035            datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date); % dates of creation
    30323036        end
    3033         [datenew,indsort2]=sort(datepair); % sort the multiplet by creation date
     3037        [~,indsort2]=sort(datepair); % sort the multiplet by creation date
    30343038        ind_s=indsort2(1:end-1); %
    30353039        ind_remove=[ind_remove ind_pairs(ind_s)]; % remove these indices, leave the last one
     
    30583062    num_j1=meshgrid(num_j,ones(size(num_i1_line)));
    30593063    num_j2=meshgrid(num_j,ones(size(num_i1_line)));
    3060     [xx,num_i1]=meshgrid(num_j,num_i1_line);
    3061     [xx,num_i2]=meshgrid(num_j,num_i2_line);
     3064    [~,num_i1]=meshgrid(num_j,num_i1_line);
     3065    [~,num_i2]=meshgrid(num_j,num_i2_line);
    30623066elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts')
    30633067    if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
     
    32003204    MaskTable=cell(NbView,2);
    32013205   
    3202     RootPath=Param.InputTable{1,1};
     3206    %RootPath=Param.InputTable{1,1};
    32033207    first_j=[];% note that the function will propose to cover the whole range of indices
    32043208    if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
    3205     last_j=[];
     3209   %last_j=[];
    32063210    if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
    32073211    PairString='';
     
    32143218            Param.InputTable{iview,5},Param.InputTable{iview,4},i1,i2,j1,j2);
    32153219       
    3216         [FileInfo,VideoObject]=get_file_info(FirstFileName);
     3220       % [FileInfo,VideoObject]=get_file_info(FirstFileName);
    32173221       
    32183222       
     
    34223426%% use a browser to choose the xml file containing the processing config
    34233427InputTable=get(handles.InputTable,'Data');
    3424 oldfile='';
    3425 if isempty(InputTable)
    3426     oldfile='';
    3427 else
    34283428oldfile=InputTable{1,1}; % current path in InputTable
    3429 end
    34303429if isempty(oldfile)
    34313430    % use a file name stored in prefdir
  • trunk/src/series/beam_forming.m

    r1179 r1184  
     1%'beam_forming': create images from multi-array acoustic signal (cf. project Philippe Roux)
     2%------------------------------------------------------------------------
     3% function ParamOut=beam_forming(Param)
     4%------------------------------------------------------------------------
     5%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
     6%
     7%OUTPUT
     8% ParamOut: sets options in the GUI series.fig needed for the function
     9%
     10%INPUT:
     11% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
     12% In batch mode, Param is the name of the corresponding xml file containing the same information
     13% when Param.Action.RUN=0 (as activated when the current Action is selected
     14% in series), the function ouput paramOut set the activation of the needed GUI elements
     15%
     16% Param contains the elements:(use the menu bar command 'export/GUI config' in series to
     17% see the current structure Param)
     18%    .InputTable: cell of input file names, (several lines for multiple input)
     19%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
     20%    .OutputSubDir: name of the subdirectory for data outputs
     21%    .OutputDirExt: directory extension for data outputs
     22%    .Action: .ActionName: name of the current activated function
     23%             .ActionPath:   path of the current activated function
     24%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
     25%             .RUN =0 for GUI input, =1 for function activation
     26%             .RunMode='local','background', 'cluster': type of function  use
     27%             
     28%    .IndexRange: set the file or frame indices on which the action must be performed
     29%    .FieldTransform: .TransformName: name of the selected transform function
     30%                     .TransformPath:   path  of the selected transform function
     31%    .InputFields: sub structure describing the input fields withfields
     32%              .FieldName: name(s) of the field
     33%              .VelType: velocity type
     34%              .FieldName_1: name of the second field in case of two input series
     35%              .VelType_1: velocity type of the second field in case of two input series
     36%              .Coord_y: name of y coordinate variable
     37%              .Coord_x: name of x coordinate variable
     38%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
     39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     40
     41
    142%=======================================================================
    243% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
  • trunk/src/series/bed_scan.m

    r1183 r1184  
    6161%=======================================================================
    6262
    63 function ParamOut=bed_scan (Param)
     63function ParamOut=bed_scan(Param)
    6464
    6565%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
     
    6767    ParamOut.NbViewMax=1;% max nbre of input file series (default , no limitation)
    6868    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    69     ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    70     ParamOut.NbSlice=1; %nbre of slices ('off' by default)
     69    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     70    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
    7171    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    7272    ParamOut.FieldName='one';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     
    7575    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
    7676    ParamOut.OutputDirExt='.bed';%set the output dir extension
    77     ParamOut.OutputFileMode='NbSlice';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
    78     %check the type of the existence and type of the first input file:
    79     Param.IndexRange.last_i=Param.IndexRange.first_i;%keep only the first index in the series
    80     if isfield(Param.IndexRange,'first_j')
    81     Param.IndexRange.last_j=Param.IndexRange.first_j;
    82     end
    83     filecell=get_file_series(Param);
    84     if ~exist(filecell{1,1},'file')
    85         msgbox_uvmat('WARNING','the first input file does not exist')
    86     else
    87         FileInfo=get_file_info(filecell{1,1});
    88         FileType=FileInfo.FileType;
    89         if isempty(find(strcmp(FileType,{'image','multimage','mmreader','video'})))% =1 for images
    90             msgbox_uvmat('ERROR',['bad input file type for ' mfilename ': an image is needed'])
    91         end
    92     end
    93 return
     77    ParamOut.OutputFileMode='NbInput_i';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice   
     78    return
    9479end
    9580
     
    11196%% root input file names and nomenclature type (cell arrays with one element)
    11297RootPath=Param.InputTable{1,1};
    113 
     98SubDir=Param.InputTable{1,2};
     99RootFile=Param.InputTable{1,3};
     100NomType=Param.InputTable{1,4};
     101FileExt=Param.InputTable{1,5};
     102i_series=Param.IndexRange.first_i:Param.IndexRange.incr_i:Param.IndexRange.last_i;
     103j_series=Param.IndexRange.first_j:Param.IndexRange.incr_j:Param.IndexRange.last_j;
     104nbfield_i=numel(i_series);
     105nbfield_j=numel(j_series);
    114106
    115107%% directory for output files
     
    117109
    118110%% get the set of input file names (cell array filecell), and file indices
    119 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
     111%[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    120112% filecell{iview,fileindex}: cell array representing the list of file names
    121113%        iview: line in the table corresponding to a given file series
    122 %        fileindex: file index within  the file series, 
    123 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 
     114%        fileindex: file index within  the file series,
     115% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
    124116% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    125 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    126 nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    127 
    128 %% set of y positions 
    129 ycalib=[-51 -1 49];% calibration planes
    130 y_scan=-51+(100/400)*(i1_series{1}-1);% transverse position given by the translating system: first view at y=-51, view 400 at y=+49
     117%nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
     118% nbfield_i=size(i1_series{1},2); %nb of fields for the i index
     119%
     120% nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
     121CheckVirtual=false;
     122if isfield(Param,'FileSeries')% virtual file indexing used (e.g. multitif images)
     123    CheckVirtual=true;
     124end
     125
     126%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%fullfile(
     127% EDIT FROM HERE
     128%% load the initial scan
     129[RootRoot,CamName]=fileparts(RootPath);
     130RootRoot=fileparts(RootRoot);
     131CalibFolder=fullfile(RootRoot,'EXP_INIT',CamName);
     132File_init=fullfile(CalibFolder,'images.png.bed','Z_init.nc');
     133Data_init=nc2struct(File_init);
     134%% set of y positions
     135
     136nb_scan=400;% nbre of planes for a scan
     137if nbfield_j<400
     138    nb_scan=nbfield_j;
     139end
     140%ycalib=[-51 -1 49];% calibration planes
     141y_scan=-51+0.25*(1:nb_scan);% transverse position given by the translating system: first view at y=-51, view 400 at y=+49
     142coord_x=0.25:0.25:450;%% coord x in phys coordinates for final projection
     143
    131144Mfiltre=ones(2,10)/20;%filter matrix for imnages
    132145
    133146%% calibration data and timing: read the ImaDoc files
    134 XmlData_A=xml2struct(fullfile(RootPath,'planeA.xml'));
    135 XmlData_B=xml2struct(fullfile(RootPath,'planeB.xml'));
    136 XmlData_C=xml2struct(fullfile(RootPath,'planeC.xml'));
    137 ycalib=[-51 -1 49];% the three y positions for calibration
    138 fx(1)=XmlData_A.GeometryCalib.fx_fy(1);
     147
     148XmlData_A=xml2struct(fullfile(CalibFolder,'planeA.xml'));
     149XmlData_B=xml2struct(fullfile(CalibFolder,'planeB.xml'));
     150XmlData_C=xml2struct(fullfile(CalibFolder,'planeC.xml'));
     151ycalib=[-51 -1 49];% the three y positions for calibration=
     152fx(1)=XmlData_C.GeometryCalib.fx_fy(1);
    139153fx(2)=XmlData_B.GeometryCalib.fx_fy(1);
    140 fx(3)=XmlData_C.GeometryCalib.fx_fy(1);
    141 fy(1)=XmlData_A.GeometryCalib.fx_fy(2);
     154fx(3)=XmlData_A.GeometryCalib.fx_fy(1);
     155fy(1)=XmlData_C.GeometryCalib.fx_fy(2);
    142156fy(2)=XmlData_B.GeometryCalib.fx_fy(2);
    143 fy(3)=XmlData_C.GeometryCalib.fx_fy(2);
    144 Tx(1)=XmlData_A.GeometryCalib.Tx_Ty_Tz(1);
     157fy(3)=XmlData_A.GeometryCalib.fx_fy(2);
     158Tx(1)=XmlData_C.GeometryCalib.Tx_Ty_Tz(1);
    145159Tx(2)=XmlData_B.GeometryCalib.Tx_Ty_Tz(1);
    146 Tx(3)=XmlData_C.GeometryCalib.Tx_Ty_Tz(1);
    147 Ty(1)=XmlData_A.GeometryCalib.Tx_Ty_Tz(2);
     160Tx(3)=XmlData_A.GeometryCalib.Tx_Ty_Tz(1);
     161Ty(1)=XmlData_C.GeometryCalib.Tx_Ty_Tz(2);
    148162Ty(2)=XmlData_B.GeometryCalib.Tx_Ty_Tz(2);
    149 Ty(3)=XmlData_C.GeometryCalib.Tx_Ty_Tz(2);
    150 R11(1)=XmlData_A.GeometryCalib.R(1,1);
     163Ty(3)=XmlData_A.GeometryCalib.Tx_Ty_Tz(2);
     164R11(1)=XmlData_C.GeometryCalib.R(1,1);
    151165R11(2)=XmlData_B.GeometryCalib.R(1,1);
    152 R11(3)=XmlData_C.GeometryCalib.R(1,1);
    153 R12(1)=XmlData_A.GeometryCalib.R(1,2);
     166R11(3)=XmlData_A.GeometryCalib.R(1,1);
     167R12(1)=XmlData_C.GeometryCalib.R(1,2);
    154168R12(2)=XmlData_B.GeometryCalib.R(1,2);
    155 R12(3)=XmlData_C.GeometryCalib.R(1,2);
    156 R21(1)=XmlData_A.GeometryCalib.R(2,1);
     169R12(3)=XmlData_A.GeometryCalib.R(1,2);
     170R21(1)=XmlData_C.GeometryCalib.R(2,1);
    157171R21(2)=XmlData_B.GeometryCalib.R(2,1);
    158 R21(3)=XmlData_C.GeometryCalib.R(2,1);
    159 R22(1)=XmlData_A.GeometryCalib.R(2,2);
     172R21(3)=XmlData_A.GeometryCalib.R(2,1);
     173R22(1)=XmlData_C.GeometryCalib.R(2,2);
    160174R22(2)=XmlData_B.GeometryCalib.R(2,2);
    161 R22(3)=XmlData_C.GeometryCalib.R(2,2);
    162 pfx=polyfit(ycalib,fx,1);%get the linear interpolation of each parameter of the three calibrations
     175R22(3)=XmlData_A.GeometryCalib.R(2,2);
     176pfx=polyfit(ycalib,fx,1);%get thfield_ie linear interpolation of each parameter of the three calibrations
    163177pfy=polyfit(ycalib,fy,1);
    164178pTx=polyfit(ycalib,Tx,1);
     
    169183p22=polyfit(ycalib,R22,1);
    170184%get the calibration parameters at each position y by interpolation of the 3 calibration parameters
    171 for img=1:nbfield_i
     185for img=1:nb_scan
    172186    Calib(img).fx_fy(1)=pfx(1)*y_scan(img)+pfx(2);
    173187    Calib(img).fx_fy(2)=pfy(1)*y_scan(img)+pfy(2);
     
    184198end
    185199
    186 %% check coincdence in time for several input file series
    187 %not relevant for this function
    188 
    189 %% coordinate transform or other user defined transform
    190 %not relevant for this function
    191 
    192 %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
    193  % EDIT FROM HERE
     200
     201
    194202
    195203%% Load the init bed scan
    196204tic
    197 nb_scan=10;
    198 for img=1:nb_scan
    199      img
    200     a=flipud(imread(filecell{1,img}));%image of the initial bed
    201     if img==1
    202         x=1:size(a,2);%image absissa in pixel coordinates
     205%filecell=reshape(filecell,nbfield_j,nbfield_i)
     206% main loop
     207for ifield=1:nbfield_i
     208    for img=1:nbfield_j% loop on positions
     209        if CheckVirtual
     210            [FileName,FrameIndex]=index2filename(Param.FileSeries,i_series(ifield),j_series(img),nbfield_j);
     211            InputFile=fullfile(RootPath,SubDir,FileName);
     212        else
     213            InputFile=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,FileIndex,ifield,[],img);
     214            FrameIndex=1;
     215        end
     216        a=flipud(read_image(InputFile,'multimage',[],FrameIndex));
     217        %a=flipud(imread(InputFile));%image of the initial bed  [X_b_new(img,:),Z_b_new(img,:)]=phys_XYZ(Calib(img),[],x,Z_sb(img,:))
     218        if img==1
     219            [nby,nbx]=size(a);
     220            x_ima=1:nbx;%image absissa in pixel coordinates
     221            X_phys=zeros(nb_scan,nbx);
     222            Z_phys=zeros(nb_scan,nbx);
     223        end
     224        % filtering
     225            a=filter2(Mfiltre,a);%smoothed image
     226        amean=mean(a,2);
     227     [~,ind_max]=max(amean);% get the max of the image averaged along x, to restrict the search region
     228    ind_range=max(1,ind_max-30):min(nby,ind_max+30);% search band to find the line
     229    z_ima=get_max(a(ind_range,:))+ind_range(1)-1;% get the max in the search band and shift to express it in indices of the original image
     230
     231 %       [~,iy]=max(a);% find the max along the first coordinate     Z_s_new=zeros(nb_scan,size(Z_s,2)); y, max values imax and the corresponding  y index iy along the first coordinate y
     232        z_ima=smooth(z_ima,20,'rloess');%smooth Z, the image index of max luminosity (dependning on x)
     233        [X_phys(img,:),Z_phys(img,:)]=phys_XYZ(Calib(img),[],x_ima,z_ima');
    203234    end
    204     % filtering
    205     a=filter2(Mfiltre,a);%smoothed image
    206     [imax,iy]=max(a);% find the max along the first coordinate y, max values imax and the corresponding  y index iy along the first coordinate y
    207     Z_s(img,:)=smooth(iy,40,'rloess');%smooth Z, the image index of max luminosity (dependning on x)
    208     Yima=y_scan(img)*ones(size(x));%positions Y transformed into a vector
    209     X_new(img,:)=phys_XYZ(Calib(img),x,Yima,1);
    210     %X_new(:,img)=phys_scan(x,y(img));
    211 end
    212 
    213 toc
    214 
    215 [X,Y]=meshgrid(x,y_scan);
    216 
    217 
    218 %% Load the current bed scan
    219 for img=1:nb_scan
    220    b=flipud(imread(filecell{2,img}));%image of the current bed
    221     b=filter2(Mfiltre,b); % filtering
    222     [imaxb,iyb]=max(b);
    223     Z_sb(img,:)=smooth(iyb,20,'rloess');
    224 end
    225 
    226 %% bed change
    227 dZ=Z_s-Z_sb;% displacement between current position and initial
    228 dZ_new=zeros(nb_scan,size(dZ,2));
    229 for img=1:nb_scan 
    230     Yima=y_scan(img)*ones(1,size(dZ,2));
    231     [~,dZ_new(img,:)]=phys_XYZ(Calib(img),dZ(img,:),Yima,1);
    232    % dZ_new(:,img)=phys_scanz(dZ(:,img),y(img));
    233 end
    234 
    235 
    236 %% PLOTS
    237 coord_x=X_new(end,1):0.1:X_new(end,end);
    238 [Y_m,X_m]=meshgrid(y_scan,coord_x);
    239 %Y_new=Y';
    240 dZ_mesh=griddata(X_new,Y,dZ_new,X_m,Y_m);
    241 
    242 if checkrun
    243     figure(1)
    244     hold on
    245     plot(x,Z_s+700)
    246     % xlim([0 4096])
    247     % ylim([0 3000])
    248    
    249     figure(2)
    250     hold on
    251     plot(x,Z_sb+700)
    252     xlim([0 4096])
    253     ylim([0 3000])
    254    
    255     figure(3)
    256     surfc(X_m,Y_m,dZ_mesh)
    257     shading interp;
    258     colorbar;
    259     caxis([0 3]);
    260    
    261     figure
    262     pcolor(X_m,Y_m,dZ_mesh);
    263     colormap;
    264     set(gca,'Xdir','reverse');
    265     caxis([0 3]);
    266     shading flat
    267     hold on
    268     colorbar
    269     title('Dz')
    270 end
    271 
    272 %save(fullfile(DirOut,'18OS_f.mat'),'dZ','dZ_new','X','Y','Z_s','Z_sb','y')
    273 
    274 % save netcdf
    275 Data.ListVarName={'coord_x','coord_y','dZ'};
    276 Data.VarDimName={'coord_x','coord_y',{'coord_y','coord_x'}};
    277 Data.VarAttribute{1}.Role='coord_x';
    278 Data.VarAttribute{1}.unit='cm';
    279 Data.VarAttribute{2}.Role='coord_y';
    280 Data.VarAttribute{2}.unit='cm';
    281 Data.VarAttribute{3}.Role='scalar';
    282 Data.VarAttribute{3}.unit='cm';
    283 Data.coord_x=[coord_x(1) coord_x(end)];
    284 Data.coord_y=[y(1) y(end)];
    285 Data.dZ=dZ_mesh';
    286 struct2nc(fullfile(DirOut,'dZ.nc'),Data)
    287 
    288 %% gives the physical position x from the image position X and the physical position y of the laser plane
    289 function F=phys_scan(X,y)
    290 % linear fct of X whose coefficient depend on y in a quadratic way
    291 F=(9.4*10^(-7)*y.^2-3.09*10^(-4)*y+0.07).*X +(-0.001023*y.^2+0.469*y+186.9);
    292 
    293 %% gives the physical position z from the image position Z and the physical position y of the laser plane
    294 function Fz=phys_scanz(Z,y)
    295 % scale factor applied to Z depending on the physical position y of the laser plane
    296 Fz=(-1.4587*10^(-5)*y.^2 + 0.001072*y+0.0833).*Z; %+(-2.1*10^(-6)*x.^2+5.1*10^(-4)*x+0.0735).*Z;
    297 
    298  
     235    disp(['last file of ' num2str(ifield)])
     236     disp(FileName)
     237     disp(FrameIndex)
     238
     239    %% interpolate on a regular grid
     240    %coord_x=X_phys(end,1):0.1:X_phys(end,end);%% coord x in phys coordinates based in the last view plane (the last)
     241    [X_m,Y_m]=meshgrid(coord_x,y_scan);
     242    Y=y_scan'*ones(1,nbx);%initialisation of X, Y final topography map
     243
     244    Data.Z=griddata(X_phys,Y,Z_phys,X_m,Y_m);% dZ interpolated on the regular ph1ys grid X_m,Y_m
     245    size(Data.Z)
     246    size(Data_init.Z_init)
     247    Data.dZ=Data.Z-Data_init.Z_init;
     248
     249    toc
     250
     251    % save netcdf
     252    Data.ListVarName={'coord_x','y_scan','Z','dZ'};
     253    Data.VarDimName={'coord_x','y_scan',{'y_scan','coord_x'},{'y_scan','coord_x'}};
     254    Data.VarAttribute{1}.Role='coord_x';
     255    Data.VarAttribute{1}.unit='cm';
     256    Data.VarAttribute{2}.Role='coord_y';
     257    Data.VarAttribute{2}.unit='cm';
     258    Data.VarAttribute{3}.Role='scalar';
     259    Data.VarAttribute{3}.unit='cm';
     260        Data.VarAttribute{4}.Role='scalar';
     261    Data.VarAttribute{4}.unit='cm';
     262    Data.coord_x=coord_x;
     263    Data.y_scan=y_scan;
     264    struct2nc(fullfile(DirOut,['dZ_' num2str(ifield) '.nc']),Data)
     265end
     266
     267%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     268function iy=get_max(a)% get the max with sub picel resolution
     269[a_max,iy]=max(a);
     270[Nby,Nbx]=size(a);
     271for ind_x=1:Nbx
     272    if iy(ind_x)>1 && iy(ind_x)<Nby
     273        a_plus=a(iy(ind_x)+1,ind_x);
     274        a_min=a(iy(ind_x)-1,ind_x);
     275        denom=2*a_max(ind_x)-a_plus-a_min;
     276        if denom >0
     277            iy(ind_x)=iy(ind_x)+0.5*(a_plus-a_min)/denom;%adjust the position of the max with a quadratic fit of the three points around the max
     278        end
     279    end
     280end
  • trunk/src/uvmat.m

    r1183 r1184  
    4040%          .FileName_1: name of the current second field (used to detect a  constant field during file scanning)
    4141%          .FileType: current file type, as defined by the fct  get_file_type.m)
    42 %          .i1_series,.i2_series,.j1_series,.j1_series: series of i1,i2,j1,j2 indices detected in the input dir,set by  the fct find_file_series
     42%          .i1_series,.i2_series,.j1_series,.j1_series: series of num_i1,num_i2,num_j1,num_j2 indices detected in the input dir,set by  the fct find_file_series
    4343%          .MovieObject: current movie object
    4444%          .TimeUnit: unit for time
     
    280280        end
    281281        if isfield(input,'TimeIndex')
    282             set(handles.i1,num2str(input.TimeIndex))
     282            set(handles.num_i1,num2str(input.TimeIndex))
    283283        end
    284284        if isfield(input,'FieldsString')
     
    21242124                i1_mod=floor(i1_mod/(NbField_j -1))+1;
    21252125            end
    2126             set(handles.i1,'String',num2str(i1_mod));%update the counters
    2127             set(handles.j1,'String',num2str(j1));%update the counters
     2126            set(handles.num_i1,'String',num2str(i1_mod));%update the counters
     2127            set(handles.num_j1,'String',num2str(j1));%update the counters
    21282128            check_index=true;
    21292129        end
     
    21312131end
    21322132if ~check_index
    2133 set(handles.i1,'String',num2str(i1));%update the counters
    2134 set(handles.i2,'String',num2str(i2));
    2135 set(handles.j1,'String',num2str(j1));
    2136 set(handles.j2,'String',num2str(j2));
     2133set(handles.num_i1,'String',num2str(i1));%update the counters
     2134set(handles.num_i2,'String',num2str(i2));
     2135set(handles.num_j1,'String',num2str(j1));
     2136set(handles.num_j2,'String',num2str(j2));
    21372137end
    21382138
     
    21412141function NomType_Callback(hObject, eventdata, handles)
    21422142%------------------------------------------------------------------------
    2143 i1=str2double(get(handles.i1,'String'));
    2144 i2=str2double(get(handles.i2,'String'));
    2145 j1=str2double(get(handles.j1,'String'));
    2146 j2=str2double(get(handles.j2,'String'));
     2143i1=str2double(get(handles.num_i1,'String'));
     2144i2=str2double(get(handles.num_i2,'String'));
     2145j1=str2double(get(handles.num_j1,'String'));
     2146j2=str2double(get(handles.num_j2,'String'));
    21472147NomType=get(hObject,'String');
    21482148if strcmp(NomType,'level')
    2149     FileIndex=str2double(get(handles.i1,'String'));
     2149    FileIndex=str2double(get(handles.num_i1,'String'));
    21502150else
    21512151FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2);
     
    21592159function NomType_1_Callback(hObject, eventdata, handles)
    21602160%------------------------------------------------------------------------
    2161 i1=str2double(get(handles.i1,'String'));
    2162 i2=str2double(get(handles.i2,'String'));
    2163 j1=str2double(get(handles.j1,'String'));
    2164 j2=str2double(get(handles.j2,'String'));
     2161i1=str2double(get(handles.num_i1,'String'));
     2162i2=str2double(get(handles.num_i2,'String'));
     2163j1=str2double(get(handles.num_j1,'String'));
     2164j2=str2double(get(handles.num_j2,'String'));
    21652165NomType=get(hObject,'String');
    21662166if strcmp(NomType,'level')
    2167     FileIndex=str2double(get(handles.i1,'String'));
     2167    FileIndex=str2double(get(handles.num_i1,'String'));
    21682168else
    21692169FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2);
     
    21742174
    21752175%------------------------------------------------------------------------
    2176 % --- Executes on button press in InputFileREFRESH.
     2176% --- Executes on press in button tagged 'InputFileREFRESH'.
    21772177function InputFileREFRESH_Callback(hObject, eventdata, handles)
    21782178%------------------------------------------------------------------------
     
    21802180set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch'
    21812181drawnow
    2182 % get the current input file name:
    2183 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    2184 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    2185 %[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     2182[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);% get the current input file name:
    21862183errormsg='';
    2187 if isempty(RootFile)
     2184if isempty(RootFile)% open the file browser if the input file is not defined
    21882185    fileinput=uigetfile_uvmat('pick an input file',fullfile(RootPath,SubDir));
    21892186    hh=dir(fileinput);
     
    21982195        end
    21992196    end
    2200 else
    2201     % initiate the input file series and refresh the current field view:
     2197else      % initiate the input file series and refresh the current field view:
    22022198    [FileInfo,VideoObject]=get_file_info(fullfile(RootPath,SubDir,[RootFile FileIndices FileExt]));
    22032199    errormsg=update_rootinfo(handles,RootPath,SubDir,[RootFile FileIndices FileExt],FileInfo,VideoObject,1);
     
    22082204    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
    22092205    % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    2210     [RootPath,SubDir,~,i1_series,i2_series,j1_series,j2_series,~,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     2206    [RootPath,SubDir,~,i1_series,~,~,~,~,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    22112207    if isempty(i1_series)
    22122208        fileinput=uigetfile_uvmat('pick an input file for the second line',fullfile(RootPath,SubDir));
     
    23112307%[FilePath,FileName,FileExt]=fileparts(fileinput);
    23122308% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    2313 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
     2309% the root name and indices may be corrected by including the first index num_i1 if a corresponding xml file exists
    23142310
    23152311set(handles_RootPath,'String',RootPath);
     
    23282324if input_line==1
    23292325    % fill file index counters if the first file series is opened
    2330     set(handles.i1,'String',num2str(i1));
    2331     set(handles.i2,'String',num2str(i2));
    2332     set(handles.j1,'String',num2stra(j1,NomType));
    2333     set(handles.j2,'String',num2stra(j2,NomType));
     2326    set(handles.num_i1,'String',num2str(i1));
     2327    set(handles.num_i2,'String',num2str(i2));
     2328    set(handles.num_j1,'String',num2stra(j1,NomType));
     2329    set(handles.num_j2,'String',num2stra(j2,NomType));
    23342330    if isfield(FileInfo,'MaskFile')
    23352331        if exist(FileInfo.MaskFile,'file')
     
    23502346    end
    23512347else %read the current field index to synchronise with the first series
    2352     i1_s=str2double(get(handles.i1,'String'));
    2353     i2_0=str2double(get(handles.i2,'String'));
     2348    i1_s=str2double(get(handles.num_i1,'String'));
     2349    i2_0=str2double(get(handles.num_i2,'String'));
    23542350    if ~isempty(i2_0)
    23552351        i2_s=i2_0;
     
    23572353        i2_s=i2;
    23582354    end
    2359     j1_0=stra2num(get(handles.j1,'String'));
     2355    j1_0=stra2num(get(handles.num_j1,'String'));
    23602356    if ~isempty(j1_0)
    23612357        j1_s=j1_0;
     
    23632359        j1_s=j1;
    23642360    end
    2365     j2_0=stra2num(get(handles.j2,'String'));
     2361    j2_0=stra2num(get(handles.num_j2,'String'));
    23662362    if ~isempty(j2_0)
    23672363        j2_s=j2_0;
     
    24442440XmlFileName=find_imadoc(RootPath,SubDir);% search the appropriate ImaDoc xml file
    24452441[~,XmlName]=fileparts(XmlFileName);
    2446 
    24472442CheckIndexing=false;% test for virtual indexing of frames different from the file name index, false by default
    24482443if isempty(XmlFileName) %no ImaDoc xml file detected
     
    24532448    set(handles.view_xml,'String','view xml')
    24542449    drawnow
    2455     [XmlData,warntext]=imadoc2struct(XmlFileName);
     2450    [XmlData,warntext]=imadoc2struct(XmlFileName);% open xml file ImaDoc
    24562451    if ~isempty(warntext)
    24572452        msgbox_uvmat('WARNING',warntext)
     
    24742469end
    24752470if CheckIndexing
    2476 set(handles.MenuRelabelFrames,'checked','on')% activate the relabel tool by default
     2471    set(handles.MenuRelabelFrames,'checked','on')% activate the relabel tool by default
    24772472else
    24782473    set(handles.MenuRelabelFrames,'checked','off')
     
    24882483TimeUnit='';%default
    24892484TimeName='';%default
     2485state_j='off'; % no visualisation of the j index by default
    24902486
    24912487%% get the file series
     
    24972493    j1_series=[];
    24982494    j2_series=[];
    2499     nbfield=[];
     2495    nbfield_i=[];
    25002496    nbfield_j=[];
    25012497    FileInfo=XmlData.FileInfo;
    2502     %     if iscell(XmlData.FileSeries.FileName)(handles.i1,'String','1')
    2503     set(handles.i1,'String','1')% the index does not correspond to file name index anymore
    2504     set(handles.j1,'String','1')
     2498    set(handles.num_i1,'String','1')% the index does not correspond to file name index anymore, set i=1, j=1 by default as s start
     2499    set(handles.num_j1,'String','1')
    25052500else % scan the input folder to get the list of existing files and NomType
    25062501    [~,~,~,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject]=...
    25072502        find_file_series(fullfile(RootPath,SubDir),FileName);
    2508     nbfield=max(max(max(i2_series)));% total number of fields (i index)
    2509     if isempty(nbfield)
    2510         nbfield=max(max(max(i1_series)));
     2503    nbfield_i=max(max(max(i2_series)));% total number of fields (i index)
     2504    if isempty(nbfield_i)
     2505        nbfield_i=max(max(max(i1_series)));
    25112506    end
    25122507    nbfield_j=max(max(max(j2_series)));% number of fields along j index
     
    25152510    end
    25162511    if ~isempty(j1_series)&& ~strcmp(NomType,'*')% the j index is used to label the frame in multimage series
    2517         set(handles.j1,'String','1')
     2512        set(handles.num_j1,'String','1')
     2513             state_j='on';
    25182514    elseif strcmp(FileInfo.FieldType,'image') && ~isequal(FileInfo.NumberOfFrames,1)
    2519         set(handles.i1,'String','1')
     2515        set(handles.num_i1,'String','1')
    25202516    end
    25212517end
     
    25252521    set(handles.NomType_1,'String',NomType)
    25262522end
    2527 % if CheckIndexing
    2528 % %     i1=str2double(get(handles.FileIndex,'String'));
    2529 % %     if isnan(i1)
    2530 % %         i1=1;
    2531 % %     else
    2532 % %         i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index
    2533 % %     end
    2534 % %     if strcmp(TimeName,'xml')% indices i and j
    2535 % %         j1=mod(i1-1,nbfield_j)+1;
    2536 % %         i1=floor((i1-1)/nbfield_j)+1;
    2537 % %         set(handles.j1,'String',num2str(j1))
    2538 % %     end
    2539 % %     set(handles.i1,'String',num2str(i1))
    2540 %
    2541 % end
    25422523
    25432524
     
    25622543            TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available)
    25632544end
    2564 
    2565 if ~CheckIndexing && isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
    2566     TimeUnit='s';
    2567     if isempty(j1_series) %frame index along i
    2568         XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2);
    2569         XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)';
    2570         set(handles.i1,'String','1')% set the frame index to 1 to start the movie
     2545if CheckIndexing
     2546    i1=str2double(get(handles.FileIndex,'String'));
     2547    if isnan(i1)
     2548        i1=1;
    25712549    else
    2572         XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate);
     2550        FirstFileIndex=1;
     2551        if isfield(XmlData.FileSeries,'FirstFileIndex')
     2552            FirstFileIndex=XmlData.FileSeries.FirstFileIndex;
     2553        end
     2554        i1=(i1-FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index
     2555    end
     2556    if isfield(XmlData,'Time') && size(XmlData.Time,2)>1%
     2557        nbfield_j=size(XmlData.Time,2)-1;
     2558        nbfield_i=size(XmlData.Time,1)-1;
     2559        j1=mod(i1-1,nbfield_j)+1;
     2560        i1=floor((i1-1)/nbfield_j)+1;
     2561        set(handles.num_j1,'String',num2str(j1))
     2562        state_j='on';
     2563    end
     2564    set(handles.num_i1,'String',num2str(i1))
     2565else
     2566    if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
     2567        TimeUnit='s';
     2568        if isempty(j1_series) %frame index along i
     2569            XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2);
     2570            XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)';
     2571            set(handles.num_i1,'String','1')% set the frame index to 1 to start the movie
     2572        else
     2573            XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate);
     2574            state_j='on';
     2575        end
    25732576    end
    25742577end
     
    26182621%% store last index in handles.MaxIndex_i and .MaxIndex_j
    26192622last_i_cell=get(handles.MaxIndex_i,'String');
    2620 if isempty(nbfield)
     2623if isempty(nbfield_i)
    26212624    last_i_cell{input_line}='';
    26222625else
    2623     last_i_cell{input_line}=num2str(nbfield);
     2626    last_i_cell{input_line}=num2str(nbfield_i);
    26242627end
    26252628set(handles.MaxIndex_i,'String',last_i_cell)
     
    26292632else
    26302633     last_j_cell{input_line}=num2str(nbfield_j);
     2634
    26312635end
    26322636set(handles.MaxIndex_j,'String',last_j_cell);
     
    27452749        end
    27462750    otherwise
    2747         set(handles_Fields,'Value',1) % set menu to 'image'
     2751        set(handles_Fields,'Value',1) % set menu to 'image'j1_series
    27482752        set(handles_Fields,'String',{'image'})
    27492753        %set(handles.Coord_x,'Value',1);
     
    27572761%% set index navigation options
    27582762scan_option='i';%default
    2759 state_j='off'; %default
     2763%state_j='off'; %default
    27602764if input_line==2
    27612765    if get(handles.scan_j,'Value')
    27622766        scan_option='j'; %keep the scan option for the second file series
    27632767    end
    2764     if strcmp(get(handles.j1,'Visible'),'on')
     2768    if strcmp(get(handles.num_j1,'Visible'),'on')
    27652769        state_j='on';
    27662770    end
     
    27992803end
    28002804set(handles.scan_j,'Visible',state_j)
    2801 set(handles.j1,'Visible',state_j)
    2802 set(handles.j2,'Visible',state_j)
     2805set(handles.num_j1,'Visible',state_j)
     2806set(handles.num_j2,'Visible',state_j)
    28032807set(handles.MaxIndex_j,'Visible',state_j);
    28042808set(handles.j_text,'Visible',state_j);
     
    28502854
    28512855%------------------------------------------------------------------------
    2852 function i1_Callback(hObject, eventdata, handles)
     2856function num_i1_Callback(hObject, eventdata, handles)
    28532857%------------------------------------------------------------------------
    28542858update_ij(handles,1)
    28552859
    28562860%------------------------------------------------------------------------
    2857 function i2_Callback(hObject, eventdata, handles)
     2861function num_i2_Callback(hObject, eventdata, handles)
    28582862%------------------------------------------------------------------------
    28592863update_ij(handles,2)
    28602864
    28612865%------------------------------------------------------------------------
    2862 function j1_Callback(hObject, eventdata, handles)
     2866function num_j1_Callback(hObject, eventdata, handles)
    28632867%------------------------------------------------------------------------
    28642868update_ij(handles,3)
    28652869
    28662870%------------------------------------------------------------------------
    2867 function j2_Callback(hObject, eventdata, handles)
     2871function num_j2_Callback(hObject, eventdata, handles)
    28682872%------------------------------------------------------------------------
    28692873update_ij(handles,4)
    28702874
    28712875%------------------------------------------------------------------------
    2872 %--- update the index display after action on edit boxes i1, i2, j1 or j2
     2876%--- update the index display after action on edit boxes num_i1, num_i2, num_j1 or num_j2
    28732877%------------------------------------------------------------------------
    28742878function update_ij(handles,index_rank)
     
    28782882
    28792883if strcmp(NomType,'level')
    2880     index_string=get(handles.i1,'String');
     2884    index_string=get(handles.num_i1,'String');
    28812885else
    28822886    index_string=get(handles.FileIndex,'String');
    28832887    if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'FileSeries')
    2884         i1=str2double(get(handles.i1,'String'));
    2885         j1=str2double(get(handles.j1,'String'));
     2888        i1=str2double(get(handles.num_i1,'String'));
     2889        j1=str2double(get(handles.num_j1,'String'));
    28862890        NbField_j_cell=get(handles.MaxIndex_j,'String');
    28872891        NbField_j=str2double(NbField_j_cell{1});
    2888         [RootFile,index_string,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j);
     2892        RootFile=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j);
     2893        index_string='';
    28892894        set(handles.RootFile,'String',RootFile)
    28902895    else
     
    28922897        switch index_rank
    28932898            case 1
    2894                 index_string=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2);
     2899                index_string=fullfile_uvmat('','','','',NomType,stra2num(get(handles.num_i1,'String')),i2,j1,j2);
    28952900            case 2
    2896                 index_string=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2);
     2901                index_string=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.num_i2,'String')),j1,j2);
    28972902            case 3
    2898                 index_string=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2);
     2903                index_string=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.num_j1,'String')),j2);
    28992904            case 4
    2900                 index_string=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String')));
     2905                index_string=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.num_j2,'String')));
    29012906        end
    29022907    end
     
    29082913    NomType_1=get(handles.NomType_1,'String');
    29092914    index_string_1=get(handles.FileIndex_1,'String');
    2910     [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(index_string_1);% the index_string for the second series taken from FileIndex_1
     2915    [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(index_string_1);% the index_string for the second series taken from FileIndex_1
    29112916    switch index_rank
    29122917        case 1
    2913             index_string_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1);
     2918            index_string_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.num_i1,'String')),i2_1,j1_1,j2_1);
    29142919        case 2
    2915             index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1);
     2920            index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.num_i2,'String')),j1_1,j2_1);
    29162921        case 3
    2917             index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1);
     2922            index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.num_j1,'String')),j2_1);
    29182923        case 4
    2919             index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String')));
     2924            index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.num_j2,'String')));
    29202925    end
    29212926    set(handles.FileIndex_1,'String',index_string_1)
     
    29472952%------------------------------------------------------------------------
    29482953mode=get(handles.slices,'String');
    2949 nb_slice_str=get(handles.num_NbSlice,'String');
    29502954if strcmp(mode,'volume')
    2951     z=stra2num(get(handles.j1,'String'));
    2952 else
    2953     num=str2double(get(handles.i1,'String'));
     2955    z=stra2num(get(handles.num_j1,'String'));
     2956else
     2957    num=str2double(get(handles.num_i1,'String'));
    29542958    nbslice=str2double(get(handles.num_NbSlice,'String'));
    29552959    z=mod(num-1,nbslice)+1;
     
    29802984        FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
    29812985    end
    2982     heditxml=editxml(FileXml);
     2986    editxml(FileXml);
    29832987end
    29842988
     
    29902994if isequal(get(handles.CheckMask,'Value'),1)
    29912995    [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    2992     if isempty(regexp(RootPath,'^http://'))
     2996    if isempty(regexp(RootPath,'^http://', 'once'))% not opendap input file
    29932997        fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
    29942998    else
     
    30293033        [MaskPath,FileName,FileExt]=fileparts(filemask);
    30303034        Mask.File=filemask;
    3031         [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(MaskPath,[FileName FileExt]);
     3035        [~,~,~,i1_series,~,~,~,NomType]=find_file_series(MaskPath,[FileName FileExt]);
    30323036        Mask.NbSlice=[];%default
    30333037        Mask.VolumeScan=0;% TO UPDATE ***
     
    30453049            msgbox_uvmat(['ERROR','error in displaying mask, ' errormsg]);
    30463050        end
    3047         testmask=1;
    30483051    end
    30493052else % desactivate mask display
     
    30733076    if isfield(MaskInfo,'NbSlice')&& ~isempty(MaskInfo.NbSlice)
    30743077        if isfield(MaskInfo,'VolumeScan') &&  MaskInfo.VolumeScan
    3075             MaskIndex_i=str2double(get(handles.j1,'String'));
     3078            MaskIndex_i=str2double(get(handles.num_j1,'String'));
    30763079        else
    3077             MaskIndex_i=mod(str2double(get(handles.i1,'String'))-1,MaskInfo.NbSlice)+1;
     3080            MaskIndex_i=mod(str2double(get(handles.num_i1,'String'))-1,MaskInfo.NbSlice)+1;
    30783081        end
    30793082        MaskName=[MaskInfo.File '_' num2str(MaskIndex_i) '.png'];
     
    32743277UvData=get(handles.uvmat,'UserData');
    32753278if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')% case of indexing documented by the xml file
    3276     i1=str2double(get(handles.i1,'String'));
    3277     j1=str2double(get(handles.j1,'String'));%read the field indices (for movie, it is not given by the file name)
     3279    i1=str2double(get(handles.num_i1,'String'));
     3280    j1=str2double(get(handles.num_j1,'String'));%read the field indices (for movie, it is not given by the file name)
    32783281    i2=[];j2=[];
    32793282else
    32803283    [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
    32813284    if isempty(i1)% no i index set by the input file name
    3282         i1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
    3283     elseif isempty(j1) && strcmp(get(handles.j1,'Visible'),'on')
    3284         j1=str2double(get(handles.j1,'String'));%case of indexed movie
     3285        i1=str2double(get(handles.num_i1,'String'));%read the field indices (for movie, it is not given by the file name)
     3286    elseif isempty(j1) && strcmp(get(handles.num_j1,'Visible'),'on')
     3287        j1=str2double(get(handles.num_j1,'String'));%case of indexed movie
    32853288    end
    32863289end
     
    32903293    [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1
    32913294    if isempty(i1_1)
    3292         i1_1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
    3293     elseif isempty(j1_1) && strcmp(get(handles.j1,'Visible'),'on')
    3294         j1_1=str2double(get(handles.j1,'String'));%case of indexed movie
     3295        i1_1=str2double(get(handles.num_i1,'String'));%read the field indices (for movie, it is not given by the file name)
     3296    elseif isempty(j1_1) && strcmp(get(handles.num_j1,'Visible'),'on')
     3297        j1_1=str2double(get(handles.num_j1,'String'));%case of indexed movie
    32953298    end
    32963299else
     
    33023305    set(handles.CheckFixPair,'Value',0)
    33033306end
    3304 %CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));
    3305 
    3306 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
     3307%CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(num_i2)&& isempty(num_j2));
     3308
     3309% the pair num_i1-num_i2 or num_j1-num_j2 is imposed (check box CheckFixPair selected)
    33073310if isnumeric(increment)
    33083311    if get(handles.scan_i,'Value')==1  % case of scanning along index i
     
    33223325    end
    33233326
    3324     % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
     3327    % the pair num_i1-num_i2 or num_j1-num_j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
    33253328else
    33263329    ref_i=i1;
     
    34653468
    34663469%% update the index counters if the index move is successfull
    3467 
    34683470if isempty(errormsg)
    3469     set(handles.i1,'String',num2stra(i1,NomType,1));
     3471    set(handles.num_i1,'String',num2stra(i1,NomType,1));
    34703472    if isequal(i2,i1)
    3471         set(handles.i2,'String','');
     3473        set(handles.num_i2,'String','');
    34723474    else
    3473         set(handles.i2,'String',num2stra(i2,NomType,1));
    3474     end
    3475     set(handles.j1,'String',num2stra(j1,NomType,2));
     3475        set(handles.num_i2,'String',num2stra(i2,NomType,1));
     3476    end
     3477    set(handles.num_j1,'String',num2stra(j1,NomType,2));
    34763478    if isequal(j2,j1)
    3477         set(handles.j2,'String','');
     3479        set(handles.num_j2,'String','');
    34783480    else
    3479         set(handles.j2,'String',num2stra(j2,NomType,2));
     3481        set(handles.num_j2,'String',num2stra(j2,NomType,2));
    34803482    end
    34813483    if strcmp(NomType,'level')
     
    34963498        set(handles.FileIndex_1,'String',indices_1);
    34973499    end
    3498     if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
    3499     if isempty(j2), set(handles.j2,'String',''); end
     3500    if isempty(i2), set(handles.num_i2,'String',''); end % suppress the second index display if not used
     3501    if isempty(j2), set(handles.num_j2,'String',''); end
    35003502end
    35013503
     
    35083510if ~get(handles.movie_pair,'value')
    35093511    set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
    3510     set(handles.i2,'String','')% the second i index display is suppressed
    3511     set(handles.j2,'String','')% the second j index display is suppressed
     3512    set(handles.num_i2,'String','')% the second i index display is suppressed
     3513    set(handles.num_j2,'String','')% the second j index display is suppressed
    35123514    set(handles.Dt_txt,'String','')% the time interval indication is suppressed
    35133515    return
     
    35233525
    35243526%% make movie until movie speed is set to 0 or STOP is activated
    3525 hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
    35263527set(handles.STOP,'Visible','on')
    35273528set(handles.speed,'Visible','on')
     
    35413542    end
    35423543    pause(1.02-get(handles.speed,'Value'));% wait for next image
    3543     get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')
    35443544end
    35453545set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    35463546set(handles.movie_pair,'Value',0)
    35473547set(handles.Dt_txt,'String','')
    3548 
    35493548set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red
    35503549
    35513550
    35523551%------------------------------------------------------------------------
    3553 % --- Executes on button press in InputFileREFRESH.
     3552% --- Executes on press in button tagged 'REFRESH'.
    35543553function REFRESH_Callback(hObject, eventdata, handles)
    35553554%------------------------------------------------------------------------
     
    35583557[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);%read the features of the input file name (first line)
    35593558[~,~,~,~,i2,~,j2]=fileparts_uvmat(FileIndex);% check back the indices used
    3560 if isempty(i2), set(handles.i2,'String',''); end % suppress the second i index display if not used
    3561 if isempty(j2), set(handles.j2,'String',''); end % suppress the second j index display if not used
    3562 if isempty(regexp(RootPath,'^http://','once'))
     3559if isempty(i2), set(handles.num_i2,'String',''); end % suppress the second i index display if not used
     3560if isempty(j2), set(handles.num_j2,'String',''); end % suppress the second j index display if not used
     3561if isempty(regexp(RootPath,'^http://','once'))% if the input is not opendap
    35633562    filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
    35643563else
     
    35713570    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; %build the input file name (second line)
    35723571end
    3573 num_i1=stra2num(get(handles.i1,'String'));
    3574 num_i2=stra2num(get(handles.i2,'String'));
    3575 num_j1=stra2num(get(handles.j1,'String'));
    3576 num_j2=stra2num(get(handles.j2,'String'));
    3577 [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
     3572num_i1=stra2num(get(handles.num_i1,'String'));
     3573num_i2=stra2num(get(handles.num_i2,'String'));
     3574num_j1=stra2num(get(handles.num_j1,'String'));
     3575num_j2=stra2num(get(handles.num_j2,'String'));
     3576[~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
    35783577if isempty(j1_1)% case of movies, the index is not given by file index
    35793578    j1_1=num_j1;
    35803579end
    3581 % in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i)
     3580% in case of movies the index is set by edit boxes num_i1 or num_j1 (case of movies indexed by index i)
    35823581errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    35833582ResizeFcn(handles.uvmat,[],handles)
     
    36613660    frame_index=1;%default
    36623661    if UvData.FileInfo{1}.NumberOfFrames>1
     3662        % if strcmp(NomType,'*')
     3663        %     if num_i1>UvData.FileInfo{1}.NumberOfFrames
     3664        %         errormsg='specified frame index exceeds file content';
     3665        %         return
     3666        %     else
     3667        %         frame_index=num_i1;%frame index from a single movies or multimage
     3668        %     end
     3669        % else
     3670        %     if num_j1>UvData.FileInfo{1}.NumberOfFrames
     3671        %         errormsg='specified frame index exceeds file content';
     3672        %         return
     3673        %     else
     3674        %         frame_index=num_j1;% frame index from a set of indexed movies
     3675        %     end
     3676        % end
    36633677        if strcmp(NomType,'*')
    3664             if num_i1>UvData.FileInfo{1}.NumberOfFrames
    3665                 errormsg='specified frame index exceeds file content';
    3666                 return
    3667             else
    3668                 frame_index=num_i1;%frame index from a single movies or multimage
    3669             end
     3678             frame_index=num_i1;%frame index from a single movies or multimage
    36703679        else
    3671             if num_j1>UvData.FileInfo{1}.NumberOfFrames
    3672                 errormsg='specified frame index exceeds file content';
    3673                 return
    3674             else
    3675                 frame_index=num_j1;% frame index from a set of indexed movies
    3676             end
     3680              frame_index=num_j1;% frame index from a set of indexed movies
    36773681        end
    36783682    end
     
    39883992            % TODO: look for time unit attribute
    39893993        elseif ~isempty(regexp(TimeName,'^dim:', 'once'))
    3990             abstime=str2double(get(handles.i1,'String'));
     3994            abstime=str2double(get(handles.num_i1,'String'));
    39913995            TimeUnit='index';
    39923996        end
     
    48734877                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% put file index in the root name
    48744878                    set(handles.NomType,'String','')
    4875                     set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix)
     4879                    set(handles.num_i1,'String','1')% set counter to 1 (now the time index in the input matrix)
    48764880                    MaxIndex_i=get(handles.MaxIndex_i,'String');
    48774881                    MaxIndex_i{1}=num2str(GetFieldData.Time.TimeDimension);
     
    48854889                    set(handles.NomType,'String','*')
    48864890                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
    4887                     set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix)
     4891                    set(handles.num_i1,'String','1')% set counter to 1 (now the time index in the input matrix)
    48884892                    MaxIndex_i=get(handles.MaxIndex_i,'String');
    48894893                    MaxIndex_i{1}=num2str(GetFieldData.Time.TimeDimension);
     
    52085212    UvData.FileName_1='';% desactivate the use of a constant second file
    52095213    set(handles.uvmat,'UserData',UvData)
    5210     num_i1=stra2num(get(handles.i1,'String'));
    5211     num_i2=stra2num(get(handles.i2,'String'));
    5212     num_j1=stra2num(get(handles.j1,'String'));
    5213     num_j2=stra2num(get(handles.j2,'String'));
     5214    num_i1=stra2num(get(handles.num_i1,'String'));
     5215    num_i2=stra2num(get(handles.num_i2,'String'));
     5216    num_j1=stra2num(get(handles.num_j1,'String'));
     5217    num_j2=stra2num(get(handles.num_j2,'String'));
    52145218    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]);
    52155219    errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
     
    62976301% Hints: contents = cellstr(get(hObject,'String')) returns LogLinHisto contents as cell array
    62986302%        contents{get(hObject,'Value')} returns selected item from LogLinHisto
    6299 
    6300 
    6301 
    6302 
Note: See TracChangeset for help on using the changeset viewer.