annotate Applications/Resources/Graveyard/Toolbox/DicomDataset.h @ 1923:f4cdcba8c32a

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Mar 2022 17:39:19 +0100
parents 7053b8a0aaec
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
11 * the License, or (at your option) any later version.
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
16 * Affero General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1586
diff changeset
17 *
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
18 * You should have received a copy of the GNU Affero General Public License
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../../Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <map>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <stdint.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <json/value.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 // This class is NOT thread-safe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 // This is a lightweight alternative to Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class DicomDataset : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 typedef std::pair<uint16_t, uint16_t> Tag;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 typedef std::map<Tag, std::string> Values;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 Values values_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 void Parse(const std::string& content);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 void Parse(const Json::Value& content);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 DicomDataset(const std::string& content)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 Parse(content);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 DicomDataset(const Json::Value& content)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 Parse(content);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 DicomDataset(OrthancPlugins::IOrthancConnection& orthanc,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 const std::string& instanceId);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 bool HasTag(const Tag& tag) const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 return values_.find(tag) != values_.end();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 std::string GetStringValue(const Tag& tag) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 std::string GetStringValue(const Tag& tag,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const std::string& defaultValue) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 float GetFloatValue(const Tag& tag) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 double GetDoubleValue(const Tag& tag) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 int GetIntegerValue(const Tag& tag) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 unsigned int GetUnsignedIntegerValue(const Tag& tag) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 void GetVectorValue(Vector& vector,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 const Tag& tag,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 size_t expectedSize) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 void GetVectorValue(Vector& vector,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 const Tag& tag) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void Print() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 bool IsGrayscale() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 void GetPixelSpacing(double& spacingX,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 double& spacingY) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 static const DicomDataset::Tag DICOM_TAG_COLUMNS(0x0028, 0x0011);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 static const DicomDataset::Tag DICOM_TAG_IMAGE_ORIENTATION_PATIENT(0x0020, 0x0037);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 static const DicomDataset::Tag DICOM_TAG_IMAGE_POSITION_PATIENT(0x0020, 0x0032);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 static const DicomDataset::Tag DICOM_TAG_NUMBER_OF_FRAMES(0x0028, 0x0008);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 static const DicomDataset::Tag DICOM_TAG_PIXEL_REPRESENTATION(0x0028, 0x0103);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 static const DicomDataset::Tag DICOM_TAG_PIXEL_SPACING(0x0028, 0x0030);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 static const DicomDataset::Tag DICOM_TAG_RESCALE_INTERCEPT(0x0028, 0x1052);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 static const DicomDataset::Tag DICOM_TAG_RESCALE_SLOPE(0x0028, 0x1053);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 static const DicomDataset::Tag DICOM_TAG_ROWS(0x0028, 0x0010);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 static const DicomDataset::Tag DICOM_TAG_SLICE_THICKNESS(0x0018, 0x0050);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 static const DicomDataset::Tag DICOM_TAG_WINDOW_CENTER(0x0028, 0x1050);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 static const DicomDataset::Tag DICOM_TAG_WINDOW_WIDTH(0x0028, 0x1051);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 static const DicomDataset::Tag DICOM_TAG_PHOTOMETRIC_INTERPRETATION(0x0028, 0x0004);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }