Mercurial > hg > orthanc-neuro
changeset 12:8747857b539e
Support Philips private tags for rescale slope/intercept
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 May 2022 17:52:56 +0200 |
parents | 12e36b1b84f3 |
children | cced327deb46 |
files | NEWS Sources/Framework/InputDicomInstance.cpp Sources/UnitTestsSources/NiftiTests.cpp |
diffstat | 3 files changed, 42 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Sat Apr 30 11:26:21 2022 +0200 +++ b/NEWS Wed May 04 17:52:56 2022 +0200 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Support Philips private tags for rescale slope/intercept + Version 1.0 (2022-04-26) ========================
--- a/Sources/Framework/InputDicomInstance.cpp Sat Apr 30 11:26:21 2022 +0200 +++ b/Sources/Framework/InputDicomInstance.cpp Wed May 04 17:52:56 2022 +0200 @@ -38,6 +38,8 @@ static const Orthanc::DicomTag DICOM_TAG_ECHO_TIME(0x0018, 0x0081); static const Orthanc::DicomTag DICOM_TAG_IN_PLANE_PHASE_ENCODING_DIRECTION(0x0018, 0x1312); static const Orthanc::DicomTag DICOM_TAG_REPETITION_TIME(0x0018, 0x0080); +static const Orthanc::DicomTag DICOM_TAG_RESCALE_INTERCEPT_PHILIPS(0x2005, 0x1409); +static const Orthanc::DicomTag DICOM_TAG_RESCALE_SLOPE_PHILIPS(0x2005, 0x140a); static const Orthanc::DicomTag DICOM_TAG_SLICE_SLOPE_PHILIPS(0x2005, 0x100e); static const Orthanc::DicomTag DICOM_TAG_SLICE_TIMING_SIEMENS(0x0019, 0x1029); static const Orthanc::DicomTag DICOM_TAG_SPACING_BETWEEN_SLICES(0x0018, 0x0088); @@ -231,50 +233,57 @@ } + static double GetSingleValue(const std::vector<double>& values) + { + if (values.size() == 1) + { + return values[0]; + } + else + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + } + } + + void InputDicomInstance::ParseRescale() { std::vector<double> v; - if (NeuroToolbox::ParseVector(v, *tags_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) + if (NeuroToolbox::ParseVector(v, *tags_, DICOM_TAG_RESCALE_SLOPE_PHILIPS)) { - if (v.size() == 1) - { - rescaleSlope_ = v[0]; - } - else - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); - } + rescaleSlope_ = GetSingleValue(v); } else { - rescaleSlope_ = 1; - } - - if (manufacturer_ == Manufacturer_Philips && - NeuroToolbox::ParseVector(v, *tags_, DICOM_TAG_SLICE_SLOPE_PHILIPS)) - { - if (v.size() == 1 && - !NeuroToolbox::IsNear(v[0], 0)) + if (NeuroToolbox::ParseVector(v, *tags_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) { - rescaleSlope_ /= v[0]; // cf. PMC3998685 + rescaleSlope_ = GetSingleValue(v); } else { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + rescaleSlope_ = 1; + } + + if (manufacturer_ == Manufacturer_Philips && + NeuroToolbox::ParseVector(v, *tags_, DICOM_TAG_SLICE_SLOPE_PHILIPS)) + { + if (v.size() == 1 && + !NeuroToolbox::IsNear(v[0], 0)) + { + rescaleSlope_ /= v[0]; // cf. PMC3998685 + } + else + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + } } } - if (NeuroToolbox::ParseVector(v, *tags_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT)) + if (NeuroToolbox::ParseVector(v, *tags_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) || + NeuroToolbox::ParseVector(v, *tags_, DICOM_TAG_RESCALE_INTERCEPT_PHILIPS)) { - if (v.size() == 1) - { - rescaleIntercept_ = v[0]; - } - else - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); - } + rescaleIntercept_ = GetSingleValue(v); } else {
--- a/Sources/UnitTestsSources/NiftiTests.cpp Sat Apr 30 11:26:21 2022 +0200 +++ b/Sources/UnitTestsSources/NiftiTests.cpp Wed May 04 17:52:56 2022 +0200 @@ -11256,6 +11256,8 @@ tags.SetValue(0x0008, 0x0060, "MR", false); tags.SetValue(0x0008, 0x0070, "Philips Medical Systems", false); tags.SetValue(0x0020, 0x0013, "4835", false); + tags.SetValue(0x2005, 0x1409, "0", false); + tags.SetValue(0x2005, 0x140a, "4.00757020757020", false); tags.SetValue(0x0018, 0x0080, "2000.00061035156", false); tags.SetValue(0x0018, 0x0081, "30", false); tags.SetValue(0x0018, 0x1312, "COL", false); @@ -11309,7 +11311,7 @@ ASSERT_FLOAT_EQ(nifti.intent_p2, 0); ASSERT_FLOAT_EQ(nifti.intent_p3, 0); ASSERT_FLOAT_EQ(nifti.pixdim[0], -1.000000); - ASSERT_FLOAT_EQ(nifti.scl_slope, 75.538353); + ASSERT_FLOAT_EQ(nifti.scl_slope, 4.007570); ASSERT_FLOAT_EQ(nifti.scl_inter, 0.000000); ASSERT_FLOAT_EQ(nifti.cal_min, 0.000000); ASSERT_FLOAT_EQ(nifti.cal_max, 0.000000);