From c2de9c2b67aa50902f03bfa3b097aedb58710179 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 21 Apr 2026 10:12:41 +0200 Subject: [PATCH] JFJochHDF5Reader: Guard for peak count datasets being not present --- reader/JFJochHDF5Reader.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/reader/JFJochHDF5Reader.cpp b/reader/JFJochHDF5Reader.cpp index 937320bc..aa37136b 100644 --- a/reader/JFJochHDF5Reader.cpp +++ b/reader/JFJochHDF5Reader.cpp @@ -155,7 +155,7 @@ void JFJochHDF5Reader::ReadFile(const std::string& filename) { dataset->spot_count_low_res = master_file->ReadOptVector("/entry/MX/peakCountLowRes"); dataset->spot_count_indexed = master_file->ReadOptVector("/entry/MX/peakCountIndexed"); - dataset->spot_count_ice_rings = master_file->ReadOptVector("/entry/MX/peakCountIceRing"); + dataset->spot_count_ice_rings = master_file->ReadOptVector("/entry/MX/peakCountIceRingRes"); dataset->indexing_result = master_file->ReadOptVector("/entry/MX/imageIndexed"); dataset->bkg_estimate = master_file->ReadOptVector("/entry/MX/bkgEstimate"); @@ -610,11 +610,16 @@ bool JFJochHDF5Reader::LoadImage_i(std::shared_ptr &dataset s.ice_ring = (spot_ice.at(i) != 0); message.spots.emplace_back(s); } - - message.spot_count = source_file->ReadElement("/entry/MX/peakCountUnfiltered", image_id); - message.spot_count_ice_rings = source_file->ReadElement("/entry/MX/peakCountIceRingRes", image_id); - message.spot_count_low_res = source_file->ReadElement("/entry/MX/peakCountLowRes", image_id); - message.spot_count_indexed = source_file->ReadElement("/entry/MX/peakCountIndexed", image_id); + if (source_file->Exists("/entry/MX/peakCountUnfiltered")) + message.spot_count = source_file->ReadElement("/entry/MX/peakCountUnfiltered", image_id); + else + message.spot_count = source_file->ReadElement("/entry/MX/nPeaks", image_id); + if (source_file->Exists("/entry/MX/peakCountIceRingRes")) + message.spot_count_ice_rings = source_file->ReadElement("/entry/MX/peakCountIceRingRes", image_id); + if (source_file->Exists("/entry/MX/peakCountLowRes")) + message.spot_count_low_res = source_file->ReadElement("/entry/MX/peakCountLowRes", image_id); + if (source_file->Exists("/entry/MX/peakCountIndexed")) + message.spot_count_indexed = source_file->ReadElement("/entry/MX/peakCountIndexed", image_id); GenerateSpotPlot(message, 1.5); }