Commit df3ad671 authored by Pilar Cossio's avatar Pilar Cossio

Cross-Correlation Optimization and more options

parent a0cc70c4
This diff is collapsed.
......@@ -77,7 +77,7 @@ __device__ static inline myfloat_t calc_logpro(const bioem_param_device& param,
if(param.debugterm){
// printf("Separate cc: %f c: %f oo: %f o: %f co: %f logP: %f\n",sumsquare,sum,sumsquareref,sumref,crossproMapConv, logpro );
// printf("Separate cc: %f c: %f oo: %f o: %f co: %f logP: %f\n",sumsquare,sum,sumsquareref,sumref,crossproMapConv, logpro );
}
return(logpro);
}
......@@ -109,6 +109,10 @@ __device__ static inline void calProb(int iRefMap, int iOrient, int iConv, myflo
}
pProbMap.Total += exp(logpro - pProbMap.Constoadd);
if(param.debugterm){
printf("Separate Ptot: %f Const: %f logProb %f \n",pProbMap.Total,pProbMap.Constoadd,logpro);
}
if (param.writeAngles)
{
bioem_Probability_angle& pProbAngle = pProb.getProbAngle(iRefMap, iOrient);
......@@ -151,32 +155,45 @@ __device__ static inline void doRefMapFFT(const int iRefMap, const int iOrient,
if (param.writeCC)
{
int cc=0;
for (int cent_x = 0; cent_x < param.NumberPixels -param.CCdisplace ; cent_x = cent_x + param.CCdisplace)
for (int cent_x = 0; cent_x < param.NumberPixels ; cent_x = cent_x + param.CCdisplace)
{
for (int cent_y = 0; cent_y < param.NumberPixels - param.CCdisplace ; cent_y = cent_y + param.CCdisplace)
for (int cent_y = 0; cent_y < param.NumberPixels ; cent_y = cent_y + param.CCdisplace)
{
bioem_Probability_cc& pProbCC = pProb.getProbCC(iRefMap, cc);
myfloat_t ttmp,ttmp2;
ttmp2 = (myfloat_t) lCC[cent_x * param.NumberPixels + cent_y] / (myfloat_t) (param.NumberPixels * param.NumberPixels);
if(not param.flipped){
//Here we are inverting the sign of the cross-correlation for the images that are not flipped
ttmp=-ttmp2; }
else{ ttmp=ttmp2; }
if(!param.CCwithBayes){
// Storing Only the Maximum both for flipped and not flipped
if(pProbCC.forCC < ttmp) pProbCC.forCC = ttmp;
}else {
// Storing the Cross-correlation with Bayesian formalism
if(pProbCC.ConstCC < ttmp)
{
pProbCC.forCC = pProbCC.forCC * exp(-ttmp + pProbCC.ConstCC);
pProbCC.ConstCC = ttmp;
}
pProbCC.forCC += exp(ttmp - pProbCC.ConstCC);
bioem_Probability_cc& pProbCC = pProb.getProbCC(iRefMap, cc);
myfloat_t ttmp;
ttmp= (myfloat_t) lCC[cent_x * param.NumberPixels + cent_y] / (myfloat_t) (param.NumberPixels * param.NumberPixels);
if(not param.flipped){
// Storing the lowest cross correlations
if(pProbCC.forCC > ttmp) pProbCC.forCC = ttmp;
}
else{
//Storing the highest cross correlations
if(pProbCC.forCC < ttmp) pProbCC.forCC = ttmp;
}
// pProbCC.forCC = ttmp;
cc++;
}
// printf("Separate Ptot: %f Const: %f logProb %f \n",pProbCC.forCC,pProbCC.ConstCC,ttmp);
cc++;
}
}
}
}
template <int GPUAlgo, class RefT>
......
......@@ -105,7 +105,8 @@ public:
class bioem_Probability_cc
{
public:
myfloat_t forCC;
myfloat_t forCC;
myfloat_t ConstCC;
};
class bioem_Probability
......@@ -139,8 +140,8 @@ public:
{
ptr_map = (bioem_Probability_map*) ptr;
ptr_angle = (bioem_Probability_angle*) (&ptr_map[nMaps]);
ptr_cc = (bioem_Probability_cc*) (&ptr_angle[nMaps * nAngles]);
// ptr_cc = (bioem_Probability_cc*) (&ptr_angle[nMaps * 2000 ]);
// ptr_cc = (bioem_Probability_cc*) (&ptr_angle[nMaps * nAngles]);
ptr_cc = (bioem_Probability_cc*) (&ptr_map[nMaps]);
}
};
......
......@@ -27,6 +27,7 @@ public:
bool flipped;
bool debugterm;
int CCdisplace;
bool CCwithBayes;
};
......@@ -43,6 +44,7 @@ public:
void PrepareFFTs();
bool doaaradius;
bool writeCTF;
bool ignoreCCoff;
myfloat_t elecwavel;
bioem_param_device param_device;
......
This diff is collapsed.
......@@ -77,8 +77,10 @@ int bioem_param::readParameters(const char* fileinput,const char* fileangles)
param_device.flipped=false;
param_device.debugterm=false;
param_device.writeCC=false;
param_device.CCwithBayes=false;
writeCTF=false;
elecwavel=0.0;
ignoreCCoff=false;
//Assigning name of angles
//Storing angle file name if existing.
......@@ -241,11 +243,21 @@ int bioem_param::readParameters(const char* fileinput,const char* fileangles)
if (param_device.CCdisplace < 0 ) { cout << "*** Error: Negative CROSSCOR_DISPLACE "; exit(1);}
cout << "Writing Cross Correlation Displacement " << param_device.CCdisplace << " \n";
}
else if (strcmp(token, "CROSSCOR_WITHBAYESIAN") == 0)
{
param_device.CCwithBayes=true;
cout << "Using Bayesian Analysis to write Cross Correlation \n";
}
else if (strcmp(token, "FLIPPED") == 0) //Key word if images are flipped for cross-correlation
{
param_device.flipped = true;
cout << "Micrograph Flipped Intensities \n";
}
else if (strcmp(token, "IGNORE_CROSSCORR_OFFSET") == 0) //Key word if images are flipped for cross-correlation
{
ignoreCCoff = true;
cout << "Ignoring Cross-Correlation offset \n";
}
else if (strcmp(token, "DO_AA_RADIUS") == 0) //If projecting CA with amino-acid radius
{
doaaradius = true;
......@@ -296,6 +308,10 @@ int bioem_param::readParameters(const char* fileinput,const char* fileangles)
if( not ( yesMDC ) ) { cout << "**** INPUT MISSING: Please provide MAX_D_CENTER \n" ; exit (1);};
if( not ( yesGCen ) ) { cout << "**** INPUT MISSING: Please provide PIXEL_GRID_CENTER \n" ; exit (1);};
if( param_device.writeCC && param_device.CCdisplace < 1 ){ cout << "**** INPUT MISSING: Please provide CROSSCOR_DISPLACE \n" ; exit (1);};
if( !param_device.writeCC && param_device.CCwithBayes ){ cout << "**** INPUT MISSING: WRITE_CROSSCOR keyword \n"; exit(1);}
if( param_device.writeCC) {if(!param_device.CCwithBayes ){ cout << "Remark:: Not Using Bayesian method to store Cross-Correlation.\n Only Printing out Maximum\n";}
if(param_device.flipped){ cout << "Remark:: Micrographs are Flipped = Particles are white\n";} else { cout << "Remark:: Micrographs are NOT Flipped = Particles are dark\n";}
}
//if only one grid point for PSF kernel:
if( (myfloat_t) numberGridPointsCTF_amp == 1 ) gridCTF_amp = startGridCTF_amp;
......@@ -645,7 +661,7 @@ int bioem_param::CalculateGridsParam() //TO DO FOR QUATERNIONS
param_device.Ntotpi = (myfloat_t) (param_device.NumberPixels * param_device.NumberPixels);
param_device.NtotDist = (2 * (int) (param_device.maxDisplaceCenter / param_device.GridSpaceCenter) + 1 ) * (2 * (int) (param_device.maxDisplaceCenter / param_device.GridSpaceCenter) + 1);
nTotCC=(myfloat_t) (param_device.NumberPixels * param_device.NumberPixels) / (myfloat_t) ( param_device.CCdisplace * param_device.CCdisplace );
nTotCC = (int) ((myfloat_t) param_device.NumberPixels / (myfloat_t) param_device.CCdisplace + 1) * (int) ((myfloat_t) param_device.NumberPixels / (myfloat_t) param_device.CCdisplace + 1);
return(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment