Index: /trunk/src/get_file_index.m
===================================================================
--- /trunk/src/get_file_index.m	(revision 1171)
+++ /trunk/src/get_file_index.m	(revision 1172)
@@ -1,3 +1,14 @@
-%=======================================================================
+
+%'get_file_index': determine the frame indexes from ref indices and pair option for civ
+% [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString)
+%------------------------------------------------------------------------
+% OUTPUT:
+% i1,i2,j1,j2: frem indices i and j for image 1 and 2
+%
+% INPUT:
+% ref_i,ref_j: reference indices set in the GUI series
+% PairString: string defining the choice of pairing: 'Di=..','Dj=..','-'
+
+%=====================================================================
 % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
 %   http://www.legi.grenoble-inp.fr
Index: /trunk/src/mouse_down.m
===================================================================
--- /trunk/src/mouse_down.m	(revision 1171)
+++ /trunk/src/mouse_down.m	(revision 1172)
@@ -493,4 +493,5 @@
         h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
         Coord=get(h_ListCoord,'Data');
+        Coord=Coord(:,1:6);
         %data=read_geometry_calib(Coord);%transform char cell to numbers
         xlim=get(haxes,'XLim');
Index: /trunk/src/series/sub_background.m
===================================================================
--- /trunk/src/series/sub_background.m	(revision 1171)
+++ /trunk/src/series/sub_background.m	(revision 1172)
@@ -229,7 +229,6 @@
 NomType=Param.InputTable(:,4);
 FileExt=Param.InputTable(:,5);
-%hdisp=disp_uvmat('WAITING...','checking the file series',checkrun);
-[filecell,i1_series,i2_series,j1_series]=get_file_series(Param);
-% if ~isempty(hdisp),delete(hdisp),end;
+[filecell,i1_series,i2_series,j1_series]=get_file_series(Param);%series of file names organised as a single array
+
 %%%%%%%%%%%%
     % The cell array filecell is the list of input file names, while
@@ -280,6 +279,4 @@
     step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
     NbSlice_j=1;
-    %nbfield_i=floor(nbfield_i/NbSlice_i);%total number of  indexes in a slice (adjusted to an integer number of slices)
-    %nbfield=nbfield_i*NbSlice_i; %total number of fields after adjustement
     nbfield_series=nbfield_i*nbfield_j;
 end
@@ -314,16 +311,30 @@
 end
 
-
-%%%%%%%  LOOP ON SLICES FOR VOLUME SCAN %%%%%%%
-for j_slice=1:NbSlice_j
+%selection of frame indices
+if Param.ActionInput.CheckVolume 
+    nbfield=floor(nbfield/NbSlice_j)*NbSlice_j;% truncate the total number of frames in case of incomplete series
+    indselect=1:nbfield;
+     indselect=reshape(indselect,NbSlice_j,[]);
+      NbSlice=NbSlice_j;
+else
+       NbSlice=NbSlice_i;
+    nbfield=floor(nbfield/NbSlice)*NbSlice;% truncate the total number of frames in case of incomplete series
+    indselect=reshape(1:nbfield,NbSlice,[]);
+    for j_slice=1:NbSlice
+    indselect(j_slice,:)=j_slice:step*NbSlice:nbfield;% select file indices of the slice
+    end
+end
+
+%%%%%%%  LOOP ON SLICES %%%%%%%
+for j_slice=1:NbSlice
     %% select the series of i indices to process
-    indselect=j_slice:step*NbSlice_j:nbfield;% select file indices of the slice
-    for ifield=1:step-1
-        indselect=[indselect;indselect(end,:)+NbSlice_j];
-    end
+ %   indselect=j_slice:step*NbSlice_j:nbfield;% select file indices of the slice
+%     for ifield=1:step-1
+%         indselect=[indselect;indselect(end,:)+NbSlice];
+%     end
     
     %% read the first series of nbaver_ima images and sort by luminosity at each pixel
     for ifield = 1:nbaver_ima
-        ifile=indselect(ifield);
+        ifile=indselect(jslice,ifield);
         filename=filecell{1,ifile};
         Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile));
@@ -341,5 +352,5 @@
         Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image
         Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor
