Changeset 26 for trunk


Ignore:
Timestamp:
Mar 2, 2010, 4:22:23 PM (15 years ago)
Author:
gostiaux
Message:

series native functions removed from series.m

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r25 r26  
    135135
    136136%loads the information stored in prefdir to initiate the browser and the list of functions
    137 menu_str=get(handles.ACTION,'String');%list of functions included in 'series.m'
    138 menu_str(end)=[];%remove from the list the last option 'more...'
    139 path_series=which('series');%path of the function 'series'
     137menu_str={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
     138 
     139% menu_str=get(handles.ACTION,'String');%list of functions included in 'series.m'
     140
     141%remove from the list the last option 'more...'
     142[path_series,name,ext]=fileparts(which('series'));
     143path_series=fullfile(path_series,'/series');%path of the function 'series'
     144
    140145for ilist=1:length(menu_str)
    141146    fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m'
     
    151156             menu_str=[menu_str; {file}];
    152157         end
    153          menu_str=[menu_str;{'more...'}];
    154          set(handles.ACTION,'String',menu_str)
    155     end
    156 end
     158    end
     159end
     160
     161menu_str=[menu_str;{'more...'}];
     162set(handles.ACTION,'String',menu_str)
    157163set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION
    158164
     
    14811487    end
    14821488end
     1489% fct_path
     1490        eval(['h_fun=@' action])
     1491if ~isequal(fct_path,path_series)
     1492        rmpath(fct_path)% add the prescribed path if not the current one   
     1493end
     1494
    14831495Series.Action=action;%name of the processing programme
    14841496set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    14851497drawnow
    14861498if length(RootPath)>1
    1487     feval(action,num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
     1499%    feval(action,num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
     1500    h_fun(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
    14881501else
    1489     feval(action,num_i1,num_i2,num_j1,num_j2,Series);
     1502    h_fun(num_i1,num_i2,num_j1,num_j2,Series);
     1503%     feval(action,num_i1,num_i2,num_j1,num_j2,Series);
    14901504end
    14911505set(handles.RUN,'BackgroundColor',[1 0 0])
     
    16111625end
    16121626if nb_builtin==0% the path of series has been changed, reinitialize
    1613     series_OpeningFcn(hObject, eventdata, handles)
     1627%     series_OpeningFcn(hObject, eventdata, handles)
    16141628    return
    16151629end
     
    16181632if isequal(ACTION,'more...')
    16191633    pathfct=fileparts(path_series);
    1620     browse_name=fullfile(path_series,'SERIES_FCT');%go to UVMAT/SERIES_FCT by default
     1634    browse_name=fullfile(path_series,'series');%go to UVMAT/SERIES_FCT by default
    16211635    if length(list_path)>nb_builtin
    16221636        browse_name=list_path{end};% initialize browser with  the path of the last introduced function
     
    16301644        return
    16311645    end
    1632     ext_fct=FileName(end-1:end);
     1646   
     1647   
     1648   
     1649    ext_fct=FileName(end-1:end);% to be replaced by fileparts
    16331650    if ~isequal(ext_fct,'.m')
    16341651        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
     
    16361653    end
    16371654    ACTION=FileName(1:end-2);% ACTION choice updated by the selected item
     1655   
     1656    addpath(PathName)
     1657    eval(['h_function=@' ACTION]);
     1658    if ~isequal(path_series,PathName)
     1659    rmpath(PathName)
     1660    end
     1661    functions(h_function)
    16381662   
    16391663   % insert the choice in the action menu
     
    18951919     update_menu(handles.FieldMenu_1,scalar)
    18961920end   
    1897 
    1898 
    1899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1900  %detect the chosen series of files and check their date of modification:
    1901 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1902 %INPUT:
    1903 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    1904 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    1905 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
    1906 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
    1907 %OTHER INPUTS given by the structure Series
    1908 function GUI_input=check_files(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series) %(filecell,filecell_1,num_i,num_j,vel_type,field,param);
    1909 
    1910 %requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
    1911 if ~exist('num_i1_cell','var')
    1912     GUI_input={'RootPath';'many';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
    1913         'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
    1914         'RootFile';'on';... %root input file name ('on' by default)
    1915         'FileExt';'on';... %input file extension ('on' by default)
    1916         'NomType';'on';...%type of file indexing ('on' by default)
    1917         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    1918         %'VelTypeMenu';'on';...% menu for selecting the velocity type (civ1,..) 'off' by default)
    1919         %'FieldMenu';'on';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    1920         %'CoordType';'on'...%can use a transform function 'off' by default
    1921         %'GetObject';'on'...%can use projection object ,'off' by default
    1922         %'GetMask';'on'...%can use mask option   ,'off' by default
    1923         %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter
    1924                ''};
    1925     return %exit the function
    1926 end
    1927 
    1928 %standard parameters for waitbar and STOP action (do not modify)
    1929 hseries=guidata(Series.hseries);%handles of the GUI series
    1930 WaitbarPos=get(hseries.waitbar_frame,'Position');
    1931 
    1932 %%%%%%%%%%%%%%%%%%%%%%%%
    1933 
    1934 % number of slices
    1935 NbSlice=str2num(get(hseries.NbSlice,'String'));
    1936 if isempty(NbSlice)
    1937     NbSlice=1;
    1938 end
    1939 NbSlice_name=num2str(NbSlice);
    1940 if isequal(NbSlice,[]),NbSlice=1; end; %default
    1941 
    1942 % number of views
    1943 count=0;
    1944 testcell=iscell(Series.RootFile);
    1945 if ~testcell
    1946     Series.RootPath={Series.RootPath};
    1947     Series.RootFile={Series.RootFile};
    1948     Series.SubDir={Series.SubDir};
    1949     Series.FileExt={Series.FileExt};
    1950     Series.NomType={Series.NomType};
    1951 end   
    1952 nbview=length(Series.RootFile);
    1953 for iview=1:nbview
    1954     filebase=fullfile(Series.RootPath{iview},Series.RootFile{iview});%root file name
    1955     if testcell
    1956         num_i1=num_i1_cell{iview}; num_i2=num_i2_cell{iview}; num_j1=num_j1_cell{iview}; num_j2=num_j2_cell{iview};
    1957     else
    1958         num_i1=num_i1_cell; num_i2=num_i2_cell; num_j1=num_j1_cell; num_j2=num_j2_cell;
    1959     end
    1960     siz=size(num_i1);
    1961     nbfield2=siz(1); %nb of consecutive fields at each level(burst
    1962     nbfield=siz(1)*siz(2);
    1963     nbfield=floor(nbfield/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices)
    1964     if isequal(lower(Series.FileExt{iview}),'.avi')
    1965         info=aviinfo([filebase Series.FileExt{iview}]);
    1966         message{1}=info.Filename;
    1967         message{2}=info.FileModDate;
    1968         message{3}=[num2str(info.FramesPerSecond) ' frames/s '];
    1969         message{4}=info.ImageType;
    1970         message{5}=['  compression' info.VideoCompression];
    1971         message{6}=[ 'quality ' num2str(info.Quality)];   
    1972         Tabchar=message;
    1973     else
    1974         datnum=[];
    1975         Tabchar={};
    1976         %LOOP ON SLICES
    1977         for i_slice=1:NbSlice
    1978             for ifield=1:nbfield
    1979                 indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice
    1980             end
    1981             for index=1:nbfield*nbfield2
    1982                 stopstate=get(hseries.RUN,'BusyAction');
    1983                 if isequal(stopstate,'queue')% enable STOP command
    1984                     update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))
    1985                     ifile=indselect(index);               
    1986                     file=...
    1987                        name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2(ifile),num_j2(ifile),Series.SubDir{iview});               
    1988                     [Path,Name,ext]=fileparts(file);
    1989                     detect=exist(file,'file'); % check the existence of the file
    1990                     if detect==0
    1991                         count=count+1;
    1992                         lastfield='not found';
    1993                     else
    1994                         datfile=dir(file);
    1995                         datnum(ifile)=datenum(datfile.date);
    1996                         filefound(ifile)={datfile.name};
    1997                         lastfield='';
    1998                         if isequal(Series.FileExt{iview},'.nc') || isequal(Series.FileExt{iview},'.cdf')
    1999                             % check the content  netcdf file
    2000                             Data=nc2struct(file,'ListGlobalAttribute','patch2','fix2','civ2','patch','fix','absolut_time_T0','hart');
    2001                             if ~isempty(Data.patch2) && isequal(Data.patch2,1)
    2002                                 lastfield='patch2';
    2003                             elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
    2004                                 lastfield='fix2';
    2005                             elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
    2006                                 lastfield='civ2';
    2007                             elseif ~isempty(Data.patch) && isequal(Data.patch,1);
    2008                                 lastfield='patch1';
    2009                             elseif ~isempty(Data.fix) && isequal(Data.fix,1);
    2010                                 lastfield='fix1';
    2011                             elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
    2012                                 lastfield='civ1';
    2013                             end                         
    2014                         end
    2015                     end
    2016                     Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
    2017                     Tabchar(index+1,i_slice)={[file '   ' lastfield]};
    2018                 end
    2019             end
    2020         end
    2021         if isempty(datnum)
    2022             if NbSlice>1
    2023                 message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
    2024             else
    2025                  message='no file found';
    2026             end
    2027         else
    2028             datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
    2029             [first,ind]=min(datnum);
    2030             [last,indlast]=max(datnum);
    2031             message={['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    2032                 ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
    2033         end
    2034         if ~isempty(Tabchar)
    2035           Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1);
    2036         end
    2037     end
    2038     hfig=figure(iview);
    2039     clf
    2040     if iview>1
    2041         pos=get(iview-1,'Position');
    2042         pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
    2043         set(hfig,'Position',pos)
    2044     end
    2045     set(hfig,'name',['view= ' num2str(iview)])
    2046    
    2047     h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', @ncbrowser_uvmat);
    2048     hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
    2049 end
    2050 %----------------------------------------------------
    2051 %  determine the list of index pairs of processing file
    2052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2053 function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
    2054 num_i1=num_i;% set of first image numbers by default
    2055 num_i2=num_i;
    2056 num_j1=num_j;
    2057 num_j2=num_j;
    2058 num_i_out=num_i;
    2059 num_j_out=num_j;
    2060 if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2')
    2061     num_i1_line=num_i+ind_shift(3);% set of first image numbers
    2062     num_i2_line=num_i+ind_shift(4);
    2063     % adjust the first and last field number
    2064         indsel=find(num_i1_line >= 1);
    2065     num_i_out=num_i(indsel);
    2066     num_i1_line=num_i1_line(indsel);
    2067     num_i2_line=num_i2_line(indsel);
    2068     num_j1=meshgrid(num_j,ones(size(num_i1_line)));
    2069     num_j2=meshgrid(num_j,ones(size(num_i1_line)));
    2070     [xx,num_i1]=meshgrid(num_j,num_i1_line);
    2071     [xx,num_i2]=meshgrid(num_j,num_i2_line);
    2072 elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab')
    2073     if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
    2074         num_j1=ind_shift(1)*ones(size(num_i));
    2075         num_j2=ind_shift(2)*ones(size(num_i));
    2076     else
    2077         num_j1_col=num_j+ind_shift(1);% set of first image numbers
    2078         num_j2_col=num_j+ind_shift(2);
    2079         % adjust the first field number
    2080         indsel=find((num_j1_col >= 1));   
    2081         num_j_out=num_j(indsel);
    2082         num_j1_col=num_j1_col(indsel);
    2083         num_j2_col=num_j2_col(indsel);
    2084         [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
    2085         [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
    2086     end   
    2087 end
    2088 
    2089 
    2090 %----------------------------------------------------------------------
    2091 % --- make average on a series of files
    2092 %----------------------------------------------------------------------
    2093 %INPUT:
    2094 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    2095 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    2096 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
    2097 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
    2098 %OTHER INPUTS given by the structure Series
    2099 %  Series.Time:
    2100 %  Series.GeometryCalib:
    2101 function GUI_input=aver_stat(num_i1,num_i2,num_j1,num_j2,Series)
    2102 %requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
    2103 if ~exist('num_i1','var')
    2104     GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
    2105         'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
    2106         'RootFile';'on';... %root input file name ('on' by default)
    2107         'FileExt';'on';... %input file extension ('on' by default)
    2108         'NomType';'on';...%type of file indexing ('on' by default)
    2109         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    2110         'VelTypeMenu';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    2111         'FieldMenu';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    2112         'CoordType'; 'on';...%can use a transform function
    2113         'GetObject';'on';...%can use projection object(option 'off'/'one'/'two',
    2114         %'GetMask';'on'...%can use mask option   
    2115         %'PARAMETER'; %options: name of the user defined parameter',repeat a line for each parameter
    2116                ''};
    2117         return
    2118 end
    2119 
    2120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2121 hseries=guidata(Series.hseries);%handles of the GUI series
    2122 WaitbarPos=get(hseries.waitbar_frame,'Position');
    2123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2124 
    2125 %root input file and type
    2126 if ~iscell(Series.RootPath)% case of a single input field series
    2127     num_i1={num_i1};num_j1={num_j1};num_i2={num_i2};num_j2={num_j2};
    2128     RootPath={Series.RootPath};
    2129     RootFile={Series.RootFile};
    2130     SubDir={Series.SubDir};
    2131     FileExt={Series.FileExt};
    2132     NomType={Series.NomType};
    2133 else
    2134     RootPath=Series.RootPath;
    2135     RootFile=Series.RootFile;
    2136     SubDir=Series.SubDir;
    2137     NomType=Series.NomType;
    2138     FileExt=Series.FileExt;
    2139 end   
    2140 ext=FileExt{1};
    2141 form=imformats(ext([2:end]));%test valid Matlab image formats
    2142 testima=0;
    2143 if ~isempty(form)||isequal(lower(ext),'.avi')||isequal(lower(ext),'.vol')
    2144     testima(1)=1;
    2145 end
    2146 if length(FileExt)>=2
    2147     ext_1=FileExt{2};
    2148     form=imformats(ext_1([2:end]));%test valid Matlab image formats
    2149     if ~isempty(form)||isequal(lower(ext_1),'.avi')||isequal(lower(ext_1),'.vol')
    2150         testima(2)=1;
    2151     end
    2152     if testima(2)~=testima(1)
    2153         msgbox_uvmat('ERROR','images and netcdf files cannot be compared')
    2154         return
    2155     end
    2156 end
    2157 
    2158 %Number of input series: this function  accepts two input file series at most (then it operates on the difference of fields)
    2159 nbview=length(RootPath);
    2160 if nbview>2 
    2161     RootPath=RootPath(1:2);
    2162     set(hseries.RootPath,'String',RootPath)
    2163     SubDir=SubDir(1:2);
    2164     set(hseries.SubDir,'String',SubDir)
    2165     RootFile=RootFile(1:2);
    2166     set(hseries.RootFile,'String',RootFile)
    2167     NomType=NomType(1:2);
    2168     FileExt=FileExt(1:2);
    2169     set(hseries.FileExt,'String',FileExt)
    2170     nbview=2;
    2171 end
    2172 hhh=which('mmreader');
    2173 for iview=1:nbview
    2174     test_movie(iview)=0;
    2175     if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
    2176         if isequal(lower(FileExt{iview}),'.avi')
    2177             MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}]));
    2178             test_movie(iview)=1;
    2179         end
    2180     end
    2181 end
    2182 
    2183 % number of slices
    2184 NbSlice=str2num(get(hseries.NbSlice,'String'));
    2185 if isempty(NbSlice)
    2186     NbSlice=1;
    2187 end
    2188 NbSlice_name=num2str(NbSlice);
    2189 
    2190 % Field and velocity type (the same for the two views)
    2191 Field_str=get(hseries.FieldMenu,'String');
    2192 FieldName=[]; %default
    2193 testfield=get(hseries.FieldMenu,'Visible');
    2194 if isequal(testfield,'on')
    2195     val=get(hseries.FieldMenu,'Value');
    2196     FieldName=Field_str(val);%the same set of fields for all views
    2197     if isequal(FieldName,{'get_field...'})
    2198         hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
    2199         if length(hget_field)>1
    2200             delete(hget_field(2:end))
    2201         elseif isempty(hget_field)
    2202            filename=...
    2203                  name_generator(fullfile(RootPath{1},RootFile{1}),num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1});
    2204            get_field(filename);
    2205            return
    2206         end
    2207         %hhget_field=guidata(hget_field);%handles of GUI elements in get_field
    2208         SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
    2209     end
    2210 end
    2211 %detect whether the two files are 'images' or 'netcdf'
    2212 testima=0;
    2213 testvol=0;
    2214 testcivx=0;
    2215 testnc=0;
    2216 FileExt=get(hseries.FileExt,'String');
    2217 % test_movie=0;
    2218 for iview=1:nbview
    2219      ext=FileExt{iview};
    2220      form=imformats(ext([2:end]));
    2221      if isequal(lower(ext),'.vol')
    2222          testvol=testvol+1;
    2223      elseif ~isempty(form)||isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab
    2224          testima=testima+1;
    2225      elseif isequal(ext,'.nc')
    2226          testnc=testnc+1;
    2227      end
    2228 end
    2229 if testvol
    2230     msgbox_uvmat('ERROR','volume images not implemented yet')
    2231     return
    2232 end
    2233 if testnc~=nbview && testima~=nbview && testvol~=nbview
    2234     msgbox_uvmat('ERROR','compare two image series or two netcdf files with the same fields as input')
    2235     return
    2236 end
    2237 if ~isequal(FieldName,{'get_field...'})
    2238     testcivx=testnc;
    2239 end
    2240 
    2241 if testcivx
    2242     VelType_str=get(hseries.VelTypeMenu,'String');
    2243     VelType_val=get(hseries.VelTypeMenu,'Value');
    2244     VelType{1}=VelType_str{VelType_val};
    2245     if nbview==2
    2246         VelType_str=get(hseries.VelTypeMenu_1,'String');
    2247         VelType_val=get(hseries.VelTypeMenu_1,'Value');
    2248         VelType{2}=VelType_str{VelType_val};
    2249     end
    2250 end
    2251 
    2252 %Calibration data and timing: read the ImaDoc files
    2253 mode=''; %default
    2254 timecell={};
    2255 itime=0;
    2256 NbSlice_calib={};
    2257 for iview=1:nbview%Loop on views
    2258     XmlData{iview}=[];%default
    2259     filebase{iview}=fullfile(RootPath{iview},RootFile{iview});
    2260     if exist([filebase{iview} '.xml'],'file')
    2261         [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']);
    2262         if isfield(XmlData{iview},'Time')
    2263             itime=itime+1;
    2264             timecell{itime}=XmlData{iview}.Time;
    2265         end
    2266         if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
    2267             NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform
    2268             if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
    2269                 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
    2270             end
    2271         end
    2272     elseif exist([filebase{iview} '.civ'],'file')
    2273         [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']);
    2274         itime=itime+1;
    2275         timecell{itime}=time;
    2276         XmlData{iview}.Time=time;
    2277         GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    2278         GeometryCalib.Tx=0;
    2279         GeometryCalib.Ty=0;
    2280         GeometryCalib.Tz=1;
    2281         GeometryCalib.dpx=1;
    2282         GeometryCalib.dpy=1;
    2283         GeometryCalib.sx=1;
    2284         GeometryCalib.Cx=0;
    2285         GeometryCalib.Cy=0;
    2286         GeometryCalib.f=1;
    2287         GeometryCalib.kappa1=0;
    2288         GeometryCalib.CoordUnit='cm';
    2289         XmlData{iview}.GeometryCalib=GeometryCalib;
    2290         if error==1
    2291             msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    2292         end
    2293     end
    2294 end
    2295 
    2296 %check coincidence in time
    2297 multitime=0;
    2298 if length(timecell)==0
    2299     time=[];
    2300 elseif length(timecell)==1
    2301     time=timecell{1};
    2302 elseif length(timecell)>1
    2303     multitime=1;
    2304     for icell=1:length(timecell)
    2305         if ~isequal(size(timecell{icell}),size(timecell{1}))
    2306             msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
    2307             time=timecell{1};
    2308             multitime=0;
    2309             break
    2310         end
    2311     end
    2312 end
    2313 if multitime
    2314     for icell=1:length(timecell)
    2315         time(icell,:,:)=timecell{icell};
    2316     end
    2317     diff_time=max(max(diff(time)));
    2318     if diff_time>0
    2319         msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)])
    2320     end   
    2321 end
    2322 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file'
    2323     time=[];
    2324 end
    2325 
    2326 % Root name of output files (TO GENERALISE FOR TWO INPUT SERIES)
    2327 filebasesub=fullfile(RootPath{1},SubDir{1},RootFile{1});
    2328 if isempty(SubDir{1}) % create a subdirectory '/mean'
    2329     subdir_result='mean';
    2330 %     filebasemean=fullfile(RootPath{1},subdir_result);
    2331     if ~exist(fullfile(RootPath{1},subdir_result),'dir')
    2332         dircur=pwd; %record current working directory
    2333         cd(RootPath{1})% goes to the iamge directory
    2334         [m1,m2,m3]=mkdir(subdir_result);
    2335         if ~isequal(m2,'')
    2336              msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation
    2337         end
    2338         cd(dircur) %back to the initial working directory
    2339     end
    2340     filebase_out=filebase{1};
    2341 else
    2342    subdir_result=SubDir{1};
    2343    filebase_out=[filebase{1} '_mean'];% output root name obtained by adding the suffix _mean to the input
    2344 end
    2345 %output nomtype (to generalise)
    2346 NomTypeOut=nomtype2pair(NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1));
    2347    
    2348 if NbSlice==1 
    2349     filebase_out=[filebasesub '_mean'];
    2350 else
    2351     filebase_out=[filebasesub '_' NbSlice_name 'mean'];
    2352     answeryes=questdlg({['will mak