Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
f1905ffe
Commit
f1905ffe
authored
6 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
Topotomo import: updated parameters import function
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
89a4f0c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
4_grains/gtGrainTopotomoUpdateParameters.m
+52
-38
52 additions, 38 deletions
4_grains/gtGrainTopotomoUpdateParameters.m
with
52 additions
and
38 deletions
4_grains/gtGrainTopotomoUpdateParameters.m
+
52
−
38
View file @
f1905ffe
function
p
=
gtGrainTopotomoUpdateParameters
(
scan_xml
,
range_basetilt
,
nproj_basetilt
,
p
,
detgeo_tt
,
pl_ind
,
gr
)
function
p
=
gtGrainTopotomoUpdateParameters
(
scan_xml
,
range_basetilt
,
nproj_basetilt
,
p
,
detgeo_tt
,
pl_ind
,
gr
,
varargin
)
conf
=
struct
(
'check_flips'
,
false
,
'verbose'
,
true
);
conf
=
parse_pv_pairs
(
conf
,
varargin
);
if
(
~
exist
(
'p'
,
'var'
)
||
isempty
(
p
))
p
=
gtLoadParameters
();
end
o
=
GtConditionalOutput
(
conf
.
verbose
);
[
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
)
o
.
fprintf
(
'Importing Topotomo acquisition into current DCT parameters:\n'
)
o
.
fprintf
(
' - Path of Topotomo scan: %s\n'
,
tt_scan_dir
)
o
.
fprintf
(
' - Path of DCT scan: %s\n'
,
p
.
acq
(
1
)
.
dir
)
if
(
~
isfield
(
p
.
acq
(
1
),
'motors'
))
fprintf
(
' - Reading DCT motor positions..'
)
o
.
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
);
...
...
@@ -21,19 +26,20 @@ function p = gtGrainTopotomoUpdateParameters(scan_xml, range_basetilt, nproj_bas
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
))
o
.
fprintf
(
'\b\b: Done in %g seconds.\n'
,
toc
(
c
))
end
acq_tt
=
p
.
acq
(
1
);
fprintf
(
' - Reading Topotomo acquisition parameters..'
)
o
.
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
.
type
=
'topotomo'
;
% The XML tends to set it to 360degree
acq_tt
=
gtAcqDefaultParameters
(
acq_tt
);
acq_tt
.
collection_dir
=
tt_scan_dir
;
fprintf
(
'\b\b: Done in %g seconds.\n'
,
toc
(
c
))
o
.
fprintf
(
'\b\b: Done in %g seconds.\n'
,
toc
(
c
))
if
(
acq_tt
.
energy
<
0
)
disp
(
' '
)
warning
(
'Energy reported by the XML file is: %d, parsing info file...'
,
acq_tt
.
energy
)
...
...
@@ -46,37 +52,42 @@ function p = gtGrainTopotomoUpdateParameters(scan_xml, range_basetilt, nproj_bas
disp
(
' '
)
end
% % Check for flips:
% cfg_file = fullfile(tt_scan_dir, [acq_tt.name '.cfg']);
% fid = fopen(cfg_file);
% valid = true;
% file_content = {};
% while (valid)
% file_content{end+1} = fgets(fid); %#ok<AGROW>
% valid = file_content{end} ~= -1;
% end
% fclose(fid);
% file_content = [file_content{:}];
% horz_flip = regexp(file_content, 'ccd_flip_horz\s*(?<value>\d+)', 'names', 'once');
% vert_flip = regexp(file_content, 'ccd_flip_vert\s*(?<value>\d+)', 'names', 'once');
% if (str2double(horz_flip.value))
% acq_tt.detroi_u_off = acq_tt.true_detsizeu - acq_tt.detroi_u_off;
% end
% if (str2double(vert_flip.value))
% acq_tt.detroi_v_off = acq_tt.true_detsizev - acq_tt.detroi_v_off;
% end
% Automatically checking for flips:
if
(
conf
.
check_flips
)
o
.
fprintf
(
' - Checking topotomo image flips..'
)
c
=
tic
();
cfg_file
=
fullfile
(
tt_scan_dir
,
[
acq_tt
.
name
'.cfg'
]);
fid
=
fopen
(
cfg_file
);
valid
=
true
;
file_content
=
{};
while
(
valid
)
file_content
{
end
+
1
}
=
fgets
(
fid
);
%#ok<AGROW>
valid
=
file_content
{
end
}
~=
-
1
;
end
fclose
(
fid
);
file_content
=
[
file_content
{:}];
horz_flip
=
regexp
(
file_content
,
'ccd_flip_horz\s*(?<value>\d+)'
,
'names'
,
'once'
);
vert_flip
=
regexp
(
file_content
,
'ccd_flip_vert\s*(?<value>\d+)'
,
'names'
,
'once'
);
if
(
str2double
(
horz_flip
.
value
))
acq_tt
.
detroi_u_off
=
acq_tt
.
true_detsizeu
-
acq_tt
.
detroi_u_off
;
end
if
(
str2double
(
vert_flip
.
value
))
acq_tt
.
detroi_v_off
=
acq_tt
.
true_detsizev
-
acq_tt
.
detroi_v_off
;
end
o
.
fprintf
(
'\b\b: Done in %g seconds.\n'
,
toc
(
c
))
end
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
];
% samr X and Y reversed, because the first on the right is the one
% applied first when doing SAM->LAB
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
;
% Translations should be handled a bit differently, especially if there
% were some initial tilts in the DCT acquisition
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
.
range_basetilt
=
range_basetilt
;
...
...
@@ -87,18 +98,21 @@ function p = gtGrainTopotomoUpdateParameters(scan_xml, range_basetilt, nproj_bas
p
.
acq
(
end
+
1
)
=
acq_tt
;
det_ind
=
numel
(
p
.
acq
);
p
.
diffractometer
(
det_ind
)
=
gtGeoDiffractometerDefinition
(
'esrf_id11'
,
...
'axes_rotation_offset'
,
p
.
acq
(
1
)
.
motors
.
diffrz
,
...
'shifts_sam_stage'
,
acq_tt
.
sample_shifts
);
p
.
detgeo
(
det_ind
)
=
detgeo_tt
;
% It might be that the Detector definition ha to be shifted as well!!
% p.detgeo(det_ind).detrefpos = p.detgeo(det_ind).detrefpos + p.diffractometer(det_ind).shifts_sam_stage;
p
.
recgeo
(
det_ind
)
=
p
.
recgeo
(
1
);
p
.
recgeo
(
det_ind
)
.
voxsize
=
mean
([
detgeo_tt
.
pixelsizeu
,
detgeo_tt
.
pixelsizev
])
*
[
1
,
1
,
1
];
if
(
isempty
(
pl_ind
))
fprintf
(
' - Guessing Topotomo pl_ind, with respect to DCT (for the range: [%g, %g])..'
,
range_basetilt
)
o
.
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
,
...
'shifts_sam_stage'
,
acq_tt
.
sample_shifts
);
diff
=
p
.
diffractometer
(
det_ind
);
tilts
=
p
.
acq
(
det_ind
)
.
sample_tilts
;
t
=
gtGeoDiffractometerTensor
(
diff
,
'sam2lab'
,
'angles_sam_tilt'
,
tilts
);
...
...
@@ -107,9 +121,9 @@ function p = gtGrainTopotomoUpdateParameters(scan_xml, range_basetilt, nproj_bas
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
))
o
.
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
))
o
.
fprintf
(
' + Chosen pl_ind: %d (%g deg)\n'
,
pl_ind
,
angle
(
pl_ind
))
end
p
.
acq
(
det_ind
)
.
pl_ind
=
pl_ind
;
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment