/**Documentation
 *  test for the class "ToFImageWriter".
 */
int mitkToFImageWriterTest(int /* argc */, char* /*argv*/[])
{
  MITK_TEST_BEGIN("ToFImageWriter");

  //testing initialization of object
  mitk::ToFImageWriter::Pointer tofWriter = mitk::ToFImageWriter::New();
  MITK_TEST_CONDITION_REQUIRED(tofWriter.GetPointer(), "Testing initialization of test object!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetExtension()!= "", "Test initialization of member extension!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetDistanceImageFileName()== "", "Test initialization of member distanceImageFileName!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetAmplitudeImageFileName()== "", "Test initialization of member amplitudeImageFileName!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetIntensityImageFileName()== "", "Test initialization of member intnensityImageFileName!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetDistanceImageSelected()==true, "Test initialization of member distanceImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetAmplitudeImageSelected()==false, "Test initialization of member amplitudeImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetIntensityImageSelected()==false, "Test initialization of member intensityImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetRGBImageSelected()==false, "Test initialization of member rgbImageSelected!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFCaptureWidth()== 200, "Test initialization of member captureWidth!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFCaptureHeight()== 200, "Test initialization of member captureHeight!");
  MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFImageType()== mitk::ToFImageWriter::ToFImageType3D, "Test initialization of member ToFImageType!");

  //set member parameter and test again
  unsigned int dimX = 255;
  unsigned int dimY = 188;
  std::string distanceImageFileName("distImg.pic");
  std::string amplitudeImageFileName("amplImg.pic");
  std::string intensityImageFileName("intImg.pic");
  std::string rgbImageFileName("rgbImg.pic");
  std::string fileExtension(".test");
  bool distanceImageSelected = false;
  bool amplitudeImageSelected = false;
  bool intensityImageSelected = false;
  bool rgbImageSelected = false;

  tofWriter->SetToFCaptureWidth(dimX);
  tofWriter->SetToFCaptureHeight(dimY);
  tofWriter->SetDistanceImageFileName(distanceImageFileName);
  tofWriter->SetAmplitudeImageFileName(amplitudeImageFileName);
  tofWriter->SetIntensityImageFileName(intensityImageFileName);
  tofWriter->SetRGBImageFileName(rgbImageFileName);
  tofWriter->SetExtension(fileExtension);
  tofWriter->SetDistanceImageSelected(distanceImageSelected);
  tofWriter->SetAmplitudeImageSelected(amplitudeImageSelected);
  tofWriter->SetIntensityImageSelected(intensityImageSelected);
  tofWriter->SetRGBImageSelected(rgbImageSelected);
  tofWriter->SetToFImageType(mitk::ToFImageWriter::ToFImageType2DPlusT);

  MITK_TEST_CONDITION_REQUIRED(distanceImageFileName==tofWriter->GetDistanceImageFileName(), "Testing set/get distance image file name");
  MITK_TEST_CONDITION_REQUIRED(amplitudeImageFileName==tofWriter->GetAmplitudeImageFileName(), "Testing set/get amplitude image file name");
  MITK_TEST_CONDITION_REQUIRED(intensityImageFileName==tofWriter->GetIntensityImageFileName(), "Testing set/get intensity image file name");
  MITK_TEST_CONDITION_REQUIRED(rgbImageFileName==tofWriter->GetRGBImageFileName(), "Testing set/get rgb image file name");
  MITK_TEST_CONDITION_REQUIRED(dimX==tofWriter->GetToFCaptureWidth(), "Testing set/get CaptureWidth");
  MITK_TEST_CONDITION_REQUIRED(dimY==tofWriter->GetToFCaptureHeight(), "Testing set/get CaptureHeight");
  MITK_TEST_CONDITION_REQUIRED(distanceImageSelected==tofWriter->GetDistanceImageSelected(), "Testing set/get distance image selection");
  MITK_TEST_CONDITION_REQUIRED(amplitudeImageSelected==tofWriter->GetAmplitudeImageSelected(), "Testing set/get amplitude image selection");
  MITK_TEST_CONDITION_REQUIRED(intensityImageSelected==tofWriter->GetIntensityImageSelected(), "Testing set/get intensity image selection");
  MITK_TEST_CONDITION_REQUIRED(rgbImageSelected==tofWriter->GetRGBImageSelected(), "Testing set/get rgb image selection");
  MITK_TEST_CONDITION_REQUIRED(fileExtension==tofWriter->GetExtension(), "Testing set/get file extension");
  MITK_TEST_CONDITION_REQUIRED(mitk::ToFImageWriter::ToFImageType2DPlusT==tofWriter->GetToFImageType(), "Testing set/get ToFImageType");

  MITK_TEST_END();
}
Exemple #2
0
/**Documentation
 *  test for the class "ToFImageCsvWriter".
 */
