Skip to content
Snippets Groups Projects
Commit 362e0c6b authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

Twins forward Simulation : try to improve the functionalities


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

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@996 4c865b51-4357-4376-afb4-474e03ccb993
parent e8dfe33a
No related branches found
No related tags found
No related merge requests found
function grain = gtTwinForwardSimulate(first, last, workingdirectory, phaseID, grain, varargin) function grain = gtTwinForwardSimulate(phaseID, grain, varargin)
% GTTWINFORWARDSIMULATE Finds diffraction spots in the database relative to the twin variant % GTTWINFORWARDSIMULATE Finds diffraction spots in the database relative to the twin variant
% grain = gtTwinForwardSimulate(first, last, workingdirectory, phaseID, grain, varargin) % grain = gtTwinForwardSimulate(phaseID, grain, varargin)
% -------------------------------------------------------------------------------------- % --------------------------------------------------------------------------------------
% %
% INPUT: % INPUT:
% first = <int> first grainid
% last = <int> last grainid
% workingdirectory = <string> working directory
% phaseID = <int> phase number {1} % phaseID = <int> phase number {1}
% grain = <struct> grain structure with fields % grain = <struct> grain structure of interest
% %
% OPTIONAL INPUT (varargin): % OPTIONAL INPUT (varargin):
% bb_size = <int> size of search area ([] will use default projection size) % save_grain = <logical> flag to save or not the twins_####.mat
% assemble_figure = <logical> collects all difspots and assembles them into a fullimage % variantIDs = <double> array of ID for variants {all}
% save_grain = <logical> flag to save or not the twins_####_##.mat
% %
% OUTPUT: % OUTPUT:
% grain = cell structure with fields for each variant: % grain = cell structure with fields for each variant:
...@@ -39,7 +35,6 @@ if isdeployed ...@@ -39,7 +35,6 @@ if isdeployed
load('workspaceGlobal.mat'); load('workspaceGlobal.mat');
end end
cd(workingdirectory);
gtDBConnect(); gtDBConnect();
parameters = []; parameters = [];
...@@ -56,11 +51,13 @@ end ...@@ -56,11 +51,13 @@ end
if isdeployed if isdeployed
phaseID = str2double(phaseID); phaseID = str2double(phaseID);
fsim.display_figure = false; fsim.display_figure = false;
else
% in interactive mode we can modify parameters
fsim = parse_pv_pairs(fsim, varargin);
end end
app.save_grain = false;
app.variantIDs = 1:length(grain.g_twins);
app = parse_pv_pairs(app, varargin);
difspotfile = '2_difspot/difspot00001.edf'; difspotfile = '2_difspot/difspot00001.edf';
if exist(difspotfile, 'file'); if exist(difspotfile, 'file');
info = edf_info(difspotfile); info = edf_info(difspotfile);
...@@ -98,15 +95,15 @@ mymcmd = sprintf(['SELECT difspotID, CentroidX, CentroidY, CentroidImage, '... ...@@ -98,15 +95,15 @@ mymcmd = sprintf(['SELECT difspotID, CentroidX, CentroidY, CentroidImage, '...
allspots.BoundingBoxYsizes, allspots.BoundingBoxXorigins, allspots.BoundingBoxYorigins] = mym(mymcmd); allspots.BoundingBoxYsizes, allspots.BoundingBoxXorigins, allspots.BoundingBoxYorigins] = mym(mymcmd);
gr = grain;
% loop over the variants % loop over the variants
for kk=1:length(gr.g_twins)
for kk=app.variantIDs
fprintf('\nRunning forward simulation for variant %d ...\n',kk); fprintf('\nRunning forward simulation for variant %d ...\n',kk);
variant = gr.g_twins(kk); variant = grain.g_twins(kk);
% assume same center for parent and twin % assume same center for parent and twin
graincenter = gr.center ./ pixelsize; % graincenter contains COM coordinates in pixels graincenter = grain.center ./ pixelsize; % graincenter contains COM coordinates in pixels
out.g = variant.g; out.g = variant.g;
out.R_vector = variant.R_vector; out.R_vector = variant.R_vector;
...@@ -114,15 +111,11 @@ for kk=1:length(gr.g_twins) ...@@ -114,15 +111,11 @@ for kk=1:length(gr.g_twins)
% define theshold values which will be used during the database search later % define theshold values which will be used during the database search later
dif_Xsize = mean(allspots.BoundingBoxXsizes); dif_Xsize = mean(allspots.BoundingBoxXsizes);
%dif_Xsize = gr.stat.bbxsmean; % average X Size of difspots
dif_Ysize = mean(allspots.BoundingBoxYsizes); dif_Ysize = mean(allspots.BoundingBoxYsizes);
%dif_Ysize = gr.stat.bbysmean; % average Y Size of difspots
% take the biggest spot and add a relative extra margin (multiplicative factor oversize) % take the biggest spot and add a relative extra margin (multiplicative factor oversize)
%hsize = round(max(gr.bbxs)*fsim.oversize);
hsize = round(max(allspots.BoundingBoxXsizes)*fsim.oversize); hsize = round(max(allspots.BoundingBoxXsizes)*fsim.oversize);
% ...same for vertical direction % ...same for vertical direction
%vsize = round(max(gr.bbys)*fsim.oversize);
vsize = round(max(allspots.BoundingBoxYsizes)*fsim.oversize); vsize = round(max(allspots.BoundingBoxYsizes)*fsim.oversize);
u = variant.allblobs.uv(:, 1); u = variant.allblobs.uv(:, 1);
...@@ -370,12 +363,12 @@ for kk=1:length(gr.g_twins) ...@@ -370,12 +363,12 @@ for kk=1:length(gr.g_twins)
out.included = flag(included) == 3; out.included = flag(included) == 3;
out.selected = flag(included) == 4;%>= fsim.selected; % vector of logicals with pre-selected spots active out.selected = flag(included) == 4;%>= fsim.selected; % vector of logicals with pre-selected spots active
out.id = gr.id; out.id = grain.id;
out.parent_R_vector = gr.R_vector; out.parent_R_vector = grain.R_vector;
out.phaseid = phaseID; out.phaseid = phaseID;
out.center = graincenter*pixelsize; out.center = graincenter*pixelsize;
out.ondet = ondet; out.ondet = ondet;
out.allblobs = gr.allblobs; out.allblobs = grain.allblobs;
out.full = full; out.full = full;
out.flag = flag; out.flag = flag;
out.status = status; out.status = status;
...@@ -384,7 +377,7 @@ for kk=1:length(gr.g_twins) ...@@ -384,7 +377,7 @@ for kk=1:length(gr.g_twins)
out.difspotID = spotid(included); out.difspotID = spotid(included);
out.omega = omega(included); out.omega = omega(included);
out.hklsp = hklsp(included,:); out.hklsp = hklsp(included,:);
out.uvw = gr.allblobs.uvw(ondet(included),:); out.uvw = grain.allblobs.uvw(ondet(included),:);
out.uv_exp = [U(included), V(included)]; out.uv_exp = [U(included), V(included)];
out.bb = bb(included,:); out.bb = bb(included,:);
out.r_th = r_th(included,:); out.r_th = r_th(included,:);
...@@ -412,16 +405,13 @@ for kk=1:length(gr.g_twins) ...@@ -412,16 +405,13 @@ for kk=1:length(gr.g_twins)
gtShowFsim(out,fsim.Grayscale) gtShowFsim(out,fsim.Grayscale)
end end
gr.g_twins(kk).out = out; grain.g_twins(kk).out = out;
end % loop over the variants end % loop over the variants
grain = gr; if app.save_grain
if fsim.save_grain
filename = fullfile(acq.dir, '4_grains', sprintf('phase_%02d',phaseID), ... filename = fullfile(acq.dir, '4_grains', sprintf('phase_%02d',phaseID), ...
sprintf('twins_%04d.mat', gr.id)); sprintf('twins_%04d.mat', grain.id));
save(filename, 'grain'); save(filename, 'grain');
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment