Index: trunk/src/series/merge_proj.m
===================================================================
--- trunk/src/series/merge_proj.m	(revision 1056)
+++ trunk/src/series/merge_proj.m	(revision 1058)
@@ -533,9 +533,4 @@
                 end
         end
-%         if isempty(FFName)
-%             FFName='FF';
-%         end
-%         MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data
-%         MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data
     end
 end
Index: trunk/src/series/merge_proj_polar.m
===================================================================
--- trunk/src/series/merge_proj_polar.m	(revision 1056)
+++ trunk/src/series/merge_proj_polar.m	(revision 1058)
@@ -100,5 +100,6 @@
 HeadData.ListVarName= {'radius','azimuth'} ;
 HeadData.VarDimName={'radius','azimuth'};
-HeadData.VarAttribute={'coord_y','coord_x'} ;
+HeadData.VarAttribute{1}.Role='coord_y';
+HeadData.VarAttribute{2}.Role='coord_x';
 HeadData.radius=radius_shifted;
 HeadData.azimuth=azimuth_arclength;    
@@ -373,5 +374,7 @@
         ProjData{iview}.ListVarName= [ProjData{iview}.ListVarName ListVarName];
         ProjData{iview}.VarDimName={'radius','azimuth'};
-        ProjData{iview}.VarAttribute=[{'coord_x'} {'coord_y'} VarAttribute];
+%         ProjData{iview}.VarAttribute{1}.Role='coord_y';
+%         ProjData{iview}.VarAttribute{2}.Role='coord_x';
+        ProjData{iview}.VarAttribute=[ProjData{iview}.VarAttribute VarAttribute];
         for ivar=1:numel(ListVarName)
             ProjData{iview}.VarDimName{ivar+2}={'radius','azimuth'};
@@ -457,4 +460,75 @@
 disp([ num2str(ellapsed_time/(60*NbField),3) ' minutes per iteration'])
 
+% %'merge_field': concatene fields
+% %------------------------------------------------------------------------
+% function [MergeData,errormsg]=merge_field(Data)
+% %% default output
+% if isempty(Data)||~iscell(Data)
+%     MergeData=[];
+%     return
+% end
+% errormsg='';
+% MergeData=Data{1};% merged field= first field by default, reproduces the global attributes of the first field
+% NbView=length(Data);
+% if NbView==1% if there is only one field, just reproduce it in MergeData
+%     return
+% end
+% 
+% %% group the variables (fields of 'Data') in cells of variables with the same dimensions
+% [CellInfo,NbDim,errormsg]=find_field_cells(Data{1});
+% if ~isempty(errormsg)
+%     return
+% end
+% 
+% %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
+% for icell=1:length(CellInfo)
+%     if NbDim(icell)~=1 % skip field cells which are of dim 1
+%         switch CellInfo{icell}.CoordType
+%             case 'scattered'  %case of input fields with unstructured coordinates: just concatene data
+%                 for ivar=CellInfo{icell}.VarIndex %  indices of the selected variables in the list FieldData.ListVarName
+%                     VarName=Data{1}.ListVarName{ivar};
+%                     for iview=2:NbView
+%                         MergeData.(VarName)=[MergeData.(VarName); Data{iview}.(VarName)];
+%                     end
+%                 end
+%             case 'grid'        %case of fields defined on a structured  grid
+%                 FFName='';
+%                 if isfield(CellInfo{icell},'VarIndex_errorflag') && ~isempty(CellInfo{icell}.VarIndex_errorflag)
+%                     FFName=Data{1}.ListVarName{CellInfo{icell}.VarIndex_errorflag};% name of errorflag variable
+%                     MergeData.ListVarName(CellInfo{icell}.VarIndex_errorflag)=[];%remove error flag variable in MergeData (will use NaN instead)
+%                     MergeData.VarDimName(CellInfo{icell}.VarIndex_errorflag)=[];
+%                     MergeData.VarAttribute(CellInfo{icell}.VarIndex_errorflag)=[];
+%                 end
+%                 % select good data on each view
+%                 for ivar=CellInfo{icell}.VarIndex  %  indices of the selected variables in the list FieldData.ListVarName
+%                     VarName=Data{1}.ListVarName{ivar};
+%                     for iview=1:NbView
+%                         if isempty(FFName)
+%                             check_bad=isnan(Data{iview}.(VarName));%=0 for NaN data values, 1 else
+%                         else
+%                             check_bad=isnan(Data{iview}.(VarName)) | Data{iview}.(FFName)~=0;%=0 for NaN or error flagged data values, 1 else
+%                         end
+%                         Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
+%                         if iview==1
+%                             %MergeData.(VarName)=Data{1}.(VarName);% initiate MergeData with the first field
+%                             MergeData.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
+%                             NbAver=~check_bad;% initiate NbAver: the nbre of good data for each point
+%                         elseif size(Data{iview}.(VarName))~=size(MergeData.(VarName))
+%                             errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
+%                             return
+%                         else
+%                             MergeData.(VarName)=MergeData.(VarName) +double(Data{iview}.(VarName));%add data
+%                             NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
+%                         end
+%                     end
+%                     MergeData.(VarName)(NbAver~=0)=MergeData.(VarName)(NbAver~=0)./NbAver(NbAver~=0);% take average of defined data at each point
+%                     MergeData.(VarName)(NbAver==0)=NaN;% set to NaN the points with no good data
+%                 end
+%         end
+%    
+%     end
+% end
+
+
 %'merge_field': concatene fields
 %------------------------------------------------------------------------
