PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
pet_storage.cpp
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
11
12#include <algorithm>
13#include <array>
14
16
17// =============================================================================
18// Transfer Syntaxes
19// =============================================================================
20
21std::vector<std::string> get_pet_transfer_syntaxes() {
22 return {
23 // Explicit VR Little Endian (preferred for interoperability)
24 "1.2.840.10008.1.2.1",
25 // Implicit VR Little Endian (universal baseline)
26 "1.2.840.10008.1.2",
27 // HTJ2K Lossless (high-throughput lossless, preserves quantitative data)
28 "1.2.840.10008.1.2.4.201",
29 // JPEG Lossless (for diagnostic quality - recommended for quantitative data)
30 "1.2.840.10008.1.2.4.70",
31 // JPEG 2000 Lossless (better compression, preserves quantitative values)
32 "1.2.840.10008.1.2.4.90",
33 // RLE Lossless
34 "1.2.840.10008.1.2.5"
35 };
36}
37
38// =============================================================================
39// Photometric Interpretation
40// =============================================================================
41
42std::string_view to_string(pet_photometric_interpretation interp) noexcept {
43 switch (interp) {
45 return "MONOCHROME2";
46 }
47 return "MONOCHROME2";
48}
49
51parse_pet_photometric_interpretation([[maybe_unused]] std::string_view value) noexcept {
52 // PET images are always MONOCHROME2
54}
55
56bool is_valid_pet_photometric(std::string_view value) noexcept {
57 return value == "MONOCHROME2";
58}
59
60// =============================================================================
61// SOP Class Information
62// =============================================================================
63
64namespace {
65
66// Static array of PET SOP class information
67constexpr std::array<pet_sop_class_info, 3> pet_sop_classes = {{
68 {
70 "PET Image Storage",
71 "Standard PET image storage",
72 false,
73 false, // single-frame
74 false // not enhanced
75 },
76 {
78 "Enhanced PET Image Storage",
79 "Enhanced PET with multi-frame and extended attributes",
80 false,
81 true, // supports multiframe
82 true // enhanced
83 },
84 {
86 "Legacy Converted Enhanced PET Image Storage",
87 "Legacy PET converted to enhanced format",
88 false,
89 true, // supports multiframe
90 true // enhanced
91 }
92}};
93
94} // namespace
95
96std::vector<std::string> get_pet_storage_sop_classes(bool include_retired) {
97 std::vector<std::string> result;
98 result.reserve(pet_sop_classes.size());
99
100 for (const auto& info : pet_sop_classes) {
101 if (!info.is_retired || include_retired) {
102 result.emplace_back(info.uid);
103 }
104 }
105
106 return result;
107}
108
109const pet_sop_class_info*
110get_pet_sop_class_info(std::string_view uid) noexcept {
111 auto it = std::find_if(
112 pet_sop_classes.begin(),
113 pet_sop_classes.end(),
114 [uid](const auto& info) { return info.uid == uid; }
115 );
116
117 if (it != pet_sop_classes.end()) {
118 return &(*it);
119 }
120 return nullptr;
121}
122
123bool is_pet_storage_sop_class(std::string_view uid) noexcept {
124 return get_pet_sop_class_info(uid) != nullptr;
125}
126
127bool is_enhanced_pet_sop_class(std::string_view uid) noexcept {
128 const auto* info = get_pet_sop_class_info(uid);
129 return info != nullptr && info->is_enhanced;
130}
131
132// =============================================================================
133// Reconstruction Type Conversion
134// =============================================================================
135
136std::string_view to_string(pet_reconstruction_type recon) noexcept {
137 switch (recon) {
139 return "FBP";
141 return "OSEM";
143 return "MLEM";
145 return "TOF-OSEM";
147 return "PSF-OSEM";
149 return "OTHER";
150 }
151 return "OTHER";
152}
153
155parse_pet_reconstruction_type(std::string_view value) noexcept {
156 if (value == "FBP" || value == "FILTERED BACK PROJECTION") {
158 }
159 if (value == "OSEM" || value == "3D-OSEM") {
161 }
162 if (value == "MLEM") {
164 }
165 if (value.find("TOF") != std::string_view::npos) {
167 }
168 if (value.find("PSF") != std::string_view::npos) {
170 }
172}
173
174// =============================================================================
175// PET Units Conversion
176// =============================================================================
177
178std::string_view to_string(pet_units units) noexcept {
179 switch (units) {
180 case pet_units::cnts:
181 return "CNTS";
182 case pet_units::bqml:
183 return "BQML";
184 case pet_units::gml:
185 return "GML";
187 return "SUV";
189 return "SUL";
191 return "SUV_BSA";
193 return "%ID/G";
194 case pet_units::other:
195 return "OTHER";
196 }
197 return "OTHER";
198}
199
200pet_units parse_pet_units(std::string_view value) noexcept {
201 if (value == "CNTS") {
202 return pet_units::cnts;
203 }
204 if (value == "BQML" || value == "BQ/ML") {
205 return pet_units::bqml;
206 }
207 if (value == "GML" || value == "G/ML") {
208 return pet_units::gml;
209 }
210 if (value == "SUV" || value == "SUV_BW") {
211 return pet_units::suv_bw;
212 }
213 if (value == "SUL" || value == "SUV_LBM") {
214 return pet_units::suv_lbm;
215 }
216 if (value == "SUV_BSA") {
217 return pet_units::suv_bsa;
218 }
219 if (value == "%ID/G" || value == "PERCENT_ID_GRAM") {
221 }
222 return pet_units::other;
223}
224
225// =============================================================================
226// Radiotracer Conversion
227// =============================================================================
228
229std::string_view to_string(pet_radiotracer tracer) noexcept {
230 switch (tracer) {
232 return "18F-FDG";
234 return "18F-NaF";
236 return "18F-FLT";
238 return "18F-FDOPA";
240 return "13N-Ammonia";
242 return "82Rb";
244 return "68Ga-DOTATATE";
246 return "PSMA";
248 return "Other";
249 }
250 return "Other";
251}
252
253} // namespace kcenon::pacs::services::sop_classes
bool is_pet_storage_sop_class(std::string_view uid) noexcept
Check if a SOP Class UID is a PET Storage SOP Class.
pet_units
PET units type (Units attribute 0054,1001)
@ suv_bw
Standardized Uptake Value (body weight)
@ percent_id_gram
Percent injected dose per gram.
@ bqml
Bq/ml (Becquerels per milliliter)
bool is_valid_pet_photometric(std::string_view value) noexcept
Check if photometric interpretation is valid for PET.
constexpr std::string_view pet_image_storage_uid
PET Image Storage SOP Class UID.
Definition pet_storage.h:37
std::vector< std::string > get_pet_transfer_syntaxes()
Get recommended transfer syntaxes for PET images.
pet_photometric_interpretation parse_pet_photometric_interpretation(std::string_view value) noexcept
Parse DICOM photometric interpretation string.
pet_photometric_interpretation
Supported photometric interpretations for PET images.
Definition pet_storage.h:75
pet_radiotracer
Common PET radiotracers.
pet_reconstruction_type
PET reconstruction algorithm type.
@ osem
Ordered Subset Expectation Maximization.
@ mlem
Maximum Likelihood Expectation Maximization.
bool is_enhanced_pet_sop_class(std::string_view uid) noexcept
Check if a SOP Class UID is an Enhanced PET Storage SOP Class.
std::vector< std::string > get_pet_storage_sop_classes(bool include_retired=true)
Get all PET Storage SOP Class UIDs.
pet_reconstruction_type parse_pet_reconstruction_type(std::string_view value) noexcept
Parse PET reconstruction type from string.
const pet_sop_class_info * get_pet_sop_class_info(std::string_view uid) noexcept
Get information about a specific PET SOP Class.
constexpr std::string_view legacy_converted_enhanced_pet_image_storage_uid
Legacy Converted Enhanced PET Image Storage SOP Class UID.
Definition pet_storage.h:45
pet_units parse_pet_units(std::string_view value) noexcept
Parse PET units from DICOM string.
constexpr std::string_view enhanced_pet_image_storage_uid
Enhanced PET Image Storage SOP Class UID.
Definition pet_storage.h:41
std::string_view to_string(dx_photometric_interpretation interp) noexcept
Convert photometric interpretation enum to DICOM string.
Positron Emission Tomography (PET) Image Storage SOP Classes.
std::string_view uid