From 2b9c8172ea459851f5045fbffbe85a9eeb53ce68 Mon Sep 17 00:00:00 2001
From: Laura Nervo <lnervo@esrf.fr>
Date: Mon, 9 Jan 2012 15:36:44 +0000
Subject: [PATCH] Add fed structure in parameters.mat and modify
 zUtil_Parameters's functions

History:
  sed -i -e "s/ 1x1>/>/g" `grep " 1x1>" */*.m | awk -F":" '{print $1}' | sort -busi` | grep ">"
  sed -i -e "s/ 1x1/>/g" `grep " 1x1" */*.m | awk -F":" '{print $1}' | sort -busi` | grep "> {"
  sed -i -e "s/}>/}/g" `grep "}>" */*.m | awk -F":" '{print $1}' | sort -busi` | grep "> {"
  sed -i -e "s/gtPlaceDifspotinFull_ln/gtPlaceDifspotinFull/g" `grep "gtPlaceDifspotinFull_ln" */*.m | awk -F":" '{print $1}' | sort -busi` | grep "gtPlaceDifspotinFull"
  sed -i -e "s/))/)/g" `grep "disp(sprintf" */*.m | grep "))" | awk -F":" '{print $1}' | sort -busi` | grep "disp(sprintf("
  sed -i -e "s/disp(sprintf(/fprintf(/g" `grep "disp(sprintf" */*.m | awk -F":" '{print $1}' | sort -busi` | grep "fprintf("
  sed -i -e "s/ );/);/g" `grep "fprintf" */*.m | awk -F":" '{print $1}' | sort -busi` | grep "fprintf(" | grep ");"

Signed-off-by: Laura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@117 4c865b51-4357-4376-afb4-474e03ccb993
---
 1_preprocessing/gtSetup.m                     |  11 +
 7_fed/AndyFunctions/gtFEDCondor.m             | 192 ++++---
 7_fed/AndyFunctions/gtFEDCondor_ln.m          | 176 ------
 .../gtFedLoadGrainFromIndexter.m              |  90 +--
 7_fed/AndyFunctions/gtFedLoadRealBlobs.m      |  33 +-
 7_fed/AndyFunctions/gtFedLoadRealGrain.m      |  81 +--
 7_fed/AndyFunctions/gtFedSetupT0.m            |  19 +-
 7_fed/Ccode_SpreadInt/gtFedInitialize.m       |   2 +-
 7_fed/gtFedGenerateRandomGrain.m              |  32 +-
 7_fed/gtFedLoadGrainFromIndexter_ln.m         | 146 -----
 7_fed/gtFedLoadGrainWoIndexter.m              |  15 +-
 7_fed/gtFedParameters.m                       |   2 +
 7_fed/gtFedSetParameters.m                    |   6 +-
 7_fed/gtFedSetupT0.m                          |  12 +-
 7_fed/gtFedShowDifBlob.m                      |  14 +-
 7_fed/gtFedTestLoadData.m                     |   8 +-
 7_fed/gtGrainPredict.m                        |  32 +-
 zUtil_Parameters/build_list.m                 |  11 +
 zUtil_Parameters/build_list_v2.m              |  14 +
 zUtil_Parameters/build_parameters.m           | 543 ------------------
 zUtil_Parameters/make_parameters.m            |   2 +-
 21 files changed, 332 insertions(+), 1109 deletions(-)
 delete mode 100644 7_fed/AndyFunctions/gtFEDCondor_ln.m
 delete mode 100644 7_fed/gtFedLoadGrainFromIndexter_ln.m
 delete mode 100644 zUtil_Parameters/build_parameters.m

diff --git a/1_preprocessing/gtSetup.m b/1_preprocessing/gtSetup.m
index 6ef24f54..1d7e32e0 100644
--- a/1_preprocessing/gtSetup.m
+++ b/1_preprocessing/gtSetup.m
@@ -8,6 +8,9 @@ function gtSetup()
 %                   '()' at the end of functions/methods
 %                   add 'clear' statements to free memory
 %
+%     Version 006 06-01-2012 by LNervo
+%       Add fed structure 
+%
 %     Version 005 01-12-2011 by LNervo
 %       Adapt to new parameters file template
 %       Cryst1 is made of cryst1, xop1, reflections1
@@ -583,6 +586,14 @@ parameters.rec.use_extspots                     = false;
 parameters.rec.percentile1                      = 90;
 parameters.rec.percentile2                      = 20;
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% FED part
+parameters.fed.dir           = parameters.acq.dir;
+parameters.fed.dct_vol       = [parameters.acq.dir '/dct_vol.edf'];
+parameters.fed.dct_offset    = [0 0 0];
+parameters.fed.renumber_list = [];
+
+
 disp('Saving parameters.mat in the analysis directory...')
 save([parameters.acq.dir '/' 'parameters.mat'],'parameters');
 disp(' ')
diff --git a/7_fed/AndyFunctions/gtFEDCondor.m b/7_fed/AndyFunctions/gtFEDCondor.m
index 869dae29..4639c68e 100644
--- a/7_fed/AndyFunctions/gtFEDCondor.m
+++ b/7_fed/AndyFunctions/gtFEDCondor.m
@@ -1,10 +1,24 @@
-
-
-function gtFEDCondor(first, last, workingdirectory)
-% cleaned FED "do all" function for condor
-
-
-disp('gtFEDCondor.m')
+function gtFEDCondor(first, last, workingdirectory, varargin)
+% GTFEDCONDOR  Run the FED code 
+%     gtFEDCondor(first, last, [workingdirectory],[varargin])
+%     -------------------------------------------------------
+%       cleaned FED "do all" function for OAR
+%
+%     INPUT:
+%       first            = first grain to be processed
+%       last             = last grain to be processed
+%       workingdirectory = current directory <string> {pwd}
+%
+%     OPTIONAL INPUT:
+%       vertical = set up the vertical detector case <logical> {0}
+%       gv_name  = grain volume name <string> {'5_reconstruction/dct.edf'}
+%       saveflag = save data on disk <logical> {1}
+% 
+
+app.vertical = false;
+app.gv_name  = '5_reconstruction/dct.edf';
+app.saveflag = true; % want to save data
+app=parse_pv_pairs(app,varargin);
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % get parameters
@@ -17,108 +31,122 @@ end
 if isdeployed
     first=str2double(first);
     last=str2double(last);
-end 
+end
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % load data files
 cd(workingdirectory);
 parameters=[];
 grain=[];
-load('parameters.mat'); % parameters
-load('grain.mat') % grain
-
-% create FED folder in FED analysis directory if needed
-if ~exist(sprintf('%s/7_FED', parameters.FED.dir), 'dir')
-    mkdir(sprintf('%s/7_FED', parameters.FED.dir))
+if exist('parameters.mat','file')
+    load('parameters.mat'); % parameters
+else 
+    disp('Attention! the parameters file does not exist. Check the current directory')
+    return
+end
+if exist('grain.mat','file')
+    load('grain.mat') % grain
+else
+    disp('grain.mat not found')
+    disp('Copy the grain.mat from the forward scan if it''s the case and restart the function')
+    return
+end
+if exist(app.gv_name,'file')
+    parameters.fed.dct_vol=app.gv_name;
+    save('parameters.mat','parameters');
 end
 
-saveflag=1; % want to save data
-
+% load volume
+if ~exist(parameters.fed.dct_vol,'file')
+    file=inputwdefault('Insert the path of the grain volume .edf file:',name);
+    dct_vol=edf_read(file);
+    parameters.fed.dct_vol=file;
+    save('parameters.mat','parameters');
+else
+    dct_vol=edf_read(parameters.fed.dct_vol);
+end
+% apply dataset specific shift
+dct_vol=gtPlaceSubVolume(zeros(size(dct_vol)), dct_vol, parameters.fed.dct_offset);
+size(dct_vol)
 
+    
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % loop through grains
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 for grainid = first:last
-
     
-    if 0 % setup grain
-        
     % create grain folder if needed
-if ~exist(sprintf('%s/7_FED/grain%d_', parameters.FED.dir, grainid), 'dir')
-    mkdir(sprintf('%s/7_FED/grain%d_', parameters.FED.dir, grainid))
-end
-
-% setup fedgrain from indexter grain output
-% save into the above grain folder
-[fedpars, fedgrain]=gtFedLoadGrainFromIndexter(grainid, grain, saveflag);
-
-
-% load volume
-dct_vol=edf_read(parameters.FED.dct_vol);
-% apply dataset specific shift
-dct_vol=gtPlaceSubVolume(zeros(size(dct_vol)), dct_vol, parameters.FED.dct_offset);
-
-% setup FED grain
-% may need to select the right grain in the original volume
-
-
-[fedpars, gv]=gtFedLoadRealGrain(grainid, dct_vol, saveflag);
-
-
-% load blobs
-[gv, bl, bluvol] = gtFedLoadRealBlobs(grainid, saveflag);
-
-    else
-        % just load the grain
-        disp('just loading gv/bl/fedgrain - not doing gtFedLoad...')
-        load(sprintf('%s/7_FED/grain%d_/gv', parameters.FED.dir, grainid))
-        load(sprintf('%s/7_FED/grain%d_/bl', parameters.FED.dir, grainid))
-        load(sprintf('%s/7_FED/grain%d_/fedgrain', parameters.FED.dir, grainid))
-        fedpars=fedgrain.fedpars;
+    [s,msg]=mkdir(sprintf('%s/7_fed/grain%d_', parameters.fed.dir, grainid));disp(msg)
+    
+    
+    if app.vertical==true
+                
+        grainFed=load(sprintf('gr%d_fed.mat',grainid),'gr');
+        grainFed=grainFed.gr;
+        
+        bbox=load('bbox.mat');
+        bbox=bbox.bbox;
+        % setup fedgrain with grainFed
+        [fedgrain,fedpars,grainFed]=gtFedLoadGrainWoIndexter(grainFed, bbox, 'save_flag',app.saveflag);
+
+    elseif app.vertical==false
+       
+        % setup fedgrain from indexter grain output
+        % save into the above grain folder
+        [fedpars, fedgrain]=gtFedLoadGrainFromIndexter(grainid, grain, app.saveflag);
     end
-
-
-
-% run the solver
-
-% do the 3 steps
-for fedstep=1:3
     
-% setup the TO matrices
-[fedpars, gv] = gtFedSetupT0(grainid, fedstep)
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    % setup FED grain
+    % may need to select the right grain in the original volume
+    [fedpars, gv]=gtFedLoadRealGrain(grainid, dct_vol, app.saveflag);
+
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    % load blobs
+    [gv, bl, bluvol] = gtFedLoadRealBlobs(grainid, app.saveflag);
+    
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    % run the solver
 
-% run the solver for this step
-[gv,bl,err]=gtFedSolve(gv,bl,[],[],[],fedpars);
+    % do the 3 steps
+    for fedstep=1:3
+         
+        % setup the TO matrices
+        [fedpars, gv] = gtFedSetupT0(grainid, fedstep);
 
+        % run the solver for this step
+        %[gv,bl,err]=gtFedSolve(grainid);
+        [gv,bl,err]=gtFedSolve(gv,bl,[],[],[],fedpars);
 
+        % shift the error info for later analysis
+        system(sprintf('mv %s/7_fed/grain%d_/err.mat %s/7_fed/grain%d_/err%d.mat', parameters.fed.dir, grainid, parameters.fed.dir, grainid, fedstep));
 
-% shift the error info for later analysis
-    system(sprintf('mv %s/7_FED/grain%d_/err.mat %s/7_FED/grain%d_/err%d.mat', parameters.FED.dir, grainid, parameters.FED.dir, grainid, fedstep));
 
+        % make and save omega images
+        bl=gtFedMakeOmegaImages(bl, 0);
+        for i=1:length(bl)
+            bl(i).imfed_omega_save(:,:,fedstep)=bl(i).imfed_omega;
+        end
+        save(sprintf('%s/7_fed/grain%d_/bl.mat', parameters.fed.dir, grainid), 'bl', '-v7.3')
 
-    % make and save omega images
-    bl=gtFedMakeOmegaImages(bl, 0);
-    for i=1:length(bl)
-        bl(i).imfed_omega_save(:,:,fedstep)=bl(i).imfed_omega;
-    end
-    save(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid), 'bl', '-v7.3')
-    
-    % save d field of gv
-    for i=1:length(gv)
-        gv(i).d_save(:,fedstep)=gv(i).d;
-    end
-    save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
+        % save d field of gv
+        for i=1:length(gv)
+            gv(i).d_save(:,fedstep)=gv(i).d;
+        end
+        save(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid), 'gv', '-v7.3')
 
-    disp(sprintf('@@@@@@@@@@@@@@@@@@@@@  done step %d for grain %d  @@@@@@@@@@@@@@@@@@@@@2', fedstep, grainid))
-end
+        fprintf('@@@@@@@@@@@@@@@@@@@@@  done step %d for grain %d  @@@@@@@@@@@@@@@@@@@@@@', fedstep, grainid)
+    end
 
