From 4eac6426e5abc99db7b37443983ec7ff3f55deb5 Mon Sep 17 00:00:00 2001 From: Wolfgang Ludwig <wolfgang.ludwig@esrf.fr> Date: Thu, 18 Jan 2018 10:06:58 +0100 Subject: [PATCH] fixing grain Thresholing on OAR; couple of small fixes Signed-off-by: Wolfgang Ludwig <wolfgang.ludwig@esrf.fr> --- 1_preprocessing/gtFillCrystFields.m | 6 +++--- 1_preprocessing/gtFindRotationAxis.m | 2 ++ 5_reconstruction/gtAstraReconstructGrain.m | 4 ++++ 5_reconstruction/gtChangeThreshold3D.m | 17 +++++++++++++---- 5_reconstruction/gtReconstructGrains.m | 8 ++++++-- 5_reconstruction/gtSetupReconstruction.m | 13 +------------ 6_rendering/gtDrawGrainUnitCells.m | 3 ++- zUtil_Indexter/gtINDEXMatchGrains.m | 8 ++++++-- zUtil_Python/oar/oar_api.py | 1 + 9 files changed, 38 insertions(+), 24 deletions(-) diff --git a/1_preprocessing/gtFillCrystFields.m b/1_preprocessing/gtFillCrystFields.m index 6d6795c4..f02b8e0a 100644 --- a/1_preprocessing/gtFillCrystFields.m +++ b/1_preprocessing/gtFillCrystFields.m @@ -370,8 +370,8 @@ function cryst = sfUpdateReflections(cryst, energy) cryst.thetasp = asind(0.5*lambda./cryst.dspacingsp); % Update the intensity info: MISSING ! - cryst.int = ones(1, numel(cryst.dspacing); - cryst.intsp = ones(1, numel(cryst.dspacingsp); - cryst.usedfam = true(1, numel(cryst.dspacing); + cryst.int = ones(1, numel(cryst.dspacing)); + cryst.intsp = ones(1, numel(cryst.dspacingsp)); + cryst.usedfam = true(1, numel(cryst.dspacing)); end diff --git a/1_preprocessing/gtFindRotationAxis.m b/1_preprocessing/gtFindRotationAxis.m index af9de586..cdd5f02c 100644 --- a/1_preprocessing/gtFindRotationAxis.m +++ b/1_preprocessing/gtFindRotationAxis.m @@ -25,6 +25,7 @@ try name_next = fullfile(raw_data_dir, sprintf('%s%04d.edf', acq.name, indx_next) ); if exist(name_next,'file') + sprintf('Using images AFTER scan for determination of rotation axis posistion\n') % FIRST CHOICE: IMAGES AFTER SCAN indx_curr = 2*acq.nproj; @@ -32,6 +33,7 @@ try name_ref0 = fullfile(raw_data_dir, sprintf('ref0000_%04d.edf', indx_curr) ); name_ref1 = name_ref0; else + sprintf('Using images DURING scan for determination of rotation axis posistion\n') % SECOND CHOICE: IMAGES DURING SCAN % WL May 2009 % changed to use per default the images at end of scan - should be more accurate; diff --git a/5_reconstruction/gtAstraReconstructGrain.m b/5_reconstruction/gtAstraReconstructGrain.m index 67d20eee..559d0c31 100644 --- a/5_reconstruction/gtAstraReconstructGrain.m +++ b/5_reconstruction/gtAstraReconstructGrain.m @@ -31,6 +31,10 @@ function varargout = gtAstraReconstructGrain(grainID, phaseID, parameters) gr_extra = gtLoadGrain(phaseID, grainID, 'fields', {'selected'}); gr.proj.selected = gr_extra.selected; end + if isempty(find(gr.proj.selected)) + warning('No projection has been selected - skipping grain') + return + end gr.proj.num_iter = rec_opts.num_iter; gr.proj.stack = gr.proj.stack(:, gr.proj.selected, :); diff --git a/5_reconstruction/gtChangeThreshold3D.m b/5_reconstruction/gtChangeThreshold3D.m index dcbe41bd..263a14aa 100644 --- a/5_reconstruction/gtChangeThreshold3D.m +++ b/5_reconstruction/gtChangeThreshold3D.m @@ -1,4 +1,4 @@ -function [varargout] = gtChangeThreshold3D(firstID, lastID, ~, phaseID, parameters, varargin) +function [varargout] = gtChangeThreshold3D(firstID, lastID, ~, phaseID, ~, varargin) % GTCHANGETHRESHOLD3D % seg = gtChangeThreshold3D(firstID, lastID, ~, phaseID, varargin) % ---------------------------------------------------------------- @@ -11,6 +11,9 @@ function [varargout] = gtChangeThreshold3D(firstID, lastID, ~, phaseID, paramete % varargin = to modify parameters.rec % + args = struct('list', [], 'verbose', false); + args = parse_pv_pairs(args, varargin); + if (isdeployed) global GT_DB global GT_MATLAB_HOME @@ -23,14 +26,20 @@ function [varargout] = gtChangeThreshold3D(firstID, lastID, ~, phaseID, paramete warning('OAR:unexpected_behavior', ... 'We should expect only strings from shell environment') end + + args.list = str2num(args.list); %#ok<ST2NM> end + % This handles OAR's habbit of passing lists of IDs in a field called + % 'list' + args.grain_ids = args.list; + args = rmfield(args, 'list'); - args = [varargin, 'verbose', false]; + args = [fieldnames(args), struct2cell(args)]'; thresh = GtThreshold(args{:}); - if (nargin >= 1) + if (nargout >= 1) varargout{1} = thresh.batchThreshold(phaseID, firstID, lastID); else - thresh.batchThreshold(phaseID, firstID, lastID) + thresh.batchThreshold(phaseID, firstID, lastID); end end diff --git a/5_reconstruction/gtReconstructGrains.m b/5_reconstruction/gtReconstructGrains.m index e4542458..dfadeab7 100644 --- a/5_reconstruction/gtReconstructGrains.m +++ b/5_reconstruction/gtReconstructGrains.m @@ -96,8 +96,12 @@ function gtReconstructGrains(first, last, workingdirectory, phaseID, parameters, gtReconstructGrainOrientation(gr_id, phaseID, parameters); end if (~isdeployed) - t.singleGrainAutoThreshold(phaseID, gr_id); - fprintf(repmat('\b', [1 num_chars])) + try + t.singleGrainAutoThreshold(phaseID, gr_id); + fprintf(repmat('\b', [1 num_chars])) + catch + sprintf('Segmentation of grain %d failed - check reconstruction!', gr_id) + end end end fprintf('Done (in %f seconds).\n', toc(c)) diff --git a/5_reconstruction/gtSetupReconstruction.m b/5_reconstruction/gtSetupReconstruction.m index a21f11b0..44fbba42 100644 --- a/5_reconstruction/gtSetupReconstruction.m +++ b/5_reconstruction/gtSetupReconstruction.m @@ -177,18 +177,7 @@ if (~isempty(conf.grain_ids)) launch_on_OAR('gtChangeThreshold3D', first, last, ... phaseID_str, parameters, 'core', 4, 'distribute', true, 'list', conf.grain_ids); else - if isempty(conf.grain_ids) - gtChangeThreshold3D(first, last, [], phase_id); - else - t=GtThreshold(); - for i = 1 : numel(conf.grain_ids) - if sample.phases{phase_id}.getSelected(conf.grain_ids(i)) - t.singleGrainAutoThreshold(phase_id, conf.grain_ids(i)); - else - sprintf('skipping deselected grain %d\n',conf.grain_ids(i)) - end - end - end + gtChangeThreshold3D(first, last, [], phase_id, [], 'list', conf.grain_ids); end end end diff --git a/6_rendering/gtDrawGrainUnitCells.m b/6_rendering/gtDrawGrainUnitCells.m index 8a618b87..1e919eba 100644 --- a/6_rendering/gtDrawGrainUnitCells.m +++ b/6_rendering/gtDrawGrainUnitCells.m @@ -98,8 +98,9 @@ app.linecolor = app.linecolor(1:numel(grains)); parameters = []; load('parameters.mat'); labgeo = parameters.labgeo; +detgeo = parameters.detgeo; if isempty(app.pxsize{1}) - app.pxsize{1} = (labgeo.pixelsizeu + labgeo.pixelsizev)/2; + app.pxsize{1} = (detgeo.pixelsizeu + detgeo.pixelsizev)/2; end if isempty(app.hf) diff --git a/zUtil_Indexter/gtINDEXMatchGrains.m b/zUtil_Indexter/gtINDEXMatchGrains.m index 6b2b5cac..2a282608 100644 --- a/zUtil_Indexter/gtINDEXMatchGrains.m +++ b/zUtil_Indexter/gtINDEXMatchGrains.m @@ -1,4 +1,4 @@ -function [match, dev, dcm, drotm, conflicts, toBeChecked] = gtINDEXMatchGrains(... +function [match, dev, dcm, drotm, conflicts, toBeChecked, tol] = gtINDEXMatchGrains(... grain1, grain2, ph1, dc, drot, tol) % GTINDEXMATCHGRAINS Matches multiple indexed grains between two datasets; % can also be used to find unmerged grains. @@ -178,7 +178,7 @@ disp('Loading pixelsize and crystallographic info from parameters.mat ...') parameters = []; load parameters cryst = parameters.cryst(ph1); -pixsize = 0.5*(parameters.labgeo.pixelsizeu + parameters.labgeo.pixelsizev); +pixsize = 0.5*(parameters.detgeo.pixelsizeu + parameters.detgeo.pixelsizev); match = NaN(nof_grains1,2); @@ -224,6 +224,10 @@ dev.rot = NaN(3,3,nof_grains1); % Extension to Rodrigues fundamental zone % Rext = 0; Rext = tol.Rdist; +spacegroup = cryst.spacegroup; +fzone_acc = gtCrystRodriguesFundZone(spacegroup,0); +fzone_ext = gtCrystRodriguesFundZone(spacegroup,Rext); + if (any(gtIndexAllGrainValues(grain1,'R_onedge',[],1,[])) || ~isempty(drot)) diff --git a/zUtil_Python/oar/oar_api.py b/zUtil_Python/oar/oar_api.py index 1c9bb50f..a3c6b683 100755 --- a/zUtil_Python/oar/oar_api.py +++ b/zUtil_Python/oar/oar_api.py @@ -17,6 +17,7 @@ except ImportError as exc: from yaml import YamlLoader try: + raise ImportError('requests has been disabled') import requests from requests.exceptions import ConnectionError, HTTPError from urllib2 import URLError -- GitLab