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

swh:1:snp:e6d42e6731ce66e3c09de07ac49964c03139e990
  • Code
  • Branches (11)
  • Releases (5)
    • Branches
    • Releases
    • HEAD
    • refs/heads/T2
    • refs/heads/develop
    • refs/heads/developCI
    • refs/heads/developCI2
    • refs/heads/developCI3
    • refs/heads/gh-pages
    • refs/heads/master
    • refs/heads/newBuild
    • refs/tags/v0.1
    • refs/tags/v0.11
    • refs/tags/v0.4
    • v0.4.3
    • v0.4.2
    • v0.4.1
    • v0.3
    • v0.2
  • e7c8b4a
  • /
  • tests
  • /
  • OxTestImage.hxx
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
  • revision
  • snapshot
  • release
content badge
swh:1:cnt:fef8f7dbdf1f7c6e7d0316f755556c71cdce4404
directory badge
swh:1:dir:7f479aacb559e8bec09e7f71320c042d56a1018e
revision badge
swh:1:rev:067df5d8b6b785ff51677fd206eade2d85896c85
snapshot badge
swh:1:snp:e6d42e6731ce66e3c09de07ac49964c03139e990
release badge
swh:1:rel:5bfe5972d951ece97af9965fe432220714f212ec

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
  • revision
  • snapshot
  • release
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 067df5d8b6b785ff51677fd206eade2d85896c85 authored by Konrad Werys on 29 October 2019, 14:20:35 UTC
feat: start point 2 params added
Tip revision: 067df5d
OxTestImage.hxx
/*!
 * \file OxTestImage.hxx
 * \author Konrad Werys
 * \date 2018/08/07
 */

#ifndef Tomato_OXTESTImage_HXX
#define Tomato_OXTESTImage_HXX


namespace Ox {

    template< typename MeasureType >
    TestImage<MeasureType>
    ::TestImage(int nRows, int nCols, std::vector <std::string> filesPaths, std::vector<int> invTimesOrder){
        init(nRows, nCols, filesPaths,  invTimesOrder);
    }

    template< typename MeasureType >
    TestImage<MeasureType>
    ::TestImage(int nRows, int nCols, std::vector <std::string> filesPaths){
        std::vector<int> invTimesOrder;
        init(nRows, nCols, filesPaths,  invTimesOrder);
    }

