annotate OrthancStone/Resources/Graveyard/Toolbox/DicomDataset.h @ 1513:24068dd8c445

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