-%compress bl for space saving...
-bl=gtFedCompressBl(bl);
-save(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid), 'bl', '-v7.3')
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    % compress bl for space saving...
+    bl=gtFedCompressBl(bl);
+    save(sprintf('%s/7_fed/grain%d_/bl.mat', parameters.fed.dir, grainid), 'bl', '-v7.3')
 
-disp(sprintf('grain %d : bl variable compressed to save diskspace', grainid))
+    fprintf('grain %d : bl variable compressed to save diskspace', grainid)
 
-disp(sprintf('%%%%%%%%%%%%   grain %d finished :-)   %%%%%%%%%%%', grainid))
+    fprintf('%%%%%%%%%%%%   grain %d finished :-)   %%%%%%%%%%%', grainid)
 
 
 end % loop through grains
diff --git a/7_fed/AndyFunctions/gtFEDCondor_ln.m b/7_fed/AndyFunctions/gtFEDCondor_ln.m
deleted file mode 100644
index 2a17d0e2..00000000
--- a/7_fed/AndyFunctions/gtFEDCondor_ln.m
+++ /dev/null
@@ -1,176 +0,0 @@
-function gtFEDCondor_ln(first, last, workingdirectory, varargin)
-% gtFEDCondor(first, last, [workingdirectory],[varargin])
-%   cleaned FED "do all" function for condor
-%
-% INPUT :
-%                first = first grain to be processed
-%                 last = last grain to be processed
-%     workingdirectory = current directory <string> {pwd}
-%
-% OPTIONAL :
-%     vertical = set up the vertical detector case <logical 1x1> {0}
-%      gv_name = grain volume name <string> {'dct.edf'}
-%     saveflag = save data on disk <logical 1x1> {1}
-% 
-
-app.vertical=false;
-app.gv_name='dct.edf';
-app.saveflag=true; % want to save data
-app=parse_pv_pairs(app,varargin);
-
-disp('### Running gtFEDCondor_ln... ###')
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% get parameters
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-% special case for running interactively in current directory
-if ~exist('workingdirectory','var')
-    workingdirectory=pwd;
-end
-if isdeployed
-    first=str2double(first);
-    last=str2double(last);
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% load data files
-cd(workingdirectory);
-parameters=[];
-grain=[];
-if exist('parameters.mat','file')
-    load('parameters.mat'); % parameters
-else 
-    disp('Attention! the parameters file does not exist. Check the current directory')
-    return
-end
-if exist('grain.mat','file')
-    load('grain.mat') % grain
-else
-    disp('grain.mat not found')
-    disp('Copy the grain.mat from the forward scan if it''s the case and restart the function')
-    return
-end
-
-parameters
-grain
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% create FED folder in FED analysis directory if needed
-
-if ~isfield(parameters, 'FED')
-    if ~isfield(parameters.FED, 'dir')
-        parameters.FED.dir=parameters.acq.dir;
-    end
-    if ~isfield(parameters.FED, 'dct_vol')
-        parameters.FED.dct_vol=[parameters.FED.dir '/' app.gv_name];
-    end
-    if ~isfield(parameters.FED, 'dct_offset')
-        parameters.FED.dct_offset=[0 0 0];
-    end
-    save parameters parameters
-end
-
-if ~exist(sprintf('%s/7_FED', parameters.FED.dir), 'dir')
-    mkdir(sprintf('%s/7_FED', parameters.FED.dir))
-end
-
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% loop through grains
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-for grainid = first:last
-    
-    % create grain folder if needed
-    if ~exist(sprintf('%s/7_FED/grain%d_', parameters.FED.dir, grainid), 'dir')
-        mkdir(sprintf('%s/7_FED/grain%d_', parameters.FED.dir, grainid))
-    end
-    
-    if app.vertical
-                
-        grainFed=load(sprintf('gr%d_fed.mat',grainid),'gr');
-        grainFed=grainFed.gr;
-        
-        bbox=load('bbox.mat');
-        bbox=bbox.bbox;
-        % setup fedgrain with grainFed
-        [fedgrain,fedpars,grainFed]=gtFedLoadGrainWoIndexter(grainFed, bbox, 'save_flag',app.saveflag);
-
-    else
-       
-        % setup fedgrain from indexter grain output
-        % save into the above grain folder
-        [fedpars, fedgrain]=gtFedLoadGrainFromIndexter(grainid, grain, app.saveflag);
-    end
-    
-    
-    % load volume
-    if ~exist(parameters.FED.dct_vol,'file')
-        file=inputwdefault('Insert the path of the direct beam scan dct.edf file:',name);
-        dct_vol=edf_read(file);
-    else
-        dct_vol=edf_read(parameters.FED.dct_vol);
-    end
-    % apply dataset specific shift
-    dct_vol=gtPlaceSubVolume(zeros(size(dct_vol)), dct_vol, parameters.FED.dct_offset);
-    size(dct_vol)
-    
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    % setup FED grain
-    % may need to select the right grain in the original volume
-    [fedpars, gv]=gtFedLoadRealGrain(grainid, dct_vol, saveflag);
-
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    % load blobs
-    [gv, bl, bluvol] = gtFedLoadRealBlobs(grainid, saveflag);
-    
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    % run the solver
-
-    % do the 3 steps
-    for fedstep=1:3
-         
-        % setup the TO matrices
-        [fedpars, gv] = gtFedSetupT0(grainid, fedstep)
-
-        % run the solver for this step
-        %[gv,bl,err]=gtFedSolve(grainid);
-        [gv,bl,err]=gtFedSolve(gv,bl,[],[],[],fedpars);
-
-        % shift the error info for later analysis
-        system(sprintf('mv %s/7_FED/grain%d_/err.mat %s/7_FED/grain%d_/err%d.mat', parameters.FED.dir, grainid, parameters.FED.dir, grainid, fedstep));
-
-
-        % make and save omega images
-        bl=gtFedMakeOmegaImages(bl, 0);
-        for i=1:length(bl)
-            bl(i).imfed_omega_save(:,:,fedstep)=bl(i).imfed_omega;
-        end
-        save(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid), 'bl', '-v7.3')
-
-        % save d field of gv
-        for i=1:length(gv)
-            gv(i).d_save(:,fedstep)=gv(i).d;
-        end
-        save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
-
-        disp(sprintf('@@@@@@@@@@@@@@@@@@@@@  done step %d for grain %d  @@@@@@@@@@@@@@@@@@@@@@', fedstep, grainid))
-    end
-
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    % compress bl for space saving...
-    bl=gtFedCompressBl(bl);
-    save(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid), 'bl', '-v7.3')
-
-    disp(sprintf('grain %d : bl variable compressed to save diskspace', grainid))
-
-    disp(sprintf('%%%%%%%%%%%%   grain %d finished :-)   %%%%%%%%%%%', grainid))
-
-
-end % loop through grains
-
-
diff --git a/7_fed/AndyFunctions/gtFedLoadGrainFromIndexter.m b/7_fed/AndyFunctions/gtFedLoadGrainFromIndexter.m
index 76a957a0..327f5693 100644
--- a/7_fed/AndyFunctions/gtFedLoadGrainFromIndexter.m
+++ b/7_fed/AndyFunctions/gtFedLoadGrainFromIndexter.m
@@ -1,30 +1,31 @@
 function [fedpars, fedgrain]=gtFedLoadGrainFromIndexter(grainid, indexter_grain, varargin)
-
+%% [fedpars, fedgrain]=gtFedLoadGrainFromIndexter(grainid, indexter_grain, varargin)
+%
 % create a file called fedgrain.mat - equivilent to the random grain in the
 % simulated data code.
 % nothing more than the indexter data "unpacked" into single blobs rather
 % than pairs.
 % setup fedpars.mat at the same time
-
+%
 % general comment - at the moment fedgrain and fedpars are saved together
 % in one variable (fedgrain).  This can perhaps be cleaned.
-
+%
 % improve, automate and clean so that it can be run form condor without
 % fucking around...
-
+%
 % fedpars.mat is grain specific - therefore it should go in the grain
 % folder.  For the moment, let's introduce a folder structure called
-% 7_FED/grain%d_/ and put fedpars / bl etc in there
-
-% add a path to the dct volume in parameters.FED.final_dct_volume
-% also add parameters.FED.volume_offset to allow for sample movements
+% 7_fed/grain%d_/ and put fedpars / bl etc in there
+%
+% add a path to the dct volume in parameters.fed.final_dct_volume
+% also add parameters.fed.volume_offset to allow for sample movements
 % (see fed_real_data_scheme script)
-
+%
 % deal with renumbering in a sequence of datasets - ie in this scan it
 % might be grain X, but in the reference dataset and the dct volume it
 % might be grain Y.
 
-
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % are we saving?
 if length(varargin)==1
     save_flag=varargin{1};
@@ -33,9 +34,10 @@ else
     disp('gtFedLoadGrainFromIndexter is not saving fedpars.mat, fedgrain.mat')
 end
 
-
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % load DCT parameters
-load parameters
+parameters=[];
+load('parameters.mat');
 % indexter output is passed in as indexter_grain
 
 %%%%%%%%%%%%%%%%%%%%%%%% INDEXTER OUTPUT INTO FEDGRAIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -48,13 +50,13 @@ fedgrain.R_vector = a.R_vector;
 %%%%%%%%%%%%%%%%%%% GRAIN ID RENUMBERING IF PART OF SEQUENCE %%%%%%%%%%%%%%%%%%%%%%
 % may need to consider renumbering
 fedgrain.grainID=grainid;
-if isfield(parameters.FED, 'renumber_list')
-    list=parameters.FED.renumber_list;
+if ~isempty(parameters.fed.renumber_list)
+    list=parameters.fed.renumber_list;
     % list: [referenceID, this dataset ID]
     ndx=find(list(:,2)==grainid);
     if isempty(ndx)
         disp('problem - this grain is not linked to a grain in the reference dataset')
-        error
+        return
     end
     fedgrain.reference_grainid=list(ndx, 1);
 else
@@ -63,9 +65,9 @@ end
 
 %%%%%%%%%%%%%%%%%%%%%%%% SETUP FEDPARS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % How many blobs?
-nbl = 2*fedgrain.nof_pairs; 
+nbl = 2*fedgrain.nof_pairs;
 
-% FED parameters definition
+%.fed parameters definition
 fedpars = gtFedParameters();
 
 % add parameters / could be interactive or use defaults
@@ -74,47 +76,47 @@ fedpars = gtFedSetParameters(fedpars, nbl, 'defaults');
 % add GrainID
 fedpars.grainID=grainid;
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % load general info from parameters.acq into fedpars
-disp('copy experiment geometry from parameters.acq to fedpars')
-fedpars.detpos=parameters.acq.detpos0;
-fedpars.detdiru=parameters.acq.detdiru0;
-fedpars.detdirv=parameters.acq.detdirv0;
-fedpars.rotdir=parameters.acq.rotdir0;
-fedpars.detucen=parameters.acq.detucen0;
-fedpars.detvcen=parameters.acq.detvcen0;
-fedpars.beamdir=parameters.acq.beamdir0;
-
-
+disp('copy experiment geometry from parameters to fedpars')
+% fedpars = gtAddMatFile(fedpars,gtGetGeometry(parameters,'geo',true),true,true,true);
+fedpars = gtAddMatFile(fedpars,gtGetGeometry(parameters,'opt',true),true,true,true);
 
 %%%%%%%%%%%%%%%%%%%%%%%% INDEXTER OUTPUT INTO FEDGRAIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % unpack variables, expanding pairs
-fedgrain.pairid = zeros(1, nbl);
+fedgrain.pairid    = zeros(1, nbl);
 fedgrain.difspots  = zeros(1, nbl);
 fedgrain.thetatype = zeros(1, nbl);
-fedgrain.hkl = zeros(nbl, size(a.hkl, 2));
-fedgrain.pl0 = zeros(nbl, 3);
-fedgrain.theta = zeros(1, nbl);
-fedgrain.eta = zeros(1, nbl);
-fedgrain.omega = zeros(1, nbl);
+fedgrain.hkl       = zeros(nbl, size(a.hkl, 2));
+fedgrain.pl0       = zeros(nbl, 3);
+fedgrain.theta     = zeros(1, nbl);
+fedgrain.eta       = zeros(1, nbl);
+fedgrain.omega     = zeros(1, nbl);
 
 % expand pairs
 fedgrain.pairid(1:2:end) = a.pairid;
 fedgrain.pairid(2:2:end) = a.pairid;
 
-fedgrain.difspots(1:2:end)=a.difspots(1:fedgrain.nof_pairs);
-fedgrain.difspots(2:2:end)=a.difspots((fedgrain.nof_pairs+1):end);
+fedgrain.difspots(1:2:end) = a.difspots(1:fedgrain.nof_pairs);
+fedgrain.difspots(2:2:end) = a.difspots((fedgrain.nof_pairs+1):end);
 
 fedgrain.thetatype(1:2:end) = a.thetatype;
 fedgrain.thetatype(2:2:end) = a.thetatype;