@@ -469,5 +543,5 @@
 NbView=length(Data);
 if NbView==1% if there is only one field, just reproduce it in MergeData
-    return
+    return 
 end
 
@@ -514,5 +588,5 @@
                             errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
                             return
-                        else
+                        else                             
                             MergeData.(VarName)=MergeData.(VarName) +double(Data{iview}.(VarName));%add data
                             NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
@@ -523,12 +597,4 @@
                 end
         end
-        %         if isempty(FFName)
-        %             FFName='FF';
-        %         end
-        %         MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data
-        %         MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data
-    end
-end
-
-
-    
+    end
+end    
Index: trunk/src/series/sub_background.m
===================================================================
--- trunk/src/series/sub_background.m	(revision 1056)
+++ trunk/src/series/sub_background.m	(revision 1058)
@@ -140,6 +140,7 @@
     
     %% setting of  parameters specific to sub_background
-    nbaver_init=23; %default number of images used for the sliding background: to be adjusted later to include an integer number of bursts  
-    if nbfield_i~=1
+    CheckVolume='No';
+    nbaver_init=23; %default number of images used for the sliding background: to be adjusted later to include an integer number of bursts 
+     if nbfield_i~=1
         nbaver=floor(nbaver_init/nbfield_j); % number of bursts used for the sliding background,
         if isequal(mod(nbaver,2),0)% if nbaver is even
@@ -148,13 +149,32 @@
         nbaver_init=nbaver*nbfield_j;%propose by default an integer number of bursts
     end
-    
+    BrightnessRankThreshold=0.1;
+    CheckSubmedian='No';
+    SaturationCoeff=0;
+    if isfield(Param,'ActionInput')
+        if isfield(Param.ActionInput,'CheckVolume') && Param.ActionInput.CheckVolume
+            CheckVolume='Yes';
+        end
+        if isfield(Param.ActionInput,'SlidingSequenceLength')
+         nbaver_init=Param.ActionInput.SlidingSequenceLength;
+        end
+        if isfield(Param.ActionInput,'BrightnessRankThreshold')
+          BrightnessRankThreshold=Param.ActionInput.BrightnessRankThreshold;
+        end
+        if isfield(Param.ActionInput,'CheckSubmedian') && Param.ActionInput.CheckSubmedian
+        CheckSubmedian='Yes';
+        end
+        if isfield(Param.ActionInput,'SaturationCoeff') 
+            SaturationCoeff=Param.ActionInput.SaturationCoeff;
+        end
+    end   
     prompt = {'volume scan mode (Yes/No)';...
         'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';...
         'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles';...
         'set to 0 image levels below median(Yes/No)';...
-        'image rescaling coefficient(high values reduce the influence of bright particles), =0 for no rescaling' };
+        'image rescaling coefficient(=2 to reduce the influence of bright particles), =0 for no rescaling' };
     dlg_title = 'get (slice by slice) a sliding background and substract to each image';
     num_lines= 5;
-    def     = { 'No';num2str(nbaver_init);'0.1';'No';'2'};
+    def     = { CheckVolume;num2str(nbaver_init);num2str(BrightnessRankThreshold);CheckSubmedian;num2str(SaturationCoeff)};
     answer = inputdlg(prompt,dlg_title,num_lines,def);
     if isempty(answer)
