7 #include "fwGdcmIO/reader/iod/SpatialFiducialsIOD.hpp" 9 #include "fwGdcmIO/helper/DicomDataReader.hxx" 10 #include "fwGdcmIO/reader/ie/SpatialFiducials.hpp" 12 #include <fwData/PointList.hpp> 13 #include <fwData/Vector.hpp> 15 #include <fwDataTools/fieldHelper/Image.hpp> 17 #include <fwMedData/ImageSeries.hpp> 19 #include <boost/algorithm/string/trim.hpp> 31 const ::fwGdcmIO::container::DicomInstance::sptr& instance,
32 const ::fwLog::Logger::sptr& logger,
33 ProgressCallback progress,
34 CancelRequestedCallback cancel) :
35 ::
fwGdcmIO::reader::iod::InformationObjectDefinition(dicomSeries, instance, logger, progress, cancel)
41 SpatialFiducialsIOD::~SpatialFiducialsIOD()
51 ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
52 SLM_ASSERT(
"ImageSeries should not be null.", imageSeries);
53 ::fwData::Image::sptr image = imageSeries->getImage();
54 SLM_ASSERT(
"::fwData::Image not instanced", image);
57 SPTR(::gdcm::Reader) reader = std::shared_ptr< ::gdcm::Reader >( new ::gdcm::Reader );
60 ::fwMedData::DicomSeries::DicomContainerType dicomContainer = m_dicomSeries->getDicomContainer();
62 if(dicomContainer.size() > 1)
64 m_logger->warning(
"More than one Spatial Fiducials item have been found in the series. " 65 "Only the first one will be read.");
68 const ::fwMemory::BufferObject::sptr bufferObj = dicomContainer.begin()->second;
69 const ::fwMemory::BufferManager::StreamInfo streamInfo = bufferObj->getStreamInfo();
70 SPTR(std::istream) is = streamInfo.stream;
71 reader->SetStream(*is);
73 const bool success = reader->Read();
75 bufferObj->getStreamInfo().fsFile.string()+
76 "\" using the GDCM Reader."), !success);
80 m_dicomSeries, reader,
m_instance, imageSeries->getImage(),
84 const ::gdcm::DataSet& datasetRoot = reader->GetFile().GetDataSet();
87 const ::gdcm::DataElement& fiducialSetSequenceDataElement =
88 datasetRoot.GetDataElement( ::gdcm::Tag(0x0070, 0x031C) );
89 const ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > fiducialSetSequence =
90 fiducialSetSequenceDataElement.GetValueAsSQ();
92 for(
unsigned int i = 1; i <= fiducialSetSequence->GetNumberOfItems(); ++i)
94 ::gdcm::Item sequenceSetItem = fiducialSetSequence->GetItem(i);
95 const ::gdcm::DataSet& sequenceSetDataset = sequenceSetItem.GetNestedDataSet();
97 const ::gdcm::DataElement& fiducialSequenceDataElement =
98 sequenceSetDataset.GetDataElement( ::gdcm::Tag(0x0070, 0x031E) );
99 const ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > fiducialSequence =
100 fiducialSequenceDataElement.GetValueAsSQ();
102 for(
unsigned int j = 1; j <= fiducialSequence->GetNumberOfItems(); ++j)
104 ::gdcm::Item fiducialItem = fiducialSequence->GetItem(j);
105 const ::gdcm::DataSet& fiducialDataset = fiducialItem.GetNestedDataSet();
106 const std::string shapeType =
107 ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0070, 0x0306>(fiducialDataset);
109 if(shapeType ==
"POINT")
115 m_logger->warning(
"Fiducial shape type not supported: \"" + shapeType +
"\"");
void readLandmark(const ::gdcm::DataSet &fiducialDataset)
Read image landmarks from dataset.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWGDCMIO_API SpatialFiducialsIOD(const ::fwMedData::DicomSeries::csptr &dicomSeries, const std::shared_ptr< ::fwGdcmIO::container::DicomInstance > &instance, const ::fwLog::Logger::sptr &logger=nullptr, ProgressCallback progress=nullptr, CancelRequestedCallback cancel=nullptr)
Constructor.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
Implements a failed exception class for fwGdcmIO.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Spatial Fiducials Information Entity class.