-fedgrain.hkl(1:2:end, :)=a.hkl;
-fedgrain.hkl(2:2:end, :)=a.hkl;
+
+fedgrain.hkl(1:2:end, :) = a.hkl;
+fedgrain.hkl(2:2:end, :) = a.hkl;
+
 fedgrain.pl0(1:2:end, :) = a.pl;
 fedgrain.pl0(2:2:end, :) = -a.pl;
+
 fedgrain.theta(1:2:end) = a.theta;
 fedgrain.theta(2:2:end) = a.theta;
-fedgrain.sinth0=sind(fedgrain.theta);
+
+fedgrain.sinth0 = sind(fedgrain.theta);
+
 fedgrain.eta(1:2:end) = a.eta;
 fedgrain.eta(2:2:end) = mod(180-a.eta, 360);
+
 fedgrain.omega(1:2:end) = a.omega;
 fedgrain.omega(2:2:end) = a.omega+180;
 
@@ -122,21 +124,21 @@ warning('USING MEASURED DIFF ANGLES, SHOULD BE THEORETICAL!!!')
 % here we should determine the specific hkls, and predict theta, eta and
 % omega and pl0 based on these and the grain R-vector
 
-%warning('HARD CODING MAX_ELEMENTS_GRAIN...')
-%fedpars.max_elements_grain=2000
+warning('HARD CODING MAX_ELEMENTS_GRAIN...')
+fedpars.max_elements_grain=2000;
 % combine fedgrain and fedpars - as fedpars can be grain specific
 fedgrain.fedpars=fedpars;
 
 if ~save_flag
-    a=inputwdefault('save fedgrain.mat (which includes fedgrain.fedpars)?', 'y');
+    a=inputwdefault('save fedgrain.mat (which includes fedgrain.fedpars)? [y/n]', 'y');
     if strcmpi(a, 'y')
-      save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
+        save(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid), 'fedgrain')
     else
         disp('not saving...  you can do it yourself')
     end
 else
     % new directory structure
-save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
+    save(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid), 'fedgrain')
 end
 
-disp('gtFedLoadGrainFromIndexter finished')
\ No newline at end of file
+end % end function
\ No newline at end of file
diff --git a/7_fed/AndyFunctions/gtFedLoadRealBlobs.m b/7_fed/AndyFunctions/gtFedLoadRealBlobs.m
index c47e9340..1c483cd9 100644
--- a/7_fed/AndyFunctions/gtFedLoadRealBlobs.m
+++ b/7_fed/AndyFunctions/gtFedLoadRealBlobs.m
@@ -27,11 +27,13 @@ else
     save_flag=0;
 end
 
-
-load parameters
+parameters=[];
+fedgrain=[];
+gv=[];
+load('parameters.mat');
 % specific to this grain
-load(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid));
-load(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid));
+load(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid));
+load(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid));
 
 gtDBConnect
 
@@ -52,6 +54,7 @@ lastimage=(parameters.acq.nproj*2)-1;
 % Sample geometry and origin of SAMPLE coord. system:
 sam=gtSampleGeoInSampleSystem;
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % matrices for computing rotation tensors / arbitary geometry unpacking
 % arbitary geometry information will all come from fedpars.
 
@@ -138,7 +141,10 @@ for i=1:nbl
     bl(i).difspotID=fedgrain.difspots(i);
     [vol,bb] = gtDBBrowseDiffractionVolume(parameters.acq.name, bl(i).difspotID);
 
-    if strcmp(parameters.acq.name, 'al_plast_dct1_b_grid_') | strcmp(parameters.acq.name, 'al_plast_dct1_b_nogrid_763V_') | strcmp(parameters.acq.name, 'al_plast_dct1_b_nogrid_1000V_19N_')
+    if strcmp(parameters.acq.name, 'al_plast_dct1_b_grid_') || ...
+       strcmp(parameters.acq.name, 'al_plast_dct1_b_nogrid_763V_') || ...
+       strcmp(parameters.acq.name, 'al_plast_dct1_b_nogrid_1000V_19N_')
+   
         disp('... apply fix for renumbered datasets')
         [tmp1, tmp2]=mym(sprintf('select startimage, endimage from %sdifspot where difspotid=%d', parameters.acq.name, bl(i).difspotID));
         bb(3)=tmp1;
@@ -253,7 +259,7 @@ for i=1:nbl
                 bl(i).addbl(2)+1:bl(i).addbl(2)+bb(5),...
                 bl(i).addbl(3)+1:bl(i).addbl(3)+bb(6)) = vol;
             mask=imdilate(mask>0, ones(10,10,5));
-        catch
+        catch Mexc
             disp('problem with bounding box / mask for this blob')
             mask=ones(size(bl(i).intm));
         end
@@ -310,7 +316,7 @@ for i=1:nbl
     end
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-    disp(sprintf('done blob %d ...', i))
+    disp(['done blob ' num2str(i) '...'])
 end
 
 % repack fedpars into fedgrain
@@ -318,9 +324,9 @@ fedgrain.fedpars=fedpars;
 
 % save updated gv and bl
 if save_flag
-    save(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid), 'bl', '-v7.3')
-    save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
-    disp(sprintf('saving updated gv and bl'))
+    save(sprintf('%s/7_fed/grain%d_/bl.mat', parameters.fed.dir, grainid), 'bl', '-v7.3')
+    save(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid), 'gv', '-v7.3')
+    disp('saving updated gv and bl')
 end
 
 
@@ -351,8 +357,9 @@ end
 
 % save updated gv and bl
 if save_flag
-    save(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid), 'bl', '-v7.3')
-    save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
-    disp(sprintf('saving updated gv and bl'))
+    save(sprintf('%s/7_fed/grain%d_/bl.mat', parameters.fed.dir, grainid), 'bl', '-v7.3')
+    save(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid), 'gv', '-v7.3')
+    disp('saving updated gv and bl')
 end
 
+end
\ No newline at end of file
diff --git a/7_fed/AndyFunctions/gtFedLoadRealGrain.m b/7_fed/AndyFunctions/gtFedLoadRealGrain.m
index a779bc24..bd224412 100644
--- a/7_fed/AndyFunctions/gtFedLoadRealGrain.m
+++ b/7_fed/AndyFunctions/gtFedLoadRealGrain.m
@@ -8,12 +8,12 @@ function [fedpars, gv]=gtFedLoadRealGrain(grainid, dct_vol, varargin)
 % for smoothness - this function is always launched in the folder of the
 % dataste (parameters.acq.dir) and all paths to files are handled nicely.
 %
-% will automatically select the gvsize (element size) to give a reasonable number of elements (<~2000) 
-% this can be forced by setting parameters.FED.auto_gvsize=0, in which case
+% will automatically select the gvsize (element size) to give a reasonable number of elements (<~2000)
+% this can be forced by setting parameters.fed.auto_gvsize=0, in which case
 % gvsize will default to whatever is set in fedpars.
 %
 % need to apply some renumbering if there is a sequence of datasets.  Add
-% this to parameters.FED.renumber_list
+% this to parameters.fed.renumber_list
 %
 
 
@@ -23,10 +23,12 @@ else
     save_flag=0;
 end
 
+parameters=[];
+fedgrain=[];
 % load variables
-load parameters
+load('parameters.mat');
 % specific to this grain
-load(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid));
+load(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid));
 % unpack fedpars for convenience
 fedpars=fedgrain.fedpars;
 
@@ -34,7 +36,7 @@ fedpars=fedgrain.fedpars;
 dct_vol=dct_vol==fedgrain.reference_grainid;
 fedpars.grainvol=sum(dct_vol(:));
 
-% use pairs only 
+% use pairs only
 nbl=2*fedgrain.nof_pairs;
 
 
@@ -55,7 +57,7 @@ z1=find(profilez, 1, 'first');
 z2=find(profilez, 1, 'last');
 sizez=1+z2-z1;
 
-% get the Grain volume 
+% get the Grain volume
 grvol  = dct_vol(x1:x2, y1:y2, z1:z2);
 fedpars.grvol = grvol;
 
@@ -69,7 +71,7 @@ x2=x2-sam.rad;
 y1=y1-sam.rad;
 y2=y2-sam.rad;
 
-fedpars.grainsize = [sizex sizey sizez];  % size of grain volume 
+fedpars.grainsize = [sizex sizey sizez];  % size of grain volume
 fedpars.grainoff  = [x1 y1 z1];           % coordinates of voxel (0,0,0) in the SAMPLE ref.
 grainoff=fedpars.grainoff;
 
@@ -92,7 +94,7 @@ if fedpars.auto_gvsize
     end
     fedpars.gvsize=[elementsize elementsize elementsize];
     gvsize=fedpars.gvsize;
-    disp(sprintf('using gvsize = %d', elementsize));
+    fprintf('using gvsize = %d\n', elementsize);
 else
     disp('using gvsize specified in fedgrain.fedpars')
     gvsize=fedpars.gvsize;
@@ -112,7 +114,7 @@ fedpars.grainenv = grenv;
 
 % pad grain volume to multiple of element size
 grvol_pad = false(grenv);
-grvol_pad(1:size(grvol,1),1:size(grvol,2),1:size(grvol,3)) = grvol; 
+grvol_pad(1:size(grvol,1),1:size(grvol,2),1:size(grvol,3)) = grvol;
 grvol     = grvol_pad;
 
 % save padded grainsize into fedpars variable - required?
@@ -125,40 +127,40 @@ fedpars.grainsize=size(grvol);
 % calculate the true required number of elements (non-empty...)
 % label the volume, then prepare gv structure
 
-grvol_labelled=zeros(size(grvol)); 
-% label this volume - this will have complete elements, 
+grvol_labelled=zeros(size(grvol));
+% label this volume - this will have complete elements,
 % which must then be masked with grvol to get the correct grain shape
 
 disp('Dividing grain volume into elements...')
 tic
 count=0;
 for i = 1:ngv(1)
-	irangel = gvsize(1)*(i-1)+1;
-	irangeh = min(gvsize(1)*i,size(grvol,1));
-	
-  for j = 1:ngv(2)
-		jrangel = gvsize(2)*(j-1)+1;
-		jrangeh = min(gvsize(2)*j,size(grvol,2));
-		
-    for k= 1:ngv(3)
-			krangel = gvsize(3)*(k-1)+1;
-			krangeh = min(gvsize(3)*k,size(grvol,3));
-
-		  subvol(:,:,:) = grvol(irangel:irangeh, jrangel:jrangeh, krangel:krangeh);
-          if any(subvol(:)) 
-              count=count+1;
-              grvol_labelled(irangel:irangeh, jrangel:jrangeh, krangel:krangeh)=count;
-          end
-          
-		end
-	end
+    irangel = gvsize(1)*(i-1)+1;
+    irangeh = min(gvsize(1)*i,size(grvol,1));
+    
+    for j = 1:ngv(2)
+        jrangel = gvsize(2)*(j-1)+1;
+        jrangeh = min(gvsize(2)*j,size(grvol,2));
+        
+        for k= 1:ngv(3)
+            krangel = gvsize(3)*(k-1)+1;
+            krangeh = min(gvsize(3)*k,size(grvol,3));
+            
+            subvol(:,:,:) = grvol(irangel:irangeh, jrangel:jrangeh, krangel:krangeh);
+            if any(subvol(:))
+                count=count+1;
+                grvol_labelled(irangel:irangeh, jrangel:jrangeh, krangel:krangeh)=count;
+            end
+            
+        end
+    end
 end
 toc
 % voxel to element map comes straight from this
 vox2gvind = grvol_labelled.*grvol;
 fedpars.vox2gvind = vox2gvind;
 nv=count;
-disp(sprintf('...found %d elements in this grain', nv))
+fprintf('...found %d elements in this grain\n', nv)
 
 %nv    = ngv(1)*ngv(2)*ngv(3); % total number of vol elements
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -180,12 +182,12 @@ for i=1:nv
     % position of the first voxel of element
     [gv(i).cs1(1), gv(i).cs1(2), gv(i).cs1(3)] = ind2sub(size(grvol_labelled), voxindices(1));
     cs1_ingrain=gv(i).cs1;
-   % element index
+    % element index
     gv(i).ind = ((gv(i).cs1-1)./gvsize)+1;
     % position allowing for grain offset
     gv(i).cs1=gv(i).cs1+grainoff;
     % element centre
-	gv(i).cs  = gv(i).cs1 + 0.5*gvsize - 0.5;
+    gv(i).cs  = gv(i).cs1 + 0.5*gvsize - 0.5;
     
     % complete element?
     voxindices=find(vox2gvind==i);
@@ -201,7 +203,7 @@ for i=1:nv
         % complete element subvolume
         gv(i).vol=true(gvsize);
     else
-        gv(i).complete   = false;   
+        gv(i).complete   = false;
         % get the element subvolume
         voxindrel=sub2ind(gvsize, voxsubrel(:,1)+1, voxsubrel(:,2)+1, voxsubrel(:,3)+1);
         gv(i).vol(voxindrel)=true;
@@ -220,15 +222,16 @@ fedgrain.fedpars=fedpars;
 if ~save_flag
     a=inputwdefault('save gv.mat and updated fedgrain.mat? y/n', 'y');
     if strcmpi(a, 'y')
