diff --git a/src/GERawConverter.cpp b/src/GERawConverter.cpp index 053e881..e869535 100644 --- a/src/GERawConverter.cpp +++ b/src/GERawConverter.cpp @@ -347,7 +347,20 @@ std::string GERawConverter::ge_header_to_xml(GERecon::Legacy::LxDownloadDataPoin writer.formatElement("ScanCenter", "%f", processingControl->Value("ScanCenter")); writer.formatElement("Landmark", "%f", processingControl->Value("Landmark")); writer.formatElement("CoilConfigUID", "%u", processingControl->Value("CoilConfigUID")); - writer.formatElement("RawPassSize", "%llu", processingControl->Value("RawPassSize")); + try { + // Attempt to use `int` for RawPassSize + writer.formatElement("RawPassSize", "%llu", processingControl->Value("RawPassSize")); + } catch (const std::exception& e) { + std::cerr << "Failed to retrieve RawPassSize as int: " << e.what() << ". Trying unsigned long long instead." << std::endl; + try { + // Fallback to `unsigned long long` if the first attempt fails + writer.formatElement("RawPassSize", "%llu", processingControl->Value("RawPassSize")); + } catch (const std::exception& e) { + // If both attempts fail, set a default value and continue + std::cerr << "Failed to retrieve RawPassSize as unsigned long long: " << e.what() << ". Using default value 0." << std::endl; + writer.formatElement("RawPassSize", "%llu", 0ULL); // Default value + } + } // ReconstructionParameters writer.addBooleanElement("CreateMagnitudeImages", processingControl->Value("CreateMagnitudeImages"));