Fix/mythenfilereading (#250)
Some checks failed
Build on RHEL8 / build (push) Failing after 0s
Build on RHEL9 / build (push) Successful in 3m23s

Add counter mask as member of RawFile
BugFix: temporarily handle -1 for ROI in mythenfile
This commit is contained in:
2025-11-24 12:29:08 +01:00
committed by GitHub
parent 03af5927ad
commit 8201c5e999
3 changed files with 28 additions and 1 deletions

View File

@@ -103,6 +103,7 @@ class RawMasterFile {
std::optional<size_t> m_digital_samples; std::optional<size_t> m_digital_samples;
std::optional<size_t> m_transceiver_samples; std::optional<size_t> m_transceiver_samples;
std::optional<size_t> m_number_of_rows; std::optional<size_t> m_number_of_rows;
std::optional<uint8_t> m_counter_mask;
std::optional<ROI> m_roi; std::optional<ROI> m_roi;
@@ -133,6 +134,7 @@ class RawMasterFile {
std::optional<size_t> digital_samples() const; std::optional<size_t> digital_samples() const;
std::optional<size_t> transceiver_samples() const; std::optional<size_t> transceiver_samples() const;
std::optional<size_t> number_of_rows() const; std::optional<size_t> number_of_rows() const;
std::optional<uint8_t> counter_mask() const;
std::optional<ROI> roi() const; std::optional<ROI> roi() const;

View File

@@ -320,4 +320,14 @@ TEST_CASE("Read file with unordered frames", "[.with-data]") {
REQUIRE(std::filesystem::exists(fpath)); REQUIRE(std::filesystem::exists(fpath));
File f(fpath); File f(fpath);
REQUIRE_THROWS((f.read_frame())); REQUIRE_THROWS((f.read_frame()));
}
TEST_CASE("Read Mythenframe", "[.with-data]") {
auto fpath = test_data_path() / "raw/newmythen03/run_2_master_1.json";
REQUIRE(std::filesystem::exists(fpath));
RawFile f(fpath);
REQUIRE(f.master().roi().value().width() == 2560);
REQUIRE(f.master().roi().value().height() == 1);
auto frame = f.read_frame();
REQUIRE(frame.cols() == 2560);
} }

View File

@@ -143,6 +143,10 @@ std::optional<size_t> RawMasterFile::number_of_rows() const {
return m_number_of_rows; return m_number_of_rows;
} }
std::optional<uint8_t> RawMasterFile::counter_mask() const {
return m_counter_mask;
}
xy RawMasterFile::geometry() const { return m_geometry; } xy RawMasterFile::geometry() const { return m_geometry; }
size_t RawMasterFile::n_modules() const { size_t RawMasterFile::n_modules() const {
@@ -313,15 +317,26 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) {
} }
// if any of the values are set update the roi // if any of the values are set update the roi
// TODO: doesnt it write garbage if one of them is not set
if (tmp_roi.xmin != 4294967295 || tmp_roi.xmax != 4294967295 || if (tmp_roi.xmin != 4294967295 || tmp_roi.xmax != 4294967295 ||
tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) { tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) {
tmp_roi.xmax++; tmp_roi.xmax++;
// Handle Mythen
if (tmp_roi.ymin == -1 && tmp_roi.ymax == -1) {
tmp_roi.ymin = 0;
tmp_roi.ymax = 0;
}
tmp_roi.ymax++; tmp_roi.ymax++;
m_roi = tmp_roi; m_roi = tmp_roi;
} }
} catch (const json::out_of_range &e) { } catch (const json::out_of_range &e) {
LOG(TLogLevel::logERROR) << e.what() << std::endl; // leave the optional empty
}
try {
// TODO: what is the best format to handle
m_counter_mask = j.at("Counter Mask");
} catch (const json::out_of_range &e) {
// leave the optional empty // leave the optional empty
} }