annotate Framework/Loaders/OrthancMultiframeVolumeLoader.cpp @ 1349:b1e6bef86955 broker

Tentative loop optimization in CopyPixelDataAndComputeDistribution
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 10 Apr 2020 16:12:14 +0200
parents b1396be5aa27
children 104e0b0f2316
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 #include "OrthancMultiframeVolumeLoader.h"
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include <Core/Endianness.h>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 #include <Core/Toolbox.h>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 namespace OrthancStone
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 class OrthancMultiframeVolumeLoader::LoadRTDoseGeometry : public LoaderStateMachine::State
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 private:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 std::unique_ptr<Orthanc::DicomMap> dicom_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 public:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 LoadRTDoseGeometry(OrthancMultiframeVolumeLoader& that,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 Orthanc::DicomMap* dicom) :
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 State(that),
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 dicom_(dicom)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 if (dicom == NULL)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 virtual void Handle(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 // Complete the DICOM tags with just-received "Grid Frame Offset Vector"
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 std::string s = Orthanc::Toolbox::StripSpaces(message.GetAnswer());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 dicom_->SetValue(Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR, s, false);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 GetLoader<OrthancMultiframeVolumeLoader>().SetGeometry(*dicom_);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 };
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 static std::string GetSopClassUid(const Orthanc::DicomMap& dicom)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 std::string s;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 if (!dicom.LookupStringValue(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false))
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 "DICOM file without SOP class UID");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 return s;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 class OrthancMultiframeVolumeLoader::LoadGeometry : public State
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 public:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 LoadGeometry(OrthancMultiframeVolumeLoader& that) :
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 State(that)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 virtual void Handle(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 OrthancMultiframeVolumeLoader& loader = GetLoader<OrthancMultiframeVolumeLoader>();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 Json::Value body;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 message.ParseJsonBody(body);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 if (body.type() != Json::objectValue)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 std::unique_ptr<Orthanc::DicomMap> dicom(new Orthanc::DicomMap);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 dicom->FromDicomAsJson(body);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 if (OrthancStone::StringToSopClassUid(GetSopClassUid(*dicom)) == OrthancStone::SopClassUid_RTDose)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 // Download the "Grid Frame Offset Vector" DICOM tag, that is
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 // mandatory for RT-DOSE, but is too long to be returned by default
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 std::unique_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 command->SetUri("/instances/" + loader.GetInstanceId() + "/content/" +
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR.Format());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 command->AcquirePayload(new LoadRTDoseGeometry(loader, dicom.release()));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 Schedule(command.release());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 loader.SetGeometry(*dicom);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 };
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 class OrthancMultiframeVolumeLoader::LoadTransferSyntax : public State
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 public:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 LoadTransferSyntax(OrthancMultiframeVolumeLoader& that) :
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 State(that)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 virtual void Handle(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 GetLoader<OrthancMultiframeVolumeLoader>().SetTransferSyntax(message.GetAnswer());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 };
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
128
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 class OrthancMultiframeVolumeLoader::LoadUncompressedPixelData : public State
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 public:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 LoadUncompressedPixelData(OrthancMultiframeVolumeLoader& that) :
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 State(that)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 virtual void Handle(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 GetLoader<OrthancMultiframeVolumeLoader>().SetUncompressedPixelData(message.GetAnswer());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 };
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 const std::string& OrthancMultiframeVolumeLoader::GetInstanceId() const
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 if (IsActive())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 return instanceId_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 LOG(ERROR) << "OrthancMultiframeVolumeLoader::GetInstanceId(): (!IsActive())";
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 void OrthancMultiframeVolumeLoader::ScheduleFrameDownloads()
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 if (transferSyntaxUid_.empty() ||
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 !volume_->HasGeometry())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 return;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 /*
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 1.2.840.10008.1.2 Implicit VR Endian: Default Transfer Syntax for DICOM
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 1.2.840.10008.1.2.1 Explicit VR Little Endian
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 1.2.840.10008.1.2.2 Explicit VR Big Endian
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 See https://www.dicomlibrary.com/dicom/transfer-syntax/
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 */
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 if (transferSyntaxUid_ == "1.2.840.10008.1.2" ||
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 transferSyntaxUid_ == "1.2.840.10008.1.2.1" ||
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 transferSyntaxUid_ == "1.2.840.10008.1.2.2")
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 std::unique_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 command->SetHttpHeader("Accept-Encoding", "gzip");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
176 command->SetUri("/instances/" + instanceId_ + "/content/" +
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
177 Orthanc::DICOM_TAG_PIXEL_DATA.Format() + "/0");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 command->AcquirePayload(new LoadUncompressedPixelData(*this));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179 Schedule(command.release());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 throw Orthanc::OrthancException(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 Orthanc::ErrorCode_NotImplemented,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 "No support for multiframe instances with transfer syntax: " + transferSyntaxUid_);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
186 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
188
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
189 void OrthancMultiframeVolumeLoader::SetTransferSyntax(const std::string& transferSyntax)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
190 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
191 transferSyntaxUid_ = Orthanc::Toolbox::StripSpaces(transferSyntax);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
192 ScheduleFrameDownloads();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
193 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
194
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195 void OrthancMultiframeVolumeLoader::SetGeometry(const Orthanc::DicomMap& dicom)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 OrthancStone::DicomInstanceParameters parameters(dicom);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
198 volume_->SetDicomParameters(parameters);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200 Orthanc::PixelFormat format;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
201 if (!parameters.GetImageInformation().ExtractPixelFormat(format, true))
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
205
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
206 double spacingZ;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
207 switch (parameters.GetSopClassUid())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
209 case OrthancStone::SopClassUid_RTDose:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 spacingZ = parameters.GetThickness();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
211 break;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
212
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 default:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 throw Orthanc::OrthancException(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 Orthanc::ErrorCode_NotImplemented,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216 "No support for multiframe instances with SOP class UID: " + GetSopClassUid(dicom));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
217 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219 const unsigned int width = parameters.GetImageInformation().GetWidth();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 const unsigned int height = parameters.GetImageInformation().GetHeight();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 const unsigned int depth = parameters.GetImageInformation().GetNumberOfFrames();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 OrthancStone::VolumeImageGeometry geometry;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
225 geometry.SetSizeInVoxels(width, height, depth);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
226 geometry.SetAxialGeometry(parameters.GetGeometry());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
227 geometry.SetVoxelDimensions(parameters.GetPixelSpacingX(),
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 parameters.GetPixelSpacingY(), spacingZ);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 volume_->Initialize(geometry, format, true /* Do compute range */);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
232 volume_->GetPixelData().Clear();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
233
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 ScheduleFrameDownloads();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 BroadcastMessage(OrthancStone::DicomVolumeImage::GeometryReadyMessage(*volume_));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
240
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 ORTHANC_FORCE_INLINE
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 static void CopyPixel(uint32_t& target, const void* source)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 // TODO - check alignement?
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
246 target = le32toh(*reinterpret_cast<const uint32_t*>(source));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 ORTHANC_FORCE_INLINE
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 static void CopyPixel(uint16_t& target, const void* source)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 // TODO - check alignement?
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
253 target = le16toh(*reinterpret_cast<const uint16_t*>(source));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 ORTHANC_FORCE_INLINE
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
257 static void CopyPixel(int16_t& target, const void* source)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
258 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
259 // byte swapping is the same for unsigned and signed integers
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
260 // (the sign bit is always stored with the MSByte)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 uint16_t* targetUp = reinterpret_cast<uint16_t*>(&target);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
262 CopyPixel(*targetUp, source);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
264
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
265 template <typename T>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
266 void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
267 const std::string& pixelData, std::map<T,uint64_t>& distribution)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
268 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
269 OrthancStone::ImageBuffer3D& target = volume_->GetPixelData();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
270
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
271 const unsigned int bpp = target.GetBytesPerPixel();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
272 const unsigned int width = target.GetWidth();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
273 const unsigned int height = target.GetHeight();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 const unsigned int depth = target.GetDepth();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
275
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
276 if (pixelData.size() != bpp * width * height * depth)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
277 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
278 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279 "The pixel data has not the proper size");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
280 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
281
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
282 if (pixelData.empty())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
284 return;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
285 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
286
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
287 // first pass to initialize map
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
288 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
289 const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData.c_str());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
290
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
291 for (unsigned int z = 0; z < depth; z++)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
292 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
293 for (unsigned int y = 0; y < height; y++)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
294 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
295 for (unsigned int x = 0; x < width; x++)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
296 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
297 T value;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
298 CopyPixel(value, source);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
299 distribution[value] = 0;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 source += bpp;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
301 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
302 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
303 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
304 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
305
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
306 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData.c_str());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
309 for (unsigned int z = 0; z < depth; z++)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
310 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
311 OrthancStone::ImageBuffer3D::SliceWriter writer(target, OrthancStone::VolumeProjection_Axial, z);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
312
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
313 assert(writer.GetAccessor().GetWidth() == width &&
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
314 writer.GetAccessor().GetHeight() == height);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
315
1349
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
316 T* targetAddr0 = reinterpret_cast<T*>(writer.GetAccessor().GetRow(0));
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
317 unsigned int pitch = writer.GetAccessor().GetPitch();
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
318 T* targetAddr = targetAddr0;
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
319 assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat()));
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
320
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
321 for (unsigned int y = 0; y < height; y++)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
322 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 for (unsigned int x = 0; x < width; x++)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
324 {
1349
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
325 CopyPixel(*targetAddr, source);
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
326
1349
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
327 distribution[*targetAddr] += 1;
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
328
1349
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
329 targetAddr++;
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
330 source += bpp;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 }
1349
b1e6bef86955 Tentative loop optimization in CopyPixelDataAndComputeDistribution
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
332 targetAddr += pitch;
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
333 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
334 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
335 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
336 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
338 template <typename T>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
339 void OrthancMultiframeVolumeLoader::ComputeMinMaxWithOutlierRejection(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
340 const std::map<T, uint64_t>& distribution)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
341 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
342 if (distribution.size() == 0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
343 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
344 LOG(ERROR) << "ComputeMinMaxWithOutlierRejection -- Volume image empty.";
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
345 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
346 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
347 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
348 OrthancStone::ImageBuffer3D& target = volume_->GetPixelData();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
349
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
350 const uint64_t width = target.GetWidth();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
351 const uint64_t height = target.GetHeight();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
352 const uint64_t depth = target.GetDepth();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
353 const uint64_t voxelCount = width * height * depth;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
354
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
355 // now that we have distribution[pixelValue] == numberOfPixelsWithValue
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
356 // compute number of values and check (assertion) that it is equal to
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
357 // width * height * depth
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
358 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
359 typename std::map<T, uint64_t>::const_iterator it = distribution.begin();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
360 uint64_t totalCount = 0;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
361 distributionRawMin_ = static_cast<float>(it->first);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
362
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
363 while (it != distribution.end())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
364 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
365 T pixelValue = it->first;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
366 uint64_t count = it->second;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
367 totalCount += count;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
368 it++;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
369 if (it == distribution.end())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
370 distributionRawMax_ = static_cast<float>(pixelValue);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
371 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
372 LOG(INFO) << "Volume image. First distribution value = "
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
373 << static_cast<float>(distributionRawMin_)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
374 << " | Last distribution value = "
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
375 << static_cast<float>(distributionRawMax_);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
376
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
377 if (totalCount != voxelCount)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
378 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
379 LOG(ERROR) << "Internal error in dose distribution computation. TC ("
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
380 << totalCount << ") != VoxC (" << voxelCount;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
381 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
382 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
383 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
384
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
385 // compute the number of voxels to reject at each end of the distribution
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
386 uint64_t endRejectionCount = static_cast<uint64_t>(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
387 outliersHalfRejectionRate_ * voxelCount);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
388
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
389 if (endRejectionCount > voxelCount)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
390 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
391 LOG(ERROR) << "Internal error in dose distribution computation."
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
392 << " endRejectionCount = " << endRejectionCount
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
393 << " | voxelCount = " << voxelCount;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
394 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
395 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
396
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
397 // this will contain the actual distribution minimum after outlier
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
398 // rejection
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
399 T resultMin = 0;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
400
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
401 // then start from start and remove pixel values up to
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
402 // endRejectionCount voxels rejected
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
403 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
404 typename std::map<T, uint64_t>::const_iterator it = distribution.begin();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
405
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
406 uint64_t currentCount = 0;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
407
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
408 while (it != distribution.end())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
409 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
410 T pixelValue = it->first;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
411 uint64_t count = it->second;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
412
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
413 // if this pixelValue crosses the rejection threshold, let's set it
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
414 // and exit the loop
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
415 if ((currentCount <= endRejectionCount) &&
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
416 (currentCount + count > endRejectionCount))
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
417 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
418 resultMin = pixelValue;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
419 break;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
420 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
421 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
422 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
423 currentCount += count;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
424 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
425 // and continue walking along the distribution
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
426 it++;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
427 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
428 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
429
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
430 // this will contain the actual distribution maximum after outlier
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
431 // rejection
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
432 T resultMax = 0;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
433 // now start from END and remove pixel values up to
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
434 // endRejectionCount voxels rejected
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
435 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
436 typename std::map<T, uint64_t>::const_reverse_iterator it = distribution.rbegin();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
437
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
438 uint64_t currentCount = 0;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
439
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
440 while (it != distribution.rend())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
441 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
442 T pixelValue = it->first;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
443 uint64_t count = it->second;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
444
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
445 if ((currentCount <= endRejectionCount) &&
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
446 (currentCount + count > endRejectionCount))
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
447 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
448 resultMax = pixelValue;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
449 break;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
450 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
451 else
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
452 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
453 currentCount += count;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
454 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
455 // and continue walking along the distribution
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
456 it++;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
457 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
458 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
459 if (resultMin > resultMax)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
460 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
461 LOG(ERROR) << "Internal error in dose distribution computation! " <<
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
462 "resultMin (" << resultMin << ") > resultMax (" << resultMax << ")";
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
463 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
464 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
465 computedDistributionMin_ = static_cast<float>(resultMin);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
466 computedDistributionMax_ = static_cast<float>(resultMax);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
467 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
468 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
469
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
470 template <typename T>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
471 void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeMinMax(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
472 const std::string& pixelData)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
473 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
474 std::map<T, uint64_t> distribution;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
475 CopyPixelDataAndComputeDistribution(pixelData, distribution);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
476 ComputeMinMaxWithOutlierRejection(distribution);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
477 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
478
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
479 void OrthancMultiframeVolumeLoader::SetUncompressedPixelData(const std::string& pixelData)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
480 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
481 switch (volume_->GetPixelData().GetFormat())
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
482 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
483 case Orthanc::PixelFormat_Grayscale32:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
484 CopyPixelDataAndComputeMinMax<uint32_t>(pixelData);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
485 break;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
486 case Orthanc::PixelFormat_Grayscale16:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
487 CopyPixelDataAndComputeMinMax<uint16_t>(pixelData);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
488 break;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
489 case Orthanc::PixelFormat_SignedGrayscale16:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
490 CopyPixelDataAndComputeMinMax<int16_t>(pixelData);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
491 break;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
492 default:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
493 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
494 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
495
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
496 volume_->IncrementRevision();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
497
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
498 pixelDataLoaded_ = true;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
499 BroadcastMessage(OrthancStone::DicomVolumeImage::ContentUpdatedMessage(*volume_));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
500 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
501
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
502 bool OrthancMultiframeVolumeLoader::HasGeometry() const
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
503 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
504 return volume_->HasGeometry();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
505 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
506
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
507 const OrthancStone::VolumeImageGeometry& OrthancMultiframeVolumeLoader::GetImageGeometry() const
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
508 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
509 return volume_->GetGeometry();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
510 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
511
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
512 OrthancMultiframeVolumeLoader::OrthancMultiframeVolumeLoader(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
513 OrthancStone::ILoadersContext& loadersContext,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
514 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
515 float outliersHalfRejectionRate)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
516 : LoaderStateMachine(loadersContext)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
517 , volume_(volume)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
518 , pixelDataLoaded_(false)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
519 , outliersHalfRejectionRate_(outliersHalfRejectionRate)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
520 , distributionRawMin_(0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
521 , distributionRawMax_(0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
522 , computedDistributionMin_(0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
523 , computedDistributionMax_(0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
524 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
525 if (volume.get() == NULL)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
526 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
527 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
528 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
529 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
530
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
531
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
532 boost::shared_ptr<OrthancMultiframeVolumeLoader>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
533 OrthancMultiframeVolumeLoader::Create(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
534 OrthancStone::ILoadersContext& loadersContext,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
535 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
536 float outliersHalfRejectionRate /*= 0.0005*/)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
537 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
538 boost::shared_ptr<OrthancMultiframeVolumeLoader> obj(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
539 new OrthancMultiframeVolumeLoader(
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
540 loadersContext,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
541 volume,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
542 outliersHalfRejectionRate));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
543 obj->LoaderStateMachine::PostConstructor();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
544 return obj;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
545 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
546
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
547 OrthancMultiframeVolumeLoader::~OrthancMultiframeVolumeLoader()
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
548 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
549 LOG(TRACE) << "OrthancMultiframeVolumeLoader::~OrthancMultiframeVolumeLoader()";
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
550 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
551
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
552 void OrthancMultiframeVolumeLoader::GetDistributionMinMax
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
553 (float& minValue, float& maxValue) const
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
554 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
555 if (distributionRawMin_ == 0 && distributionRawMax_ == 0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
556 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
557 LOG(WARNING) << "GetDistributionMinMaxWithOutliersRejection called before computation!";
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
558 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
559 minValue = distributionRawMin_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
560 maxValue = distributionRawMax_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
561 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
562
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
563 void OrthancMultiframeVolumeLoader::GetDistributionMinMaxWithOutliersRejection
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
564 (float& minValue, float& maxValue) const
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
565 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
566 if (computedDistributionMin_ == 0 && computedDistributionMax_ == 0)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
567 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
568 LOG(WARNING) << "GetDistributionMinMaxWithOutliersRejection called before computation!";
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
569 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
570 minValue = computedDistributionMin_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
571 maxValue = computedDistributionMax_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
572 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
573
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
574 void OrthancMultiframeVolumeLoader::LoadInstance(const std::string& instanceId)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
575 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
576 Start();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
577
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
578 instanceId_ = instanceId;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
579
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
580 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
581 std::unique_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
582 command->SetHttpHeader("Accept-Encoding", "gzip");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
583 command->SetUri("/instances/" + instanceId + "/tags");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
584 command->AcquirePayload(new LoadGeometry(*this));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
585 Schedule(command.release());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
586 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
587
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
588 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
589 std::unique_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
590 command->SetUri("/instances/" + instanceId + "/metadata/TransferSyntax");
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
591 command->AcquirePayload(new LoadTransferSyntax(*this));
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
592 Schedule(command.release());
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
593 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
594 }
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
595 }