Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNrrdTbssImageReader.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __mitkNrrdTbssImageReader_h
18 #define __mitkNrrdTbssImageReader_h
19 
20 #include "mitkCommon.h"
21 #include "mitkFileReader.h"
22 #include "mitkTbssImageSource.h"
23 #include "itkImage.h"
24 #include "itkVectorImage.h"
25 #include "mitkTbssImage.h"
26 
27 namespace mitk
28 {
29 
34  class MITKQUANTIFICATION_EXPORT NrrdTbssImageReader : public mitk::TbssImageSource, public FileReader
35  {
36  public:
37 
39  typedef itk::VectorImage<float,3> ImageType;
41 
42 
43 
44  mitkClassMacro( NrrdTbssImageReader, TbssVolSourceType )
45  itkFactorylessNewMacro(Self)
46  itkCloneMacro(Self)
47 
48  const char* GetFileName() const override;
49  void SetFileName(const char* aFileName) override;
50  const char* GetFilePrefix() const override;
51  void SetFilePrefix(const char* aFilePrefix) override;
52  const char* GetFilePattern() const override;
53  void SetFilePattern(const char* aFilePattern) override;
54 
55  static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern);
56 
57  protected:
58 
60  virtual void GenerateData() override;
61  virtual void GenerateOutputInformation() override;
62 
63 
64  std::string m_FileName;
65  std::string m_FilePrefix;
66  std::string m_FilePattern;
67 
68  std::vector< std::pair<std::string, int> > m_GroupInfo;
69 
70  OutputType::Pointer m_OutputCache;
71  itk::TimeStamp m_CacheTime;
72 
73 
74  void Tokenize(const std::string& str,
75  std::vector<std::string>& tokens,
76  const std::string& delimiters = " ")
77  {
78  // Skip delimiters at beginning.
79  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
80  // Find first "non-delimiter".
81  std::string::size_type pos = str.find_first_of(delimiters, lastPos);
82 
83  while (std::string::npos != pos || std::string::npos != lastPos)
84  {
85  // Found a token, add it to the vector.
86  tokens.push_back(str.substr(lastPos, pos - lastPos));
87  // Skip delimiters. Note the "not_of"
88  lastPos = str.find_first_not_of(delimiters, pos);
89  // Find next "non-delimiter"
90  pos = str.find_first_of(delimiters, lastPos);
91  }
92  }
93 
94 
95 
96  private:
97  void operator=(const Self&); //purposely not implemented
98  };
99 
100 } //namespace MITK
101 
102 
103 #endif // __mitkNrrdTbssImageReader_h
Superclass of all classes generating some kind of mitk::BaseData.
itk::VectorImage< float, 3 > ImageType
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
Superclass of all classes generating diffusion volumes (instances of class DiffusionImage) as output...
static const std::string filename
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
Interface class of readers that read from files.
this class encapsulates diffusion volumes (vectorimages not yet supported by mitkImage) ...
Definition: mitkTbssImage.h:34