    template< typename MeasureType >
    int
    TestImage<MeasureType>
    ::init(int nRows, int nCols, std::vector <std::string> filesPaths, std::vector<int> invTimesOrder) {
        _nCols = nCols;
        _nRows = nRows;
        int nTissues = filesPaths.size();
        std::vector< TestData <MeasureType> > TestDataVector; // vector with TestData objects

        // I do want to have less 'tissues' (TestData objects) than Columns, just for the sake of simplicity
        if (nTissues > _nCols){
            throw std::runtime_error("Give me more nCols or less tissues");
        }

        // populate TestDataVector
        for (int i = 0; i < nTissues; ++i){
            TestDataVector.push_back(TestData<MeasureType>((char*)filesPaths.at(i).c_str()));
        }

        // check if invTimes are equal
        for (int i = 1; i < nTissues; ++i){
            if(!(TestDataVector.at(i).getInvTimes() == TestDataVector.at(i-1).getInvTimes())){
                throw std::runtime_error("InvTimes are different");
            }
        }
        std::vector<MeasureType> invTimesWithoutOrder = TestDataVector.at(0).getInvTimes();
        _nSamples = invTimesWithoutOrder.size();

        if (invTimesOrder.empty()){
            // _invTimes = 1,2,3, ... , nSamples
            invTimesOrder = std::vector<int>(_nSamples);
            for (int i = 0; i < _nSamples; ++i){
                invTimesOrder.at(i) = i;
            }
        }

        if (invTimesOrder.size() != _nSamples){
            throw std::runtime_error("invTimesOrder size is different than the input files nSamples");
        }

        _invTimes = std::vector <MeasureType>(_nSamples);
        for (int i = 0; i < _nSamples; ++i){
            _invTimes.at(i) = invTimesWithoutOrder.at(invTimesOrder.at(i));
        }

        _invTimesOrder = invTimesOrder;

        // allocate memory
        _imageMag = new MeasureType[_nCols*_nRows*_nSamples];
        _imagePha = new MeasureType[_nCols*_nRows*_nSamples];
        _imageResultsMolli = new MeasureType[_nRows*_nCols*3];
        _imageResultsShmolli = new MeasureType[_nRows*_nCols*3];

        // how to divide the memory?
        std::vector<int> ranges = KWUtil::bounds<int>(nTissues, _nCols);

//        std::cout << std::endl;
//        std::cout << std::endl;
//        for (int i = 0; i < ranges.size(); ++i ){
//            std::cout << ranges[i] << std::endl;
//        }

        // fill memory
        for (int iSample = 0; iSample < _nSamples; ++iSample){
            //for (int iCol = 0; iCol < _nCols; ++iCol) {
            for (int iRow = 0; iRow < _nRows; ++iRow) {
                for (int iTissue = 0; iTissue < ranges.size()-1; ++iTissue) {
                    //for (int iRow = ranges[iTissue]; iRow < ranges[iTissue+1]; ++iRow) {
                    for (int iCol = ranges[iTissue]; iCol < ranges[iTissue+1]; ++iCol) {
                        int invTimesIdx = _invTimesOrder.at(iSample);
                        //int index = iSample * (nRows * nCols) + iCol * nRows + iRow;
                        int index = iSample * (nRows * nCols) + iRow * nCols + iCol;
                        _imageMag[index] = TestDataVector.at(iTissue).getSignalMagPtr()[invTimesIdx];
                        _imagePha[index] = TestDataVector.at(iTissue).getSignalPhaPtr()[invTimesIdx];
                    }
                }
            }
        }

        for (int iDim = 0; iDim < 3; ++iDim){
            //for (int iCol = 0; iCol < _nCols; ++iCol) {
            for (int iRow = 0; iRow < _nRows; ++iRow) {
                for (int iTissue = 0; iTissue < ranges.size()-1; ++iTissue) {
                    //for (int iRow = ranges[iTissue]; iRow < ranges[iTissue+1]; ++iRow) {
                    for (int iCol = ranges[iTissue]; iCol < ranges[iTissue+1]; ++iCol) {
                        //int index = iDim * (nRows * nCols) + iCol * nRows + iRow;
                        int index = iDim * (nRows * nCols) + iRow * nCols + iCol;
                        _imageResultsMolli[index] = TestDataVector.at(iTissue).getResultsMolliPtr()[iDim];
                        _imageResultsShmolli[index] = TestDataVector.at(iTissue).getResultsShmolliPtr()[iDim];
                    }
                }
            }
        }
        return 0; // EXIT_SUCCESS
    }

    template< typename MeasureType >
    TestImage<MeasureType>
    ::~TestImage(){
        delete [] _imageMag;
        delete [] _imagePha;
        delete [] _imageResultsMolli;
        delete [] _imageResultsShmolli;

    }
    template< typename MeasureType >
    std::vector<MeasureType>
    TestImage<MeasureType>
    ::getInvTimes() const {
        return _invTimes;
    }

    template< typename MeasureType >
    MeasureType *
    TestImage<MeasureType>
    ::getInvTimesPtr()  {
        return &_invTimes.at(0);
    }


    template< typename MeasureType >
    MeasureType *
    TestImage<MeasureType>
    ::getImageMagPtr() const {
        return _imageMag;
    }

    template< typename MeasureType >
    MeasureType *
    TestImage<MeasureType>
    ::getImagePhaPtr() const {
        return _imagePha;
    }

    template< typename MeasureType >
    MeasureType *
    TestImage<MeasureType>
    ::getImageResultsMolliPtr() const {
        return _imageResultsMolli;
    }

    template< typename MeasureType >
    MeasureType *
    TestImage<MeasureType>
    ::getImageResultsShmolliPtr() const {
        return _imageResultsShmolli;
    }

} // namespace Ox



#endif //Tomato_OXTESTImage_HXX

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