changeset 1970:33d2ff1aeaae

start ultrasound series at their first frame
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 28 Oct 2022 13:36:40 +0200
parents ee68ee732aa7
children e5b31d55206d
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 1 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Oct 28 13:20:36 2022 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Oct 28 13:36:40 2022 +0200
@@ -1198,9 +1198,10 @@
   }
   
 public:
-  explicit SeriesCursor(size_t framesCount) :
+  explicit SeriesCursor(size_t framesCount,
+                        bool startAtMiddle /* Whether to start at the middle frame */) :
     framesCount_(framesCount),
-    currentFrame_(framesCount / 2),  // Start at the middle frame    
+    currentFrame_(startAtMiddle ? framesCount / 2 : 0),
     isCircularPrefetch_(false),
     lastAction_(Action_None)
   {
@@ -2763,7 +2764,28 @@
     OrthancStone::LinearAlgebra::AssignVector(synchronizationOffset_, 0, 0, 0);
 
     frames_.reset(frames);
-    cursor_.reset(new SeriesCursor(frames_->GetFramesCount()));
+    cursor_.reset(new SeriesCursor(frames_->GetFramesCount(), false));
+    
+    if (frames_->GetFramesCount() != 0)
+    {
+      const OrthancStone::DicomInstanceParameters& firstInstance = frames_->GetInstanceOfFrame(0);
+      std::string modality;
+      if (firstInstance.GetTags().LookupStringValue(modality, Orthanc::DICOM_TAG_MODALITY, false))
+      {
+        if (modality == "MR" ||
+            modality == "CT" ||
+            modality == "NM" ||
+            modality == "OPT" ||
+            modality == "PT" ||
+            modality == "RTDOSE" ||
+            modality == "XA")
+        {
+          // For series that might correspond to 3D images, use their
+          // central frame as the first frame to be displayed
+          cursor_.reset(new SeriesCursor(frames_->GetFramesCount(), true));
+        }
+      }
+    }
 
     LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount();