当前位置: 首页>>代码示例>>C++>>正文


C++ hoNDArray类代码示例

本文整理汇总了C++中hoNDArray的典型用法代码示例。如果您正苦于以下问题:C++ hoNDArray类的具体用法?C++ hoNDArray怎么用?C++ hoNDArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了hoNDArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: maxAbsolute

    void maxAbsolute(const hoNDArray<T>& x, T& r, size_t& ind)
    {
        size_t N = x.get_number_of_elements();
        const T* pX = x.begin();

        ind = 0;
        if ( N == 0 ) return;

        long long n;

        typename realType<T>::Type v = abs(pX[0]);
        typename realType<T>::Type v2;

        ind = 0;
        for ( n=1; n<(long long)N; n++ )
        {
            v2 = std::abs(pX[n]);
            if ( v2 > v )
            {
                v = v2;
                ind = n;
            }
        }

        r = pX[ind];
    }
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:26,代码来源:hoNDArray_reductions.cpp

示例2: correct_time_stamp_with_fitting

    void correct_time_stamp_with_fitting(hoNDArray<float>& time_stamp, size_t startE1, size_t endE1)
    {
        try
        {
            size_t E1 = time_stamp.get_size(0);
            size_t N = time_stamp.get_size(1);
            size_t rE1 = endE1 - startE1 + 1;

            size_t e1, n;

            size_t num_acq_read_outs = 0;
            for ( n=0; n<N; n++ )
            {
                for ( e1=0; e1<E1; e1++ )
                {
                    if ( time_stamp(e1, n) > 0 )
                    {
                        num_acq_read_outs++;
                    }
                }
            }

            GDEBUG_STREAM(" Number of acquired lines : " << num_acq_read_outs);

            float a, b; // y = a + b*x
            {
                std::vector<float> x(num_acq_read_outs), y(num_acq_read_outs);

                size_t ind = 0;
                for ( n=0; n<N; n++ )
                {
                    for ( e1=startE1; e1<=endE1; e1++ )
                    {
                        float acq_time = time_stamp(e1, n);
                        if ( acq_time > 0 )
                        {
                            x[ind] = (float)(e1-startE1 + n*rE1);
                            y[ind] = acq_time;
                            ind++;
                        }
                    }
                }

                Gadgetron::simple_line_fit(x, y, a, b);
            }

            for ( n=0; n<N; n++ )
            {
                for ( e1=startE1; e1<=endE1; e1++ )
                {
                    float x_v = (float)(e1-startE1 + n*rE1);
                    time_stamp(e1, n) = a + b*x_v;
                }
            }
        }
        catch(...)
        {
            GADGET_THROW("Exceptions happened in correct_time_stamp_with_fitting(...) ... ");
        }
    }
开发者ID:DerOrfa,项目名称:gadgetron,代码行数:60,代码来源:cmr_time_stamp.cpp

示例3: grappa2d_calib_convolution_kernel

void grappa2d_calib_convolution_kernel(const hoNDArray<T>& acsSrc, const hoNDArray<T>& acsDst, size_t accelFactor, double thres, size_t kRO, size_t kNE1, hoNDArray<T>& convKer)
{
    size_t startRO = 0;
    size_t endRO = acsSrc.get_size(0) - 1;
    size_t startE1 = 0;
    size_t endE1 = acsSrc.get_size(1) - 1;

    grappa2d_calib_convolution_kernel(acsSrc, acsDst, accelFactor, thres, kRO, kNE1, startRO, endRO, startE1, endE1, convKer);
}
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:9,代码来源:mri_core_grappa.cpp

示例4: cfZero

