Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/DicomInstanceParameters.cpp @ 1303:83af7e562b45 broker
IGeometryProvider interface for deprecated loaders (required for AB testing in older app)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 04 Mar 2020 09:44:09 +0100 |
parents | 7ec8fea061b9 |
children | 6ab03e429f06 |
rev | line source |
---|---|
746 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1206
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
746 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "DicomInstanceParameters.h" | |
23 | |
24 #include "../Scene2D/ColorTextureSceneLayer.h" | |
25 #include "../Scene2D/FloatTextureSceneLayer.h" | |
26 #include "../Toolbox/GeometryToolbox.h" | |
27 | |
28 #include <Core/Images/Image.h> | |
29 #include <Core/Images/ImageProcessing.h> | |
30 #include <Core/Logging.h> | |
31 #include <Core/OrthancException.h> | |
32 #include <Core/Toolbox.h> | |
33 | |
34 | |
35 namespace OrthancStone | |
36 { | |
37 void DicomInstanceParameters::Data::ComputeDoseOffsets(const Orthanc::DicomMap& dicom) | |
38 { | |
39 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html | |
40 | |
41 { | |
42 std::string increment; | |
43 | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
44 if (dicom.LookupStringValue(increment, Orthanc::DICOM_TAG_FRAME_INCREMENT_POINTER, false)) |
746 | 45 { |
46 Orthanc::Toolbox::ToUpperCase(increment); | |
949
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
768
diff
changeset
|
47 if (increment != "3004,000C") // This is the "Grid Frame Offset Vector" tag (DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) |
746 | 48 { |
49 LOG(ERROR) << "RT-DOSE: Bad value for the \"FrameIncrementPointer\" tag"; | |
50 return; | |
51 } | |
52 } | |
53 } | |
54 | |
55 if (!LinearAlgebra::ParseVector(frameOffsets_, dicom, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) || | |
56 frameOffsets_.size() < imageInformation_.GetNumberOfFrames()) | |
57 { | |
58 LOG(ERROR) << "RT-DOSE: No information about the 3D location of some slice(s)"; | |
59 frameOffsets_.clear(); | |
60 } | |
61 else | |
62 { | |
63 if (frameOffsets_.size() >= 2) | |
64 { | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
65 thickness_ = std::abs(frameOffsets_[1] - frameOffsets_[0]); |
746 | 66 } |
67 } | |
68 } | |
69 | |
70 | |
71 DicomInstanceParameters::Data::Data(const Orthanc::DicomMap& dicom) : | |
72 imageInformation_(dicom) | |
73 { | |
74 if (imageInformation_.GetNumberOfFrames() <= 0) | |
75 { | |
76 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
77 } | |
78 | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
79 if (!dicom.LookupStringValue(studyInstanceUid_, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
80 !dicom.LookupStringValue(seriesInstanceUid_, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) || |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
81 !dicom.LookupStringValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false)) |
746 | 82 { |
83 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
84 } | |
85 | |
86 std::string s; | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
87 if (!dicom.LookupStringValue(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false)) |
746 | 88 { |
89 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
90 } | |
91 else | |
92 { | |
93 sopClassUid_ = StringToSopClassUid(s); | |
94 } | |
95 | |
96 if (!dicom.ParseDouble(thickness_, Orthanc::DICOM_TAG_SLICE_THICKNESS)) | |
97 { | |
98 thickness_ = 100.0 * std::numeric_limits<double>::epsilon(); | |
99 } | |
100 | |
101 GeometryToolbox::GetPixelSpacing(pixelSpacingX_, pixelSpacingY_, dicom); | |
102 | |
103 std::string position, orientation; | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
104 if (dicom.LookupStringValue(position, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, false) && |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
105 dicom.LookupStringValue(orientation, Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false)) |
746 | 106 { |
107 geometry_ = CoordinateSystem3D(position, orientation); | |
108 } | |
109 | |
110 if (sopClassUid_ == SopClassUid_RTDose) | |
111 { | |
112 ComputeDoseOffsets(dicom); | |
1091
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
113 |
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
114 static const Orthanc::DicomTag DICOM_TAG_DOSE_UNITS(0x3004, 0x0002); |
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
115 |
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
116 if (!dicom.LookupStringValue(doseUnits_, DICOM_TAG_DOSE_UNITS, false)) |
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
117 { |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
118 LOG(ERROR) << "Tag DoseUnits (0x3004, 0x0002) is missing in " << sopInstanceUid_; |
1091
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
119 doseUnits_ = ""; |
5a18e6a395bc
Added DoseUnit tag retrieval to DicomInstanceParameters
Benjamin Golinvaux <bgo@osimis.io>
parents:
1027
diff
changeset
|
120 } |
746 | 121 } |
122 | |
123 isColor_ = (imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 && | |
124 imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2); | |
125 | |
126 if (dicom.ParseDouble(rescaleIntercept_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) && | |
127 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) | |
128 { | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
129 if (sopClassUid_ == SopClassUid_RTDose) |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
130 { |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
131 LOG(INFO) << "DOSE HAS Rescale*: rescaleIntercept_ = " << rescaleIntercept_ << " rescaleSlope_ = " << rescaleSlope_; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
132 // WE SHOULD NOT TAKE THE RESCALE VALUE INTO ACCOUNT IN THE CASE OF DOSES |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
133 hasRescale_ = false; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
134 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
135 else |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
136 { |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
137 hasRescale_ = true; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
138 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
139 |
746 | 140 } |
141 else | |
142 { | |
143 hasRescale_ = false; | |
144 } | |
145 | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
146 if (dicom.ParseDouble(doseGridScaling_, Orthanc::DICOM_TAG_DOSE_GRID_SCALING)) |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
147 { |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
148 if (sopClassUid_ == SopClassUid_RTDose) |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
149 { |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
150 LOG(INFO) << "DOSE HAS DoseGridScaling: doseGridScaling_ = " << doseGridScaling_; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
151 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
152 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
153 else |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
154 { |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
155 doseGridScaling_ = 1.0; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
156 if (sopClassUid_ == SopClassUid_RTDose) |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
157 { |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
158 LOG(ERROR) << "Tag DoseGridScaling (0x3004, 0x000e) is missing in " << sopInstanceUid_ << " doseGridScaling_ will be set to 1.0"; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
159 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
160 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
161 |
746 | 162 Vector c, w; |
163 if (LinearAlgebra::ParseVector(c, dicom, Orthanc::DICOM_TAG_WINDOW_CENTER) && | |
164 LinearAlgebra::ParseVector(w, dicom, Orthanc::DICOM_TAG_WINDOW_WIDTH) && | |
165 c.size() > 0 && | |
166 w.size() > 0) | |
167 { | |
168 hasDefaultWindowing_ = true; | |
169 defaultWindowingCenter_ = static_cast<float>(c[0]); | |
170 defaultWindowingWidth_ = static_cast<float>(w[0]); | |
171 } | |
172 else | |
173 { | |
174 hasDefaultWindowing_ = false; | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
175 defaultWindowingCenter_ = 0; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
176 defaultWindowingWidth_ = 0; |
746 | 177 } |
178 | |
179 if (sopClassUid_ == SopClassUid_RTDose) | |
180 { | |
181 switch (imageInformation_.GetBitsStored()) | |
182 { | |
183 case 16: | |
184 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; | |
185 break; | |
186 | |
187 case 32: | |
188 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale32; | |
189 break; | |
190 | |
191 default: | |
192 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
193 } | |
194 } | |
195 else if (isColor_) | |
196 { | |
197 expectedPixelFormat_ = Orthanc::PixelFormat_RGB24; | |
198 } | |
199 else if (imageInformation_.IsSigned()) | |
200 { | |
201 expectedPixelFormat_ = Orthanc::PixelFormat_SignedGrayscale16; | |
202 } | |
203 else | |
204 { | |
205 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; | |
206 } | |
980
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
207 |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
208 // This computes the "IndexInSeries" metadata from Orthanc (check |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
209 // out "Orthanc::ServerIndex::Store()") |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
210 hasIndexInSeries_ = ( |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
211 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_INSTANCE_NUMBER) || |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
212 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_IMAGE_INDEX)); |
746 | 213 } |
214 | |
215 | |
216 CoordinateSystem3D DicomInstanceParameters::Data::GetFrameGeometry(unsigned int frame) const | |
217 { | |
218 if (frame == 0) | |
219 { | |
220 return geometry_; | |
221 } | |
222 else if (frame >= imageInformation_.GetNumberOfFrames()) | |
223 { | |
224 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
225 } | |
226 else if (sopClassUid_ == SopClassUid_RTDose) | |
227 { | |
228 if (frame >= frameOffsets_.size()) | |
229 { | |
230 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
231 } | |
232 | |
233 return CoordinateSystem3D( | |
234 geometry_.GetOrigin() + frameOffsets_[frame] * geometry_.GetNormal(), | |
235 geometry_.GetAxisX(), | |
236 geometry_.GetAxisY()); | |
237 } | |
238 else | |
239 { | |
240 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
241 } | |
242 } | |
243 | |
244 | |
245 bool DicomInstanceParameters::Data::IsPlaneWithinSlice(unsigned int frame, | |
246 const CoordinateSystem3D& plane) const | |
247 { | |
248 if (frame >= imageInformation_.GetNumberOfFrames()) | |
249 { | |
250 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
251 } | |
252 | |
253 CoordinateSystem3D tmp = geometry_; | |
254 | |
255 if (frame != 0) | |
256 { | |
257 tmp = GetFrameGeometry(frame); | |
258 } | |
259 | |
260 double distance; | |
261 | |
757 | 262 return (CoordinateSystem3D::ComputeDistance(distance, tmp, plane) && |
746 | 263 distance <= thickness_ / 2.0); |
264 } | |
265 | |
266 | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
267 void DicomInstanceParameters::Data::ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image, |
1159
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
268 bool useDouble) const |
746 | 269 { |
270 if (image.GetFormat() != Orthanc::PixelFormat_Float32) | |
271 { | |
272 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | |
273 } | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
274 |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
275 double factor = doseGridScaling_; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
276 double offset = 0.0; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
277 |
746 | 278 if (hasRescale_) |
279 { | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
280 factor *= rescaleSlope_; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
281 offset = rescaleIntercept_; |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
282 } |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
283 |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
284 if ( (factor != 1.0) || (offset != 0.0) ) |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
285 { |
746 | 286 const unsigned int width = image.GetWidth(); |
287 const unsigned int height = image.GetHeight(); | |
288 | |
289 for (unsigned int y = 0; y < height; y++) | |
290 { | |
291 float* p = reinterpret_cast<float*>(image.GetRow(y)); | |
292 | |
293 if (useDouble) | |
294 { | |
295 // Slower, accurate implementation using double | |
296 for (unsigned int x = 0; x < width; x++, p++) | |
297 { | |
298 double value = static_cast<double>(*p); | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
299 *p = static_cast<float>(value * factor + offset); |
746 | 300 } |
301 } | |
302 else | |
303 { | |
304 // Fast, approximate implementation using float | |
305 for (unsigned int x = 0; x < width; x++, p++) | |
306 { | |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
307 *p = (*p) * static_cast<float>(factor) + static_cast<float>(offset); |
746 | 308 } |
309 } | |
310 } | |
311 } | |
312 } | |
313 | |
314 double DicomInstanceParameters::GetRescaleIntercept() const | |
315 { | |
316 if (data_.hasRescale_) | |
317 { | |
318 return data_.rescaleIntercept_; | |
319 } | |
320 else | |
321 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
322 LOG(ERROR) << "DicomInstanceParameters::GetRescaleIntercept(): !data_.hasRescale_"; |
746 | 323 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
324 } | |
325 } | |
326 | |
327 | |
328 double DicomInstanceParameters::GetRescaleSlope() const | |
329 { | |
330 if (data_.hasRescale_) | |
331 { | |
332 return data_.rescaleSlope_; | |
333 } | |
334 else | |
335 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
336 LOG(ERROR) << "DicomInstanceParameters::GetRescaleSlope(): !data_.hasRescale_"; |
746 | 337 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
338 } | |
339 } | |
340 | |
341 | |
342 float DicomInstanceParameters::GetDefaultWindowingCenter() const | |
343 { | |
344 if (data_.hasDefaultWindowing_) | |
345 { | |
346 return data_.defaultWindowingCenter_; | |
347 } | |
348 else | |
349 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
350 LOG(ERROR) << "DicomInstanceParameters::GetDefaultWindowingCenter(): !data_.hasRescale_"; |
746 | 351 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
352 } | |
353 } | |
354 | |
355 | |
356 float DicomInstanceParameters::GetDefaultWindowingWidth() const | |
357 { | |
358 if (data_.hasDefaultWindowing_) | |
359 { | |
360 return data_.defaultWindowingWidth_; | |
361 } | |
362 else | |
363 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
364 LOG(ERROR) << "DicomInstanceParameters::GetDefaultWindowingWidth(): !data_.hasRescale_"; |
746 | 365 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
366 } | |
367 } | |
368 | |
369 | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
370 Orthanc::ImageAccessor* DicomInstanceParameters::ConvertToFloat(const Orthanc::ImageAccessor& pixelData) const |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
371 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
372 std::auto_ptr<Orthanc::Image> converted(new Orthanc::Image(Orthanc::PixelFormat_Float32, |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
373 pixelData.GetWidth(), |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
374 pixelData.GetHeight(), |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
375 false)); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
376 Orthanc::ImageProcessing::Convert(*converted, pixelData); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
377 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
378 // Correct rescale slope/intercept if need be |
1141
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
379 //data_.ApplyRescaleAndDoseScaling(*converted, (pixelData.GetFormat() == Orthanc::PixelFormat_Grayscale32)); |
7681f3943748
Changed handling of DoseGridScaling: before this commit, rescaleSlope was set to
Benjamin Golinvaux <bgo@osimis.io>
parents:
1091
diff
changeset
|
380 data_.ApplyRescaleAndDoseScaling(*converted, false); |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
381 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
382 return converted.release(); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
383 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
384 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
385 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
386 TextureBaseSceneLayer* DicomInstanceParameters::CreateTexture |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
387 (const Orthanc::ImageAccessor& pixelData) const |
746 | 388 { |
389 assert(sizeof(float) == 4); | |
390 | |
391 Orthanc::PixelFormat sourceFormat = pixelData.GetFormat(); | |
392 | |
393 if (sourceFormat != GetExpectedPixelFormat()) | |
394 { | |
395 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | |
396 } | |
397 | |
398 if (sourceFormat == Orthanc::PixelFormat_RGB24) | |
399 { | |
400 // This is the case of a color image. No conversion has to be done. | |
401 return new ColorTextureSceneLayer(pixelData); | |
402 } | |
403 else | |
404 { | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
405 // This is the case of a grayscale frame. Convert it to Float32. |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
406 std::auto_ptr<FloatTextureSceneLayer> texture; |
746 | 407 |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
408 if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) |
746 | 409 { |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
410 texture.reset(new FloatTextureSceneLayer(pixelData)); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
411 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
412 else |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
413 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
414 std::auto_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); |
746 | 415 texture.reset(new FloatTextureSceneLayer(*converted)); |
416 } | |
417 | |
418 if (data_.hasDefaultWindowing_) | |
419 { | |
420 texture->SetCustomWindowing(data_.defaultWindowingCenter_, | |
421 data_.defaultWindowingWidth_); | |
422 } | |
1206
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
423 |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
424 |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
425 if (data_.imageInformation_.GetPhotometricInterpretation() |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
426 == Orthanc::PhotometricInterpretation_Monochrome1) |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
427 { |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
428 texture->SetInverted(true); |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
429 } |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
430 else if (data_.imageInformation_.GetPhotometricInterpretation() |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
431 == Orthanc::PhotometricInterpretation_Monochrome2) |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
432 { |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
433 texture->SetInverted(false); |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
434 } |
c93a6218f0cd
Fixed photometric interpretation in texture creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
1141
diff
changeset
|
435 |
746 | 436 return texture.release(); |
437 } | |
438 } | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
439 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
440 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
441 LookupTableTextureSceneLayer* DicomInstanceParameters::CreateLookupTableTexture |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
442 (const Orthanc::ImageAccessor& pixelData) const |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
443 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
444 std::auto_ptr<FloatTextureSceneLayer> texture; |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
445 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
446 if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
447 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
448 return new LookupTableTextureSceneLayer(pixelData); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
449 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
450 else |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
451 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
452 std::auto_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
453 return new LookupTableTextureSceneLayer(*converted); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
454 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
455 } |
980
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
456 |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
457 |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
458 unsigned int DicomInstanceParameters::GetIndexInSeries() const |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
459 { |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
460 if (data_.hasIndexInSeries_) |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
461 { |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
462 return data_.indexInSeries_; |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
463 } |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
464 else |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
465 { |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
466 LOG(ERROR) << "DicomInstanceParameters::GetIndexInSeries(): !data_.hasIndexInSeries_"; |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
467 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
468 } |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
469 } |
1159
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
470 |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
471 |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
472 double DicomInstanceParameters::Data::ApplyRescale(double value) const |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
473 { |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
474 double factor = doseGridScaling_; |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
475 double offset = 0.0; |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
476 |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
477 if (hasRescale_) |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
478 { |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
479 factor *= rescaleSlope_; |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
480 offset = rescaleIntercept_; |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
481 } |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
482 |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
483 return (value * factor + offset); |
acb399643945
DicomInstanceParameters::ApplyRescale()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1141
diff
changeset
|
484 } |
1161
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
485 |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
486 |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
487 bool DicomInstanceParameters::Data::ComputeRegularSpacing(double& spacing) const |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
488 { |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
489 if (frameOffsets_.size() == 0) // Not a RT-DOSE |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
490 { |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
491 return false; |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
492 } |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
493 else if (frameOffsets_.size() == 1) |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
494 { |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
495 spacing = 1; // Edge case: RT-DOSE with one single frame |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
496 return true; |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
497 } |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
498 else |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
499 { |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
500 spacing = std::abs(frameOffsets_[1] - frameOffsets_[0]); |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
501 |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
502 for (size_t i = 1; i + 1 < frameOffsets_.size(); i++) |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
503 { |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
504 double s = frameOffsets_[i + 1] - frameOffsets_[i]; |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
505 if (!LinearAlgebra::IsNear(spacing, s, 0.001)) |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
506 { |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
507 return false; |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
508 } |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
509 } |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
510 |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
511 return true; |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
512 } |
19b1c8caade4
fix sagittal geometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1159
diff
changeset
|
513 } |
746 | 514 } |