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

mitk::PicVolumeTimeSeriesReader Class Reference
[IO Classes]

Reader to read a series of volume files in DKFZ-pic-format. More...

#include <mitkPicVolumeTimeSeriesReader.h>

Inheritance diagram for mitk::PicVolumeTimeSeriesReader:
Inheritance graph
[legend]
Collaboration diagram for mitk::PicVolumeTimeSeriesReader:
Collaboration graph
[legend]

List of all members.

Public Types

typedef PicVolumeTimeSeriesReader Self
typedef FileReader Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void SetFileName (const char *_arg)
 Specify the file to load.
virtual const char * GetFileName () const
 Get the specified the file to load.
virtual void SetFilePrefix (const char *_arg)
 Specify file prefix for the file(s) to load.
virtual const char * GetFilePrefix () const
 Get the specified file prefix for the file(s) to load.
virtual void SetFilePattern (const char *_arg)
 Specified file pattern for the file(s) to load. The sprintf format used to build filename from FilePrefix and number.
virtual 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.

Static Public Member Functions

static Pointer New ()
static bool CanReadFile (const std::string filename, const std::string filePrefix, const std::string filePattern)

Protected Member Functions

virtual void GenerateData ()
 A version of GenerateData() specific for image processing filters.
virtual void GenerateOutputInformation ()
 PicVolumeTimeSeriesReader ()
 ~PicVolumeTimeSeriesReader ()

Protected Attributes

itk::TimeStamp m_ReadHeaderTime

Detailed Description

Reader to read a series of volume files in DKFZ-pic-format.

Definition at line 32 of file mitkPicVolumeTimeSeriesReader.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::PicVolumeTimeSeriesReader::ConstPointer

Reimplemented from mitk::FileSeriesReader.

Definition at line 35 of file mitkPicVolumeTimeSeriesReader.h.

typedef itk::SmartPointer<Self> mitk::PicVolumeTimeSeriesReader::Pointer

Reimplemented from mitk::FileSeriesReader.

Definition at line 35 of file mitkPicVolumeTimeSeriesReader.h.

Reimplemented from mitk::FileSeriesReader.

Definition at line 35 of file mitkPicVolumeTimeSeriesReader.h.

Reimplemented from mitk::FileSeriesReader.

Definition at line 35 of file mitkPicVolumeTimeSeriesReader.h.


Constructor & Destructor Documentation

mitk::PicVolumeTimeSeriesReader::PicVolumeTimeSeriesReader (  ) [protected]

Definition at line 169 of file mitkPicVolumeTimeSeriesReader.cpp.

{
    //this->DebugOn();
}
mitk::PicVolumeTimeSeriesReader::~PicVolumeTimeSeriesReader (  ) [protected]

Definition at line 174 of file mitkPicVolumeTimeSeriesReader.cpp.

{}

Member Function Documentation

bool mitk::PicVolumeTimeSeriesReader::CanReadFile ( const std::string  filename,
const std::string  filePrefix,
const std::string  filePattern 
) [static]

Definition at line 143 of file mitkPicVolumeTimeSeriesReader.cpp.

{
  if( filePattern == "" && filePrefix == "" )
    return false;

  bool extensionFound = false;
  std::string::size_type PICPos = filePattern.rfind(".pic");
  if ((PICPos != std::string::npos)
      && (PICPos == filePattern.length() - 4))
    {
    extensionFound = true;
    }

  PICPos = filePattern.rfind(".pic.gz");
  if ((PICPos != std::string::npos)
      && (PICPos == filePattern.length() - 7))
    {
    extensionFound = true;
    }

  if( !extensionFound )
    return false;

  return true;
}
void mitk::PicVolumeTimeSeriesReader::GenerateData (  ) [protected, virtual]

A version of GenerateData() specific for image processing filters.

This implementation will split the processing across multiple threads. The buffer is allocated by this method. Then the BeforeThreadedGenerateData() method is called (if provided). Then, a series of threads are spawned each calling ThreadedGenerateData(). After all the threads have completed processing, the AfterThreadedGenerateData() method is called (if provided). If an image processing filter cannot be threaded, the filter should provide an implementation of GenerateData(). That implementation is responsible for allocating the output buffer. If a filter an be threaded, it should NOT provide a GenerateData() method but should provide a ThreadedGenerateData() instead.

See also:
ThreadedGenerateData()

Reimplemented from mitk::ImageSource.

Definition at line 84 of file mitkPicVolumeTimeSeriesReader.cpp.

References mitk::PicFileReader::ConvertHandedness(), MITK_INFO, mitkIpPicDescriptor, MITKipPicGet(), and QuadProgPP::t().

