#include <mitkNrrdDiffusionImageReader.h>
Public Types | |
typedef mitk::DiffusionImage < TPixelType > | OutputType |
typedef itk::VectorImage < TPixelType, 3 > | ImageType |
typedef DiffusionImageSource < TPixelType > | DiffVolSourceType |
typedef vnl_vector_fixed < double, 3 > | GradientDirectionType |
typedef itk::VectorContainer < unsigned int, GradientDirectionType > | GradientDirectionContainerType |
typedef NrrdDiffusionImageReader | Self |
typedef DiffVolSourceType | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
const char * | GetFileName () const |
Get the specified the file to load. | |
void | SetFileName (const char *aFileName) |
Specify the file to load. | |
const char * | GetFilePrefix () const |
Get the specified file prefix for the file(s) to load. | |
void | SetFilePrefix (const char *aFilePrefix) |
Specify file prefix for the file(s) to load. | |
const char * | GetFilePattern () const |
Get the specified file pattern for the file(s) to load. The sprintf format used to build filename from FilePrefix and number. | |
void | SetFilePattern (const char *aFilePattern) |
Specified file pattern for the file(s) to load. The sprintf format used to build filename from FilePrefix and number. | |
Static Public Member Functions | |
static Pointer | New () |
Method for creation through the object factory. | |
static bool | CanReadFile (const std::string filename, const std::string filePrefix, const std::string filePattern) |
Protected Member Functions | |
virtual void | GenerateData () |
virtual void | GenerateOutputInformation () |
Protected Attributes | |
std::string | m_FileName |
std::string | m_FilePrefix |
std::string | m_FilePattern |
OutputType::Pointer | m_OutputCache |
itk::TimeStamp | m_CacheTime |
GradientDirectionContainerType::Pointer | m_DiffusionVectors |
float | m_B_Value |
Definition at line 35 of file mitkNrrdDiffusionImageReader.h.
typedef itk::SmartPointer<const Self> mitk::NrrdDiffusionImageReader< TPixelType >::ConstPointer |
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
Definition at line 46 of file mitkNrrdDiffusionImageReader.h.
typedef DiffusionImageSource<TPixelType> mitk::NrrdDiffusionImageReader< TPixelType >::DiffVolSourceType |
Definition at line 41 of file mitkNrrdDiffusionImageReader.h.
typedef itk::VectorContainer< unsigned int, GradientDirectionType > mitk::NrrdDiffusionImageReader< TPixelType >::GradientDirectionContainerType |
Definition at line 44 of file mitkNrrdDiffusionImageReader.h.
typedef vnl_vector_fixed< double, 3 > mitk::NrrdDiffusionImageReader< TPixelType >::GradientDirectionType |
Definition at line 42 of file mitkNrrdDiffusionImageReader.h.
typedef itk::VectorImage<TPixelType,3> mitk::NrrdDiffusionImageReader< TPixelType >::ImageType |
Definition at line 40 of file mitkNrrdDiffusionImageReader.h.
typedef mitk::DiffusionImage<TPixelType> mitk::NrrdDiffusionImageReader< TPixelType >::OutputType |
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
Definition at line 39 of file mitkNrrdDiffusionImageReader.h.
typedef itk::SmartPointer<Self> mitk::NrrdDiffusionImageReader< TPixelType >::Pointer |
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
Definition at line 46 of file mitkNrrdDiffusionImageReader.h.
typedef NrrdDiffusionImageReader mitk::NrrdDiffusionImageReader< TPixelType >::Self |
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
Definition at line 46 of file mitkNrrdDiffusionImageReader.h.
typedef DiffVolSourceType mitk::NrrdDiffusionImageReader< TPixelType >::Superclass |
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
Definition at line 46 of file mitkNrrdDiffusionImageReader.h.
bool mitk::NrrdDiffusionImageReader< TPixelType >::CanReadFile | ( | const std::string | filename, |
const std::string | filePrefix, | ||
const std::string | filePattern | ||
) | [static] |
Definition at line 201 of file mitkNrrdDiffusionImageReader.cpp.
{ // First check the extension if( filename == "" ) { return false; } std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); if (ext == ".hdwi" || ext == ".dwi") { itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); typedef itk::ImageFileReader<ImageType> FileReaderType; typename FileReaderType::Pointer reader = FileReaderType::New(); reader->SetImageIO(io); reader->SetFileName(filename); reader->Update(); typename ImageType::Pointer img = reader->GetOutput(); itk::MetaDataDictionary imgMetaDictionary = img->GetMetaDataDictionary(); std::vector<std::string> imgMetaKeys = imgMetaDictionary.GetKeys(); std::vector<std::string>::const_iterator itKey = imgMetaKeys.begin(); std::string metaString; for (; itKey != imgMetaKeys.end(); itKey ++) { itk::ExposeMetaData<std::string> (imgMetaDictionary, *itKey, metaString); if (itKey->find("modality") != std::string::npos) { if (metaString.find("DWMRI") != std::string::npos) { return true; } } } } return false; }
void mitk::NrrdDiffusionImageReader< TPixelType >::GenerateData | ( | ) | [protected, virtual] |
Does the real work.
Reimplemented from mitk::ImageSource.
Definition at line 32 of file mitkNrrdDiffusionImageReader.cpp.
{ // Since everything is completely read in GenerateOutputInformation() it is stored // in a cache variable. A timestamp is associated. // If the timestamp of the cache variable is newer than the MTime, we only need to // assign the cache variable to the DataObject. // Otherwise, the tree must be read again from the file and OuputInformation must // be updated! if ( ( ! m_OutputCache ) || ( this->GetMTime( ) > m_CacheTime.GetMTime( ) ) ) { this->GenerateOutputInformation(); itkWarningMacro("Cache regenerated!"); } if (!m_OutputCache) { itkWarningMacro("Tree cache is empty!"); } static_cast<OutputType*>(this->GetOutput()) ->SetVectorImage(m_OutputCache->GetVectorImage()); static_cast<OutputType*>(this->GetOutput()) ->SetB_Value(m_OutputCache->GetB_Value()); static_cast<OutputType*>(this->GetOutput()) ->SetDirections(m_OutputCache->GetDirections()); static_cast<OutputType*>(this->GetOutput()) ->InitializeFromVectorImage(); }
void mitk::NrrdDiffusionImageReader< TPixelType >::GenerateOutputInformation | ( | void | ) | [protected, virtual] |
Definition at line 63 of file mitkNrrdDiffusionImageReader.cpp.
{ typename OutputType::Pointer outputForCache = OutputType::New(); if ( m_FileName == "") { throw itk::ImageFileReaderException(__FILE__, __LINE__, "Sorry, the filename to be read is empty!"); } else { try { itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); typedef itk::ImageFileReader<ImageType> FileReaderType; typename FileReaderType::Pointer reader = FileReaderType::New(); reader->SetImageIO(io); reader->SetFileName(this->m_FileName); reader->Update(); typename ImageType::Pointer img = reader->GetOutput(); itk::MetaDataDictionary imgMetaDictionary = img->GetMetaDataDictionary(); std::vector<std::string> imgMetaKeys = imgMetaDictionary.GetKeys(); std::vector<std::string>::const_iterator itKey = imgMetaKeys.begin(); std::string metaString; GradientDirectionType vect3d; m_DiffusionVectors = GradientDirectionContainerType::New(); int numberOfImages = 0; int numberOfGradientImages = 0; bool readb0 = false; for (; itKey != imgMetaKeys.end(); itKey ++) { double x,y,z; itk::ExposeMetaData<std::string> (imgMetaDictionary, *itKey, metaString); if (itKey->find("DWMRI_gradient") != std::string::npos) { std::cout << *itKey << " ---> " << metaString << std::endl; sscanf(metaString.c_str(), "%lf %lf %lf\n", &x, &y, &z); vect3d[0] = x; vect3d[1] = y; vect3d[2] = z; m_DiffusionVectors->InsertElement( numberOfImages, vect3d ); ++numberOfImages; // If the direction is 0.0, this is a reference image if (vect3d[0] == 0.0 && vect3d[1] == 0.0 && vect3d[2] == 0.0) { continue; } ++numberOfGradientImages;; } else if (itKey->find("DWMRI_b-value") != std::string::npos) { std::cout << *itKey << " ---> " << metaString << std::endl; readb0 = true; m_B_Value = atof(metaString.c_str()); } } std::cout << "Number of gradient images: " << numberOfGradientImages << " and Number of reference images: " << numberOfImages - numberOfGradientImages << std::endl; if(!readb0) { std::cerr << "BValue not specified in header file" << std::endl; } // This call updates the output information of the associated VesselTreeData outputForCache->SetVectorImage(img); outputForCache->SetB_Value(m_B_Value); outputForCache->SetDirections(m_DiffusionVectors); // Since we have already read the tree, we can store it in a cache variable // so that it can be assigned to the DataObject in GenerateData(); m_OutputCache = outputForCache; m_CacheTime.Modified(); } catch(std::exception& e) { throw itk::ImageFileReaderException(__FILE__, __LINE__, e.what()); } catch(...) { throw itk::ImageFileReaderException(__FILE__, __LINE__, "Sorry, an error occurred while reading the requested vessel tree file!"); } } }
virtual const char* mitk::NrrdDiffusionImageReader< TPixelType >::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
const char * mitk::NrrdDiffusionImageReader< TPixelType >::GetFileName | ( | ) | const [virtual] |
Get the specified the file to load.
Either the FileName or FilePrefix plus FilePattern are used to read.
Implements mitk::FileReader.
Definition at line 159 of file mitkNrrdDiffusionImageReader.cpp.
{ return m_FileName.c_str(); }
const char * mitk::NrrdDiffusionImageReader< TPixelType >::GetFilePattern | ( | ) | const [virtual] |
Get the specified file pattern for the file(s) to load. The sprintf format used to build filename from FilePrefix and number.
You should specify either a FileName or FilePrefix. Use FilePrefix if the data is stored in multiple files.
Implements mitk::FileReader.
Definition at line 187 of file mitkNrrdDiffusionImageReader.cpp.
{ return m_FilePattern.c_str(); }
const char * mitk::NrrdDiffusionImageReader< TPixelType >::GetFilePrefix | ( | ) | const [virtual] |
Get the specified file prefix for the file(s) to load.
You should specify either a FileName or FilePrefix. Use FilePrefix if the data is stored in multiple files.
Implements mitk::FileReader.
Definition at line 173 of file mitkNrrdDiffusionImageReader.cpp.
{ return m_FilePrefix.c_str(); }
static Pointer mitk::NrrdDiffusionImageReader< TPixelType >::New | ( | ) | [static] |
Method for creation through the object factory.
Reimplemented from mitk::DiffusionImageSource< TPixelType >.
void mitk::NrrdDiffusionImageReader< TPixelType >::SetFileName | ( | const char * | aFileName ) | [virtual] |
Specify the file to load.
Either the FileName or FilePrefix plus FilePattern are used to read.
Implements mitk::FileReader.
Definition at line 166 of file mitkNrrdDiffusionImageReader.cpp.
{ m_FileName = aFileName; }
void mitk::NrrdDiffusionImageReader< TPixelType >::SetFilePattern | ( | const char * | aFilePattern ) | [virtual] |
Specified file pattern for the file(s) to load. The sprintf format used to build filename from FilePrefix and number.
You should specify either a FileName or FilePrefix. Use FilePrefix if the data is stored in multiple files.
Implements mitk::FileReader.
Definition at line 194 of file mitkNrrdDiffusionImageReader.cpp.
{ m_FilePattern = aFilePattern; }
void mitk::NrrdDiffusionImageReader< TPixelType >::SetFilePrefix | ( | const char * | aFilePrefix ) | [virtual] |
Specify file prefix for the file(s) to load.
You should specify either a FileName or FilePrefix. Use FilePrefix if the data is stored in multiple files.
Implements mitk::FileReader.
Definition at line 180 of file mitkNrrdDiffusionImageReader.cpp.
{ m_FilePrefix = aFilePrefix; }
float mitk::NrrdDiffusionImageReader< TPixelType >::m_B_Value [protected] |
Definition at line 72 of file mitkNrrdDiffusionImageReader.h.
itk::TimeStamp mitk::NrrdDiffusionImageReader< TPixelType >::m_CacheTime [protected] |
Definition at line 69 of file mitkNrrdDiffusionImageReader.h.
GradientDirectionContainerType::Pointer mitk::NrrdDiffusionImageReader< TPixelType >::m_DiffusionVectors [protected] |
Definition at line 71 of file mitkNrrdDiffusionImageReader.h.
std::string mitk::NrrdDiffusionImageReader< TPixelType >::m_FileName [protected] |
Definition at line 64 of file mitkNrrdDiffusionImageReader.h.
std::string mitk::NrrdDiffusionImageReader< TPixelType >::m_FilePattern [protected] |
Definition at line 66 of file mitkNrrdDiffusionImageReader.h.
std::string mitk::NrrdDiffusionImageReader< TPixelType >::m_FilePrefix [protected] |
Definition at line 65 of file mitkNrrdDiffusionImageReader.h.
OutputType::Pointer mitk::NrrdDiffusionImageReader< TPixelType >::m_OutputCache [protected] |
Definition at line 68 of file mitkNrrdDiffusionImageReader.h.