-        save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
-        save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
+        save(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid), 'fedgrain')
+        save(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid), 'gv', '-v7.3')
     else
         disp('not saving...  you can do it yourself')
     end
 else
     disp('auto-saving fedgrain and  gv')
-    save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
-    save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
+    save(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid), 'fedgrain')
+    save(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid), 'gv', '-v7.3')
 end
 
 
+end
diff --git a/7_fed/AndyFunctions/gtFedSetupT0.m b/7_fed/AndyFunctions/gtFedSetupT0.m
index eb663ae5..c011ee5c 100644
--- a/7_fed/AndyFunctions/gtFedSetupT0.m
+++ b/7_fed/AndyFunctions/gtFedSetupT0.m
@@ -21,15 +21,19 @@ else
     phase=0;
 end
 
+parameters=[];
+gv=[];
+bl=[];
+fedgrain=[];
 % load variables
 load parameters
-load(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid));
-load(sprintf('%s/7_FED/grain%d_/bl.mat', parameters.FED.dir, grainid));
-load(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid));
+load(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid));
+load(sprintf('%s/7_fed/grain%d_/bl.mat', parameters.fed.dir, grainid));
+load(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid));
 fedpars=fedgrain.fedpars;
 
 
-if phase==0 | ~isfield(fedpars, 'strategy')
+if phase==0 || ~isfield(fedpars, 'strategy')
     % get the relevent fedpars parameters from user
     list{1,1}='niter';              list{1,2}='Number of iterations in this phase';
     list{2,1}='crude_acceleration'; list{2,2}='Crude acceleration of forward projector?';
@@ -157,5 +161,8 @@ fedgrain.fedpars=fedpars;
 
 % save updated structures
 disp('saving updated fedgrain and gv')
-save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
-save(sprintf('%s/7_FED/grain%d_/gv.mat', parameters.FED.dir, grainid), 'gv', '-v7.3')
+save(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.fed.dir, grainid), 'fedgrain')
+save(sprintf('%s/7_fed/grain%d_/gv.mat', parameters.fed.dir, grainid), 'gv', '-v7.3')
+
+
+end
\ No newline at end of file
diff --git a/7_fed/Ccode_SpreadInt/gtFedInitialize.m b/7_fed/Ccode_SpreadInt/gtFedInitialize.m
index 5783cea1..d6b3debf 100644
--- a/7_fed/Ccode_SpreadInt/gtFedInitialize.m
+++ b/7_fed/Ccode_SpreadInt/gtFedInitialize.m
@@ -48,7 +48,7 @@ clear mexFedSpreadIntByVoxel
 %   mexFedSpreadIntByVoxel.o  (object file) and
 %   mexFedSpreadIntByVoxel.mexa64  files will be (re)created
 disp(' ')
-disp('Current folder has to be .../matlabDCT/zUtil_FED/Ccode_SpreadInt ')
+disp('Current folder has to be .../matlabDCT/7_fed/Ccode_SpreadInt ')
 disp('Start compiling gtFedSpreadIntByVoxel function...')
 tmp = system('mexFed.sh');
 
diff --git a/7_fed/gtFedGenerateRandomGrain.m b/7_fed/gtFedGenerateRandomGrain.m
index 89b2b56e..1d5d957d 100644
--- a/7_fed/gtFedGenerateRandomGrain.m
+++ b/7_fed/gtFedGenerateRandomGrain.m
@@ -8,7 +8,7 @@ function grain = gtFedGenerateRandomGrain(grain,vert,pars,varargin)
 %     INPUT:
 %
 %            grain = grain of interest (<struct>)
-%             vert = difspots image output from "gtPlaceDifspotinFull_ln" (<double MxM>)
+%             vert = difspots image output from "gtPlaceDifspotinFull" (<double MxM>)
 %                    M is the size of the image (typically 2048)
 %             pars = parameters file (<struct> {parameters.mat})
 %         varargin = optional arguments list given by pairs
@@ -18,30 +18,30 @@ function grain = gtFedGenerateRandomGrain(grain,vert,pars,varargin)
 %
 %       Reflections = number N of first reflections to consider (<double Nx1> {[]})
 %       Beamchroma = beam chromaticity (<char 1x4 > {'mono'}, 'poly')
-%       Beamenergymin = minimum beam energy (in keV) (<double 1x1> {5})
-%       Beamenergymax = maximum beam energy (in keV) (<double 1x1> {25})
-%       showfigure = show or not the figure (<logical 1x1> {0})
+%       Beamenergymin = minimum beam energy (in keV) (<double> {5})
+%       Beamenergymax = maximum beam energy (in keV) (<double> {25})
+%       showfigure = show or not the figure (<logical> {0})
 %            color = show or not the prediction spot positions coloured as
-%                    omega (<logical 1x1> {0})
-%           Dlimit = maximum strain value (<double 1x1 {0}>)
-%             Gref = reference full deformation gradient tensor (<double 3x3 {zeros(3)}>)
-%            debug = debug mode on/off (<logical 1x1 {0}>)
+%                    omega (<logical> {0})
+%           Dlimit = maximum strain value (<double> {0})
+%             Gref = reference full deformation gradient tensor (<double 3x3 {zeros(3)})
+%            debug = debug mode on/off (<logical> {0})
 %             axis = plot axis, image reference and beam direction in the
 %                    image (<logical> {0})
-%             save = save or not the grain (<logical 1x1> {0})
+%             save = save or not the grain (<logical> {0})
 %       Markersize = marker size (<double> {15})
 %        Grayscale = scale of grays (<double 1x2> {[-300 500]})
 %
 %
 %     OUTPUT:
 %
-%       grain = grain of interest (<struct 1x1>) 
+%       grain = grain of interest (<struct>) 
 %              added fields:
-%                - randomID <int32 1x1>
+%                - randomID <int32>
 %                - pllab <double Nx3>
 %                - hklsp <double Nx3>
 %                - dvec <double Nx3>
-%                - allblobs <struct 1x1>
+%                - allblobs <struct>
 %
 %              updated fields:
 %                - thetatype <double Nx1>
@@ -257,13 +257,13 @@ end
 %% Detector geometry
 disp('Getting the detector geometry...')
 
-detdiru = acq.detdiru0';
-detdirv = acq.detdirv0';
+detdiru = geo.detdiru0';
+detdirv = geo.detdirv0';
 Qdet = gtFedDetectorProjectionTensor(detdiru,detdirv,1,1);
 tn = cross(detdiru,detdirv);
-detpos = (acq.detpos0./acq.pixelsize)';
+detpos = (geo.detpos0./acq.pixelsize)';
 %uvorig = [acq.rotx; acq.ydet/2];
-uvorig = [acq.detucen0, acq.detvcen0]';
+uvorig = [geo.detucen0, geo.detvcen0]';
 csam=grain.center';
 omstep=180/acq.nproj;
 
diff --git a/7_fed/gtFedLoadGrainFromIndexter_ln.m b/7_fed/gtFedLoadGrainFromIndexter_ln.m
deleted file mode 100644
index 1183a048..00000000
--- a/7_fed/gtFedLoadGrainFromIndexter_ln.m
+++ /dev/null
@@ -1,146 +0,0 @@
-function [fedpars, fedgrain]=gtFedLoadGrainFromIndexter_ln(grainid, indexter_grain, varargin)
-%% [fedpars, fedgrain]=gtFedLoadGrainFromIndexter_ln(grainid, indexter_grain, varargin)
-%
-% create a file called fedgrain.mat - equivilent to the random grain in the
-% simulated data code.
-% nothing more than the indexter data "unpacked" into single blobs rather
-% than pairs.
-% setup fedpars.mat at the same time
-%
-% general comment - at the moment fedgrain and fedpars are saved together
-% in one variable (fedgrain).  This can perhaps be cleaned.
-%
-% improve, automate and clean so that it can be run form condor without
-% fucking around...
-%
-% fedpars.mat is grain specific - therefore it should go in the grain
-% folder.  For the moment, let's introduce a folder structure called
-% 7_FED/grain%d_/ and put fedpars / bl etc in there
-%
-% add a path to the dct volume in parameters.FED.final_dct_volume
-% also add parameters.FED.volume_offset to allow for sample movements
-% (see fed_real_data_scheme script)
-%
-% deal with renumbering in a sequence of datasets - ie in this scan it
-% might be grain X, but in the reference dataset and the dct volume it
-% might be grain Y.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% are we saving?
-if length(varargin)==1
-    save_flag=varargin{1};
-else
-    save_flag=0;
-    disp('gtFedLoadGrainFromIndexter is not saving fedpars.mat, fedgrain.mat')
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% load DCT parameters
-load('parameters.mat');
-% indexter output is passed in as indexter_grain
-
-%%%%%%%%%%%%%%%%%%%%%%%% INDEXTER OUTPUT INTO FEDGRAIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% simplify/unpack blob data from indexter
-a=indexter_grain{grainid};
-fedgrain.nof_pairs = a.nof_pairs;
-fedgrain.R_vector = a.R_vector;
-
-
-%%%%%%%%%%%%%%%%%%% GRAIN ID RENUMBERING IF PART OF SEQUENCE %%%%%%%%%%%%%%%%%%%%%%
-% may need to consider renumbering
-fedgrain.grainID=grainid;
-if isfield(parameters.FED, 'renumber_list')
-    list=parameters.FED.renumber_list;
-    % list: [referenceID, this dataset ID]
-    ndx=find(list(:,2)==grainid);
-    if isempty(ndx)
-        disp('problem - this grain is not linked to a grain in the reference dataset')
-        return
-    end
-    fedgrain.reference_grainid=list(ndx, 1);
-else
-    fedgrain.reference_grainid=grainid;
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%% SETUP FEDPARS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% How many blobs?
-nbl = 2*fedgrain.nof_pairs;
-
-% FED parameters definition
-fedpars = gtFedParameters(nbl);
-
-% add parameters / could be interactive or use defaults
-fedpars = gtFedSetParameters(fedpars, nbl, 'defaults');
-
-% add GrainID
-fedpars.grainID=grainid;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% load general info from parameters.acq into fedpars
-disp('copy experiment geometry from parameters.acq to fedpars')
-fedpars.detpos=parameters.acq.detpos0;
-fedpars.detdiru=parameters.acq.detdiru0;
-fedpars.detdirv=parameters.acq.detdirv0;
-fedpars.rotdir=parameters.acq.rotdir0;
-fedpars.detucen=parameters.acq.detucen0;
-fedpars.detvcen=parameters.acq.detvcen0;
-fedpars.beamdir=parameters.acq.beamdir0;
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%% INDEXTER OUTPUT INTO FEDGRAIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% unpack variables, expanding pairs
-fedgrain.pairid = zeros(1, nbl);
-fedgrain.difspots  = zeros(1, nbl);
-fedgrain.thetatype = zeros(1, nbl);
-fedgrain.hkl = zeros(nbl, size(a.hkl, 2));
-fedgrain.pl0 = zeros(nbl, 3);
-fedgrain.theta = zeros(1, nbl);
-fedgrain.eta = zeros(1, nbl);
-fedgrain.omega = zeros(1, nbl);
-
-% expand pairs
-fedgrain.pairid(1:2:end) = a.pairid;
-fedgrain.pairid(2:2:end) = a.pairid;
-
-fedgrain.difspots(1:2:end)=a.difspots(1:fedgrain.nof_pairs);
-fedgrain.difspots(2:2:end)=a.difspots((fedgrain.nof_pairs+1):end);
-
-fedgrain.thetatype(1:2:end) = a.thetatype;
-fedgrain.thetatype(2:2:end) = a.thetatype;
-fedgrain.hkl(1:2:end, :)=a.hkl;
-fedgrain.hkl(2:2:end, :)=a.hkl;
-fedgrain.pl0(1:2:end, :) = a.pl;
-fedgrain.pl0(2:2:end, :) = -a.pl;
-fedgrain.theta(1:2:end) = a.theta;
-fedgrain.theta(2:2:end) = a.theta;
-fedgrain.sinth0=sind(fedgrain.theta);
-fedgrain.eta(1:2:end) = a.eta;
-fedgrain.eta(2:2:end) = mod(180-a.eta, 360);
-fedgrain.omega(1:2:end) = a.omega;
-fedgrain.omega(2:2:end) = a.omega+180;
-
-warning('USING MEASURED DIFF ANGLES, SHOULD BE THEORETICAL!!!')
-% here we should determine the specific hkls, and predict theta, eta and
-% omega and pl0 based on these and the grain R-vector
-
-warning('HARD CODING MAX_ELEMENTS_GRAIN...')
-fedpars.max_elements_grain=2000;
-% combine fedgrain and fedpars - as fedpars can be grain specific
-fedgrain.fedpars=fedpars;
-
-if ~save_flag
-    a=inputwdefault('save fedgrain.mat (which includes fedgrain.fedpars)?', 'y');
-    if strcmpi(a, 'y')
-        save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
-    else
-        disp('not saving...  you can do it yourself')
-    end
-else
-    % new directory structure
-    save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.FED.dir, grainid), 'fedgrain')
-end
-
-disp('gtFedLoadGrainFromIndexter finished')
-
-end % end function
\ No newline at end of file
diff --git a/7_fed/gtFedLoadGrainWoIndexter.m b/7_fed/gtFedLoadGrainWoIndexter.m
index 100c612b..293ea49f 100644
--- a/7_fed/gtFedLoadGrainWoIndexter.m
+++ b/7_fed/gtFedLoadGrainWoIndexter.m
@@ -20,9 +20,9 @@ function [fedgrain,fedpars,gr]=gtFedLoadGrainWoIndexter(gr, bbox, varargin)
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % are we saving?
-app.save_flag=false;
-app.debug=false;
-app.max_el=2000;
+app.save_flag = false;
+app.debug     = false;
+app.max_el    = 2000;
 app=parse_pv_pairs(app,varargin);
 if ~app.save_flag && app.debug
     disp('gtFedLoadGrainWoIndexter is not saving fedpars.mat, fedgrain.mat')
