fw4spl
writer/tid/MeasurementReport.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwGdcmIO/writer/tid/MeasurementReport.hpp"
8 
9 #include "fwGdcmIO/container/DicomCodedAttribute.hpp"
10 #include "fwGdcmIO/container/sr/DicomSRCodeNode.hpp"
11 #include "fwGdcmIO/container/sr/DicomSRContainerNode.hpp"
12 #include "fwGdcmIO/container/sr/DicomSRImageNode.hpp"
13 #include "fwGdcmIO/container/sr/DicomSRNumNode.hpp"
14 #include "fwGdcmIO/container/sr/DicomSRSCoord3DNode.hpp"
15 #include "fwGdcmIO/container/sr/DicomSRSCoordNode.hpp"
16 #include "fwGdcmIO/container/sr/DicomSRTextNode.hpp"
17 #include "fwGdcmIO/container/sr/DicomSRUIDRefNode.hpp"
18 #include "fwGdcmIO/writer/tid/Fiducial.hpp"
19 #include "fwGdcmIO/writer/tid/Measurement.hpp"
20 
21 #include <fwData/PointList.hpp>
22 #include <fwData/String.hpp>
23 #include <fwData/Vector.hpp>
24 
25 #include <fwDataTools/fieldHelper/Image.hpp>
26 
27 #include <fwMedData/Series.hpp>
28 #include <fwMedData/types.hpp>
29 
30 #include <boost/algorithm/string/split.hpp>
31 
32 #include <gdcmUIDGenerator.h>
33 
34 #include <sstream>
35 
36 namespace fwGdcmIO
37 {
38 namespace writer
39 {
40 namespace tid
41 {
42 
43 //------------------------------------------------------------------------------
44 
45 MeasurementReport::MeasurementReport(const SPTR(::gdcm::Writer)& writer,
46  const SPTR(::fwGdcmIO::container::DicomInstance)& instance,
47  const ::fwData::Image::csptr& image) :
48  ::fwGdcmIO::writer::tid::TemplateID< ::fwData::Image >(writer, instance, image)
49 {
50 }
51 
52 //------------------------------------------------------------------------------
53 
55 {
56 }
57 
58 //------------------------------------------------------------------------------
59 
61 {
62  // Create Root Node - Measurement Report Document Titles
64  std::make_shared< ::fwGdcmIO::container::sr::DicomSRContainerNode >(
65  ::fwGdcmIO::container::DicomCodedAttribute("dd1dd1", "DCM", "Imaging Measurement Report"));
66 
67  // Create Language of Content Item and Descendants Node (TID 1204)
69  std::make_shared< ::fwGdcmIO::container::sr::DicomSRCodeNode >(
70  ::fwGdcmIO::container::DicomCodedAttribute("121049", "DCM", "Language of Content Item and Descendants"),
71  "HAS CONCEPT MOD",
72  ::fwGdcmIO::container::DicomCodedAttribute("en-US", "RFC3066", "English, United States")); // FIXME Do we
73  // keep English
74  // US ?
75  rootNode->addSubNode(languagesNode);
76 
77  // Create Observation Context Node (TID 1001) FIXME Do we need to add that template ?
78 
79  // Create Procedure Reported Node
80  SPTR(::fwGdcmIO::container::sr::DicomSRCodeNode) procedureReportedNode =
81  std::make_shared< ::fwGdcmIO::container::sr::DicomSRCodeNode >(
82  ::fwGdcmIO::container::DicomCodedAttribute("121058", "DCM", "Procedure reported"),
83  "HAS CONCEPT MOD",
84  ::fwGdcmIO::container::DicomCodedAttribute("P5-09051", "SRT", "Magnetic resonance imaging guidance")); // FIXME
85  // Find
86  // a good
87  // value
88  rootNode->addSubNode(procedureReportedNode);
89 
90  // Create ImageLibrary Node
92  std::make_shared< ::fwGdcmIO::container::sr::DicomSRContainerNode >(
93  ::fwGdcmIO::container::DicomCodedAttribute("111028", "DCM", "Image Library"), "CONTAINS");
94  rootNode->addSubNode(imageLibraryNode);
95 
96  // Add landmarks
98  {
99  // Create Fiducial Container
101  std::make_shared< ::fwGdcmIO::container::sr::DicomSRContainerNode >(
102  ::fwGdcmIO::container::DicomCodedAttribute("dd1d93", "DCM", "Fiducials"), "CONTAINS");
103  rootNode->addSubNode(fiducialNode);
104 
106  fiducialTID.createNodes(fiducialNode, useSCoord3D);
107  }
108 
109  // Add distances
111  {
112  // Create Imaging Measurements Container
113  SPTR(::fwGdcmIO::container::sr::DicomSRContainerNode) imagingMeasurementsNode =
114  std::make_shared< ::fwGdcmIO::container::sr::DicomSRContainerNode >(
115  ::fwGdcmIO::container::DicomCodedAttribute("dd1d91", "DCM", "Imaging Measurements"), "CONTAINS");
116  rootNode->addSubNode(imagingMeasurementsNode);
117 
118  // Create Measurement Group node
119  SPTR(::fwGdcmIO::container::sr::DicomSRContainerNode) measurementGroupNode =
120  std::make_shared< ::fwGdcmIO::container::sr::DicomSRContainerNode >(
121  ::fwGdcmIO::container::DicomCodedAttribute("125007", "DCM", "Measurement Group"), "CONTAINS");
122  imagingMeasurementsNode->addSubNode(measurementGroupNode);
123 
124  // Create Tracking ID node
126  std::make_shared< ::fwGdcmIO::container::sr::DicomSRTextNode >(
127  ::fwGdcmIO::container::DicomCodedAttribute("112039", "DCM", "Tracking Identifier"),
128  "HAS OBS CONTEXT", "1");
129  imagingMeasurementsNode->addSubNode(idNode);
130 
131  // Create Tracking UID node
132  ::gdcm::UIDGenerator generator;
134  std::make_shared< ::fwGdcmIO::container::sr::DicomSRUIDRefNode >(
135  ::fwGdcmIO::container::DicomCodedAttribute("112040", "DCM", "Tracking Unique Identifier"),
136  "HAS OBS CONTEXT", generator.Generate());
137  imagingMeasurementsNode->addSubNode(uidNode);
138 
140  measurementTID.createNodes(imagingMeasurementsNode, useSCoord3D);
141 
142  }
143 
144  return rootNode;
145 }
146 
147 //------------------------------------------------------------------------------
148 
149 } // namespace tid
150 } // namespace writer
151 } // namespace fwGdcmIO
#define SPTR(_cls_)
This class defines a UIDREF node in a SR document.
std::shared_ptr< const ::fwData::Image > m_object
FW4SPL Object.
virtual FWGDCMIO_API void createNodes(const std::shared_ptr< ::fwGdcmIO::container::sr::DicomSRNode > &parent, bool useSCoord3D=true)
Create nodes according to the template.
std::shared_ptr< ::gdcm::Writer > m_writer
GDCM Writer.
This class defines a TEXT node in a SR document.
virtual FWGDCMIO_API std::shared_ptr< ::fwGdcmIO::container::sr::DicomSRNode > createRootNode(bool useSCoord3D=true)
Create Measurement Report template root node.
This class defines a DICOM SOP instance. It is useful during the whole writing process. This class allows to share data between module writers.
virtual FWGDCMIO_API void createNodes(const std::shared_ptr< ::fwGdcmIO::container::sr::DicomSRNode > &parent, bool useSCoord3D=true)
Create nodes according to the template.
TemplateID base class used to write templates.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
FWGDCMIO_API MeasurementReport(const std::shared_ptr< ::gdcm::Writer > &writer, const std::shared_ptr< ::fwGdcmIO::container::DicomInstance > &instance, const ::fwData::Image::csptr &image)
Constructor.
This class defines a node in a SR document.
Definition: DicomSRNode.hpp:27
This class defines a vector of objects.
This class represents a DICOM basic coded entry. It stores the four mains attributes : Code Value...
std::shared_ptr< ::fwGdcmIO::container::DicomInstance > m_instance
DICOM Instance.
This class defines a CONTAINER node in a SR document.
This class defines a CODE node in a SR document.
This class defines a list of points.
Contains the representation of the data objects used in the framework.
virtual FWGDCMIO_API ~MeasurementReport()
Destructor.
Measurement Report TID - This a root template.