int CS_FOCUSS_2D::fRecon(hoNDArray<std::complex<float> >  &hacfInput, hoNDArray<std::complex<float> >  &hacfRecon){

	// input dimensions
	vtDim_ = *hacfInput.get_dimensions();

	// number of channels
	iNChannels_ = (int)vtDim_[2];

	// if Matlab is used, initialize singleton variables
	/*if (bMatlab_){
		for (int iI = 0; iI < 20; iI++){
			GlobalVar_FOCUSS::instance()->vbStatPrinc_.push_back(false);
			GlobalVar_FOCUSS::instance()->vfPrincipleComponents_.push_back(new hoNDArray<std::complex<float> > ());
		}
	}*/

	// const complex values
	const std::complex<float> cfZero(0.0);
	const std::complex<float> cfOne(1.0);

	// store incoming data in array
	hoNDArray<std::complex<float> >  hacfKSpace = hacfInput;

	// permute kSpace: x-y-c -> y-x-c
	std::vector<size_t> vtDimOrder; vtDimOrder.push_back(1); vtDimOrder.push_back(0); vtDimOrder.push_back(2);
	hacfKSpace = *permute(&hacfKSpace, &vtDimOrder,false);

	// update dim_ vector
	vtDim_.clear(); vtDim_ = *hacfKSpace.get_dimensions();

	//------------------------------------------------------------------------
	//-------------------------- sampling mask -------------------------------
	//------------------------------------------------------------------------
	hoNDArray<std::complex<float> >  hacfFullMask(hacfKSpace.get_dimensions()); hacfFullMask.fill(cfZero);
	hoNDArray<bool> habFullMask(hacfKSpace.get_dimensions()); habFullMask.fill(false);
	pcfPtr_ = hacfKSpace.get_data_ptr();
	pcfPtr2_ = hacfFullMask.get_data_ptr();
	pbPtr_ = habFullMask.get_data_ptr();
	for (int i = 0; i < hacfKSpace.get_number_of_elements(); i++)
		if (pcfPtr_[i] != cfZero){
			pcfPtr2_[i] = cfOne;
			pbPtr_[i] = true;
		}

	//-------------------------------------------------------------------------
	//---------------- iFFT x direction - x ky kz ^= v (n�) -------------------
	//-------------------------------------------------------------------------
	if (Transform_fftBA_->get_active()){
		if (!bMatlab_ && bDebug_)
			#if __GADGETRON_VERSION_HIGHER_3_6__ == 1
				GDEBUG("FFT in read direction..\n");
			#else
				GADGET_DEBUG1("FFT in read direction..\n");
			#endif
		else if(bMatlab_ && bDebug_){
			// mexPrintf("FFT in read direction..\n");mexEvalString("drawnow;");
		}
		Transform_fftBA_->FTransform(hacfKSpace);
	}
开发者ID:thomaskuestner,项目名称:CS_LAB,代码行数:59,代码来源:CS_FOCUSS_2D.cpp

示例5: compute_phase_time_stamp

    void compute_phase_time_stamp(const hoNDArray<float>& time_stamp, const hoNDArray<float>& cpt_time_stamp, size_t startE1, size_t endE1, 
        hoNDArray<float>& phs_time_stamp, hoNDArray<float>& phs_cpt_time_stamp)
    {
        try
        {
            size_t E1 = time_stamp.get_size(0);
            size_t N = time_stamp.get_size(1);
            size_t rE1 = endE1 - startE1 + 1;

            size_t e1, n;

            for ( n=0; n<N; n++ )
            {
                // phase time stamp as the mean of all aquired lines
                size_t num = 0;
                float tt = 0.0f;
                for ( e1=startE1; e1<=endE1; e1++ )
                {
                    if(time_stamp(e1, n)>0)
                    {
                        tt += time_stamp(e1, n);
                        num++;
                    }
                }
                phs_time_stamp(n, 0) = tt/((num>0) ? num : 1);

                //// phase cpt time as the median of all acquired lines
                //std::vector<float> cpt_buf(rE1, 0);
                //for ( e1=startE1; e1<=endE1; e1++ )
                //{
                //    if(cpt_time_stamp(e1, n)>=0)
                //        cpt_buf[e1-startE1] = cpt_time_stamp(e1, n);
                //}

                //std::sort(cpt_buf.begin(), cpt_buf.end());
                //phs_cpt_time_stamp(n, 0) = cpt_buf[E1/2-startE1];

                // phase cpt time as the cpt time of center line
                phs_cpt_time_stamp(n, 0) = cpt_time_stamp(E1/2, n);
            }
        }
        catch(...)
        {
            GADGET_THROW("Exceptions happened in compute_phase_time_stamp(...) ... ");
        }
    }
开发者ID:DerOrfa,项目名称:gadgetron,代码行数:46,代码来源:cmr_time_stamp.cpp

示例6: apply_unmix_coeff_kspace

void apply_unmix_coeff_kspace(const hoNDArray<T>& kspace, const hoNDArray<T>& unmixCoeff, hoNDArray<T>& complexIm)
{
    try
    {
        GADGET_CHECK_THROW(kspace.get_size(0) == unmixCoeff.get_size(0));
        GADGET_CHECK_THROW(kspace.get_size(1) == unmixCoeff.get_size(1));
        GADGET_CHECK_THROW(kspace.get_size(2) == unmixCoeff.get_size(2));

        hoNDArray<T> buffer2DT(kspace);
        GADGET_CATCH_THROW(Gadgetron::hoNDFFT<typename realType<T>::Type>::instance()->ifft2c(kspace, buffer2DT));

        std::vector<size_t> dim;
        kspace.get_dimensions(dim);
        dim[2] = 1;

        if (!complexIm.dimensions_equal(&dim))
        {
            complexIm.create(&dim);
        }

        Gadgetron::multiply(buffer2DT, unmixCoeff, buffer2DT);
        Gadgetron::sum_over_dimension(buffer2DT, complexIm, 2);
    }
    catch (...)
    {
        GADGET_THROW("Errors in apply_unmix_coeff_kspace(const hoNDArray<T>& kspace, const hoNDArray<T>& unmixCoeff, hoNDArray<T>& complexIm) ... ");
    }
}
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:28,代码来源:mri_core_grappa.cpp

示例7: apply_unmix_coeff_aliased_image

void apply_unmix_coeff_aliased_image(const hoNDArray<T>& aliasedIm, const hoNDArray<T>& unmixCoeff, hoNDArray<T>& complexIm)
{
    try
    {
        GADGET_CHECK_THROW(aliasedIm.get_size(0) == unmixCoeff.get_size(0));
        GADGET_CHECK_THROW(aliasedIm.get_size(1) == unmixCoeff.get_size(1));
        GADGET_CHECK_THROW(aliasedIm.get_size(2) == unmixCoeff.get_size(2));

        std::vector<size_t> dim;
        aliasedIm.get_dimensions(dim);
        dim[2] = 1;

        if (!complexIm.dimensions_equal(&dim))
        {
            complexIm.create(&dim);
        }

        hoNDArray<T> buffer2DT(aliasedIm);

        Gadgetron::multiply(aliasedIm, unmixCoeff, buffer2DT);
        Gadgetron::sum_over_dimension(buffer2DT, complexIm, 2);
    }
    catch (...)
    {
        GADGET_THROW("Errors in apply_unmix_coeff_aliased_image(const hoNDArray<T>& aliasedIm, const hoNDArray<T>& unmixCoeff, hoNDArray<T>& complexIm) ... ");
    }
}
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:27,代码来源:mri_core_grappa.cpp

示例8: update_field_map

    hoNDArray<uint16_t>
    update_field_map(const hoNDArray<uint16_t> &field_map_index, const hoNDArray<uint16_t> &proposed_field_map_index,
                     const hoNDArray<float> &residuals_map, const hoNDArray<float> &lambda_map) {


        hoNDArray<float> residual_diff_map(field_map_index.get_dimensions());
        const auto X = field_map_index.get_size(0);
        const auto Y = field_map_index.get_size(1);
        const auto Z = field_map_index.get_size(2);

        for (size_t kz = 0; kz < Z; kz++) {
            for (size_t ky = 0; ky < Y; ky++) {
                for (size_t kx = 0; kx < X; kx++) {
                    residual_diff_map(kx, ky,kz) = residuals_map(field_map_index(kx, ky,kz), kx, ky,kz) -
                                                residuals_map(proposed_field_map_index(kx, ky,kz), kx, ky,kz);


                }
            }
        }


        std::vector<boost::default_color_type> color_map;
        if (Z == 1) {
            color_map = graph_cut<2>(field_map_index, proposed_field_map_index, lambda_map,
                                     residual_diff_map);
        } else {
            color_map = graph_cut<3>(field_map_index, proposed_field_map_index, lambda_map, residual_diff_map);
        }



        auto result = field_map_index;
        size_t updated_voxels = 0;
        for (size_t i = 0; i < field_map_index.get_number_of_elements(); i++) {
            if (color_map[i] != boost::default_color_type::black_color) {
                updated_voxels++;
                result[i] = proposed_field_map_index[i];
            }
        }

        return result;

    }
开发者ID:congzhangzh,项目名称:gadgetron,代码行数:44,代码来源:graph_cut.cpp

示例9: maxValue

    void maxValue(const hoNDArray<T>& a, T& v)
    {
        typedef T ValueType;

        try
        {
            const ValueType* pA = a.begin();
            size_t n = a.get_number_of_elements();
            v = pA[0];

            size_t ii;
            for (ii=1; ii<n; ii++)
            {
                if (pA[ii]>v) v = pA[ii];
            }
        }
        catch(...)
        {
            GADGET_THROW("Errors in maxValue(const hoNDArray<T>& a, T& v) ... ");
        }
    }
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:21,代码来源:hoNDArray_reductions.cpp

示例10: sort

    void sort(const hoNDArray<T>& x, hoNDArray<T>& r, bool isascending)
    {
        if ( &r != &x )
        {
            if ( r.get_number_of_elements()!=x.get_number_of_elements())
            {
                r = x;
            }
            else
            {
                memcpy(r.begin(), x.begin(), x.get_number_of_bytes());
            }
        }

        sort(x.get_number_of_elements(), x.begin(), r.begin(), isascending);
    }
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:16,代码来源:hoNDArray_reductions.cpp

示例11: outputPlotIm

void outputPlotIm(const hoNDArray<unsigned char>& im, bool trueColor, hoNDArray<float>& plotIm)
{
    size_t xsize = im.get_size(1);
    size_t ysize = im.get_size(2);

    plotIm.copyFrom(im);

    if (trueColor)
    {
        std::vector<size_t> dim_order(3);
        dim_order[0] = 1;
        dim_order[1] = 2;
        dim_order[2] = 0;

        hoNDArray<float> plotImPermuted;
        plotImPermuted.copyFrom(plotIm);

        plotIm.create(xsize, ysize, 3);

        Gadgetron::permute(plotImPermuted, plotIm, dim_order);
    }
    else
    {
        hoNDArray<float> plotIm2D;
        Gadgetron::sum_over_dimension(plotIm, plotIm2D, 0);

        plotIm2D.squeeze();

        std::vector<size_t> dim_order(2);
        dim_order[0] = 0;
        dim_order[1] = 1;

        plotIm.create(xsize, ysize);
        Gadgetron::permute(plotIm2D, plotIm, dim_order);
    }
}
开发者ID:congzhangzh,项目名称:gadgetron,代码行数:36,代码来源:GtPLplot.cpp

示例12: fatwater_separation

    hoNDArray< std::complex<float> > fatwater_separation(hoNDArray< std::complex<float> >& data, FatWaterParameters p, FatWaterAlgorithm a)
    {

	//Get some data parameters
	//7D, fixed order [X, Y, Z, CHA, N, S, LOC]
        uint16_t X = data.get_size(0);
        uint16_t Y = data.get_size(1);
        uint16_t Z = data.get_size(2);
        uint16_t CHA = data.get_size(3);
        uint16_t N = data.get_size(4);
        uint16_t S = data.get_size(5);
        uint16_t LOC = data.get_size(6);

	GDEBUG("Size of my array: %d, %d, %d .\n", X,Y,Z);

	hoNDArray< std::complex<float> > out(X,Y,Z,CHA,N,2,LOC); // S dimension gets replaced by water/fat stuff

	float fieldStrength = p.fieldStrengthT_;
        std::vector<float> echoTimes = p.echoTimes_;
	bool precessionIsClockwise = p.precessionIsClockwise_;
        for (auto& te: echoTimes) {
          te = te*0.001; // Echo times in seconds rather than milliseconds
        }

	GDEBUG("In toolbox - Field Strength: %f T \n", fieldStrength);
        for (auto& te: echoTimes) {
	  GDEBUG("In toolbox - Echo time: %f seconds \n", te);
        }
	GDEBUG("In toolbox - PrecessionIsClockwise: %d \n", precessionIsClockwise);

	//Get or set some algorithm parameters
	//Gadgetron::ChemicalSpecies w = a.species_[0];
	//Gadgetron::ChemicalSpecies f = a.species_[1];

	//	GDEBUG("In toolbox - Fat peaks: %f  \n", f.ampFreq_[0].first);
	//	GDEBUG("In toolbox - Fat peaks 2: %f  \n", f.ampFreq_[0].second);

	// Set some initial parameters so we can get going
	// These will have to be specified in the XML file eventually
	std::pair<float,float> range_r2star = std::make_pair(0.0,0.0);
	uint16_t num_r2star = 1;
	std::pair<float,float> range_fm = std::make_pair(-80.0,80.0);
	uint16_t num_fm = 101;
	uint16_t num_iterations = 40;
	uint16_t subsample = 1;
	float lmap_power = 2.0;
	float lambda = 0.02;
	float lambda_extra = 0.02;

	//Check that we have reasonable data for fat-water separation


	//Calculate residual
	//
	float relAmp, freq_hz;
	uint16_t npeaks;
	uint16_t nspecies = a.species_.size();
	uint16_t nte = echoTimes.size();
	GDEBUG("In toolbox - NTE: %d \n", nte);

	hoMatrix< std::complex<float> > phiMatrix(nte,nspecies);
	for( int k1=0;k1<nte;k1++) {
	  for( int k2=0;k2<nspecies;k2++) {
	    phiMatrix(k1,k2) = 0.0;
	    npeaks = a.species_[k2].ampFreq_.size();
	    for( int k3=0;k3<npeaks;k3++) {
	      relAmp = a.species_[k2].ampFreq_[k3].first;
	      freq_hz = fieldStrength*GAMMABAR*a.species_[k2].ampFreq_[k3].second;
	      phiMatrix(k1,k2) += relAmp*std::complex<float>(cos(2*PI*echoTimes[k1]*freq_hz),sin(2*PI*echoTimes[k1]*freq_hz));
	    }
	    GDEBUG("Cur value phiMatrix = (%f,%f) \n", phiMatrix(k1,k2).real(), phiMatrix(k1,k2).imag());
	  }
	}
	//auto a_phiMatrix = as_arma_matrix(&phiMatrix);
	//auto mymat2 = mymat.t()*mymat;

	for(int ka=0;ka<phiMatrix.get_size(0);ka++) {
	  for(int kb=0;kb<phiMatrix.get_size(1);kb++) {
	    GDEBUG("Check phiMatrix(%d,%d) = %f + i %f \n", ka,kb,phiMatrix(ka,kb).real(),phiMatrix(ka,kb).imag());
	  }
	}




	hoMatrix< std::complex<float> > IdentMat(nte,nte);
	for( int k1=0;k1<nte;k1++) {
	  for( int k2=0;k2<nte;k2++) {
	    if( k1==k2 ) {
	      IdentMat(k1,k2) = std::complex<float>(1.0,0.0);
	    } else {
	      IdentMat(k1,k2) = std::complex<float>(0.0,0.0);
	    }
	  }
	}
	//	auto a_phiMatrix = as_arma_matrix(&IdentMat);

	float fm;
	std::vector<float> fms(num_fm);
	fms[0] = range_fm.first;
//.........这里部分代码省略.........
开发者ID:rajramasawmy,项目名称:gadgetron,代码行数:101,代码来源:fatwater.cpp

示例13: correct_heart_beat_time_stamp_with_fitting

    void correct_heart_beat_time_stamp_with_fitting(hoNDArray<float>& cpt_time_stamp, hoNDArray<int>& ind_hb, size_t startE1, size_t endE1, 
                                                const std::vector<size_t>& start_e1_hb, const std::vector<size_t>& end_e1_hb, 
                                                const std::vector<size_t>& start_n_hb, const std::vector<size_t>& end_n_hb )
    {
        try
        {
            size_t E1 = cpt_time_stamp.get_size(0);
            size_t N = cpt_time_stamp.get_size(1);
            size_t rE1 = endE1-startE1+1;

            size_t e1, n, ind, ii;

            size_t num_acq_read_outs = 0;
            for ( n=0; n<N; n++ )
            {
                for ( e1=0; e1<E1; e1++ )
                {
                    if ( cpt_time_stamp(e1, n) >= 0 )
                    {
                        num_acq_read_outs++;
                    }
                }
            }

            size_t numOfHB = start_e1_hb.size();

            std::vector<size_t> ind_HB_start(numOfHB);
            std::vector<size_t> ind_HB_end(numOfHB);

            for ( ind=0; ind<numOfHB; ind++ )
            {
                ind_HB_start[ind] = start_e1_hb[ind] + start_n_hb[ind] * E1;
                ind_HB_end[ind] = end_e1_hb[ind] + end_n_hb[ind] * E1;
            }

            // --------------------------------------------------------
            // fit a line to every heart beat
            // --------------------------------------------------------
            float a, b;
            std::vector<float> A(numOfHB, 0.0f), B(numOfHB, 0.0f);
            for ( ind=0; ind<numOfHB; ind++ )
            {
                std::vector<float> x, y;

                size_t cpt;
                for ( cpt=ind_HB_start[ind]; cpt<=ind_HB_end[ind]; cpt++ )
                {
                    size_t n = cpt / E1;
                    size_t e1 = cpt - n*E1;

                    if(e1>=startE1 && e1<=endE1)
                    {
                        if ( cpt_time_stamp[cpt] > -1 )
                        {
                            size_t x_ind = (e1-startE1) + n*rE1;
                            x.push_back( (float)x_ind );
                            y.push_back(cpt_time_stamp[cpt]);
                        }
                    }
                }

                if ( !x.empty() )
                {
                    Gadgetron::simple_line_fit(x, y, a, b);
                    A[ind] = a;
                    B[ind] = b;
                }
            }

            // --------------------------------------------------------
            // compute cpt time stamp for every line
            // --------------------------------------------------------
            size_t num = cpt_time_stamp.get_number_of_elements();
            for ( ind=0; ind<num; ind++ )
            {
                n = ind / E1;
                e1 = ind - n*E1;

                if(e1>=startE1 && e1<=endE1)
                {
                    // find to which heart beat this line belongs
                    bool foundHB = false;
                    for ( ii=0; ii<numOfHB; ii++ )
                    {
                        size_t startHB = ind_HB_start[ii];
                        size_t endHB = ind_HB_end[ii];

                        if ( ii==0 && ind<=startHB )
                        {
                            foundHB = true;
                            break;
                        }

                        if ( ii==numOfHB-1 && ind>=endHB )
                        {
                            foundHB = true;
                            break;
                        }

                        if ( ind>=startHB && ind<=endHB )
//.........这里部分代码省略.........
开发者ID:DerOrfa,项目名称:gadgetron,代码行数:101,代码来源:cmr_time_stamp.cpp

示例14: dotu

 void dotu(const hoNDArray<T>& x, const hoNDArray<T>& y, T& r)
 {
     GADGET_DEBUG_CHECK_THROW(x.get_number_of_elements()==y.get_number_of_elements());
     dotu(x.get_number_of_elements(), x.begin(), y.begin(), r);
 }
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:5,代码来源:hoNDArray_reductions.cpp

示例15: amax

 template<class T> size_t amax(const hoNDArray<T>& x)
 {
     return amax(x.get_number_of_elements(), x.begin());
 }
开发者ID:ACampbellWashburn,项目名称:gadgetron,代码行数:4,代码来源:hoNDArray_reductions.cpp


注:本文中的hoNDArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。