Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::NrrdDiffusionImageWriter< TPixelType > Class Template Reference
[Process Classes]

#include <mitkNrrdDiffusionImageWriter.h>

Inheritance diagram for mitk::NrrdDiffusionImageWriter< TPixelType >:
Inheritance graph
[legend]
Collaboration diagram for mitk::NrrdDiffusionImageWriter< TPixelType >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef NrrdDiffusionImageWriter Self
typedef
mitk::FileWriterWithInformation 
Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer
typedef mitk::DiffusionImage
< TPixelType > 
InputType

Public Member Functions

virtual const char * GetClassName () const
virtual void Write ()
virtual void Update ()
virtual void SetFileName (const char *_arg)
virtual const char * GetFileName () const
virtual void SetFilePrefix (const char *_arg)
virtual const char * GetFilePrefix () const
virtual void SetFilePattern (const char *_arg)
virtual const char * GetFilePattern () const
void SetInput (InputType *input)
InputTypeGetInput ()
virtual bool GetSuccess ()
virtual std::vector< std::string > GetPossibleFileExtensions ()
virtual const char * GetDefaultFilename ()
virtual const char * GetFileDialogPattern ()
virtual const char * GetDefaultExtension ()
virtual bool CanWriteDataType (BaseData::Pointer data)
virtual void DoWrite (BaseData::Pointer data)

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 NrrdDiffusionImageWriter ()
virtual ~NrrdDiffusionImageWriter ()
virtual void GenerateData ()

Protected Attributes

std::string m_FileName
std::string m_FilePrefix
std::string m_FilePattern
bool m_Success

Detailed Description

template<class TPixelType>
class mitk::NrrdDiffusionImageWriter< TPixelType >

Writes diffusion volumes to a file

Definition at line 34 of file mitkNrrdDiffusionImageWriter.h.


Member Typedef Documentation

template<class TPixelType >
typedef itk::SmartPointer<const Self> mitk::NrrdDiffusionImageWriter< TPixelType >::ConstPointer

Reimplemented from mitk::FileWriterWithInformation.

Definition at line 38 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
typedef mitk::DiffusionImage<TPixelType> mitk::NrrdDiffusionImageWriter< TPixelType >::InputType

Definition at line 42 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
typedef itk::SmartPointer<Self> mitk::NrrdDiffusionImageWriter< TPixelType >::Pointer

Reimplemented from mitk::FileWriterWithInformation.

Definition at line 38 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
typedef NrrdDiffusionImageWriter mitk::NrrdDiffusionImageWriter< TPixelType >::Self

Reimplemented from mitk::FileWriterWithInformation.

Definition at line 38 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
typedef mitk::FileWriterWithInformation mitk::NrrdDiffusionImageWriter< TPixelType >::Superclass

Reimplemented from mitk::FileWriterWithInformation.

Definition at line 38 of file mitkNrrdDiffusionImageWriter.h.


Constructor & Destructor Documentation

template<typename TPixelType >
mitk::NrrdDiffusionImageWriter< TPixelType >::NrrdDiffusionImageWriter (  ) [protected]

Definition at line 28 of file mitkNrrdDiffusionImageWriter.cpp.

    : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false)
{
    this->SetNumberOfRequiredInputs( 1 );
}
template<typename TPixelType >
mitk::NrrdDiffusionImageWriter< TPixelType >::~NrrdDiffusionImageWriter (  ) [protected, virtual]

Definition at line 35 of file mitkNrrdDiffusionImageWriter.cpp.

{}

Member Function Documentation

template<class TPixelType >
virtual bool mitk::NrrdDiffusionImageWriter< TPixelType >::CanWriteDataType ( BaseData::Pointer  data ) [inline, virtual]

Implements mitk::FileWriterWithInformation.

Definition at line 102 of file mitkNrrdDiffusionImageWriter.h.

Referenced by mitk::NrrdDiffusionImageWriter< TPixelType >::DoWrite().

