IndexerWrapper: Add indexed spots information
This commit is contained in:
@@ -9,11 +9,27 @@ void IndexerWrapper::Setup(const UnitCell &cell) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Select spots that belong to indexing solution
|
||||
// - cell cell in real space
|
||||
// - spots spots in reciprocal space
|
||||
// - threshold radius around approximated miller indices
|
||||
template <typename Mat3, typename MatX3, typename float_type=typename Mat3::Scalar>
|
||||
inline auto select_indexed_spots(const Eigen::MatrixBase<Mat3>& cell,
|
||||
const Eigen::MatrixBase<MatX3>& spots,
|
||||
float_type threshold=.02f)
|
||||
{
|
||||
using M3x = Eigen::MatrixX3<float_type>;
|
||||
M3x resid = spots * cell.transpose();
|
||||
const M3x miller = round(resid.array());
|
||||
resid -= miller;
|
||||
return resid.rowwise().norm().array() < threshold;
|
||||
}
|
||||
|
||||
std::vector<IndexingResult> IndexerWrapper::Run(const std::vector<Coord> &coord) {
|
||||
#ifdef JFJOCH_USE_CUDA
|
||||
std::vector<IndexingResult> ret;
|
||||
|
||||
if (coord.size() < MIN_SPOTS_TO_INDEX)
|
||||
if (coord.size() <= min_spots)
|
||||
return ret;
|
||||
|
||||
size_t nspots = std::min<size_t>(MAX_SPOTS_TO_INDEX, coord.size());
|
||||
@@ -30,10 +46,21 @@ std::vector<IndexingResult> IndexerWrapper::Run(const std::vector<Coord> &coord)
|
||||
// Get best cell
|
||||
auto id = fast_feedback::refine::best_cell(indexer.oScoreV());
|
||||
|
||||
// Check if is viable
|
||||
if (fast_feedback::refine::is_viable_cell(indexer.oCell(id), indexer.Spots(), 0.05f, 9u)) {
|
||||
// Get indexed spots
|
||||
auto arr = select_indexed_spots(indexer.oCell(id), indexer.Spots(), threshold);
|
||||
|
||||
auto indexed_spot_count = arr.count();
|
||||
// Check if result is viable
|
||||
if (indexed_spot_count > min_spots) {
|
||||
IndexingResult result;
|
||||
result.l = CrystalLattice(indexer.oCell(id));
|
||||
|
||||
result.indexed_spots.resize(coord.size());
|
||||
for (int i = 0; i < arr.size(); i++)
|
||||
result.indexed_spots[i] = arr[i];
|
||||
|
||||
result.indexed_spots_count = indexed_spot_count;
|
||||
|
||||
ret.emplace_back(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user