Skip to content

Commit

Permalink
Fix imageviewer for tof data when including integrated reflections. F…
Browse files Browse the repository at this point in the history
…ilter out reflections with bounding boxes outside of detectors rather than truncating them. Allow for user defined sigma_b and sigma_m in tof integration. Integrate all predicted spots by default rather than just those observed.
  • Loading branch information
toastisme committed May 28, 2024
1 parent 3e4a2c4 commit b156483
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ namespace dials {
if (z1 > max_z) {
z1 = max_z;
}
if (z0 > z1) {
z0 = -1;
z1 = 0;
}

int6 bbox(x0, x1, y0, y1, z0, z1);
DIALS_ASSERT(bbox[1] > bbox[0]);
Expand Down
27 changes: 21 additions & 6 deletions src/dials/command_line/simple_tof_integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from dials.algorithms.integration.report import IntegrationReport, ProfileModelReport
from dials.algorithms.profile_model.gaussian_rs import GaussianRSProfileModeller
from dials.algorithms.profile_model.gaussian_rs import Model as GaussianRSProfileModel
from dials.algorithms.profile_model.gaussian_rs.calculator import (
ComputeEsdBeamDivergence,
)
from dials.algorithms.shoebox import MaskCode
from dials.array_family import flex
from dials.command_line.integrate import process_reference
Expand Down Expand Up @@ -64,6 +67,12 @@
.help = "Use integration by profile fitting using a Gaussian"
"convoluted with back-to-back exponential functions"
}
sigma_b = 0.01
.type = float
.help = "Used to calculate xy bounding box of predicted reflections"
sigma_m = 3
.type = float
.help = "Used to calculate z bounding box of predicted reflections"
keep_shoeboxes = False
.type = bool
.help = "Retain shoeboxes in output reflection table"
Expand Down Expand Up @@ -592,10 +601,9 @@ def run_simple_integrate(params, experiments, reflections):
matched, reflections, unmatched = predicted_reflections.match_with_reference(
reflections
)
sel = predicted_reflections.get_flags(predicted_reflections.flags.reference_spot)
predicted_reflections = predicted_reflections.select(sel)
if "idx" in reflections:
predicted_reflections["idx"] = reflections["idx"]
# if "idx" in reflections:
# predicted_reflections["idx"] = reflections["idx"]
# sel = predicted_reflections.get_flags(predicted_reflections.flags.reference_spot)

"""
Create profile model and add it to experiment.
Expand All @@ -606,9 +614,13 @@ def run_simple_integrate(params, experiments, reflections):
used_in_ref = reflections.get_flags(reflections.flags.used_in_refinement)
model_reflections = reflections.select(used_in_ref)

sigma_b = ComputeEsdBeamDivergence(
experiment.detector, model_reflections, centroid_definition="s1"
).sigma()

# sigma_m in 3.1 of Kabsch 2010
sigma_m = 3
sigma_b = 0.01
sigma_m = params.sigma_m
sigma_b = 0.001
# The Gaussian model given in 2.3 of Kabsch 2010
for idx, experiment in enumerate(experiments):
experiments[idx].profile = GaussianRSProfileModel(
Expand All @@ -625,9 +637,12 @@ def run_simple_integrate(params, experiments, reflections):

predicted_reflections.compute_bbox(experiments)
x1, x2, y1, y2, t1, t2 = predicted_reflections["bbox"].parts()
predicted_reflections = predicted_reflections.select(t1 > 0)
x1, x2, y1, y2, t1, t2 = predicted_reflections["bbox"].parts()
predicted_reflections = predicted_reflections.select(
t2 < experiments[0].sequence.get_image_range()[1]
)

predicted_reflections.compute_d(experiments)
predicted_reflections.compute_partiality(experiments)

Expand Down
5 changes: 3 additions & 2 deletions src/dials/util/image_viewer/spotfinder_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from cctbx import crystal, uctbx
from cctbx.miller import index_generator
from dxtbx.imageset import ImageSet
from dxtbx.model import Scan
from dxtbx.model.detector_helpers import get_detector_projection_2d_axes
from dxtbx.model.experiment_list import ExperimentList, ExperimentListFactory
from libtbx.utils import flat_list
Expand Down Expand Up @@ -2005,7 +2006,7 @@ def _basis_vector_overlay_data(self, i_expt, i_frame, experiment):
beam = imageset.get_beam()
gonio = imageset.get_goniometer()
still = scan is None or gonio is None
if not still:
if not still and isinstance(scan, Scan):
phi = scan.get_angle_from_array_index(
i_frame - imageset.get_array_range()[0], deg=True
)
Expand All @@ -2029,7 +2030,7 @@ def _basis_vector_overlay_data(self, i_expt, i_frame, experiment):
for i, h in enumerate(((1, 0, 0), (0, 1, 0), (0, 0, 1))):
r = A * matrix.col(h) * self.settings.basis_vector_scale

if still:
if still or not isinstance(scan, Scan):
s1 = matrix.col(beam.get_unit_s0()) + r
else:
r_phi = r.rotate_around_origin(axis, phi, deg=True)
Expand Down

0 comments on commit b156483

Please sign in to comment.