diff --git a/src/RawMasterFile.cpp b/src/RawMasterFile.cpp index 919b2d9..46843dc 100644 --- a/src/RawMasterFile.cpp +++ b/src/RawMasterFile.cpp @@ -194,6 +194,15 @@ ScanParameters RawMasterFile::scan_parameters() const { } std::optional RawMasterFile::roi() const { + if (!m_rois) { + return std::nullopt; + } + + if (m_rois->empty()) { + throw std::runtime_error(LOCATION + + "Zero ROIs in metadata."); + } + if (m_rois.value().size() > 1) { throw std::runtime_error(LOCATION + "Multiple ROIs present, use rois() method.");