Add mechanics to save per spot lattice information (WIP)

This commit is contained in:
2026-06-05 14:17:19 +02:00
parent 74c1a7a828
commit 83f467d4dc
10 changed files with 34 additions and 13 deletions
+3 -2
View File
@@ -82,9 +82,10 @@ std::optional<SpotToSave> DiffractionSpot::Export(const DiffractionGeometry &geo
.phi = phi,
.intensity = static_cast<float>(photons),
.maxc = max_photons,
.lattice = -1,
.image = image_num,
.d_A = d,
.ice_ring = false,
.indexed = false,
.image = image_num
.indexed = false
};
}
+4 -4
View File
@@ -11,13 +11,13 @@ struct SpotToSave {
float phi = 0;
float intensity = 0;
int64_t maxc = 0;
int64_t lattice = -1; // -1 non indexed
int64_t image = 0;
int64_t h = 0, k = 0, l= 0;
float d_A = 0.0;
float dist_ewald_sphere = 0.0;
bool ice_ring = false;
bool indexed = false;
int64_t image = 0;
int64_t h = 0, k = 0, l= 0;
float dist_ewald_sphere = 0.0;
Coord ReciprocalCoord(const DiffractionGeometry &experiment) const;
};
+1
View File
@@ -136,6 +136,7 @@ See [DECTRIS documentation](https://github.com/dectris/documentation/tree/main/s
| - maxc | int64 | max count (photons) | | |
| - ice_ring | bool | spot in resolution range for ice rings | | |
| - indexed | bool | indexed solution | | |
| - latt | int64 | Lattice to which the peak belongs (negative number = not indexed) | | |
| reflections | Array(object) | Reflections: | | |
| - h | int64 | Miller index | | |
| - k | int64 | Miller index | | |
@@ -446,6 +446,8 @@ namespace {
s.ice_ring = GetCBORBool(map_value);
else if (key == "indexed")
s.indexed = GetCBORBool(map_value);
else if (key == "latt")
s.lattice = GetCBORInt(map_value);
else if (key == "h")
s.h = GetCBORInt(map_value);
else if (key == "k")
@@ -224,6 +224,7 @@ inline void CBOR_ENC(CborEncoder &encoder, const SpotToSave& spot) {
CBOR_ENC(mapEncoder, "maxc", spot.maxc);
CBOR_ENC(mapEncoder, "ice_ring", spot.ice_ring);
CBOR_ENC(mapEncoder, "indexed", spot.indexed);
CBOR_ENC(mapEncoder, "latt", spot.lattice);
CBOR_ENC(mapEncoder, "image", spot.image);
if (spot.indexed) {
CBOR_ENC(mapEncoder, "h", spot.h);
+3 -2
View File
@@ -354,9 +354,10 @@ bool AnalyzeIndexing(DataMessage &message,
if (ok(uc.a) && ok(uc.b) && ok(uc.c) && ok(uc.alpha) && ok(uc.beta) && ok(uc.gamma)) {
message.indexing_result = true;
assert(indexed_spots.size() == message.spots.size());
for (int i = 0; i < message.spots.size(); i++)
for (int i = 0; i < message.spots.size(); i++) {
message.spots[i].indexed = indexed_spots[i];
message.spots[i].lattice = 0;
}
message.profile_radius = FitProfileRadius(message.spots);
message.spot_count_indexed = nspots_indexed;
message.indexing_lattice = latt;
+11 -2
View File
@@ -785,6 +785,13 @@ static void ReadSpotsFromFiles(HDF5Object &master_file,
"/entry/MX/peakL",
{master_image, 0}, {source_image, 0}, {1, spot_count}
);
auto spot_lattice = ReadVectorMasterFirst<int8_t>(
master_file, source_file,
"/entry/MX/peakLattice",
{master_image, 0}, {source_image, 0}, {1, spot_count}
);
auto spot_dist_ewald_sphere = ReadVectorMasterFirst<float>(
master_file, source_file,
"/entry/MX/peakDistEwaldSphere",
@@ -800,8 +807,8 @@ static void ReadSpotsFromFiles(HDF5Object &master_file,
.x = x,
.y = y,
.intensity = spot_intensity.at(i),
.d_A = geom.PxlToRes(x, y),
.image = image_number
.image = image_number,
.d_A = geom.PxlToRes(x, y)
};
if (spot_indexed.size() > i)
s.indexed = (spot_indexed.at(i) != 0);
@@ -815,6 +822,8 @@ static void ReadSpotsFromFiles(HDF5Object &master_file,
s.dist_ewald_sphere = spot_dist_ewald_sphere.at(i);
if (spot_ice.size() > i)
s.ice_ring = (spot_ice.at(i) != 0);
if (spot_lattice.size() > i)
s.lattice = spot_lattice.at(i);
message.spots.emplace_back(s);
}
+5 -1
View File
@@ -72,6 +72,7 @@ void HDF5DataFilePluginMX::OpenFile(HDF5File &data_file, const DataMessage &msg,
spot_h.reserve(max_spots * images_per_file);
spot_k.reserve(max_spots * images_per_file);
spot_l.reserve(max_spots * images_per_file);
spot_lattice.reserve(max_spots * images_per_file);
spot_dist_ewald.reserve(max_spots * images_per_file);
if (indexing)
spot_indexed.reserve(max_spots * images_per_file);
@@ -118,7 +119,8 @@ void HDF5DataFilePluginMX::Write(const DataMessage &msg, uint64_t image_number)
spot_h.resize(max_spots * (max_image_number + 1));
spot_k.resize(max_spots * (max_image_number + 1));
spot_l.resize(max_spots * (max_image_number + 1));
spot_dist_ewald.resize(max_spots * (max_image_number + 1));
spot_lattice.resize(max_spots * (max_image_number + 1), -1);
spot_dist_ewald.resize(max_spots * (max_image_number + 1), NAN);
if (indexing)
spot_indexed.resize(max_spots * (max_image_number + 1));
@@ -134,6 +136,7 @@ void HDF5DataFilePluginMX::Write(const DataMessage &msg, uint64_t image_number)
spot_int[max_spots * image_number + i] = msg.spots[i].intensity;
if (indexing) {
spot_indexed[max_spots * image_number + i] = msg.spots[i].indexed;
spot_lattice[max_spots * image_number + i] = msg.spots[i].lattice;
spot_h[max_spots * image_number + i] = msg.spots[i].h;
spot_k[max_spots * image_number + i] = msg.spots[i].k;
spot_l[max_spots * image_number + i] = msg.spots[i].l;
@@ -204,6 +207,7 @@ void HDF5DataFilePluginMX::WriteFinal(HDF5File &data_file) {
data_file.SaveVector("/entry/MX/peakDistEwaldSphere", spot_dist_ewald,
{(hsize_t) (max_image_number + 1), max_spots});
data_file.SaveVector("/entry/MX/peakIndexed", spot_indexed, {(hsize_t) (max_image_number + 1), max_spots});
data_file.SaveVector("/entry/MX/peakLattice", spot_lattice, {(hsize_t) (max_image_number + 1), max_spots});
}
}
+1
View File
@@ -15,6 +15,7 @@ class HDF5DataFilePluginMX : public HDF5DataFilePlugin {
std::vector<float> spot_int;
std::vector<int8_t> spot_indexed;
std::vector<int8_t> spot_ice_ring;
std::vector<int8_t> spot_lattice;
std::vector<int32_t> spot_h;
std::vector<int32_t> spot_k;
std::vector<int32_t> spot_l;
+3 -2
View File
@@ -126,12 +126,13 @@ void NXmx::LinkToData_VDS(const StartMessage &start, const EndMessage &end) {
VDS(start, "/entry/MX/peakXPosRaw",{total_images, start.max_spot_count}, HDF5DataType(0.0f));
VDS(start, "/entry/MX/peakYPosRaw",{total_images, start.max_spot_count}, HDF5DataType(0.0f));
VDS(start, "/entry/MX/peakTotalIntensity",{total_images, start.max_spot_count}, HDF5DataType(0.0f));
VDS(start, "/entry/MX/peakIceRingRes", {total_images, start.max_spot_count}, HDF5DataType((uint8_t) 0));
VDS(start, "/entry/MX/peakIceRingRes", {total_images, start.max_spot_count}, HDF5DataType(static_cast<int8_t>(0)));
VDS(start, "/entry/MX/nPeaks", {total_images}, HDF5DataType((uint32_t) 0));
}
if (start.indexing_algorithm != IndexingAlgorithmEnum::None) {
VDS(start, "/entry/MX/peakIndexed", {total_images, start.max_spot_count}, HDF5DataType((uint8_t) 0));
VDS(start, "/entry/MX/peakIndexed", {total_images, start.max_spot_count}, HDF5DataType(static_cast<int8_t>(0)));
VDS(start, "/entry/MX/peakLattice", {total_images, start.max_spot_count}, HDF5DataType(static_cast<int8_t>(-1)));
VDS(start, "/entry/MX/peakH", {total_images, start.max_spot_count}, HDF5DataType((int32_t) 0));
VDS(start, "/entry/MX/peakK", {total_images, start.max_spot_count}, HDF5DataType((int32_t) 0));
VDS(start, "/entry/MX/peakL", {total_images, start.max_spot_count}, HDF5DataType((int32_t) 0));