Skip to content
Snippets Groups Projects
Commit e663fc29 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

6D-Clusters: added more customization options to Cluter creation function

parent 8af10980
No related branches found
No related tags found
No related merge requests found
function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_id, varargin) function [refor, estim_space_bbox_pix, estim_orient_bbox_rod] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_id, varargin)
% FUNCTION [proj, refor, or] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_id, varargin) % FUNCTION [proj, refor, or] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_id, varargin)
% proj: is a grain.proj structure % proj: is a grain.proj structure
% refor: is a grain structure for the average orientation in the average % refor: is a grain structure for the average orientation in the average
...@@ -15,6 +15,8 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -15,6 +15,8 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
'min_eta', 15, ... 'min_eta', 15, ...
'det_index', 1, ... 'det_index', 1, ...
'ospace_oversize', 1.1, ... 'ospace_oversize', 1.1, ...
'rspace_oversize', 1, ...
'stack_oversize', 1.4, ...
'save', true, ... 'save', true, ...
'cluster_type', 0, ... 'cluster_type', 0, ...
'active', true); 'active', true);
...@@ -66,7 +68,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -66,7 +68,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
fwdsim_sel_refl = ref_ondet(ref_included(ref_selected)); fwdsim_sel_refl = ref_ondet(ref_included(ref_selected));
% Real-space volume size % Real-space volume size
[gr_center_pix, bbox_size_pix, estim_space_bbox_pix] = gt6DMergeRealSpaceVolumes(grs, conf.det_index); [gr_center_pix, bbox_size_pix, estim_space_bbox_pix] = gt6DMergeRealSpaceVolumes(grs, conf.det_index, conf.rspace_oversize);
gr_center_mm = gtGeoSam2Sam(gr_center_pix, p.recgeo, p.samgeo, false, false); gr_center_mm = gtGeoSam2Sam(gr_center_pix, p.recgeo, p.samgeo, false, false);
estim_space_bbox_mm = [ ... estim_space_bbox_mm = [ ...
...@@ -81,15 +83,15 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -81,15 +83,15 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
odfw_R_vectors{ii_g} = sampler.guess_ODF_BB()'; odfw_R_vectors{ii_g} = sampler.guess_ODF_BB()';
end end
r_vecs = cat(1, odfw_R_vectors{:}); r_vecs = cat(1, odfw_R_vectors{:});
estim_orient_bbox = [min(r_vecs, [], 1), max(r_vecs, [], 1)]; estim_orient_bbox_rod = [min(r_vecs, [], 1), max(r_vecs, [], 1)];
bbox_size_rod = estim_orient_bbox(4:6) - estim_orient_bbox(1:3); bbox_size_rod = estim_orient_bbox_rod(4:6) - estim_orient_bbox_rod(1:3);
% oversizing the orienation BB a bit % oversizing the orienation BB a bit
delta_bbox_size_rod = bbox_size_rod * (conf.ospace_oversize - 1) / 2; delta_bbox_size_rod = bbox_size_rod * (conf.ospace_oversize - 1) / 2;
estim_orient_bbox = estim_orient_bbox + [-delta_bbox_size_rod, delta_bbox_size_rod]; estim_orient_bbox_rod = estim_orient_bbox_rod + [-delta_bbox_size_rod, delta_bbox_size_rod];
bbox_size_rod = estim_orient_bbox(4:6) - estim_orient_bbox(1:3); bbox_size_rod = estim_orient_bbox_rod(4:6) - estim_orient_bbox_rod(1:3);
gr_center_rod = (estim_orient_bbox(4:6) + estim_orient_bbox(1:3)) / 2; gr_center_rod = (estim_orient_bbox_rod(4:6) + estim_orient_bbox_rod(1:3)) / 2;
bbox_size_deg = 2 * atand(bbox_size_rod); bbox_size_deg = 2 * atand(bbox_size_rod);
...@@ -97,9 +99,12 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -97,9 +99,12 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
f = figure(); f = figure();
ax = axes('parent', f); ax = axes('parent', f);
hold(ax, 'on'); hold(ax, 'on');
gt6DPlotOrientationBBox(ax, [estim_orient_bbox(1:3); estim_orient_bbox(4:6)]); gt6DPlotOrientationBBox(ax, [estim_orient_bbox_rod(1:3); estim_orient_bbox_rod(4:6)]);
for ii_g = 1:num_grains for ii_g = 1:num_grains
scatter3(ax, grs(ii_g).R_vector(1), grs(ii_g).R_vector(2), grs(ii_g).R_vector(3), 30); scatter3(ax, grs(ii_g).R_vector(1), grs(ii_g).R_vector(2), grs(ii_g).R_vector(3), 30);
grain_r_vecs = odfw_R_vectors{ii_g};
grain_orient_bbox_rod = [min(grain_r_vecs, [], 1), max(grain_r_vecs, [], 1)];
gt6DPlotOrientationBBox(ax, [grain_orient_bbox_rod(1:3); grain_orient_bbox_rod(4:6)]);
end end
hold(ax, 'off'); hold(ax, 'off');
...@@ -109,7 +114,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -109,7 +114,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
fprintf('Estimated spatial voxel BBox: [%3d, %3d, %3d] -> [%3d, %3d, %3d]\n', estim_space_bbox_pix); fprintf('Estimated spatial voxel BBox: [%3d, %3d, %3d] -> [%3d, %3d, %3d]\n', estim_space_bbox_pix);
fprintf(' BBox size: %3d, %3d, %3d (%f, %f, %f mm)\n', bbox_size_pix, bbox_size_mm); fprintf(' BBox size: %3d, %3d, %3d (%f, %f, %f mm)\n', bbox_size_pix, bbox_size_mm);
fprintf(' Estimated orientation BBox: [%3.3f, %3.3f, %3.3f] -> [%3.3f, %3.3f, %3.3f]\n', estim_orient_bbox); fprintf(' Estimated orientation BBox: [%3.3f, %3.3f, %3.3f] -> [%3.3f, %3.3f, %3.3f]\n', estim_orient_bbox_rod);
fprintf(' BBox size: %3.3f, %3.3f, %3.3f (deg)\n', bbox_size_deg); fprintf(' BBox size: %3.3f, %3.3f, %3.3f (deg)\n', bbox_size_deg);
fprintf('\n'); fprintf('\n');
end end
...@@ -119,7 +124,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -119,7 +124,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
% orientation bb. % orientation bb.
ors = gt6DCalculateFullSpaceCorners( ... ors = gt6DCalculateFullSpaceCorners( ...
estim_space_bbox_mm, bbox_size_mm, ... estim_space_bbox_mm, bbox_size_mm, ...
estim_orient_bbox, bbox_size_rod, ... estim_orient_bbox_rod, bbox_size_rod, ...
refgr, p); refgr, p);
or_abs = cat(1, ors(:).allblobs); or_abs = cat(1, ors(:).allblobs);
...@@ -150,15 +155,15 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -150,15 +155,15 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
img_sizes = img_bboxes(:, 4:6) - img_bboxes(:, 1:3) + 1; img_sizes = img_bboxes(:, 4:6) - img_bboxes(:, 1:3) + 1;
if (conf.verbose) if (conf.verbose)
fprintf('du %8d, dv %8d, dw %8d, eta: %7.3f <- used: %d, u: [%4d %4d], v: [%4d %4d], w: [%4d %4d]\n', ... fprintf('%2d) du %8d, dv %8d, dw %8d, eta: %7.3f <- used: %d, u: [%4d %4d], v: [%4d %4d], w: [%4d %4d]\n', ...
[img_sizes, refor_ns, ~inconvenient_etas, img_bboxes(:, [1 4 2 5 3 6]) ]'); [(1:numel(fwdsim_sel_refl))', img_sizes, refor_ns, ~inconvenient_etas, img_bboxes(:, [1 4 2 5 3 6]) ]');
end end
img_bboxes = img_bboxes(~inconvenient_etas, :); img_bboxes = img_bboxes(~inconvenient_etas, :);
img_sizes = img_sizes(~inconvenient_etas, :); img_sizes = img_sizes(~inconvenient_etas, :);
max_img_sizes = [max(img_sizes(:, 1)), max(img_sizes(:, 2))]; max_img_sizes = [max(img_sizes(:, 1)), max(img_sizes(:, 2))];
stack_imgs_oversize = min(p.fsim.oversize, 1.4); stack_imgs_oversize = min(p.fsim.oversize, conf.stack_oversize);
stackUSize = round(max_img_sizes(1) * stack_imgs_oversize); stackUSize = round(max_img_sizes(1) * stack_imgs_oversize);
stackVSize = round(max_img_sizes(2) * stack_imgs_oversize); stackVSize = round(max_img_sizes(2) * stack_imgs_oversize);
...@@ -273,7 +278,8 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -273,7 +278,8 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
proj.centerpix = gr_center_pix; proj.centerpix = gr_center_pix;
proj.bl = blobs; proj.bl = blobs;
proj.stack = spots; proj.stack = spots;
vol_size = bbox_size_pix + mean(bbox_size_pix) * 0.3; vol_size = bbox_size_pix;
% vol_size = bbox_size_pix + mean(bbox_size_pix) * 0.3;
proj.vol_size_x = vol_size(2); proj.vol_size_x = vol_size(2);
proj.vol_size_y = vol_size(1); proj.vol_size_y = vol_size(1);
proj.vol_size_z = vol_size(3); proj.vol_size_z = vol_size(3);
...@@ -300,7 +306,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr ...@@ -300,7 +306,7 @@ function [refor, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDataFr
fprintf('Saving to sample.mat..') fprintf('Saving to sample.mat..')
sample = GtSample.loadFromFile(); sample = GtSample.loadFromFile();
cl_info = GtPhase.makeCluster(grs_list, refor.R_vector, ... cl_info = GtPhase.makeCluster(grs_list, refor.R_vector, ...
estim_space_bbox_pix, estim_orient_bbox, conf.cluster_type, conf.active); estim_space_bbox_pix, estim_orient_bbox_rod, conf.cluster_type, conf.active);
sample.phases{phase_id}.setClusterInfo(grs_list, cl_info); sample.phases{phase_id}.setClusterInfo(grs_list, cl_info);
sample.saveToFile(); sample.saveToFile();
fprintf('\b\b: Done.\n') fprintf('\b\b: Done.\n')
......
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