@@ -30,6 +30,7 @@ end
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % load DCT parameters
+parameters=[];
 load('parameters.mat');
 % indexter output is passed in as indexter_grain
 
@@ -157,9 +158,11 @@ fedgrain.fedpars=fedpars;
 % saving...
 if app.save_flag
     % new directory structure
-    save(sprintf('%s/7_FED/grain%d_/fedgrain.mat', parameters.acq.dir, gr.id), 'fedgrain')
+    save(sprintf('%s/7_fed/grain%d_/fedgrain.mat', parameters.acq.dir, gr.id), 'fedgrain')
 end
 
-disp('### Exiting from gtFedLoadGrainFromIndexter... ###')
-disp(' ')
+if app.debug
+    disp('### Exiting from gtFedLoadGrainFromIndexter... ###')
+    disp(' ')
+end
 end % end function 
\ No newline at end of file
diff --git a/7_fed/gtFedParameters.m b/7_fed/gtFedParameters.m
index 8e8128f5..11a236cd 100644
--- a/7_fed/gtFedParameters.m
+++ b/7_fed/gtFedParameters.m
@@ -62,3 +62,5 @@ fedpars.centoffs_correction = false;  % this should no longer exist - leave in j
 %     fedpars.strategy.s1.solver = 'Flow'; fedpars.strategy.s1.dindex = ...
 %     fedpars.strategy.s2.solver = 'LSQR'; fedpars.strategy.s2.dindex = ...
 %     etc.
+
+end
\ No newline at end of file
diff --git a/7_fed/gtFedSetParameters.m b/7_fed/gtFedSetParameters.m
index cd721310..4316595b 100644
--- a/7_fed/gtFedSetParameters.m
+++ b/7_fed/gtFedSetParameters.m
@@ -138,7 +138,7 @@ if ~defaults
     % get rid of "excess" default phases
     if fedpars.nphases<3
         for i=fedpars.nphases+1:3
-            fedpars.strategy=rmfield(fedpars.strategy, sprintf('s%d', i))
+            fedpars.strategy=rmfield(fedpars.strategy, sprintf('s%d', i)
         end
     end
     
@@ -154,8 +154,8 @@ if ~defaults
     list{10,1}='fbbminsize';        list{10,2}='Minimum flow bounding box size';
     
         for i=1:fedpars.nphases
-        disp(sprintf('Now set the dynamic values for phase %d', i))
-        fedpars.strategy.(sprintf('s%d', i))=gtModifyStructure(fedpars.strategy.(sprintf('s%d', i)), list);
+        fprintf('Now set the dynamic values for phase %d', i)
+        fedpars.strategy.(sprintf('s%d', i)=gtModifyStructure(fedpars.strategy.(sprintf('s%d', i), list);
         end
     
 end
diff --git a/7_fed/gtFedSetupT0.m b/7_fed/gtFedSetupT0.m
index d38a118c..1e9b7a54 100644
--- a/7_fed/gtFedSetupT0.m
+++ b/7_fed/gtFedSetupT0.m
@@ -19,7 +19,7 @@ end
 load fedpars
 
 
-if (phase == 0) || (phase == ~isfield(fedpars, 'strategy'))
+if (phase == 0) || (phase == ~isfield(fedpars, 'strategy')
     % get the relevent fedpars parameters from user
     fedpars.dindex     = inputwdefaultnumeric('enter the desired dindex vector [Rx Ry Rz e11 e22 e33 e23 e13 e12]:', '[1 1 1 0 0 0 0 0 0]');
     fedpars.T0strategy = inputwdefault('enter the desired T0 strategy A/B :', 'B');
@@ -54,8 +54,8 @@ end
 r = setdiff(fedpars.loadbl, fedpars.usebl);
 for i = 1:length(r)
     pair  = floor((r(i)+1)/2);
-    pairA = (2*(pair-1))+1;
-    pairB = (2*(pair-1))+2;
+    pairA = (2*(pair-1)+1;
+    pairB = (2*(pair-1)+2;
     fedpars.usebl(fedpars.usebl==pairA) = [];
     fedpars.usebl(fedpars.usebl==pairB) = [];
 end
@@ -102,7 +102,7 @@ for i=1:length(gv)
 		if strcmpi(fedpars.T0strategy, 'A')
 			% solve for T0 as normal
 			[Usvd,Ssvd,Vsvd] = svd(U0_allbl,0);
-			gv(i).T0 = Vsvd*diag(1./diag(Ssvd))*Usvd';
+			gv(i).T0 = Vsvd*diag(1./diag(Ssvd)*Usvd';
 			% force lines of T0 to zeros
 			gv(i).T0(~fedpars.dindex, :) = 0;
 			
@@ -110,7 +110,7 @@ for i=1:length(gv)
 			% remove terms from U0_allbl
 			U0_allbl(:, ~fedpars.dindex) = [];
 			[Usvd,Ssvd,Vsvd] = svd(U0_allbl,0);
-			tmpT0 = Vsvd*diag(1./diag(Ssvd))*Usvd';
+			tmpT0 = Vsvd*diag(1./diag(Ssvd)*Usvd';
 			% restore to standard dimensions
 			gv(i).T0 = zeros(9, 3*nbl);
 			gv(i).T0(fedpars.dindex, :) = tmpT0;
@@ -135,7 +135,7 @@ for i=1:length(gv)
 end
 
 % save updated structures
-disp(sprintf('saving updated fedpars and gv in %s', fedpars.filename))
+fprintf('saving updated fedpars and gv in %s', fedpars.filename)
 save(fedpars.filename, 'fedpars', 'gv', '-append')
 
 
diff --git a/7_fed/gtFedShowDifBlob.m b/7_fed/gtFedShowDifBlob.m
index e36ee0b0..70e25015 100644
--- a/7_fed/gtFedShowDifBlob.m
+++ b/7_fed/gtFedShowDifBlob.m
@@ -4,14 +4,14 @@ function gtFedShowDifBlob(nbl,bl,wint,cmap)
 % vol=permute(vol,[2,1,3]);
 % 
 % 
-% vol_view(vol,'plane','zx','slicendx',bl(nbl).cent(3))
+% vol_view(vol,'plane','zx','slicendx',bl(nbl).cent(3)
 % xlabel('u - horizontal')  % vol_view will change it back
 % ylabel('v - vertical')
 % 
-% disp(sprintf('vol=bl(%d).int(:,:,:);',nbl))
+% fprintf('vol=bl(%d).int(:,:,:);',nbl)
 % disp('vol=permute(vol,[2,1,3]);');
-% %disp(sprintf('vol_view(vol,''plane'',''zx'',''slicendx'',%d)',bl(nbl).cent(3)-bl(nbl).bbw(1)))
-% disp(sprintf('vol_view(vol,''slicendx'',%d)',bl(nbl).cent(3)-bl(nbl).bbw(1)))
+% %fprintf('vol_view(vol,''plane'',''zx'',''slicendx'',%d)',bl(nbl).cent(3)-bl(nbl).bbw(1))
+% fprintf('vol_view(vol,''slicendx'',%d)',bl(nbl).cent(3)-bl(nbl).bbw(1))
 % %disp('xlabel(''u - horizontal'')')
 % %disp('ylabel(''v - vertical'')')
 
@@ -42,14 +42,14 @@ s = warning('query', 'all');
 warning off
 
 if cmap == 0
-	h = dipshow(vol,'lin','name',sprintf('Blob #%d ',nbl));
+	h = dipshow(vol,'lin','name',sprintf('Blob #%d ',nbl);
 else
-	h = dipshow(vol,[0 max(vol(:))],'name',sprintf('Blob #%d  ',nbl));
+	h = dipshow(vol,[0 max(vol(:)],'name',sprintf('Blob #%d  ',nbl);
 end	
 
 warning(s)
 
 set(h,'numbertitle','off')
-dipshow(h,'ch_slice',round(bl(nbl).commbl(3)))
+dipshow(h,'ch_slice',round(bl(nbl).commbl(3))
 
 
diff --git a/7_fed/gtFedTestLoadData.m b/7_fed/gtFedTestLoadData.m
index 74d0dbb3..5d42bace 100644
--- a/7_fed/gtFedTestLoadData.m
+++ b/7_fed/gtFedTestLoadData.m
@@ -67,9 +67,9 @@ omstep = 180/parameters.acq.nproj;
 
 beamdir  = parameters.acq.beamdir0';
 
-detuvorig= [parameters.acq.detucen0; parameters.acq.detvcen0]; % in detector pixels
-detdiru  = parameters.acq.detdiru0'; % unit vector
-detdirv  = parameters.acq.detdirv0'; % unit vector
+detuvorig= [parameters.geo.detucen0; parameters.geo.detvcen0]; % in detector pixels
+detdiru  = parameters.geo.detdiru0'; % unit vector
+detdirv  = parameters.geo.detdirv0'; % unit vector
 
 detnorm  = cross(detdiru,detdirv);   % unit vector
 
@@ -77,7 +77,7 @@ detnorm  = cross(detdiru,detdirv);   % unit vector
 %   originally in detector pixels !!!
 %   change to grain voxels !!!
 %   pixel sizes in mm-s !!!
-detpos   = parameters.acq.detpos0'*parameters.acq.pixelsize/fedpars.voxelsize;
+detpos   = parameters.geo.detpos0'*parameters.acq.pixelsize/fedpars.voxelsize;
 rotdir   = parameters.acq.rotdir0';  % unit vector
 
 detscaleu = fedpars.voxelsize/parameters.acq.pixelsize; % detector scaling along u (grain voxel size / det. pixel size)
diff --git a/7_fed/gtGrainPredict.m b/7_fed/gtGrainPredict.m
index b570642a..740766e2 100644
--- a/7_fed/gtGrainPredict.m
+++ b/7_fed/gtGrainPredict.m
@@ -8,7 +8,7 @@ function grain = gtFedGenerateRandomGrain(grain,vert,pars,varargin)
 %     INPUT:
 %
 %            grain = grain of interest (<struct>)
-%             vert = difspots image output from "gtPlaceDifspotinFull_ln" (<double MxM>)
+%             vert = difspots image output from "gtPlaceDifspotinFull" (<double MxM>)
 %                    M is the size of the image (typically 2048)
 %             pars = parameters file (<struct> {parameters.mat})
 %         varargin = optional arguments list given by pairs
@@ -18,30 +18,30 @@ function grain = gtFedGenerateRandomGrain(grain,vert,pars,varargin)
 %
 %       Reflections = number N of first reflections to consider (<double Nx1> {[]})
 %       Beamchroma = beam chromaticity (<char 1x4 > {'mono'}, 'poly')
-%       Beamenergymin = minimum beam energy (in keV) (<double 1x1> {5})
-%       Beamenergymax = maximum beam energy (in keV) (<double 1x1> {25})
-%       showfigure = show or not the figure (<logical 1x1> {0})
+%       Beamenergymin = minimum beam energy (in keV) (<double> {5})
+%       Beamenergymax = maximum beam energy (in keV) (<double> {25})
+%       showfigure = show or not the figure (<logical> {0})
 %            color = show or not the prediction spot positions coloured as
-%                    omega (<logical 1x1> {0})
-%           Dlimit = maximum strain value (<double 1x1 {0}>)
-%             Gref = reference full deformation gradient tensor (<double 3x3 {zeros(3)}>)
-%            debug = debug mode on/off (<logical 1x1 {0}>)
+%                    omega (<logical> {0})
+%           Dlimit = maximum strain value (<double> {0})
+%             Gref = reference full deformation gradient tensor (<double 3x3 {zeros(3)})
+%            debug = debug mode on/off (<logical> {0})
 %             axis = plot axis, image reference and beam direction in the
 %                    image (<logical> {0})
-%             save = save or not the grain (<logical 1x1> {0})
+%             save = save or not the grain (<logical> {0})
 %       Markersize = marker size (<double> {15})
 %        Grayscale = scale of grays (<double 1x2> {[-300 500]})
 %
 %
 %     OUTPUT:
 %
-%       grain = grain of interest (<struct 1x1>) 
+%       grain = grain of interest (<struct>) 
 %              added fields:
-%                - randomID <int32 1x1>
+%                - randomID <int32>
 %                - pllab <double Nx3>
 %                - hklsp <double Nx3>
 %                - dvec <double Nx3>
-%                - allblobs <struct 1x1>
+%                - allblobs <struct>
 %
 %              updated fields:
 %                - thetatype <double Nx1>
@@ -251,13 +251,13 @@ end
 %% Detector geometry
 disp('Getting the detector geometry...')
 
-detdiru = acq.detdiru0';
-detdirv = acq.detdirv0';
+detdiru = geo.detdiru0';
+detdirv = geo.detdirv0';
 Qdet = gtFedDetectorProjectionTensor(detdiru,detdirv,1,1);
 tn = cross(detdiru,detdirv);
-detpos = (acq.detpos0./acq.pixelsize)';
+detpos = (geo.detpos0./acq.pixelsize)';
 %uvorig = [acq.rotx; acq.ydet/2];
-uvorig = [acq.detucen0, acq.detvcen0]';
+uvorig = [geo.detucen0, geo.detvcen0]';
 csam=grain.center';
 omstep=180/acq.nproj;
 
diff --git a/zUtil_Parameters/build_list.m b/zUtil_Parameters/build_list.m
index c074f155..5154de92 100644
--- a/zUtil_Parameters/build_list.m
+++ b/zUtil_Parameters/build_list.m
@@ -22,6 +22,7 @@ function list = build_list(saveflag)
 %           match
 %           index
 %           rec
+%           fed
 %
 %       list.mat has the same fields as parameters.mat, except for index:
 %           acq, cryst, xop, geo, opt, database, prep, seg, match_calib, match, rec
@@ -367,6 +368,16 @@ list.rec{8,1} = 'percentile2';              	list.rec{8,2} = 'Percentile thresho
 list.rec{8,3} = 'double';
 
 
+list.fed{1,1} = 'dir';                          list.fed{1,2} = 'Data analysis directory';       	
+list.fed{1,3} = 'char';
+list.fed{2,1} = 'dct_vol';                      list.fed{2,2} = 'Dct reconstructed volume filename (.edf)';                             
+list.fed{2,3} = 'char';
+list.fed{3,1} = 'dct_offset';                   list.fed{3,2} = 'Offset to be applied to the volume [x y z]';    	
+list.fed{3,3} = 'double';
+list.fed{4,1} = 'renumber_list';                list.fed{4,2} = 'Renumbering list for grainID';    	
+list.fed{4,3} = 'double';
+
+
 if saveflag
     fnames=gtLastFileName('template_list','new');
     save(fnames,'list','-v7.3');
diff --git a/zUtil_Parameters/build_list_v2.m b/zUtil_Parameters/build_list_v2.m
index ce380ed1..a219c369 100644
--- a/zUtil_Parameters/build_list_v2.m
+++ b/zUtil_Parameters/build_list_v2.m
@@ -25,6 +25,7 @@ function list = build_list(varargin)
 %           match
 %           index
 %           rec
+%           fed
 %
 %       The list  has the same fields as parameters.mat, except for index:
 %       list.mat
@@ -403,6 +404,19 @@ list.rec{10,1} = 'voxelsize';                   list.rec{10,2} = 'Voxelsize (mm/
 list.rec{10,3} = 'double';
 
 
+%fed
+list.fed{1,1} = 'dir';                          list.fed{1,2} = 'Data analysis directory';       	
+list.fed{1,3} = 'char';
+list.fed{2,1} = 'dct_vol';                      list.fed{2,2} = 'Dct reconstructed volume filename (.edf)';                             
+list.fed{2,3} = 'char';
+list.fed{3,1} = 'dct_offset';                   list.fed{3,2} = 'Offset to be applied to the volume [x y z]';    	
+list.fed{3,3} = 'double';
+list.fed{4,1} = 'renumber_list';                list.fed{4,2} = 'Renumbering list for grainID';    	
+list.fed{4,3} = 'double';
+
+
+
+
 if app.saveflag
     fnames=gtLastFileName('template_list','new');
     if isempty(strfind(version,'2011'))
diff --git a/zUtil_Parameters/build_parameters.m b/zUtil_Parameters/build_parameters.m
deleted file mode 100644
index c72e1e59..00000000
--- a/zUtil_Parameters/build_parameters.m
+++ /dev/null
@@ -1,543 +0,0 @@
-function list=build_parameters
-
-list=[];
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% ACQUISITION structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-acq.collection_dir     = '';
-acq.name               = '';
-acq.dir                = '';
-acq.date               = '';
-acq.xdet               = NaN;
-acq.ydet               = NaN;
-acq.nproj              = NaN;
-acq.refon              = NaN;
-acq.nref               = NaN;
-acq.ndark              = NaN;
-acq.pixelsize          = NaN;
-acq.count_time         = NaN;
-acq.energy             = NaN;
-acq.dist               = NaN;
-acq.sensortype         = '';
-acq.type               = '';
-acq.interlaced_turns   = false;
-acq.mono_tune          = false;
-acq.rotation_axis      = '';
-acq.distortion         = '';
-acq.flip_images        = false;
-acq.no_direct_beam     = false;
-acq.rotation_direction = '';
-acq.collection_dir_old = '';
-acq.rotu               = NaN;
-acq.rotx               = NaN;
-acq.bb                 = [NaN NaN NaN NaN];
-acq.bbdir              = [NaN NaN NaN NaN];
-acq.maxradius          = NaN;
-acq.pair_tablename     = '';
-acq.calib_tablename    = '';
-acq.orig_xdet          = NaN;
-acq.orig_ydet          = NaN;
-acq.roi_x_off          = NaN;
-acq.roi_y_off          = NaN;
-
-list.acq{1,1}  = 'collection_dir';          list.acq{1,2}  = 'Collection directory';
-list.acq{1,3}  = 'char';
-list.acq{2,1}  = 'name';            	    list.acq{2,2}  = 'Name of the dataset';
-list.acq{2,3}  = 'char';
-list.acq{3,1}  = 'dir';             	    list.acq{3,2}  = 'Directory in which to analyse the data';
-list.acq{3,3}  = 'char';
-list.acq{4,1}  = 'date';                    list.acq{4,2}  = 'Date?';
-list.acq{4,3}  = 'char';
-list.acq{5,1}  = 'xdet';            	    list.acq{5,2}  = 'Detector size X (pixels)';
-list.acq{5,3}  = 'double';
-list.acq{6,1}  = 'ydet';            	    list.acq{6,2}  = 'Detector size Y (pixels)';
-list.acq{6,3}  = 'double';
-list.acq{7,1}  = 'nproj';           	    list.acq{7,2}  = 'Number of images in *180 DEGREES* of scan';
-list.acq{7,3}  = 'double';
-list.acq{8,1}  = 'refon';           	    list.acq{8,2}  = 'References after how many images?';
-list.acq{8,3}  = 'double';
-list.acq{9,1}  = 'nref';            	    list.acq{9,2}  = 'How many reference images in a group?';
-list.acq{9,3}  = 'double';
-list.acq{10,1} = 'ndark';           	    list.acq{10,2} = 'How many dark images taken?';
-list.acq{10,3} = 'double';
-list.acq{11,1} = 'pixelsize';               list.acq{11,2} = 'Pixelsize (mm)';
-list.acq{11,3} = 'double';
-list.acq{12,1} = 'count_time';              list.acq{12,2} = 'image integration time (s)';
-list.acq{12,3} = 'double';
-list.acq{13,1} = 'energy';          	    list.acq{13,2} = 'Beam energy (keV)';
-list.acq{13,3} = 'double';
-list.acq{14,1} = 'dist';            	    list.acq{14,2} = 'Sample-detector distance (mm)';
-list.acq{14,3} = 'double';
-list.acq{15,1} = 'sensortype';              list.acq{15,2} = 'Camera type (frelon / kodak4mv1)?';
-list.acq{15,3} = 'char';
-list.acq{16,1} = 'type';            	    list.acq{16,2} = 'DCT scan type (360degree, 180degree, etc)';
-list.acq{16,3} = 'char';
-list.acq{17,1} = 'interlaced_turns';        list.acq{17,2} = 'Interlaced scan? 0 for normal scan, 1 for one extra turn, etc';
-list.acq{17,3} = 'double';
-list.acq{18,1} = 'mono_tune';               list.acq{18,2} = 'Monochromator was tuned after N reference groups, or 0 for not tuned';
-list.acq{18,3} = 'double';
-list.acq{19,1} = 'rotation_axis';           list.acq{19,2} = 'Rotation axis orientation (vertical / horizontal)';
-list.acq{19,3} = 'char';
-list.acq{20,1} = 'distortion';              list.acq{20,2} = 'Distortion correction file with path (or "none")';
-list.acq{20,3} = 'char';
-list.acq{21,1} = 'flip_images';             list.acq{21,2} = 'Flip images for future coordinate system - normally no';
-list.acq{21,3} = 'char';
-list.acq{22,1} = 'no_direct_beam';          list.acq{22,2} = 'Special scan with no direct beam (taper frelon, offset detector)?';
-list.acq{22,3} = 'double';
-list.acq{23,1} = 'rotation_direction';      list.acq{23,2} = 'Horizontal axis scan - rotate images "clockwise" or "counterclockwise"?';
-list.acq{23,3} = 'double';
-list.acq{24,1} = 'collection_dir_old';      list.acq{24,2} = 'Old collection directory';
-list.acq{24,3} = 'char';
-list.acq{25,1} = 'rotu';            	    list.acq{25,2} = '';
-list.acq{25,3} = 'char';
-list.acq{26,1} = 'rotx';                    list.acq{26,2} = '';
-list.acq{26,3} = 'double';
-list.acq{27,1} = 'bb';                      list.acq{27,2} = '';
-list.acq{27,3} = 'double';
-list.acq{28,1} = 'bbdir';           	    list.acq{28,2} = '';
-list.acq{28,3} = 'char';
-list.acq{29,1} = 'maxradius';               list.acq{29,2} = '';
-list.acq{29,3} = 'char';
-list.acq{30,1} = 'pair_tablename';          list.acq{30,2} = 'Table for spot pairs';
-list.acq{30,3} = 'char';
-list.acq{31,1} = 'calib_tablename';         list.acq{31,2} = 'Table for calibration of pair matching';
-list.acq{31,3} = 'double';
-list.acq{32,1} = 'orig_xdet';               list.acq{32,2} = 'Original detector width'
-list.acq{32,3} = 'double';
-list.acq{33,1} = 'orig_ydet';               list.acq{33,2} = 'Original detector height'
-list.acq{33,3} = 'double';
-list.acq{34,1} = 'roi_x_off';               list.acq{34,2} = 'Horizontal offset of ROI'
-list.acq{34,3} = 'double';
-list.acq{35,1} = 'roi_y_off';               list.acq{35,2} = 'Vertical offset of ROI'
-list.acq{35,3} = 'double';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% CRYSTALLOGRAPHY structure               
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-cryst.material         = '';
-cryst.latticepar       = [NaN NaN NaN NaN NaN NaN];
-cryst.spacegroup       = NaN;
-cryst.hermann_mauguin  = '';
-cryst.crystal_system   = '';
-
-list.cryst{1,1} = 'material';           list.cryst{1,2} = 'Sample material';
-list.cryst{1,3} = 'char';
-list.cryst{2,1} = 'latticepar';         list.cryst{2,2} = 'Sample lattice parameters [a b c alpha beta gamma] (angstrom, deg)';
-list.cryst{2,3} = 'double';
-list.cryst{3,1} = 'spacegroup';         list.cryst{3,2} = 'Sample spacegroup';
-list.cryst{3,3} = 'double';
-list.cryst{4,1} = 'hermann_mauguin';    list.cryst{4,2} = 'Hermann Mauguin short symbol';
-list.cryst{4,3} = 'char';
-list.cryst{5,1} = 'crystal_system';     list.cryst{5,2} = 'Crystallographic unit-cell structure system';
-list.cryst{5,3} = 'char';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% XOP structure               
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-xop.No       = NaN;
-xop.tt       = NaN;
-xop.dspacing = NaN;
-xop.Int      = NaN;
-xop.F        = NaN;
-xop.h        = NaN;
-xop.k        = NaN;
-xop.l        = NaN;
-xop.Mult     = NaN;
-xop.hkl      = [NaN NaN NaN];
-xop.name     = '';
-xop.xop_dir  = '';
-
-list.xop{1,1}  = 'No';              list.xop{1,2}  = 'Number of reflection';                    list.xop{1,3}  = 'int8';
-list.xop{2,1}  = 'tt';              list.xop{2,2}  = 'Twotheta angle';                          list.xop{2,3}  = 'single';
-list.xop{3,1}  = 'dspacing';        list.xop{3,2}  = 'd-spacing';                               list.xop{3,3}  = 'single';
-list.xop{4,1}  = 'Int';             list.xop{4,2}  = 'Intensity';                               list.xop{4,3}  = 'single';
-list.xop{5,1}  = 'F';               list.xop{5,2}  = 'Form factor';                             list.xop{5,3}  = 'single';
-list.xop{6,1}  = 'h';               list.xop{6,2}  = 'h';                                       list.xop{6,3}  = 'int8';
-list.xop{7,1}  = 'k';               list.xop{7,2}  = 'k';                                       list.xop{7,3}  = 'int8';
-list.xop{8,1}  = 'l';               list.xop{8,2}  = 'l';                                       list.xop{8,3}  = 'int8';
-list.xop{9,1}  = 'Mult';            list.xop{9,2}  = 'Multiplicity';                            list.xop{9,3}  = 'int8';
-list.xop{10,1} = 'hkl';             list.xop{10,2} = 'hkl Miller indexes';                      list.xop{10,3} = 'int8';
-list.xop{11,1} = 'name';            list.xop{11,2} = 'XOP/Diamond crystallographic file';       list.xop{11,3} = 'char';
-list.xop{12,1} = 'xop_dir';         list.xop{12,2} = 'Directory for the XOP input file';        list.xop{12,3} = 'char';
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% GEOMETRY structure               
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-geo.detpos0     = [NaN NaN NaN];
-geo.detdiru0    = [NaN NaN NaN];
-geo.detdirv0    = [NaN NaN NaN];
-geo.beamdir0    = [NaN NaN NaN];
-geo.rotdir0     = [NaN NaN NaN];
-geo.detucen0    = NaN;
-geo.detvcen0    = NaN;
-geo.detdir0     = [NaN NaN NaN];
-geo.detanglemin = NaN;
-geo.detanglemax = NaN;
-
-list.geo{1,1}  = 'detpos0';         list.geo{1,2}  = 'Detector position';               list.geo{1,3}  = 'double';
-list.geo{2,1}  = 'detdiru0';        list.geo{2,2}  = 'Detector u-direction';            list.geo{2,3}  = 'double';
-list.geo{3,1}  = 'detdirv0';        list.geo{3,2}  = 'Detector v-direction';            list.geo{3,3}  = 'double';
-list.geo{4,1}  = 'beamdir0';        list.geo{4,2}  = 'Beam direction';                  list.geo{4,3}  = 'double';
-list.geo{5,1}  = 'rotdir0';         list.geo{5,2}  = 'Rotation axis direction';         list.geo{5,3}  = 'double';
-list.geo{6,1}  = 'detucen0';        list.geo{6,2}  = 'Detector u-centre';               list.geo{6,3}  = 'double';
-list.geo{7,1}  = 'detvcen0';        list.geo{7,2}  = 'Detector v-centre';               list.geo{7,3}  = 'double';
-list.geo{8,1}  = 'detdir0';         list.geo{8,2}  = 'Detector normal direction';       list.geo{8,3}  = 'double';
-list.geo{9,1}  = 'detanglemin';     list.geo{9,2}  = 'Detector minimum 2Theta angle';	list.geo{9,3}  = 'double';
-list.geo{10,1} = 'detanglemax';     list.geo{10,2} = 'Detector maximum 2Theta angle';	list.geo{10,3} = 'double';   
-         
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% OPTIMIZED GEOMETRY parameters
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-opt.detpos  = [NaN NaN NaN];
-opt.detdiru = [NaN NaN NaN];
-opt.detdirv = [NaN NaN NaN];
-opt.beamdir = [NaN NaN NaN];
-opt.rotdir  = [NaN NaN NaN];
-opt.detucen = NaN;
-opt.detvcen = NaN;
-opt.detdir  = [NaN NaN NaN];
-
-list.opt{1,1} = 'detpos';          list.opt{1,2} = 'Detector position';             list.opt{1,3} = 'double';
-list.opt{2,1} = 'detdiru';         list.opt{2,2} = 'Detector u-direction';          list.opt{2,3} = 'double';
-list.opt{3,1} = 'detdirv';         list.opt{3,2} = 'Detector v-direction';          list.opt{3,3} = 'double';
-list.opt{4,1} = 'beamdir';         list.opt{4,2} = 'Beam direction';		        list.opt{4,3} = 'double';
-list.opt{5,1} = 'rotdir';          list.opt{5,2} = 'Rotation axis direction';		list.opt{5,3} = 'double';
-list.opt{6,1} = 'detucen';         list.opt{6,2} = 'Detector u-centre';             list.opt{6,3} = 'double';
-list.opt{7,1} = 'detvcen';         list.opt{7,2} = 'Detector v-centre';             list.opt{7,3} = 'double';
-list.opt{8,1} = 'detdir';          list.opt{8,2} = 'Detector normal direction';		list.opt{8,3} = 'double';
- 
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% DATABASE structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-database.name     = '';
-database.host     = '';
-database.user     = '';
-database.password = '';
-
-list.database{1,1} = 'name';             list.database{1,2} = 'Database name';            list.database{1,3} = 'char';
-list.database{2,1} = 'host';             list.database{2,2} = 'Database host';            list.database{2,3} = 'char';
-list.database{3,1} = 'user';             list.database{3,2} = 'Database user';            list.database{3,3} = 'char';
-list.database{4,1} = 'password';         list.database{4,2} = 'Database password';        list.database{4,3} = 'char';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% PREPROCESSING structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-prep.normalisation = '';
-prep.absint        = NaN;
-prep.absrange      = NaN;
-prep.fullint       = NaN;
-prep.fullrange     = NaN;
-prep.margin        = NaN;
-prep.intensity     = NaN;
-prep.filtsize      = [NaN NaN];
-prep.drifts_pad    = '';
-prep.renumbered    = false; 
-prep.bb            = [NaN NaN NaN NaN];
-prep.correct_drift = '';
-prep.udrift        = NaN;
-prep.udriftabs     = NaN;
-prep.vdrift        = NaN;
-
-list.prep{1,1}  = 'normalisation';          list.prep{1,2}  = '';                list.prep{1,3}  = 'char';
-list.prep{2,1}  = 'absint';          		list.prep{2,2}  = '';                list.prep{2,3}  = 'double';
-list.prep{3,1}  = 'absrange';               list.prep{3,2}  = '';                list.prep{3,3}  = 'double';
-list.prep{4,1}  = 'fullint';         		list.prep{4,2}  = '';                list.prep{4,3}  = 'double';
-list.prep{5,1}  = 'fullrange';              list.prep{5,2}  = '';                list.prep{5,3}  = 'double';
-list.prep{6,1}  = 'margin';          		list.prep{6,2}  = '';                list.prep{6,3}  = 'double';
-list.prep{7,1}  = 'intensity';              list.prep{7,2}  = '';                list.prep{7,3}  = 'double';
-list.prep{8,1}  = 'filtsize';               list.prep{8,2}  = '';                list.prep{8,3}  = 'double';
-list.prep{9,1}  = 'drifts_pad';             list.prep{9,2}  = '';                list.prep{9,3}  = 'char';
-list.prep{10,1} = 'renumbered';             list.prep{10,2} = '';                list.prep{10,3} = 'logical';
-list.prep{11,1} = 'bb';              		list.prep{11,2} = '';                list.prep{11,3} = 'double';
-list.prep{12,1} = 'correct_drift';          list.prep{12,2} = '';                list.prep{12,3} = 'char';
-list.prep{13,1} = 'udrift';          		list.prep{13,2} = '';                list.prep{13,3} = 'double';
-list.prep{14,1} = 'udriftabs';              list.prep{14,2} = '';                list.prep{14,3} = 'double';
-list.prep{15,1} = 'vdrift';          		list.prep{15,2} = '';                list.prep{15,3} = 'double';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% SEGMENTATION structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-seg.th2                 = NaN;
-seg.th1                 = NaN;
-seg.th_grow_low         = NaN;
-seg.th_grow_high        = NaN;
-seg.minsize             = NaN;
-seg.minint              = NaN;
-seg.icut                = NaN;
-seg.ExtLimImInt         = NaN;
-seg.ExtLimTailInt       = NaN;
-seg.DifSpotMask         = '';
-seg.dbfields            = '';
-seg.bb                  = [NaN NaN NaN NaN];
-seg.background_subtract = false;
-seg.overlaps_removed    = false;
-
-list.seg{1,1}  = 'th2';             	list.seg{1,2}  = '';                
-list.seg{1,3}  = 'double';
-list.seg{2,1}  = 'th1';             	list.seg{2,2}  = 'Threshold for finding seeds';             
-list.seg{2,3}  = 'double';
-list.seg{3,1}  = 'th_grow_low';         list.seg{3,2}  = 'Lower limit of threshold for growing seeds';              
-list.seg{3,3}  = 'double';
-list.seg{4,1}  = 'th_grow_high';        list.seg{4,2}  = 'Upper limit of threshold for growing seeds';              
-list.seg{4,3}  = 'double';
-list.seg{5,1}  = 'minsize';             list.seg{5,2}  = '';                
-list.seg{5,3}  = 'double';
-list.seg{6,1}  = 'minint';          	list.seg{6,2}  = '';                
-list.seg{6,3}  = 'double';
-list.seg{7,1}  = 'icut';            	list.seg{7,2}  = '';                
-list.seg{7,3}  = 'double';
-list.seg{8,1}  = 'ExtLimImInt';         list.seg{8,2}  = 'First and last image in the stack with this minimum relative intensity';  
-list.seg{8,3}  = 'double';
-list.seg{9,1}  = 'ExtLimTailInt';       list.seg{9,2}  = 'Size of tails cut off the summed intensity curve through the image stack';   
-list.seg{9,3}  = 'double';
-list.seg{10,1} = 'DifSpotMask';         list.seg{10,2} = 'Mask used to create difspot.edf from blob';               
-list.seg{10,3} = 'char';
-list.seg{11,1} = 'dbfields';            list.seg{11,2} = 'Database ''difspot'' table fields list';            
-list.seg{11,3} = 'char';
-list.seg{12,1} = 'bb';              	list.seg{12,2} = 'Bounding Box';            
-list.seg{12,3} = 'double';
-list.seg{13,1} = 'background_subtract'; list.seg{13,2} = 'Subtraction of the background';           
-list.seg{13,3} = 'double';
-list.seg{14,1} = 'overlaps_removed';    list.seg{14,2} = 'Removing of overlaps';            
-list.seg{14,3} = 'logical';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% MATCHING - CALIBRATION structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%match_calib = gtMatchDefaultParametersCalib;
-match_calib.thr_ang          = NaN;
-match_calib.thr_ang_scale    = NaN;
-match_calib.thr_max_offset   = NaN;
-match_calib.thr_ext_offset   = NaN;
-match_calib.thr_genim_offset = NaN;
-match_calib.corr_rot_to_det  = NaN;
-match_calib.thr_for_corr     = NaN;
-match_calib.thr_goodness     = NaN;
-match_calib.thr_intint       = NaN;
-match_calib.thr_area         = NaN;
-match_calib.thr_bbsize       = NaN;
-match_calib.minsizeX         = NaN;
-match_calib.minsizeY         = NaN;
-match_calib.tiltY            = NaN;
-match_calib.tiltZ            = NaN;
-match_calib.centmode         = NaN;
-match_calib.addconstr        = NaN;
-match_calib.theta_bounds     = NaN;
-
-list.match_calib{1,1}  = 'thr_ang';             list.match_calib{1,2}  = '';                list.match_calib{1,3}  = 'double';
-list.match_calib{2,1}  = 'thr_ang_scale';       list.match_calib{2,2}  = '';                list.match_calib{2,3}  = 'double';
-list.match_calib{3,1}  = 'thr_max_offset';      list.match_calib{3,2}  = '';                list.match_calib{3,3}  = 'double';
-list.match_calib{4,1}  = 'thr_ext_offset';      list.match_calib{4,2}  = '';                list.match_calib{4,3}  = 'double';
-list.match_calib{5,1}  = 'thr_genim_offset';    list.match_calib{5,2}  = '';                list.match_calib{5,3}  = 'double';
-list.match_calib{6,1}  = 'corr_rot_to_det';     list.match_calib{6,2}  = '';                list.match_calib{6,3}  = 'double';
-list.match_calib{7,1}  = 'thr_for_corr';        list.match_calib{7,2}  = '';                list.match_calib{7,3}  = 'double';
-list.match_calib{8,1}  = 'thr_goodness';        list.match_calib{8,2}  = '';                list.match_calib{8,3}  = 'double';
-list.match_calib{9,1}  = 'thr_intint';          list.match_calib{9,2}  = '';                list.match_calib{9,3}  = 'double';
-list.match_calib{10,1} = 'thr_area';            list.match_calib{10,2} = '';                list.match_calib{10,3} = 'double';
-list.match_calib{11,1} = 'thr_bbsize';          list.match_calib{11,2} = '';                list.match_calib{11,3} = 'double';
-list.match_calib{12,1} = 'minsizeX';            list.match_calib{12,2} = '';                list.match_calib{12,3} = 'double';
-list.match_calib{13,1} = 'minsizeY';            list.match_calib{13,2} = '';                list.match_calib{13,3} = 'double';
-list.match_calib{14,1} = 'tiltY';               list.match_calib{14,2} = '';                list.match_calib{14,3} = 'double';
-list.match_calib{15,1} = 'tiltZ';               list.match_calib{15,2} = '';                list.match_calib{15,3} = 'double';
-list.match_calib{16,1} = 'centmode';            list.match_calib{16,2} = '';                list.match_calib{16,3} = 'double';
-list.match_calib{17,1} = 'addconstr';           list.match_calib{17,2} = '';                list.match_calib{17,3} = 'double';
-list.match_calib{18,1} = 'theta_bounds';        list.match_calib{18,2} = '';                list.match_calib{18,3} = 'double';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% MATCHING structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%match = gtMatchDefaultParameters;
-match.thr_ang          = NaN;
-match.thr_ang_scale    = NaN;
-match.thr_max_offset   = NaN;
-match.thr_ext_offset   = NaN;
-match.thr_genim_offset = NaN;
-match.corr_rot_to_det  = NaN;
-match.thr_for_corr     = NaN;
-match.thr_goodness     = NaN;
-match.thr_intint       = NaN;
-match.thr_area         = NaN;
-match.thr_bbsize       = NaN;
-match.minsizeX         = NaN;
-match.minsizeY         = NaN;
-match.tiltY            = NaN;
-match.tiltZ            = NaN;
-match.centmode         = NaN;
-match.addconstr        = NaN;
-
-list.match{1,1}  = 'thr_ang';           list.match{1,2}  = '';                list.match{1,3}  = 'double';
-list.match{2,1}  = 'thr_ang_scale';     list.match{2,2}  = '';                list.match{2,3}  = 'double';
-list.match{3,1}  = 'thr_max_offset';    list.match{3,2}  = '';                list.match{3,3}  = 'double';
-list.match{4,1}  = 'thr_ext_offset';    list.match{4,2}  = '';                list.match{4,3}  = 'double';
-list.match{5,1}  = 'thr_genim_offset';  list.match{5,2}  = '';                list.match{5,3}  = 'double';
-list.match{6,1}  = 'corr_rot_to_det';   list.match{6,2}  = '';                list.match{6,3}  = 'double';
-list.match{7,1}  = 'thr_for_corr';      list.match{7,2}  = '';                list.match{7,3}  = 'double';
-list.match{8,1}  = 'thr_goodness';      list.match{8,2}  = '';                list.match{8,3}  = 'double';
-list.match{9,1}  = 'thr_intint';        list.match{9,2}  = '';                list.match{9,3}  = 'double';
-list.match{10,1} = 'thr_area';          list.match{10,2} = '';                list.match{10,3} = 'double';
-list.match{11,1} = 'thr_bbsize';        list.match{11,2} = '';                list.match{11,3} = 'double';
-list.match{12,1} = 'minsizeX';          list.match{12,2} = '';                list.match{12,3} = 'double';
-list.match{13,1} = 'minsizeY';          list.match{13,2} = '';                list.match{13,3} = 'double';
-list.match{14,1} = 'tiltY';             list.match{14,2} = '';                list.match{14,3} = 'double';
-list.match{15,1} = 'tiltZ';             list.match{15,2} = '';                list.match{15,3} = 'double';
-list.match{16,1} = 'centmode';          list.match{16,2} = '';                list.match{16,3} = 'double';
-list.match{17,1} = 'addconstr';         list.match{17,2} = '';                list.match{17,3} = 'double';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% INDEXING structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%index.strategy = gtIndexDefaultStrategy;
-index.strategy.iter = NaN;
-index.strategy.r    = NaN;
-index.strategy.s    = NaN; 
-
-list.index.strategy{1,1} = 'iter'; 	list.index.strategy{1,2} = 'Number of iterations';                                        
-list.index.strategy{1,3} = 'double';
-list.index.strategy{2,1} = 'r';    	list.index.strategy{2,2} = 'Tolerance for marking outliers in final grain sets (in std)'; 
-list.index.strategy{2,3} = 'double';
-list.index.strategy{3,1} = 's';    	list.index.strategy{3,2} = 'Tolerance for marking outliers in final grain sets (in std)'; 
-list.index.strategy{3,3} = 'double';
-
-% Tolerances for building grains in the first iteration:
-index.strategy.b.beg.ang     = NaN;    
-index.strategy.b.beg.int     = NaN;    
-index.strategy.b.beg.bbxs    = NaN;    
-index.strategy.b.beg.bbys    = NaN;    
-index.strategy.b.beg.distsf  = NaN;    
-index.strategy.b.beg.distmax = NaN;  
-index.strategy.b.beg.ming    = NaN;      
-index.strategy.b.beg.geo     = NaN;
-
-list.index.strategy.b.beg{1,1} = 'ang';              list.index.strategy.b.beg{1,2} = 'angular difference in degrees';    	
-list.index.strategy.b.beg{1,3} = 'double';
-list.index.strategy.b.beg{2,1} = 'int';              list.index.strategy.b.beg{2,2} = 'max. intensity ratio';         		
-list.index.strategy.b.beg{2,3} = 'double';
-list.index.strategy.b.beg{3,1} = 'bbxs';             list.index.strategy.b.beg{3,2} = 'max. bbox x size ratio';           	
-list.index.strategy.b.beg{3,3} = 'double';
-list.index.strategy.b.beg{4,1} = 'bbys';             list.index.strategy.b.beg{4,2} = 'max. bbox y size ratio';           	
-list.index.strategy.b.beg{4,3} = 'double';
-list.index.strategy.b.beg{5,1} = 'distsf';           list.index.strategy.b.beg{5,2} = 'size factor for maximum distance'; 	
-list.index.strategy.b.beg{5,3} = 'double';
-list.index.strategy.b.beg{6,1} = 'distmax';          list.index.strategy.b.beg{6,2} = 'max. absolut distance';            	
-list.index.strategy.b.beg{6,3} = 'double';
-list.index.strategy.b.beg{7,1} = 'ming';             list.index.strategy.b.beg{7,2} = 'min. no. of Friedel pairs in a grain';     
-list.index.strategy.b.beg{7,3} = 'double';
-list.index.strategy.b.beg{8,1} = 'geo';              list.index.strategy.b.beg{8,2} = 'safety margin around sample volume';       
-list.index.strategy.b.beg{8,3} = 'double';
-
-% Tolerances for building grains in the last iteration:
-index.strategy.b.end.ang     = NaN;    
-index.strategy.b.end.int     = NaN;    
-index.strategy.b.end.bbxs    = NaN;    
-index.strategy.b.end.bbys    = NaN;    
-index.strategy.b.end.distsf  = NaN;    
-index.strategy.b.end.distmax = NaN;  
-index.strategy.b.end.ming    = NaN;      
-index.strategy.b.end.geo     = NaN;
-
-list.index.strategy.b.end{1,1} = 'ang';              list.index.strategy.b.end{1,2} = 'angular difference in degrees';    	
-list.index.strategy.b.end{1,3} = 'double';
-list.index.strategy.b.end{2,1} = 'int';              list.index.strategy.b.end{2,2} = 'max. intensity ratio';         		
-list.index.strategy.b.end{2,3} = 'double';
-list.index.strategy.b.end{3,1} = 'bbxs';             list.index.strategy.b.end{3,2} = 'max. bbox x size ratio';           	
-list.index.strategy.b.end{3,3} = 'double';
-list.index.strategy.b.end{4,1} = 'bbys';             list.index.strategy.b.end{4,2} = 'max. bbox y size ratio';           	
-list.index.strategy.b.end{4,3} = 'double';
-list.index.strategy.b.end{5,1} = 'distsf';           list.index.strategy.b.end{5,2} = 'size factor for maximum distance'; 	
-list.index.strategy.b.end{5,3} = 'double';
-list.index.strategy.b.end{6,1} = 'distmax';          list.index.strategy.b.end{6,2} = 'max. absolut distance';            	
-list.index.strategy.b.end{6,3} = 'double';
-list.index.strategy.b.end{7,1} = 'ming';             list.index.strategy.b.end{7,2} = 'min. no. of Friedel pairs in a grain';     
-list.index.strategy.b.end{7,3} = 'double';
-list.index.strategy.b.end{8,1} = 'geo';              list.index.strategy.b.end{8,2} = 'safety margin around sample volume';       
-list.index.strategy.b.end{8,3} = 'double';
-
-
-% Tolerances for merging grains in the first iteration:
-index.strategy.m.beg.bbxs   = NaN;   
-index.strategy.m.beg.bbys   = NaN;   
-index.strategy.m.beg.distsf = NaN;                
-index.strategy.m.beg.int    = NaN;   
-
-list.index.strategy.m.beg{1,1} = 'bbxs';             list.index.strategy.m.beg{1,2} = 'max. bbox x size ratio';         		
-list.index.strategy.m.beg{1,3} = 'double';
-list.index.strategy.m.beg{2,1} = 'bbys';             list.index.strategy.m.beg{2,2} = 'max. bbox y size ratio';         		
-list.index.strategy.m.beg{2,3} = 'double';
-list.index.strategy.m.beg{3,1} = 'distsf';           list.index.strategy.m.beg{3,2} = 'size factor for maximum distance';         
-list.index.strategy.m.beg{3,3} = 'double';
-list.index.strategy.m.beg{4,1} = 'int';              list.index.strategy.m.beg{4,2} = 'max. intensity ratio';         		
-list.index.strategy.m.beg{4,3} = 'double';
-
-% Tolerances for merging grains in the last iteration:
-index.strategy.m.end.bbxs   = NaN;   
-index.strategy.m.end.bbys   = NaN;   
-index.strategy.m.end.distsf = NaN;                
-index.strategy.m.end.int    = NaN;   
-
-list.index.strategy.m.end{1,1} = 'bbxs';             list.index.strategy.m.end{1,2} = 'max. bbox x size ratio';         		
-list.index.strategy.m.end{1,3} = 'double';
-list.index.strategy.m.end{2,1} = 'bbys';             list.index.strategy.m.end{2,2} = 'max. bbox y size ratio';         	
-list.index.strategy.m.end{2,3} = 'double';
-list.index.strategy.m.end{3,1} = 'distsf';           list.index.strategy.m.end{3,2} = 'size factor for maximum distance';         
-list.index.strategy.m.end{3,3} = 'double';
-list.index.strategy.m.end{4,1} = 'int';              list.index.strategy.m.end{4,2} = 'max. intensity ratio';         		
-list.index.strategy.m.end{4,3} = 'double';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% RECONSTRUCTION structure
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-rec.ROI                     = '';
-rec.select_projections_auto = false;
-rec.do_forward_simulation   = false;
-rec.do_reconstruction       = false; 
-rec.update_db               = false;
-rec.show_results            = false;
-rec.use_extspots            = false;
-rec.percentile1             = NaN;
-rec.percentile2             = NaN;
-
-list.rec{1,1} = 'ROI';                          list.rec{1,2} = 'Region Of Interest';       	list.rec{1,3} = 'char';
-list.rec{2,1} = 'select_projections_auto';  	list.rec{2,2} = '';                             list.rec{2,3} = 'double';
-list.rec{3,1} = 'do_forward_simulation';    	list.rec{3,2} = 'Do forward simulation';    	list.rec{3,3} = 'double';
-list.rec{4,1} = 'update_db';                	list.rec{4,2} = 'Do reconstruction';        	list.rec{4,3} = 'double';
-list.rec{5,1} = 'show_results';             	list.rec{5,2} = 'Update database';          	list.rec{5,3} = 'double';
-list.rec{6,1} = 'use_extspots';             	list.rec{6,2} = 'Show results';             	list.rec{6,3} = 'double';
-list.rec{7,1} = 'percentile1';              	list.rec{7,2} = 'Use extension spots';      	list.rec{7,3} = 'double';
-list.rec{8,1} = 'percentile2';              	list.rec{8,2} = '';                             list.rec{8,3} = 'double';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% BUILDING TOGETHER
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-parameters.acq         = acq;
-parameters.cryst       = cryst;
-parameters.xop         = xop;
-parameters.geo         = geo;
-parameters.opt         = opt;
-parameters.prep        = prep;
-parameters.seg         = seg;
-parameters.match_calib = match_calib;
-parameters.match       = match;
-parameters.index       = index;
-parameters.rec         = rec;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% SAVING 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-save('/data/id11/graintracking/HowTo/template_parameters.mat','parameters','-v7.3');
-save('/data/id11/graintracking/HowTo/template_list.mat','list','-v7.3');
-
-disp('Saved parameters template in /data/id11/graintracking/HowTo/template_parameters.mat')
-disp('Saved parameters fields list in /data/id11/graintracking/HowTo/template_list.mat')
-
diff --git a/zUtil_Parameters/make_parameters.m b/zUtil_Parameters/make_parameters.m
index c2f22fad..bb571fe4 100644
--- a/zUtil_Parameters/make_parameters.m
+++ b/zUtil_Parameters/make_parameters.m
@@ -18,7 +18,7 @@ function [parameters, list] = make_parameters(version)
 %
 %
 %     FUNCTIONS CALLED:
-%[use]- complete_structure
+%[use]- build_list
 %[use]- build_structure_v0
 
 disp('Getting the field list of parameters...')
-- 
GitLab