int mitkToFImageCsvWriterTest(int /* argc */, char* /*argv*/[])
{
  MITK_TEST_BEGIN("ToFImageCsvWriter");
  mitk::ToFImageCsvWriter::Pointer csvWriter = mitk::ToFImageCsvWriter::New();
  MITK_TEST_CONDITION_REQUIRED(csvWriter.GetPointer(), "Testing initialization of test object!");
  MITK_TEST_CONDITION_REQUIRED(csvWriter->GetExtension() == ".csv", "Testing correct initialization of member variable extension!");

  srand(time(0));

  unsigned int dimX = 100 + rand()%100;
  unsigned int dimY = 100 + rand()%100;
  unsigned int pixelNumber = dimX*dimY;
  unsigned int numOfFrames = 1 + rand()%100;

  MITK_INFO<<dimX;
  MITK_INFO<<dimY;
  MITK_INFO<<numOfFrames;

  mitk::Image::Pointer distanceImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames);
  mitk::Image::Pointer amplitudeImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames);
  mitk::Image::Pointer intensityImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames);


  std::string distanceImageFileName("distImg.csv");
  std::string amplitudeImageFileName("amplImg.csv");
  std::string intensityImageFileName("intImg.csv");

  csvWriter->SetDistanceImageFileName(distanceImageFileName);
  csvWriter->SetAmplitudeImageFileName(amplitudeImageFileName);
  csvWriter->SetIntensityImageFileName(intensityImageFileName);

  csvWriter->SetCaptureWidth(dimX);
  csvWriter->SetCaptureHeight(dimY);
  csvWriter->SetToFImageType(mitk::ToFImageWriter::ToFImageType3D);

  mitk::ImageSliceSelector::Pointer distanceSelector = mitk::ImageSliceSelector::New();
  mitk::ImageSliceSelector::Pointer amplitudeSelector = mitk::ImageSliceSelector::New();
  mitk::ImageSliceSelector::Pointer intensitySelector = mitk::ImageSliceSelector::New();

  mitk::Image::Pointer tmpDistance;
  mitk::Image::Pointer tmpAmplitude;
  mitk::Image::Pointer tmpIntensity;

  distanceSelector->SetInput(distanceImage);
  amplitudeSelector->SetInput(amplitudeImage);
  intensitySelector->SetInput(intensityImage);

  //buffer
  float* distanceArray;
  float* amplitudeArray;
  float* intensityArray;

  csvWriter->Open(); //open file/stream
  for(unsigned int i = 0; i<numOfFrames; i++)
  { //write values to file/stream
    distanceSelector->SetSliceNr(i);
    distanceSelector->Update();
    tmpDistance = distanceSelector->GetOutput();
    distanceArray = (float*)tmpDistance->GetData();

    amplitudeSelector->SetSliceNr(i);
    amplitudeSelector->Update();
    tmpAmplitude = amplitudeSelector->GetOutput();
    amplitudeArray = (float*)tmpAmplitude->GetData();

    intensitySelector->SetSliceNr(i);
    intensitySelector->Update();
    tmpIntensity = intensitySelector->GetOutput();
    intensityArray = (float*)tmpIntensity->GetData();

    csvWriter->Add(distanceArray, amplitudeArray, intensityArray);
  }
  csvWriter->Close(); //close file

  FILE* distanceInfile = NULL;
  FILE* amplitudeInfile = NULL;
  FILE* intensityInfile = NULL;

  //open file again
  OpenCsvFile(&(distanceInfile), distanceImageFileName);
  OpenCsvFile(&(amplitudeInfile), amplitudeImageFileName);
  OpenCsvFile(&(intensityInfile), intensityImageFileName);

  float distVal = 0.0, amplVal = 0.0, intenVal = 0.0;
  int dErr = 0, aErr = 0, iErr = 0;
  bool readingCorrect = true;

  //for all frames...
  for(unsigned int j=0; j<numOfFrames; j++)
  {
    distanceSelector->SetSliceNr(j);
    distanceSelector->Update();
    tmpDistance = distanceSelector->GetOutput();
    distanceArray = (float*)tmpDistance->GetData();

    amplitudeSelector->SetSliceNr(j);
    amplitudeSelector->Update();
    tmpAmplitude = amplitudeSelector->GetOutput();
    amplitudeArray = (float*)tmpAmplitude->GetData();

    intensitySelector->SetSliceNr(j);
    intensitySelector->Update();
    tmpIntensity = intensitySelector->GetOutput();
    intensityArray = (float*)tmpIntensity->GetData();

    //for all pixels
    for(unsigned int i=0; i<pixelNumber; i++)
    {
      if (i==0 && j==0)
      {      //no comma at the beginning of the document
        dErr = fscanf (distanceInfile, "%f", &distVal);
        aErr = fscanf (amplitudeInfile, "%f", &amplVal);
        iErr = fscanf (intensityInfile, "%f", &intenVal);
      }
      else
      {      //comma seperated values now
        dErr = fscanf (distanceInfile, ",%f", &distVal);
        aErr = fscanf (amplitudeInfile, ",%f", &amplVal);
        iErr = fscanf (intensityInfile, ",%f", &intenVal);
      }

      //check if reading error or EOF occurs
      if (dErr==0 || dErr==EOF)
      {
        MITK_TEST_CONDITION_REQUIRED((dErr!=0 && dErr!=EOF), "Testing open and read csv distance file");
      }
      if (aErr==0 || aErr==EOF)
      {
        MITK_TEST_CONDITION_REQUIRED((aErr!=0 && aErr!=EOF), "Testing open and read csv amplitude file");
      }
      if (iErr==0 || iErr==EOF)
      {
        MITK_TEST_CONDITION_REQUIRED((iErr!=0 && iErr!=EOF), "Testing open and read csv intensity file");
      }

      //compare if input == output
      if(!mitk::Equal(distVal,distanceArray[i]) || !mitk::Equal(amplVal, amplitudeArray[i]) || !mitk::Equal(intenVal, intensityArray[i]))
      {
        readingCorrect = false;
      }
    }
  }
  MITK_TEST_CONDITION_REQUIRED(readingCorrect, "Testing if the output values are correct.");

  //check if end of file is reached
  dErr = fscanf (distanceInfile, ",%f", &distVal);
  aErr = fscanf (amplitudeInfile, ",%f", &amplVal);
  iErr = fscanf (intensityInfile, ",%f", &intenVal);
  MITK_TEST_CONDITION_REQUIRED((dErr==EOF), "Testing EOF distance file");
  MITK_TEST_CONDITION_REQUIRED((aErr==EOF), "Testing EOF amplitude file");
  MITK_TEST_CONDITION_REQUIRED((iErr==EOF), "Testing EOF intensity file");

  //close testing files
  CloseCsvFile(distanceInfile);
  CloseCsvFile(amplitudeInfile);
  CloseCsvFile(intensityInfile);

  remove( distanceImageFileName.c_str() );
  remove( amplitudeImageFileName.c_str() );
  remove( intensityImageFileName.c_str() );

  MITK_TEST_END();
}
/**Documentation
 *  test for the class "ToFCameraMITKPlayerController".
 */
