Ejemplo n.º 1
0
void actualPhaseFlip(MultidimArray<double> &I, CTFDescription ctf)
{
    // Perform the Fourier transform
    FourierTransformer transformer;
    MultidimArray< std::complex<double> > M_inFourier;
    transformer.FourierTransform(I,M_inFourier,false);

    Matrix1D<double> freq(2); // Frequencies for Fourier plane
    int yDim=YSIZE(I);
    int xDim=XSIZE(I);
    double iTm=1.0/ctf.Tm;
    for (size_t i=0; i<YSIZE(M_inFourier); ++i)
    {
    	FFT_IDX2DIGFREQ(i, yDim, YY(freq));
    	YY(freq) *= iTm;
        for (size_t j=0; j<XSIZE(M_inFourier); ++j)
        {
        	FFT_IDX2DIGFREQ(j, xDim, XX(freq));
        	XX(freq) *= iTm;
            ctf.precomputeValues(XX(freq),YY(freq));
            if (ctf.getValuePureWithoutDampingAt()<0)
                DIRECT_A2D_ELEM(M_inFourier,i,j)*=-1;
        }
    }

    // Perform inverse Fourier transform and finish
    transformer.inverseFourierTransform();
}
Ejemplo n.º 2
0
void ProgCTFPhaseFlipping::run()
{
    show();

    // Read the micrograph in an array of doubles
    Image<double> M_in;
    M_in.read(fn_in);

    // Read CTF
    CTFDescription ctf;
    ctf.clear();
    ctf.read(fnt_ctf);
    ctf.changeSamplingRate(ctf.Tm*downsampling);
    ctf.produceSideInfo();

    actualPhaseFlip(M_in(),ctf);

    M_in.write(fn_out);
}
Ejemplo n.º 3
0
PyObject *
Image_applyCTF(PyObject *obj, PyObject *args, PyObject *kwargs)
{
    PyObject *input = NULL;
    double Ts=1.0;
    try
    {
        PyArg_ParseTuple(args, "Od", &input,&Ts);
        if (input != NULL)
        {
			PyObject *pyStr;
			if ((pyStr = PyObject_Str(input)) != NULL)
			{
				FileName fnCTF=PyString_AsString(pyStr);
			    ImageObject *self = (ImageObject*) obj;
	            ImageGeneric *image = self->image;
	            image->convert2Datatype(DT_Double);
	            MultidimArray<double> * pImage=NULL;
	            MULTIDIM_ARRAY_GENERIC(*image).getMultidimArrayPointer(pImage);

			    self->image->data->getMultidimArrayPointer(pImage);

		        CTFDescription ctf;
		        ctf.enable_CTF=true;
		        ctf.enable_CTFnoise=false;
		        ctf.read(fnCTF);
		        ctf.produceSideInfo();
		        ctf.applyCTF(*pImage,Ts);
		        Py_RETURN_NONE;
			}
        }
    }
    catch (XmippError &xe)
    {
        PyErr_SetString(PyXmippError, xe.msg.c_str());
    }
    return NULL;
}