Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkRTPlanReaderService.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
15 
16 #include "mitkImage.h"
18 #include "mitkIOMimeTypes.h"
19 #include <mitkDICOMIOHelper.h>
20 #include "mitkDICOMTagPath.h"
23 #include "mitkDicomRTIOMimeTypes.h"
24 
25 
26 namespace mitk
27 {
28 
29  RTPlanReaderService::RTPlanReaderService() : AbstractFileReader(CustomMimeType(mitk::DicomRTIOMimeTypes::DICOMRT_PLAN_MIMETYPE_NAME()), mitk::DicomRTIOMimeTypes::DICOMRT_PLAN_MIMETYPE_DESCRIPTION()) {
30  m_FileReaderServiceReg = RegisterService();
31 
32  }
33 
35  {
36  }
37 
39 
40  std::vector<itk::SmartPointer<BaseData> > RTPlanReaderService::Read()
41  {
42  std::vector<itk::SmartPointer<mitk::BaseData> > result;
44  auto tagsOfInterest = DICOMTagsOfInterestService->GetTagsOfInterest();
45  DICOMTagPathList tagsOfInterestList;
46  for (const auto& tag : tagsOfInterest) {
47  tagsOfInterestList.push_back(tag.first);
48  }
49 
50  std::string location = GetInputLocation();
51  mitk::StringList files = { location };
52  mitk::DICOMDCMTKTagScanner::Pointer scanner = mitk::DICOMDCMTKTagScanner::New();
53  scanner->SetInputFiles(files);
54  scanner->AddTagPaths(tagsOfInterestList);
55  scanner->Scan();
56 
57  mitk::DICOMDatasetAccessingImageFrameList frames = scanner->GetFrameInfoList();
58  if (frames.empty()) {
59  MITK_ERROR << "Error reading the RTPLAN file" << std::endl;
60  return result;
61  }
62 
63  auto findings = ExtractPathsOfInterest(tagsOfInterestList, frames);
64 
65  //just create empty image. No image information available in RTPLAN. But properties will be attached.
66  Image::Pointer dummyImage = Image::New();
67  mitk::PixelType pt = mitk::MakeScalarPixelType<int>();
68  unsigned int dim[] = { 1,1};
69  dummyImage->Initialize(pt, 2, dim);
70  SetProperties(dummyImage, findings);
71 
72  result.push_back(dummyImage.GetPointer());
73 
74  return result;
75  }
76 
77  RTPlanReaderService* RTPlanReaderService::Clone() const
78  {
79  return new RTPlanReaderService(*this);
80  }
81 
82 }
MITKDICOMREADER_EXPORT FindingsListVectorType ExtractPathsOfInterest(const DICOMTagPathList &pathsOfInterest, const DICOMDatasetAccessingImageFrameList &frames)
#define MITK_ERROR
Definition: mitkLogMacros.h:20
RTPlanReaderService reads DICOM files of modality RTPLAN.
DataCollection - Class to facilitate loading/accessing structured data.
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
static Pointer New()
std::vector< std::string > StringList
std::vector< DICOMTagPath > DICOMTagPathList
MITKDICOMREADER_EXPORT void SetProperties(BaseDataPointer image, const FindingsListVectorType &findings)
std::vector< DICOMDatasetAccessingImageFrameInfo::Pointer > DICOMDatasetAccessingImageFrameList
DICOMTagPathMapType GetTagsOfInterest() const override
Base class for creating mitk::BaseData objects from files or streams.
MITKDICOMREADER_EXPORT mitk::IDICOMTagsOfInterest * GetDicomTagsOfInterestService()
std::string GetInputLocation() const override
Get the current input location.
std::vector< itk::SmartPointer< BaseData > > Read() override
Reads the file (only tags).
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51