void ReadFileFormatTestCase(std::string extension, mitk::ToFImageGrabber::Pointer grabber)
{
  MITK_INFO<<"Checking image processing with file format " << extension.c_str();
  //create some test image
  unsigned int* dim = new unsigned int[3];
  dim[0] = 100;
  dim[1] = 100;
  dim[2] = 1;
  int end = dim[0]*dim[1]*dim[2];
  float* data = new float[end];
  int index = 0;

  while(index != end)
  {
    data[index] = (float) index;
    index++;
  }

  mitk::Image::Pointer testImage = mitk::Image::New();

  mitk::PixelType FloatType = mitk::MakeScalarPixelType<float>();
  testImage->Initialize( FloatType, 3, dim);
  testImage->SetVolume(data);

  // save image as dist, ampl and inten image to file.
  std::string distanceImageFileName("distTestImage");
  std::string amplitudeImageFileName("amplTestImage");
  std::string intensityImageFileName("intenTestImage");

  mitk::ImageWriter::Pointer writer = mitk::ImageWriter::New();
  writer->SetInput(testImage);
  writer->SetExtension(extension);
  writer->SetFileName(distanceImageFileName);
  writer->Update();

  writer->SetFileName(amplitudeImageFileName);
  writer->Update();

  writer->SetFileName(intensityImageFileName);
  writer->Update();

  // load the files from directory

  grabber->SetStringProperty("DistanceImageFileName", (distanceImageFileName.append(extension)).c_str());
  grabber->SetStringProperty("AmplitudeImageFileName", (amplitudeImageFileName.append(extension)).c_str());
  grabber->SetStringProperty("IntensityImageFileName", (intensityImageFileName.append(extension)).c_str());

  MITK_TEST_CONDITION_REQUIRED(grabber->ConnectCamera() ,"Are the image files loaded correctly?");

  mitk::ToFCameraMITKPlayerController::Pointer testObject = static_cast<mitk::ToFCameraMITKPlayerDeviceImpl*>(grabber->GetCameraDevice())->GetController();
  // test load image from image grabber
  testObject->UpdateCamera();
  index = 0;
  bool distOK = true;
  bool amplOK = true;
  bool intenOK = true;
  float* dist = new float[end];
  float* ampl = new float[end];
  float* inten = new float[end];
  testObject->GetDistances( dist );
  testObject->GetAmplitudes( ampl );
  testObject->GetIntensities( inten );

  while( index != end )
  {
    if( dist[index] != data[index])
    {
      distOK = false;
    }
    if( ampl[index] != data[index])
    {
      amplOK = false;
    }
    if( inten[index] != data[index])
    {
      intenOK = false;
    }
    index++;
  }

  MITK_TEST_CONDITION_REQUIRED(distOK ,"Testing correct loading and passing of distance image information!");
  MITK_TEST_CONDITION_REQUIRED(amplOK ,"Testing correct loading and passing of amplitude image information!");
  MITK_TEST_CONDITION_REQUIRED(intenOK ,"Testing correct loading and passing of intensity image information!");
  MITK_TEST_CONDITION_REQUIRED(testObject->CloseCameraConnection(),"Testing disconnection of controller");

  //clean up and delete saved image files
  if(remove(distanceImageFileName.c_str())!=0)
  {
    MITK_ERROR<<"File: "<<distanceImageFileName<<" not successfully deleted!";
  }

  if(std::remove(amplitudeImageFileName.c_str())!=0)
  {
    MITK_ERROR<<"File: "<<amplitudeImageFileName<<" not successfully deleted!";
  }
  if(remove(intensityImageFileName.c_str())!=0)
  {
    MITK_ERROR<<"File: "<<intensityImageFileName<<" not successfully deleted!";
  }
  delete[] dist;
  delete[] ampl;
  delete[] inten;
  delete[] dim;
}
/**Documentation
 *  test for the class "ToFImageWriter".
 */
