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

Toptomo: added parameters import function

parent 377fbca9
No related branches found
No related tags found
No related merge requests found
......@@ -5,47 +5,49 @@ function par_acq = gtAcqDefaultParameters(par_acq)
% -----------------------------------------
%
% Version 001 15-05-2012 by LNervo
% Splitted from gtLoadAcquisitionXML()
par_acq.true_detsizeu = 2048;
par_acq.true_detsizev = 2048;
% interlacing parameters
% try to guess whether the scan is interlaced
if exist([par_acq.name '0_0000.edf'], 'file')
par_acq.interlaced_turns = 1; % assume one extra turn is reasonable guess
disp('This looks like an interlaced scan! Doubling nproj...')
par_acq.nproj = par_acq.nproj*2;
else
par_acq.interlaced_turns = 0;
% Split from gtLoadAcquisitionXML()
% is_dct = ismember(lower(par_acq.type), {'360degree', '180degree', 'dct'});
is_dct_360 = ismember(lower(par_acq.type), {'360degree', 'dct'});
par_acq.true_detsizeu = 2048;
par_acq.true_detsizev = 2048;
% interlacing parameters
% try to guess whether the scan is interlaced
if (is_dct_360 && exist([par_acq.name '0_0000.edf'], 'file'))
par_acq.interlaced_turns = 1; % assume one extra turn is reasonable guess
disp('This looks like an interlaced scan! Doubling nproj...')
par_acq.nproj = par_acq.nproj * 2;
else
par_acq.interlaced_turns = 0;
end
% mono tuned during scan? If yes, put the number of ref groups
par_acq.mono_tune = 0;
% if we have a horizontal rotation axis we turn the images during the copying process
par_acq.rotation_axis = 'vertical';
par_acq.distortion = 'none';
% deal with flips and rotations
% subsequently, deal with flips and rotations, scans without direct beam
par_acq.flip_images = false;
par_acq.no_direct_beam = false;
% rotate images to the gt coordinate system !!! Help !!!
par_acq.rotation_direction = 'clockwise';
par_acq.detector_definition = 'inline';
% Images will be shifted in gtCreateFullLive to have rotation axis in center...
par_acq.rotu = par_acq.xdet / 2 + 0.5;
par_acq.rotx = par_acq.rotu;
par_acq.maxradius = max(par_acq.xdet, par_acq.ydet) / 2 * sqrt(2);
par_acq.beamchroma = 'mono';
% if it is 360degree data, we need a pair table
if (is_dct_360)
% pair tablename can be derived from the scan name
par_acq.pair_tablename = [par_acq.name 'spotpairs'];
par_acq.calib_tablename = [par_acq.name 'paircalib'];
end
end
% mono tuned during scan? If yes, put the number of ref groups
par_acq.mono_tune = 0;
% if we have a horizontal rotation axis we turn the images during the copying process
par_acq.rotation_axis = 'vertical';
par_acq.distortion = 'none';
% deal with flips and rotations
% subsequently, deal with flips and rotations, scans without direct beam
par_acq.flip_images = false;
par_acq.no_direct_beam = false;
% rotate images to the gt coordinate system !!! Help !!!
par_acq.rotation_direction = 'clockwise';
par_acq.detector_definition = 'inline';
par_acq.rotu = par_acq.xdet/2+0.5; % Images will be shifted in gtCreateFullLive to have rotation axis in center...
par_acq.rotx = par_acq.rotu;
par_acq.maxradius = max(par_acq.xdet,par_acq.ydet)/2*sqrt(2);
par_acq.beamchroma = 'mono';
% if it is 360degree data, we need a pair table
if strcmpi(par_acq.type, '360degree')
% pair tablename can be derived from the scan name
par_acq.pair_tablename = [par_acq.name 'spotpairs'];
par_acq.calib_tablename = [par_acq.name 'paircalib'];
end
end % end of function
function acq = gtLoadAcquisitionXML(xmlfname, interactive)
function acq = gtLoadAcquisitionXML(xmlfname, interactive, verbose)
% FUNCTION gtLoadAcquisitionXML Try to read the .xml file that may be present
% params_acq = gtLoadAcquisitionXML(xmlfname, interactive)
% --------------------------------------------------------
......@@ -6,11 +6,16 @@ function acq = gtLoadAcquisitionXML(xmlfname, interactive)
% Version 002 15/05/2012 by LNervo
% Split acq parameters from parameters read from xml file
if (~exist('verbose', 'var') || isempty(verbose))
verbose = true;
end
% try to read the .xml file that may be present
acq = [];
if exist(xmlfname,'file')
disp('Reading parameters from xml file');
if (verbose)
disp('Reading parameters from xml file');
end
tmpxml = xml_read(xmlfname);
tmpxml = tmpxml.acquisition;
......
function p = gtGrainTopotomoUpdateParameters(scan_xml, range_basetilt, nproj_basetilt, p, detgeo_tt, pl_ind, gr)
if (~exist('p', 'var') || isempty(p))
p = gtLoadParameters();
end
[tt_scan_dir, ~, ~] = fileparts(scan_xml);
fprintf('Importing Topotomo acquisition into current DCT parameters:\n')
fprintf(' - Path of Topotomo scan: %s\n', tt_scan_dir)
fprintf(' - Path of DCT scan: %s\n', p.acq(1).dir)
if (~isfield(p.acq(1), 'motors'))
fprintf(' - Reading DCT motor positions..')
c = tic();
xmlfname = fullfile(p.acq.dir, '0_rawdata', 'Orig', [p.acq.name '.xml']);
acq_xml = gtLoadAcquisitionXML(xmlfname, false, false);
p.acq(1).motors = acq_xml.motors;
base_acq = make_parameters(2);
base_acq = base_acq.acq;
for ii_a = numel(p.acq):-1:1
new_acq(ii_a) = gtAddMatFile(base_acq, p.acq(ii_a), true);
end
p.acq = new_acq;
fprintf('\b\b: Done in %g seconds.\n', toc(c))
end
acq_tt = p.acq(1);
acq_tt.type = 'topotomo';
fprintf(' - Reading Topotomo acquisition parameters..')
c = tic();
topotomo_xml = gtLoadAcquisitionXML(scan_xml, false, false);
acq_tt = gtAddMatFile(acq_tt, topotomo_xml, true, false, false);
acq_tt = gtAcqDefaultParameters(acq_tt);
fprintf('\b\b: Done in %g seconds.\n', toc(c))
dct_samt = [p.acq(1).motors.samtx, p.acq(1).motors.samty, p.acq(1).motors.samtz];
tt_samt = [acq_tt.motors.samtx, acq_tt.motors.samty, acq_tt.motors.samtz];
dct_samr = [p.acq(1).motors.samry, p.acq(1).motors.samrx];
tt_samr = [acq_tt.motors.samry, acq_tt.motors.samrx];
dct_diffrz_start = p.acq(1).motors.diffrz;
acq_tt.sample_shifts = tt_samt - dct_samt;
% samr X and Y reversed, because the first on the right is the one
% applied first when doing SAM->LAB
acq_tt.sample_tilts = tt_samr - dct_samr;
acq_tt.sample_tilts
acq_tt.range_basetilt = range_basetilt;
acq_tt.nproj_basetilt = nproj_basetilt;
acq_tt.dist = detgeo_tt.detrefpos(1);
p.acq(end+1) = acq_tt;
det_ind = numel(p.acq);
p.detgeo(det_ind) = detgeo_tt;
p.recgeo(det_ind) = p.recgeo(1);
if (~isempty(pl_ind))
p.acq(det_ind).pl_ind = pl_ind;
else
fprintf(' - Guessing Topotomo pl_ind, with respect to DCT (for the range: [%g, %g])..', range_basetilt)
c = tic();
% Trying to detect the tilts
p.diffractometer(det_ind) = gtGeoDiffractometerDefinition('esrf_id11', 'axes_rotation_offset', dct_diffrz_start);
diff = p.diffractometer(det_ind);
tilts = p.acq(det_ind).sample_tilts;
t = gtGeoDiffractometerTensor(diff, 'sam2lab', true, 'angles_sam_tilt', tilts);
pl_samd_sign = gr.allblobs(1).pl;
pl_labd = gtGeoSam2Lab(pl_samd_sign, t, p.labgeo, p.samgeo, true);
angle = gtMathsVectorsAnglesDeg(diff.axes_rotation, pl_labd, false);
fprintf('\b\b: Done in %g seconds.\n', toc(c))
[~, pl_ind] = min(angle);
fprintf(' + Chosen pl_ind: %d (%g deg)\n', pl_ind, angle(pl_ind))
end
end
\ No newline at end of file
function diff = gtGeoDiffractometerDefinition(types)
function diff = gtGeoDiffractometerDefinition(types, varargin)
diff = struct( ...
'axes_basetilt', {zeros(1, 3)}, ...
'axes_rotation', {zeros(1, 3)}, ...
......@@ -6,8 +6,14 @@ function diff = gtGeoDiffractometerDefinition(types)
'origin_basetilt', {zeros(1, 3)}, ...
'origin_rotation', {zeros(1, 3)}, ...
'origin_sam_tilt', {zeros(0, 3)}, ...
'limits_sam_tilt', {zeros(0, 2)}, ...
'shifts_sam_stage', {zeros(0, 3)} );
conf = struct( ...
'axes_rotation_offset', [], ...
'axes_sam_tilt_offset', []);
conf = parse_pv_pairs(conf, varargin);
if (iscell(types))
diff(2:numel(types)) = diff;
for ii = 1:numel(types)
......@@ -21,6 +27,22 @@ function diff = gtGeoDiffractometerDefinition(types)
diff.axes_sam_tilt = [0, 1, 0; 1, 0, 0];
diff.origin_sam_tilt = [0, 0, 0; 0, 0, 0];
diff.limits_sam_tilt = [-15, 15; -20 20];
if (~isempty(conf.axes_sam_tilt_offset))
rot = eye(3);
for ii = (size(diff.axes_sam_tilt, 1)-1):-1:1
rotcomp = gtMathsRotationMatrixComp(diff.axes_sam_tilt(ii, :), 'row');
rot_ii = gtMathsRotationTensor(conf.axes_sam_tilt_offset(ii), rotcomp);
rot = rot * rot_ii;
end
diff.axes_sam_tilt = diff.axes_sam_tilt * rot;
end
if (~isempty(conf.axes_rotation_offset))
rotcomp = gtMathsRotationMatrixComp(diff.axes_rotation, 'row');
rot = gtMathsRotationTensor(conf.axes_rotation_offset, rotcomp);
diff.axes_sam_tilt = diff.axes_sam_tilt * rot;
end
otherwise
error('gtAcqDiffractometerDefinition:wrong_argument', ...
'Unknown diffractometer: %s', types)
......
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