{
    mitk::Image::Pointer output = this->GetOutput();

    //
    // Check to see if we can read the file given the name or prefix
    //
    if ( m_FilePrefix == "" || m_FilePattern == "" )
    {
        throw itk::ImageFileReaderException( __FILE__, __LINE__, "Both FilePattern and FilePrefix must be non-empty" );
    }

    if ( m_MatchedFileNames.size() == 0 )
    {
        throw itk::ImageFileReaderException( __FILE__, __LINE__, "Sorry, there are no files to read!" );
    }


    //
    // read 3d volumes and copy them to the 4d volume
    //
    mitkIpPicDescriptor* volume3d = NULL;
    for ( unsigned int t = 0 ; t < m_MatchedFileNames.size() ; ++t )
    {
        char* filename = const_cast< char* >( m_MatchedFileNames[ t ].c_str() );
        MITK_INFO << "Reading file " << filename << "..." << std::endl;
        volume3d = MITKipPicGet( filename, NULL );

        if ( volume3d == NULL )
        {
          ::itk::OStringStream message;
          message << "mitk::ERROR: " << this->GetNameOfClass() << "(" << this << "): "
                  << "File (" << filename << ") of time frame " << t << " could not be read!";
          throw itk::ImageFileReaderException( __FILE__, __LINE__, message.str().c_str() );
        }

        //
        // @TODO do some error checking
        //

        //
        // copy the 3d data volume to the 4d volume
        //

        // \todo use memory of Image as in PicFileReader (or integrate everything into the PicFileReader!)
        PicFileReader::ConvertHandedness(volume3d);
        bool result;
        result = output->SetPicVolume( volume3d, t );
        if(result==false)
        {
          ::itk::OStringStream message;
          message << "mitk::ERROR: " << this->GetNameOfClass() << "(" << this << "): "
                  << "Volume of time frame " << t << " did not match size of other time frames.";
          throw itk::ImageFileReaderException( __FILE__, __LINE__, message.str().c_str() );
        }
        mitkIpPicFree ( volume3d );
    }
}
void mitk::PicVolumeTimeSeriesReader::GenerateOutputInformation (  ) [protected, virtual]

Definition at line 31 of file mitkPicVolumeTimeSeriesReader.cpp.

References mitk::FileSeriesReader::GenerateFileList(), mitk::ImageSource::GetOutput(), mitk::FileSeriesReader::m_FileName, mitk::FileSeriesReader::m_MatchedFileNames, m_ReadHeaderTime, mitkIpPicDescriptor, and MITKipPicGetTags().

{
    mitk::Image::Pointer output = this->GetOutput();

    if ( ( output->IsInitialized() ) && ( this->GetMTime() <= m_ReadHeaderTime.GetMTime() ) )
        return ;

    itkDebugMacro( << "Reading file for GenerateOutputInformation()" << m_FileName );

    if ( ! this->GenerateFileList() )
    {
        itkWarningMacro( "Sorry, file list could not be generated!" );
        return ;
    }

    //
    // Read the first file of the image sequence. Assume equal size and spacings for all
    // other volumes. @TODO Integrate support for different sizes and spacings
    //
    char* filename = const_cast<char *> ( m_MatchedFileNames[ 0 ].c_str() );
    mitkIpPicDescriptor * header = mitkIpPicGetHeader( filename, NULL );
    header = MITKipPicGetTags( filename, header );

    if ( header == NULL )
    {
        itk::ImageFileReaderException e( __FILE__, __LINE__ );
        itk::OStringStream msg;
        msg << " Could not read file " << m_FileName.c_str();
        e.SetDescription( msg.str().c_str() );
        throw e;
        return ;
    }
    if ( header->dim != 3 )
    {
        itk::ImageFileReaderException e( __FILE__, __LINE__ , "Only 3D-pic volumes are supported! " );
        throw e;
        return ;
    }

    //
    // modify the header to match the real temporal extent
    //
    header->dim = 4;
    header->n[ 3 ] = m_MatchedFileNames.size();

    output->Initialize( header );

    mitkIpPicFree( header );

    m_ReadHeaderTime.Modified();
}
virtual const char* mitk::PicVolumeTimeSeriesReader::GetClassName (  ) const [virtual]

Reimplemented from mitk::FileSeriesReader.

virtual const char* mitk::PicVolumeTimeSeriesReader::GetFileName (  ) const [virtual]

Get the specified the file to load.

Either the FileName or FilePrefix plus FilePattern are used to read.

Implements mitk::FileReader.

virtual const char* mitk::PicVolumeTimeSeriesReader::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.

virtual const char* mitk::PicVolumeTimeSeriesReader::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.

static Pointer mitk::PicVolumeTimeSeriesReader::New (  ) [static]

Method for creation through the object factory.

Reimplemented from mitk::ImageSource.

virtual void mitk::PicVolumeTimeSeriesReader::SetFileName ( const char *  aFileName ) [virtual]

Specify the file to load.

Either the FileName or FilePrefix plus FilePattern are used to read.

Implements mitk::FileReader.

virtual void mitk::PicVolumeTimeSeriesReader::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.

virtual void mitk::PicVolumeTimeSeriesReader::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.


Member Data Documentation

Definition at line 62 of file mitkPicVolumeTimeSeriesReader.h.

Referenced by GenerateOutputInformation().


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