RotationIndexer: Remove logic controlling image accumulation
This commit is contained in:
@@ -16,30 +16,11 @@ RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPo
|
||||
geom_(x.GetDiffractionGeometry()),
|
||||
updated_geom_(geom_),
|
||||
indexer_(indexer) {
|
||||
if (axis_) {
|
||||
angle_norm_deg = std::fabs(axis_->GetIncrement_deg());
|
||||
if (angle_norm_deg < 1e-6) {
|
||||
// Guard against rotation close to zero
|
||||
axis_ = std::nullopt;
|
||||
} else {
|
||||
if (x.GetImageNum() < min_images_for_indexing) {
|
||||
// For short measurements - only indexing at the end
|
||||
first_image_to_try_indexing = std::max<int64_t>(0, x.GetImageNum() - 1);
|
||||
next_image_to_try_indexing = first_image_to_try_indexing;
|
||||
image_stride = 1;
|
||||
} else {
|
||||
first_image_to_try_indexing = std::max<int64_t>(min_images_for_indexing,
|
||||
x.GetIndexingSettings().GetRotationIndexingMinAngularRange_deg() / angle_norm_deg);
|
||||
next_image_to_try_indexing = first_image_to_try_indexing;
|
||||
image_stride = std::ceil(x.GetIndexingSettings().GetRotationIndexingAngularStride_deg() / angle_norm_deg);
|
||||
if (image_stride == 0)
|
||||
image_stride = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IndexerResult RotationIndexer::RunIndexing() const {
|
||||
void RotationIndexer::RunIndexing() {
|
||||
std::unique_lock ul(m);
|
||||
|
||||
std::vector<Coord> coords;
|
||||
coords.reserve(max_spots_per_image * v_.size());
|
||||
|
||||
@@ -50,13 +31,9 @@ IndexerResult RotationIndexer::RunIndexing() const {
|
||||
for (const auto &s: v_[i])
|
||||
coords.emplace_back(rot * s.ReciprocalCoord(geom_));
|
||||
}
|
||||
const auto indexer_result = indexer_.Run(experiment, coords);
|
||||
|
||||
return indexer_.Run(experiment, coords);
|
||||
}
|
||||
|
||||
void RotationIndexer::TryIndex() {
|
||||
if (auto indexer_result = RunIndexing();
|
||||
!indexer_result.lattice.empty() && indexer_result.lattice[0].CalcVolume() > 1.0) {
|
||||
if (!indexer_result.lattice.empty() && indexer_result.lattice[0].CalcVolume() > 1.0) {
|
||||
auto sg = experiment.GetGemmiSpaceGroup();
|
||||
if (sg) {
|
||||
search_result_ = LatticeSearchResult{
|
||||
@@ -97,15 +74,6 @@ void RotationIndexer::TryIndex() {
|
||||
axis_ = data.axis;
|
||||
}
|
||||
}
|
||||
|
||||
if (!indexed_lattice) {
|
||||
if (indexing_range_multiplier < max_indexing_range_multiplier) {
|
||||
indexing_range_multiplier++;
|
||||
next_image_to_try_indexing = first_image_to_try_indexing * indexing_range_multiplier;
|
||||
} else {
|
||||
next_image_to_try_indexing = INT64_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave> &spots) {
|
||||
@@ -115,15 +83,12 @@ void RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave>
|
||||
if (!axis_)
|
||||
return;
|
||||
|
||||
if (accumulated_images >= max_images_for_indexing)
|
||||
if (accumulated_spots >= max_spots)
|
||||
return;
|
||||
|
||||
if (indexed_lattice)
|
||||
return;
|
||||
|
||||
if (image < last_accumulated_image + image_stride)
|
||||
return;
|
||||
|
||||
v_[image].reserve(spots.size());
|
||||
|
||||
for (const auto &s: spots) {
|
||||
@@ -131,26 +96,20 @@ void RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave>
|
||||
v_[image].emplace_back(s);
|
||||
}
|
||||
|
||||
if (v_[image].size() > max_spots_per_image) {
|
||||
std::ranges::nth_element(v_[image], v_[image].begin() + max_spots_per_image,
|
||||
// truncate spots, so we don't get above max_spots (total) and max_spots_per_image (for this image)
|
||||
size_t max_spots_limit = std::min(max_spots_per_image, max_spots - accumulated_spots);
|
||||
|
||||
if (v_[image].size() > max_spots_limit) {
|
||||
std::ranges::nth_element(v_[image], v_[image].begin() + max_spots_limit,
|
||||
[](const SpotToSave &a, const SpotToSave &b) {
|
||||
return a.intensity > b.intensity;
|
||||
}
|
||||
);
|
||||
|
||||
v_[image].resize(max_spots_per_image);
|
||||
v_[image].resize(max_spots_limit);
|
||||
}
|
||||
|
||||
accumulated_images++;
|
||||
last_accumulated_image = image;
|
||||
|
||||
const bool short_scan_last_image =
|
||||
(experiment.GetImageNum() < min_images_for_indexing) &&
|
||||
(image >= experiment.GetImageNum() - 1);
|
||||
|
||||
if ((accumulated_images >= min_images_for_indexing || short_scan_last_image) &&
|
||||
image >= next_image_to_try_indexing)
|
||||
TryIndex();
|
||||
accumulated_spots += v_[image].size();
|
||||
}
|
||||
|
||||
std::optional<RotationIndexerResult> RotationIndexer::GetLattice() const {
|
||||
@@ -166,6 +125,3 @@ std::optional<RotationIndexerResult> RotationIndexer::GetLattice() const {
|
||||
};
|
||||
}
|
||||
|
||||
int64_t RotationIndexer::GetAccumulatedImages() const {
|
||||
return accumulated_images;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user