{ return (dynamic_cast<mitk::DiffusionImage<TPixelType>*>(data.GetPointer()) != NULL); };  
template<class TPixelType >
virtual void mitk::NrrdDiffusionImageWriter< TPixelType >::DoWrite ( BaseData::Pointer  data ) [inline, virtual]
template<typename TPixelType >
void mitk::NrrdDiffusionImageWriter< TPixelType >::GenerateData (  ) [protected, virtual]

Definition at line 39 of file mitkNrrdDiffusionImageWriter.cpp.

References mitk::DiffusionImage< TPixelType >::GetB_Value(), mitk::DiffusionImage< TPixelType >::GetDirections(), and mitk::DiffusionImage< TPixelType >::GetVectorImage().

{
    m_Success = false;
    InputType* input = this->GetInput();
    if (input == NULL)
    {
        itkWarningMacro(<<"Sorry, input to NrrdDiffusionImageWriter is NULL!");    
        return;
    }
    if ( m_FileName == "" )
    {
        itkWarningMacro( << "Sorry, filename has not been set!" );
        return ;
    }
    
    char keybuffer[512];
    char valbuffer[512];
    std::string tmp;

    itk::VectorImage<short,3>::Pointer img = input->GetVectorImage();
    img->GetMetaDataDictionary();

    //itk::MetaDataDictionary dic = input->GetImage()->GetMetaDataDictionary();
    sprintf( valbuffer, "(%1f,%1f,%1f) (%1f,%1f,%1f) (%1f,%1f,%1f)", 1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f);
    itk::EncapsulateMetaData<std::string>(input->GetVectorImage()->GetMetaDataDictionary(),std::string("measurement frame"),std::string(valbuffer));

    sprintf( valbuffer, "DWMRI");
    itk::EncapsulateMetaData<std::string>(input->GetVectorImage()->GetMetaDataDictionary(),std::string("modality"),std::string(valbuffer));

    if(input->GetDirections()->Size())
    {
      sprintf( valbuffer, "%1f", input->GetB_Value() );
      itk::EncapsulateMetaData<std::string>(input->GetVectorImage()->GetMetaDataDictionary(),std::string("DWMRI_b-value"),std::string(valbuffer));
    }

    for(unsigned int i=0; i<input->GetDirections()->Size(); i++)
    {
      sprintf( keybuffer, "DWMRI_gradient_%04d", i );

      /*if(itk::ExposeMetaData<std::string>(input->GetMetaDataDictionary(),
      std::string(keybuffer),tmp))
      continue;*/

      sprintf( valbuffer, "%1f %1f %1f", input->GetDirections()->ElementAt(i).get(0),
        input->GetDirections()->ElementAt(i).get(1), input->GetDirections()->ElementAt(i).get(2));

      itk::EncapsulateMetaData<std::string>(input->GetVectorImage()->GetMetaDataDictionary(),std::string(keybuffer),std::string(valbuffer));
    }

    itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New();
    //io->SetNrrdVectorType( nrrdKindList );
    io->SetFileType( itk::ImageIOBase::Binary );

    typedef itk::VectorImage<TPixelType,3> ImageType;
    typedef itk::ImageFileWriter<ImageType> WriterType;
    typename WriterType::Pointer nrrdWriter = WriterType::New();
    nrrdWriter->UseInputMetaDataDictionaryOn();
    nrrdWriter->SetInput( input->GetVectorImage() );
    nrrdWriter->SetImageIO(io);
    nrrdWriter->SetFileName(m_FileName);

    try
    {
      nrrdWriter->Update();
    }
    catch (itk::ExceptionObject e)
    {
      std::cout << e << std::endl;
    }

    m_Success = true;
}
template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetClassName (  ) const [virtual]

Reimplemented from mitk::FileWriterWithInformation.

template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetDefaultExtension (  ) [inline, virtual]

Implements mitk::FileWriterWithInformation.

Definition at line 101 of file mitkNrrdDiffusionImageWriter.h.

{ return ".dwi"; }
template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetDefaultFilename (  ) [inline, virtual]

Implements mitk::FileWriterWithInformation.

Definition at line 99 of file mitkNrrdDiffusionImageWriter.h.