int mitkToFNrrdImageWriterTest(int /* argc */, char* /*argv*/[])
{
  MITK_TEST_BEGIN("ToFNrrdImageWriter");

  mitk::ToFNrrdImageWriter::Pointer tofNrrdWriter = mitk::ToFNrrdImageWriter::New();
  // testing correct initialization
  MITK_TEST_CONDITION_REQUIRED(tofNrrdWriter.GetPointer(), "Testing initialization of test object!");
  MITK_TEST_CONDITION_REQUIRED(tofNrrdWriter->GetExtension() == ".nrrd", "testing initialization of extension member variable!");

  //GENERATE TEST DATA
  ////run the test with some unusual parameters
  unsigned int dimX = 255;
  unsigned int dimY = 178;
  unsigned int pixelNumber = dimX*dimY;
  unsigned int numOfFrames = 23; //or numberOfSlices
  ////create 3 images filled with random values
  mitk::Image::Pointer distanceImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames,1.0, 1.0f, 1.0f);
  mitk::Image::Pointer amplitudeImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames,1.0, 1.0f, 2000.0f);
  mitk::Image::Pointer intensityImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames,1.0, 1.0f, 100000.0f);

  //SET NEEDED PARAMETER
  //file names on the disc
  std::string distanceImageFileName("distImg.nrrd");
  std::string amplitudeImageFileName("amplImg.nrrd");
  std::string intensityImageFileName("intImg.nrrd");

  // set file name methods
  tofNrrdWriter->SetDistanceImageFileName(distanceImageFileName);
  tofNrrdWriter->SetAmplitudeImageFileName(amplitudeImageFileName);
  tofNrrdWriter->SetIntensityImageFileName(intensityImageFileName);
  tofNrrdWriter->SetToFCaptureWidth(dimX);
  tofNrrdWriter->SetToFCaptureHeight(dimY);
  tofNrrdWriter->SetToFImageType(mitk::ToFNrrdImageWriter::ToFImageType3D);
  tofNrrdWriter->SetRGBImageSelected(false);

  //buffer for each slice
  float* distanceArray;
  float* amplitudeArray;
  float* intensityArray;

  float* distanceArrayRead;
  float* amplitudeArrayRead;
  float* intensityArrayRead;

  tofNrrdWriter->Open(); //open file/stream

  for(unsigned int i = 0; i < numOfFrames ; i++)
  {
    distanceArray = (float*)distanceImage->GetSliceData(i, 0, 0)->GetData();
    amplitudeArray = (float*)amplitudeImage->GetSliceData(i, 0, 0)->GetData();
    intensityArray = (float*)intensityImage->GetSliceData(i, 0, 0)->GetData();

    //write (or add) the three slices to the file
    tofNrrdWriter->Add(distanceArray, amplitudeArray, intensityArray);
  }

  tofNrrdWriter->Close(); //close file


  //read in the three images from disc
  mitk::ItkImageFileReader::Pointer fileReader = mitk::ItkImageFileReader::New();
  fileReader->SetFileName(distanceImageFileName);
  fileReader->Update();
  mitk::Image::Pointer distanceImageRead = fileReader->GetOutput();

  fileReader = mitk::ItkImageFileReader::New();
  fileReader->SetFileName(amplitudeImageFileName);
  fileReader->Update();
  mitk::Image::Pointer amplitudeImageRead = fileReader->GetOutput();

  fileReader = mitk::ItkImageFileReader::New();
  fileReader->SetFileName(intensityImageFileName);
  fileReader->Update();
  mitk::Image::Pointer intensityImageRead = fileReader->GetOutput();

  bool readingCorrect = true;
  //  for all frames...
  for(unsigned int j=0; j < numOfFrames; j++)
  {
    //get one slice of each image and compare it
    //original data
    distanceArray = (float*)distanceImage->GetSliceData(j, 0, 0)->GetData();
    amplitudeArray = (float*)amplitudeImage->GetSliceData(j, 0, 0)->GetData();
    intensityArray = (float*)intensityImage->GetSliceData(j, 0, 0)->GetData();

    //data read from disc
    distanceArrayRead = (float*)distanceImageRead->GetSliceData(j, 0, 0)->GetData();
    amplitudeArrayRead = (float*)amplitudeImageRead->GetSliceData(j, 0, 0)->GetData();
    intensityArrayRead = (float*)intensityImageRead->GetSliceData(j, 0, 0)->GetData();

    //for all pixels
    for(unsigned int i=0; i<pixelNumber; i++)
    {
      //compare if input == output
      if(!mitk::Equal(distanceArrayRead[i], distanceArray[i]) ||
         !mitk::Equal(amplitudeArrayRead[i], amplitudeArray[i]) ||
         !mitk::Equal(intensityArrayRead[i], intensityArray[i]))
      {
        readingCorrect = false;
      }
    }
  }

  remove( distanceImageFileName.c_str() );
  remove( amplitudeImageFileName.c_str() );
  remove( intensityImageFileName.c_str() );
  MITK_TEST_CONDITION_REQUIRED(readingCorrect, "Testing if the output values are correct.");

  //delete created image files

  MITK_TEST_END();
}
/**Documentation
 *  test for the class "ToFImageWriter".
 */
int mitkToFImageWriterTest(int /* argc */, char* /*argv*/[])
{
  MITK_TEST_BEGIN("ToFImageWriter");

  //run the test with some unusual parameters
  unsigned int dimX = 255;
  unsigned int dimY = 188;
  unsigned int pixelNumber = dimX*dimY;
  unsigned int numOfFrames = 117; //or numberOfSlices

  //create 3 images filled with random values
  mitk::Image::Pointer distanceImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames,0);
  mitk::Image::Pointer amplitudeImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames,0);
  mitk::Image::Pointer intensityImage = mitk::ImageGenerator::GenerateRandomImage<float>(dimX, dimY, numOfFrames,0);

  mitk::ToFImageWriter::Pointer tofWriter = mitk::ToFImageWriter::New();

  //file names on the disc
  std::string distanceImageFileName("distImg.pic");
  std::string amplitudeImageFileName("amplImg.pic");
  std::string intensityImageFileName("intImg.pic");

  tofWriter->SetDistanceImageFileName(distanceImageFileName);
  tofWriter->SetAmplitudeImageFileName(amplitudeImageFileName);
  tofWriter->SetIntensityImageFileName(intensityImageFileName);

  MITK_TEST_CONDITION_REQUIRED(distanceImageFileName==tofWriter->GetDistanceImageFileName(), "Testing set/get distance image file name");
  MITK_TEST_CONDITION_REQUIRED(amplitudeImageFileName==tofWriter->GetAmplitudeImageFileName(), "Testing set/get amplitude image file name");
  MITK_TEST_CONDITION_REQUIRED(intensityImageFileName==tofWriter->GetIntensityImageFileName(), "Testing set/get intensity image file name");

  tofWriter->SetCaptureWidth(dimX);
  tofWriter->SetCaptureHeight(dimY);

  MITK_TEST_CONDITION_REQUIRED(dimX==tofWriter->GetCaptureWidth(), "Testing set/get CaptureWidth");
  MITK_TEST_CONDITION_REQUIRED(dimY==tofWriter->GetCaptureHeight(), "Testing set/get CaptureHeight");

  tofWriter->SetToFImageType(mitk::ToFImageWriter::ToFImageType2DPlusT);

  MITK_TEST_CONDITION_REQUIRED(mitk::ToFImageWriter::ToFImageType2DPlusT==tofWriter->GetToFImageType(), "Testing set/get ToFImageType");

  tofWriter->SetToFImageType(mitk::ToFImageWriter::ToFImageType3D);

  //buffer for each slice
  float* distanceArray;
  float* amplitudeArray;
  float* intensityArray;

  float* distanceArrayRead;
  float* amplitudeArrayRead;
  float* intensityArrayRead;

  tofWriter->Open(); //open file/stream
  //Note: the slices are written out reverse order, because the ToFImageWriter has to write them out immediately.
  //A PicFileWriter would write them out vice versa and the PicFileWriter reads the slices vice versa.
  for(unsigned int i = numOfFrames; i > 0 ; i--)
  { //write values to file/stream
    //The slice index is "i-1", because "for(unsigned int i = numOfFrames-1; i >= 0 ; i--)" does not work for some reason
    distanceArray = (float*)distanceImage->GetSliceData(i-1, 0, 0)->GetData();
    amplitudeArray = (float*)amplitudeImage->GetSliceData(i-1, 0, 0)->GetData();
    intensityArray = (float*)intensityImage->GetSliceData(i-1, 0, 0)->GetData();

    //write (or add) the three slices to the file
    tofWriter->Add(distanceArray, amplitudeArray, intensityArray);
  }
  tofWriter->Close(); //close file

  //read in the three images from disc
  mitk::PicFileReader::Pointer fileReader = mitk::PicFileReader::New();
  fileReader->SetFileName(distanceImageFileName);
  fileReader->Update();
  mitk::Image::Pointer distanceImageRead = fileReader->GetOutput();

  fileReader = mitk::PicFileReader::New();
  fileReader->SetFileName(amplitudeImageFileName);
  fileReader->Update();
  mitk::Image::Pointer amplitudeImageRead = fileReader->GetOutput();

  fileReader = mitk::PicFileReader::New();
  fileReader->SetFileName(intensityImageFileName);
  fileReader->Update();
  mitk::Image::Pointer intensityImageRead = fileReader->GetOutput();

  bool readingCorrect = true;
  //  for all frames...
  for(unsigned int j=0; j<numOfFrames; j++)
  {
    //get one slice of each image and compare it
    //original data
    distanceArray = (float*)distanceImage->GetSliceData(j, 0, 0)->GetData();
    amplitudeArray = (float*)amplitudeImage->GetSliceData(j, 0, 0)->GetData();
    intensityArray = (float*)intensityImage->GetSliceData(j, 0, 0)->GetData();

    //data read from disc
    distanceArrayRead = (float*)distanceImageRead->GetSliceData(j, 0, 0)->GetData();
    amplitudeArrayRead = (float*)amplitudeImageRead->GetSliceData(j, 0, 0)->GetData();
    intensityArrayRead = (float*)intensityImageRead->GetSliceData(j, 0, 0)->GetData();

    //for all pixels
for(unsigned int i=0; i<pixelNumber; i++)
    {
      //compare if input == output
      if(!mitk::Equal(distanceArrayRead[i],distanceArray[i]) ||
         !mitk::Equal(amplitudeArrayRead[i], amplitudeArray[i]) ||
         !mitk::Equal(intensityArrayRead[i], intensityArray[i]))
      {
        readingCorrect = false;
      }
    }
  }
  MITK_TEST_CONDITION_REQUIRED(readingCorrect, "Testing if the output values are correct.");

  //delete created image files
  remove( distanceImageFileName.c_str() );
  remove( amplitudeImageFileName.c_str() );
  remove( intensityImageFileName.c_str() );

  MITK_TEST_END();  
}