annotate OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h @ 2114:c23eef785569

update year to 2024
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Jan 2024 16:44:04 +0100
parents 07964689cb0b
children 16c01cc201e7
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
2114
c23eef785569 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2077
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
c23eef785569 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2077
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 *
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * 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
11 * 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
12 *
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * 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
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
17 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
20 * <http://www.gnu.org/licenses/>.
1337
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
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 #pragma once
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 #include "LoaderStateMachine.h"
1339
556b4bc19118 The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents: 1337
diff changeset
27 #include "../Volumes/DicomVolumeImage.h"
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 #include "../Volumes/IGeometryProvider.h"
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 #include <boost/shared_ptr.hpp>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 namespace OrthancStone
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 class OrthancMultiframeVolumeLoader :
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 public LoaderStateMachine,
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
36 public IObservable,
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 public IGeometryProvider
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 private:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 class LoadRTDoseGeometry;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 class LoadGeometry;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 class LoadTransferSyntax;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 class LoadUncompressedPixelData;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44
1757
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
45 struct PixelCount
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
46 {
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
47 uint64_t count_;
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
48 PixelCount() { count_ = 0; }
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
49 };
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
50
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
51 boost::shared_ptr<DicomVolumeImage> volume_;
2076
990f396484b1 fix rendering of RT-DOSE with negative GridFrameOffsetVector
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
52 bool isReversedFrameOffsets_;
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 std::string instanceId_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 std::string transferSyntaxUid_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 bool pixelDataLoaded_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 float outliersHalfRejectionRate_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 float distributionRawMin_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 float distributionRawMax_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 float computedDistributionMin_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 float computedDistributionMax_;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 const std::string& GetInstanceId() const;
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 void ScheduleFrameDownloads();
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 void SetTransferSyntax(const std::string& transferSyntax);
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 void SetGeometry(const Orthanc::DicomMap& dicom);
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 This method will :
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 - copy the pixel values from the response to the volume image
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 - compute the maximum and minimum value while discarding the
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 outliersHalfRejectionRate_ fraction of the outliers from both the start
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 and the end of the distribution.
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 In English, this means that, if the volume dataset contains a few extreme
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 values very different from the rest (outliers) that we want to get rid of,
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 this method allows to do so.
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 If you supply 0.005, for instance, it means 1% of the extreme values will
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 be rejected (0.5% on each side of the distribution)
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 */
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 template <typename T>
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 void CopyPixelDataAndComputeMinMax(const std::string& pixelData);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 /** Service method for CopyPixelDataAndComputeMinMax*/
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 template <typename T>
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
91 void CopyPixelDataAndComputeDistribution(const std::string& pixelData,
1757
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
92 std::map<T, PixelCount>& distribution);
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 /** Service method for CopyPixelDataAndComputeMinMax*/
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 template <typename T>
1757
28979b77ce90 Suppressed one pass on the dose distribution computation
bgo@SHARKNADO.localdomain
parents: 1739
diff changeset
96 void ComputeMinMaxWithOutlierRejection(const std::map<T, PixelCount>& distribution);
1337
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 void SetUncompressedPixelData(const std::string& pixelData);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 protected:
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
101 OrthancMultiframeVolumeLoader(ILoadersContext& loadersContext,
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
102 boost::shared_ptr<DicomVolumeImage> volume,
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
103 float outliersHalfRejectionRate);
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
104
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 public:
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 static boost::shared_ptr<OrthancMultiframeVolumeLoader> Create(
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
107 ILoadersContext& loadersContext,
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
108 boost::shared_ptr<DicomVolumeImage> volume,
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 float outliersHalfRejectionRate = 0.0005);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 virtual ~OrthancMultiframeVolumeLoader();
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
113 bool HasGeometry() const ORTHANC_OVERRIDE;
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
114
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
115 virtual const VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE;
1488
7f16987131e1 Missing include + docs + public getter for volume geometry in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1381
diff changeset
116
1337
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 bool IsPixelDataLoaded() const
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 {
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 return pixelDataLoaded_;
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 void GetDistributionMinMax
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 (float& minValue, float& maxValue) const;
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 void GetDistributionMinMaxWithOutliersRejection
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 (float& minValue, float& maxValue) const;
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 void LoadInstance(const std::string& instanceId);
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 };
b1396be5aa27 Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 }