File: DicomDataTools.hpp

package info (click to toggle)
sight 21.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 36,592 kB
  • sloc: cpp: 228,341; xml: 19,066; ansic: 9,854; python: 302; sh: 135; makefile: 32
file content (111 lines) | stat: -rw-r--r-- 3,702 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/************************************************************************
 *
 * Copyright (C) 2017-2022 IRCAD France
 * Copyright (C) 2017-2019 IHU Strasbourg
 *
 * This file is part of Sight.
 *
 * Sight is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Sight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
 *
 ***********************************************************************/

#pragma once

#include "io/dicom/config.hpp"
#include "io/dicom/container/DicomCodedAttribute.hpp"
#include "io/dicom/exception/Failed.hpp"

#include <data/Image.hpp>
#include <data/Material.hpp>
#include <data/Point.hpp>

#include <gdcmImage.h>
#include <gdcmSurface.h>

namespace sight::io::dicom
{

namespace helper
{

/**
 * @brief This class contains helpers to handle GDCM data.
 * It implements many tag value getters/setters. It defines
 * also some tools for converting GDCM data to Sight data.
 */
class IO_DICOM_CLASS_API DicomDataTools
{
public:

    /**
     * @brief Return the gdcm pixel type of a sight image.
     * @param[in] type pixel type from a sight.
     * @return The pixel format (e.g: INT8, UINT16, ...)
     */
    IO_DICOM_API static const gdcm::PixelFormat getPixelType(const core::tools::Type& type);

    /**
     * @brief Return the photometric interpretation of an acquisition.
     * @param[in] image Image
     * @return The photometric interpretation (e.g: MONOCHROME2, RGB, ...)
     */
    IO_DICOM_API static const gdcm::PhotometricInterpretation getPhotometricInterpretation(
        const data::Image::csptr& image
    );

    /**
     * @brief Convert a surface representation mode (Sight) into recommended presentation type (DICOM).
     * @see Recommended Presentation Type Tag (0066,000d).
     * @param[in] representationMode Surface representation mode.
     * @return Corresponding recommended presentation type.
     */
    IO_DICOM_API static gdcm::Surface::VIEWType convertToPresentationType(
        data::Material::RepresentationType representationMode
    );

    /**
     * @brief Convert a surface recommended presentation type (DICOM) into representation mode (Sight).
     * @param[in] presentationType Surface recommended presentation type.
     * @return Corresponding representation mode
     */
    IO_DICOM_API static data::Material::RepresentationType convertToRepresentationMode(
        gdcm::Surface::VIEWType presentationType
    );

    /**
     * @brief Convert a 3D point to the closest frame number index
     * @param[in] image Image containing the point
     * @param[in] point 3D point
     * @throw io::dicom::exception::Failed
     */
    IO_DICOM_API static std::size_t convertPointToFrameNumber(
        const data::Image::csptr& image,
        const data::Point::csptr& point
    );

    /**
     * @brief Convert a frame number to a Z coordinate
     * @param[in] image Image containing the point
     * @param[in] frameNumber Frame number
     * @throw io::dicom::exception::Failed
     */
    IO_DICOM_API static double convertFrameNumberToZCoordinate(
        const data::Image::csptr& image,
        const std::size_t frameNumber
    );
};

} // namespace helper

} // namespace sight::io::dicom