changeset 63:2ea8148b8002

wsi: the imaged volume width can be provided
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Nov 2025 17:13:08 +0100
parents 4edf4051a50b
children fc9fdc2ffb2e
files NEWS Sources/Dicomization/WholeSlideImagingDicomizer.cpp Sources/Dicomization/WholeSlideImagingDicomizer.h Sources/EducationRestApi.cpp
diffstat 4 files changed, 57 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Nov 07 15:21:11 2025 +0100
+++ b/NEWS	Fri Nov 07 17:13:08 2025 +0100
@@ -1,8 +1,10 @@
 Pending changes in the mainline
 ===============================
 
-* Fix DICOM-ization of MRXS files from MIRAX
-* Display the image title in the whole-slide imaging viewer
+* Enhancements to DICOM-ization of whole-slide images:
+  - The imaged volume width can be specified in the Web interface
+  - Display the image title in the whole-slide imaging viewer
+  - Fixed support of MRXS files from MIRAX
 
 
 Version 1.0 (2025-10-22)
--- a/Sources/Dicomization/WholeSlideImagingDicomizer.cpp	Fri Nov 07 15:21:11 2025 +0100
+++ b/Sources/Dicomization/WholeSlideImagingDicomizer.cpp	Fri Nov 07 17:13:08 2025 +0100
@@ -32,6 +32,7 @@
 #include <SystemToolbox.h>
 
 #include <boost/algorithm/string/predicate.hpp>
+#include <boost/lexical_cast.hpp>
 #include <boost/thread.hpp>
 
 
@@ -116,6 +117,13 @@
     args.push_back("--openslide");
     args.push_back(openslide);
   }
+
+  // New in release 1.1
+  if (!imagedVolumeAutodetect_)
+  {
+    args.push_back("--imaged-width");
+    args.push_back(boost::lexical_cast<std::string>(imagedVolumeWidth_));
+  }
 }
 
 
@@ -124,6 +132,13 @@
                                                   SharedLogs& logs,
                                                   const bool& stopped)
 {
+  logs.Append("$ " + dicomizer);
+  for (std::list<std::string>::const_iterator it = args.begin(); it != args.end(); ++it)
+  {
+    logs.Append(" " + *it);
+  }
+  logs.Append("\n\n");
+
   ProcessRunner runner;
   runner.Start(dicomizer, args, ProcessRunner::Stream_Error);
 
@@ -195,7 +210,9 @@
   backgroundGreen_(255),
   backgroundBlue_(255),
   forceOpenSlide_(false),
-  reconstructPyramid_(true)
+  reconstructPyramid_(true),
+  imagedVolumeAutodetect_(true),
+  imagedVolumeWidth_(15.0f)
 {
 }
 
@@ -210,6 +227,21 @@
 }
 
 
+void WholeSlideImagingDicomizer::SetImagedVolumeWidth(float width)
+{
+  if (width <= 0)
+  {
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, "The imaged volume width must be positive, got: " +
+                                    boost::lexical_cast<std::string>(imagedVolumeWidth_));
+  }
+  else
+  {
+    imagedVolumeAutodetect_ = false;
+    imagedVolumeWidth_ = width;
+  }
+}
+
+
 bool WholeSlideImagingDicomizer::Execute(std::unique_ptr<Orthanc::TemporaryFile>& upload,
                                          SharedLogs& logs,
                                          const bool& stopped)
--- a/Sources/Dicomization/WholeSlideImagingDicomizer.h	Fri Nov 07 15:21:11 2025 +0100
+++ b/Sources/Dicomization/WholeSlideImagingDicomizer.h	Fri Nov 07 17:13:08 2025 +0100
@@ -40,6 +40,10 @@
   bool         forceOpenSlide_;
   bool         reconstructPyramid_;
 
+  // New in release 1.1
+  bool         imagedVolumeAutodetect_;
+  float        imagedVolumeWidth_;
+
   static bool Unzip(TemporaryDirectory& target,
                     std::string& unzipMaster,
                     const Orthanc::TemporaryFile& zip,
@@ -77,6 +81,8 @@
     reconstructPyramid_ = reconstruct;
   }
 
+  void SetImagedVolumeWidth(float width);
+
   virtual std::string GetName() ORTHANC_OVERRIDE
   {
     return studyDescription_;
--- a/Sources/EducationRestApi.cpp	Fri Nov 07 15:21:11 2025 +0100
+++ b/Sources/EducationRestApi.cpp	Fri Nov 07 17:13:08 2025 +0100
@@ -1325,6 +1325,20 @@
         dicomizer->SetStudyDescription(Orthanc::SerializationToolbox::ReadString(body, "study-description"));
         dicomizer->SetForceOpenSlide(Orthanc::SerializationToolbox::ReadBoolean(body, "force-openslide"));
         dicomizer->SetReconstructPyramid(Orthanc::SerializationToolbox::ReadBoolean(body, "reconstruct-pyramid"));
+
+        static const char* const IMAGED_WIDTH = "imaged-width";
+        if (body.isMember(IMAGED_WIDTH))
+        {
+          const Json::Value& width = body[IMAGED_WIDTH];
+          if (width.isNumeric())
+          {
+            dicomizer->SetImagedVolumeWidth(width.asFloat());
+          }
+          else
+          {
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
+          }
+        }
       }
       catch (Orthanc::OrthancException&)
       {