{ return "DiffusionWeightedImages.dwi"; }
template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetFileDialogPattern (  ) [inline, virtual]

Implements mitk::FileWriterWithInformation.

Definition at line 100 of file mitkNrrdDiffusionImageWriter.h.

{ return "Diffusion Weighted Images (*.dwi *.hdwi)"; }
template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetFileName (  ) const [virtual]
Returns:
the name of the file to be written to disk.

Implements mitk::FileWriter.

template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetFilePattern (  ) const [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<class TPixelType >
virtual const char* mitk::NrrdDiffusionImageWriter< TPixelType >::GetFilePrefix (  ) const [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<typename TPixelType >
mitk::DiffusionImage< TPixelType > * mitk::NrrdDiffusionImageWriter< TPixelType >::GetInput ( void   )
Returns:
the 0'th input object of the filter.

Definition at line 119 of file mitkNrrdDiffusionImageWriter.cpp.

{
    if ( this->GetNumberOfInputs() < 1 )
    {
        return NULL;
    }
    else
    {
        return dynamic_cast<InputType*> ( this->ProcessObject::GetInput( 0 ) );
    }
}
template<typename TPixelType >
std::vector< std::string > mitk::NrrdDiffusionImageWriter< TPixelType >::GetPossibleFileExtensions (  ) [virtual]
Returns:
possible file extensions for the data type associated with the writer

Implements mitk::FileWriter.

Definition at line 132 of file mitkNrrdDiffusionImageWriter.cpp.

{
  std::vector<std::string> possibleFileExtensions;
  possibleFileExtensions.push_back(".dwi");
  possibleFileExtensions.push_back(".hdwi");
  return possibleFileExtensions;
}
template<class TPixelType >
virtual bool mitk::NrrdDiffusionImageWriter< TPixelType >::GetSuccess (  ) [virtual]

Returns false if an error happened during writing

template<class TPixelType >
static Pointer mitk::NrrdDiffusionImageWriter< TPixelType >::New (  ) [static]
template<class TPixelType >
virtual void mitk::NrrdDiffusionImageWriter< TPixelType >::SetFileName ( const char *  _arg ) [virtual]

Sets the filename of the file to write.

Parameters:
FileNamethe name of the file to write.

Implements mitk::FileWriter.

template<class TPixelType >
virtual void mitk::NrrdDiffusionImageWriter< TPixelType >::SetFilePattern ( const char *  _arg ) [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<class TPixelType >
virtual void mitk::NrrdDiffusionImageWriter< TPixelType >::SetFilePrefix ( const char *  _arg ) [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<typename TPixelType >
void mitk::NrrdDiffusionImageWriter< TPixelType >::SetInput ( InputType input )

Sets the input object for the filter.

Parameters:
inputthe diffusion volumes to write to file.

Definition at line 113 of file mitkNrrdDiffusionImageWriter.cpp.

Referenced by mitk::NrrdDiffusionImageWriter< TPixelType >::DoWrite().

{
    this->ProcessObject::SetNthInput( 0, diffVolumes );
}
template<class TPixelType >
virtual void mitk::NrrdDiffusionImageWriter< TPixelType >::Update (  ) [inline, virtual]
template<class TPixelType >
virtual void mitk::NrrdDiffusionImageWriter< TPixelType >::Write (  ) [inline, virtual]

Implements mitk::FileWriter.

Definition at line 40 of file mitkNrrdDiffusionImageWriter.h.


Member Data Documentation

template<class TPixelType >
std::string mitk::NrrdDiffusionImageWriter< TPixelType >::m_FileName [protected]

Definition at line 118 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
std::string mitk::NrrdDiffusionImageWriter< TPixelType >::m_FilePattern [protected]

Definition at line 122 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
std::string mitk::NrrdDiffusionImageWriter< TPixelType >::m_FilePrefix [protected]

Definition at line 120 of file mitkNrrdDiffusionImageWriter.h.

template<class TPixelType >
bool mitk::NrrdDiffusionImageWriter< TPixelType >::m_Success [protected]

Definition at line 124 of file mitkNrrdDiffusionImageWriter.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines