Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 09bbb25
  • /
  • Tomato_sameAsShmolli_test.cpp
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:12df40d56c66f7dc67144d8c33bb76409a6f5d41
directory badge
swh:1:dir:09bbb2507ea65f0c6c31a9f457fc8553eed0041f

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tomato_sameAsShmolli_test.cpp
/*!
 * \file Tomato_sameAsShmolli_test.cpp
 * \author Konrad Werys
 * \date 2018/08/20
 */

#include "gtest/gtest.h"
#include "Tomato.h"

#include "CmakeConfigForTomato.h"
#ifdef USE_PRIVATE_NR2

#ifdef USE_ITK
#include "itkImageFileReader.h"
#include "itkTestingComparisonImageFilter.h"

// TODO: make sure all fitparams give the same results

TEST(Tomato, sameAsShmolli) {

    bool doVisualise = false; //for debugging

    // primitive data types
    typedef int16_t PixelType;

    // image data types
    typedef itk::Image< PixelType, 2 > ImageType2D;

    typedef itk::ImageFileReader<ImageType2D> ReadImage2dFilterType;
    typedef itk::Testing::ComparisonImageFilter<ImageType2D, ImageType2D> ComparisonImageFilter2dType;

    std::string configFilePath = "testData/Hcmr_Phantom_1916_Shmolli_192i_e11___Shmolli_config___fileList.yaml";

    std::vector<std::string> originalFilePaths;
    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_T1MAP_14/IM-0003-0001.dcm");
//    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0001.dcm");
    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0002.dcm");
    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0003.dcm");
    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0004.dcm");
//    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0005.dcm");
//    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0006.dcm");
//    originalFilePaths.push_back("testData/dicom/Hcmr_Phantom_1916_260C/Konrad_Shmolli/ShMOLLI_192i_e11_FITPARAMS_15/IM-0004-0007.dcm");

    Ox::Tomato<double> Tomato_object(configFilePath);
    Tomato_object.readAndSort();
    Tomato_object.calculate();
    Tomato_object.exportToDicom();

    std::string output_map_series_number = KWUtil::NumberToString(Tomato_object._opts->output_map_series_number);
    std::string output_fitparams_series_number = KWUtil::NumberToString(Tomato_object._opts->output_fitparams_series_number);

    std::vector<std::string> calculatedFilePaths;
    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_map + "/" + output_map_series_number + "_T1.dcm");
//    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_R2.dcm");
    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_A.dcm");
    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_B.dcm");
    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_T1star.dcm");
//    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_ShMolliRange.dcm");
//    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_RelSNRFinal.dcm");
//    calculatedFilePaths.push_back(Tomato_object._opts->dir_output_fitparams + "/" + output_fitparams_series_number + "_nAmebaCallFinal.dcm");

    ReadImage2dFilterType::Pointer readerOriginalT1Map = ReadImage2dFilterType::New();
    ReadImage2dFilterType::Pointer readerCalculatedT1Map = ReadImage2dFilterType::New();
    ComparisonImageFilter2dType::Pointer diff = ComparisonImageFilter2dType::New();

    for (unsigned int i = 0; i < calculatedFilePaths.size(); ++i) {
        readerOriginalT1Map->SetFileName(originalFilePaths.at(i));
        readerCalculatedT1Map->SetFileName(calculatedFilePaths.at(i));

        // for comparing the images
        diff->SetValidInput(readerOriginalT1Map->GetOutput());
        diff->SetTestInput(readerCalculatedT1Map->GetOutput());
        diff->Update();

        std::cout << diff->GetMaximumDifference() << std::endl;

        // compare
        diff->UpdateLargestPossibleRegion();
        ASSERT_LE(diff->GetMaximumDifference(), 2); // max allowed error is 2
    }

#ifdef USE_VTK
    if (doVisualise){
        // view
        QuickView viewer;
        viewer.AddImage(readerCalculatedT1Map->GetOutput(), true, "T1 calculated");
        viewer.AddImage(readerOriginalT1Map->GetOutput(), true, "T1 original");
        viewer.Visualize();
    }
#endif // USE_VTK

}

#endif // USE_PRIVATE_NR2

#endif // USE_ITK

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API