-        ifile=indselect(ifield);
+        ifile=indselect(jslice,ifield);
         j1=1;
         if ~isempty(j1_series{1})
@@ -381,5 +392,5 @@
             %incorporate next burst in the current image series
             for iburst=1:step
-                ifile=indselect(ifield+iburst+step*halfnbaver);
+                ifile=indselect(jslice,ifield+iburst+step*halfnbaver);
                 j1=1;
                 if ~isempty(j1_series{1})
@@ -400,5 +411,5 @@
                 Acor=double(Ak(:,:,step*halfnbaver+iburst))-double(B); %the current image has been already read ans stored as index step*halfnbaver+iburst in the current series
                 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor
-                ifile=indselect(ifield+iburst);
+                ifile=indselect(jslice,ifield+iburst);
                 if ~isempty(j1_series{1})
                     j1=j1_series{1}(ifile);
@@ -428,5 +439,5 @@
         Acor=double(Ak(:,:,ifield-nbfield_series+step*(2*halfnbaver+1)))-double(B);
         Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor
-        ifile=indselect(ifield);
+        ifile=indselect(jslice,ifield);
         if ~isempty(j1_series{1})
             j1=j1_series{1}(ifile);
Index: unk/src/series/sub_background_special.m
===================================================================
--- /trunk/src/series/sub_background_special.m	(revision 1171)
+++ 	(revision )
@@ -1,163 +1,0 @@
-%'bed_scan': get the bed shape from laser ipact
-
-%------------------------------------------------------------------------
-% function GUI_input=bed_scan(Param)
-%
-%------------------------------------------------------------------------
-%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-%OUTPUT
-% ParamOut: sets options in the GUI series.fig needed for the function
-%
-%INPUT:
-% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
-% In batch mode, Param is the name of the corresponding xml file containing the same information
-% when Param.Action.RUN=0 (as activated when the current Action is selected
-% in series), the function ouput paramOut set the activation of the needed GUI elements
-%
-% Param contains the elements:(use the menu bar command 'export/GUI config' in series to 
-% see the current structure Param)
-%    .InputTable: cell of input file names, (several lines for multiple input)
-%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
-%    .OutputSubDir: name of the subdirectory for data outputs
-%    .OutputDirExt: directory extension for data outputs
-%    .Action: .ActionName: name of the current activated function
-%             .ActionPath:   path of the current activated function
-%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
-%             .RUN =0 for GUI input, =1 for function activation
-%             .RunMode='local','background', 'cluster': type of function  use
-%             
-%    .IndexRange: set the file or frame indices on which the action must be performed
-%    .FieldTransform: .TransformName: name of the selected transform function
-%                     .TransformPath:   path  of the selected transform function
-%    .InputFields: sub structure describing the input fields withfields
-%              .FieldName: name(s) of the field
-%              .VelType: velocity type
-%              .FieldName_1: name of the second field in case of two input series
-%              .VelType_1: velocity type of the second field in case of two input series
-%              .Coord_y: name of y coordinate variable
-%              .Coord_x: name of x coordinate variable
-%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%=======================================================================
-% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
-%   http://www.legi.grenoble-inp.fr
-%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
-%
-%     This file is part of the toolbox UVMAT.
-%
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published
-%     by the Free Software Foundation; either version 2 of the license,series
-%     or (at your option) any later version.
-%
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (see LICENSE.txt) for more details.
-%=======================================================================
-
-function ParamOut=sub_background_special (Param)
-
-%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
-if isstruct(Param) && isequal(Param.Action.RUN,0)
-    ParamOut.NbViewMax=1;% max nbre of input file series (default , no limitation)
-    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
-    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
-    ParamOut.NbSlice='on'; %nbre of slices ('off' by default)
-    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
-    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
-    ParamOut.FieldTransform = 'off';%can use a transform function
-    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
-    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
-    ParamOut.OutputDirExt='.sback';%set the output dir extension
-    ParamOut.OutputFileMode='NbInput';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
-    %check the type of the existence and type of the first input file:
-return
-end
-
-%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
-%% read input parameters from an xml file if input is a file name (batch mode)
-ParamOut=[];
-RUNHandle=[];
-WaitbarHandle=[];
-checkrun=1;
-if ischar(Param)% case of batch: Param is the name of the xml file containing the input parameters
-    Param=xml2struct(Param);% read Param as input file (batch case)
-    checkrun=0;
-else% interactive mode in Matlab
-    hseries=findobj(allchild(0),'Tag','series');
-    RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
-    WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
-end
-%% estimate the position of bottom and mask for each Z Index
-NbSlice=Param.IndexRange.NbSlice;
-switch NbSlice
-    case 11
-        BottomIndex=[1900 1800 1700 1650 1650 1600 1600 1600 1600 1600 1600];
-    case 4
-        BottomIndex=[1950 1850 1740 1700];
-end
-MaxIndex=BottomIndex+100;
-MinIndex=BottomIndex-100;
-
-maskindex=[665 1080];% range of x index perturbed by shadows 
-Bfilter=ones(1,20)/20;
-%% root input file names and nomenclature type (cell arrays with one element)
-OutputDir=[Param.OutputSubDir Param.OutputDirExt];
-nbj=numel(Param.IndexRange.first_i:Param.IndexRange.last_i);
-for i_ind=Param.IndexRange.first_i:Param.IndexRange.last_i
-    ZIndex=mod(i_ind-1,NbSlice)+1; 
-    for j_ind=Param.IndexRange.first_j:Param.IndexRange.last_j
-        % read the current image
-        InputFile=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},Param.InputTable{1,4},i_ind,i_ind,j_ind);
-        A=imread(InputFile);
-        % get the bottom as the max of luminosity along vertical lines    
-        IndexMax=ones(1,size(A,2));%initiate the index position of the bottom
-        if j_ind==Param.IndexRange.first_j
-            indexMax_j=ones(nbj,size(A,2));%initiate the matrix of index position of the bottom
-        end
-        for icolumn=1:maskindex(1)
-            [M,IndexMax(icolumn)] = max(A(MinIndex(ZIndex)+1:MaxIndex(ZIndex),icolumn),[],1);
-        end
-        [M,IndexMax(maskindex(2))] = max(A(MinIndex(ZIndex)+1:MaxIndex(ZIndex),maskindex(2)),[],1);
-        for icolumn=maskindex(1)+1:maskindex(2)-1 % linear interpolation in the masked region
-            IndexMax(icolumn)= IndexMax(maskindex(1))*(maskindex(2)-icolumn)+IndexMax(maskindex(2))*(icolumn-maskindex(1));
-            IndexMax(icolumn)=IndexMax(icolumn)/(maskindex(2)-maskindex(1));
-        end
-        for icolumn=maskindex(2)+1:size(A,2)
-            [M,IndexMax(icolumn)] = max(A(MinIndex(ZIndex)+1:MaxIndex(ZIndex),icolumn),[],1);
-        end
-        IndexFilt=filter(Bfilter,1,IndexMax);% smoothed IndexMax
-        peakdetect=find(abs(IndexFilt-IndexMax)>5);% detect strong departures from the filtered values
-        IndexMax(peakdetect)=IndexFilt(peakdetect);%replace the peaks by the filtered values
-        IndexMax_j(j_ind,:)=round(filter(Bfilter,1,IndexMax));%filter again and take the closest integer
-        % get the background image as the min at each point in the j series 
-        if j_ind==Param.IndexRange.first_j
-            Amin=A;
-        else
-            Amin=min(Amin,A);
-        end
-    end
-    
-    for j_ind=Param.IndexRange.first_j:Param.IndexRange.last_j
-        InputFile=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},Param.InputTable{1,4},i_ind,i_ind,j_ind);
-        A=imread(InputFile);
-        A=A-Amin;
-        for icolumn=1:size(A,2)
-            A(MinIndex(ZIndex)+IndexMax_j(j_ind,icolumn):end,icolumn)=0;
-        end
-        OutputFile=fullfile_uvmat(Param.InputTable{1,1},OutputDir,Param.InputTable{1,3},Param.InputTable{1,5},Param.InputTable{1,4},i_ind,i_ind,j_ind);
-        imwrite(A,OutputFile)
-        disp([OutputFile ' written'])
-    end
-end
-
-
-
-
-
-
- 
-
