Commit 797ab249 authored by Pilar Cossio's avatar Pilar Cossio

No B-factor, Prior B-envelop, PSF correction

parent 048ebbce
......@@ -7,7 +7,7 @@ GRIDPOINTS_ALPHA 2
GRIDPOINTS_BETA 2
##### Constrast transfer integration: #######
CTF_B_FACTOR 100.0 300.5 2
CTF_B_ENV 100.0 300.5 2
CTF_DEFOCUS 1.0 6.0 5
CTF_AMPLITUDE 0.1 0.1 1
......
......@@ -4,10 +4,9 @@ PIXEL_SIZE 1.77
##### Quaterion grid points: #######
USE_QUATERNIONS
#GRIDPOINTS_QUATERNION 5
##### Constrast transfer integration: #######
CTF_B_FACTOR 100.0 300.5 8
CTF_B_ENV 100.0 300.5 2
CTF_DEFOCUS 1.0 6.0 5
CTF_AMPLITUDE 0.1 0.1 1
......
NUMBER_PIXELS 220
PIXEL_SIZE 1.77
QUATERNIONS 4
GRIDPOINTS_ENVELOPE 4
START_ENVELOPE 0.0002
END_ENVELOPE 0.0012
GRIDPOINTS_PSF_PHASE 4
START_PSF_PHASE 0.004
END_PSF_PHASE 0.016
GRIDPOINTS_PSF_AMP 1
START_PSF_AMP 1.
END_PSF_AMP 1.
MAX_D_CENTER 25
PIXEL_GRID_CENTER 2
PROJECT_RADIUS
WRITE_PROB_ANGLES
##### Micrograph Parameters #######
NUMBER_PIXELS 220
PIXEL_SIZE 1.77
##### Using quaterions #######
USE_QUATERNIONS
##### Constrast transfer integration: #######
CTF_B_ENV 10.0 500. 5.
CTF_DEFOCUS 1.0 6.0 10.
CTF_AMPLITUDE 0.1 0.9 5.
## Gaussian width of Prior of b-parameter
SIGMA_PRIOR_B_CTF 50.
##### Center displacement: #######
DISPLACE_CENTER 40 1
10
0.12635612 0.01592012 0.99114512 0.03758812
0.12337412 0.03159012 0.97867212 0.16119012
0.11845812 0.04676412 0.95084612 0.28226312
0.11168312 0.06120512 0.90810412 0.39890812
0.10315612 0.07468612 0.85111612 0.50929612
0.09301112 0.08699512 0.78077612 0.61169412
0.08140712 0.09793912 0.69818812 0.70449612
0.06852512 0.10734712 0.60464712 0.78624612
0.05456912 0.11507112 0.50162112 0.85566212
0.03975712 0.12099012 0.39072512 0.91165512
......@@ -439,6 +439,7 @@ int bioem::run()
if (mpi_rank == 0) printf("\tInitializing Probabilities\n");
// Inizialzing Probabilites to zero and constant to -Infinity
for (int iRefMap = 0; iRefMap < RefMap.ntotRefMap; iRefMap ++)
{
......@@ -479,6 +480,9 @@ int bioem::run()
if(!FFTAlgo){cout << "Cross correlation calculation must be with enviormental variable FFTALGO=1\n"; exit(1);}
}
}
if(!FFTAlgo){cout << "Remark: Not using FFT algorithm. Not using Prior in B-Env.";}
// **************************************************************************************
deviceStartRun();
......@@ -537,7 +541,13 @@ int bioem::run()
// ***************************************************************************************
// *** Comparing each calculated convoluted map with all experimental maps ***
if (DebugOutput >= 2) timer.ResetStart();
compareRefMaps(iOrient, iConv, conv_map, conv_mapFFT, sumCONV, sumsquareCONV);
myfloat_t amp,pha,env;
amp=param.CtfParam[iConv].pos[0];
pha=param.CtfParam[iConv].pos[1];
env=param.CtfParam[iConv].pos[2];
compareRefMaps(iOrient, iConv, amp, pha, env, conv_map, conv_mapFFT, sumCONV, sumsquareCONV);
if (DebugOutput >= 2)
{
......@@ -724,15 +734,15 @@ int bioem::run()
if(!param.doquater){
if(param.usepsf){
outputProbFile << "Notation= RefMap: MapNumber ; Maximizing Param: MaxLogProb - alpha[rad] - beta[rad] - gamma[rad] - PSF amp - PSF phase - PSF envelope - center x - center y - normalization - offsett \n";}else{
outputProbFile << "Notation= RefMap: MapNumber ; Maximizing Param: MaxLogProb - alpha[rad] - beta[rad] - gamma[rad] - CTF amp - CTF defocus - CTF B-factor - center x - center y - normalization - offsett \n";}
outputProbFile << "Notation= RefMap: MapNumber ; Maximizing Param: MaxLogProb - alpha[rad] - beta[rad] - gamma[rad] - CTF amp - CTF defocus - CTF B-Env - center x - center y - normalization - offsett \n";}
}else {
if(param.usepsf){
// if( localcc[rx * param.param_device.NumberPixels + ry] <
outputProbFile << "Notation= RefMap: MapNumber ; Maximizing Param: MaxLogProb - q1 - q2 - q3 - PSF amp - PSF phase - PSF envelope - center x - center y - normalization - offsett \n";
}else{
outputProbFile << "Notation= RefMap: MapNumber ; Maximizing Param: MaxLogProb - q1 - q2 - q3 - CTF amp - CTF defocus - CTF B-factor - center x - center y - normalization - offsett \n";
outputProbFile << "Notation= RefMap: MapNumber ; Maximizing Param: MaxLogProb - q1 - q2 - q3 - CTF amp - CTF defocus - CTF B-Env - center x - center y - normalization - offsett \n";
}}
if(param.writeCTF) outputProbFile << " RefMap: MapNumber ; CTFMaxParm: defocus - b-factor (B ref. Penzeck 2010)\n";
if(param.writeCTF) outputProbFile << " RefMap: MapNumber ; CTFMaxParm: defocus - b-Env (B ref. Penzeck 2010)\n";
outputProbFile <<"************************* HEADER:: NOTATION *******************************************\n\n";
// Loop over reference maps
......@@ -779,7 +789,7 @@ int bioem::run()
// outputProbFile << 2*M_PI*param.CtfParam[pProbMap.max.max_prob_conv].pos[1]/denomi/param.elecwavel << " [micro-m]; ";
// outputProbFile << param.CtfParam[pProbMap.max.max_prob_conv].pos[1] << param.CtfParam[pProbMap.max.max_prob_conv].pos[2] << denomi ;
outputProbFile << 2*M_PI*param.CtfParam[pProbMap.max.max_prob_conv].pos[1]/denomi/param.elecwavel*0.0001 << " [micro-m] ";
outputProbFile << 4*M_PI*M_PI*param.CtfParam[pProbMap.max.max_prob_conv].pos[2]/denomi*2. << " [A²] \n";
outputProbFile << 4*M_PI*M_PI*param.CtfParam[pProbMap.max.max_prob_conv].pos[2]/denomi << " [A²] \n";
}
// Writing Individual Angle probabilities
......@@ -905,7 +915,7 @@ int bioem::run()
return(0);
}
int bioem::compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap)
int bioem::compareRefMaps(int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap)
{
//***************************************************************************************
......@@ -917,7 +927,7 @@ int bioem::compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map, myc
for (int iRefMap = startMap; iRefMap < RefMap.ntotRefMap; iRefMap ++)
{
const int num = omp_get_thread_num();
calculateCCFFT(iRefMap, iOrient, iConv, sumC, sumsquareC, localmultFFT, param.fft_scratch_complex[num], param.fft_scratch_real[num]);
calculateCCFFT(iRefMap, iOrient, iConv, amp, pha, env, sumC, sumsquareC, localmultFFT, param.fft_scratch_complex[num], param.fft_scratch_real[num]);
}
}
else
......@@ -932,7 +942,7 @@ int bioem::compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map, myc
return(0);
}
inline void bioem::calculateCCFFT(int iRefMap, int iOrient, int iConv, myfloat_t sumC, myfloat_t sumsquareC, mycomplex_t* localConvFFT, mycomplex_t* localCCT, myfloat_t* lCC)
inline void bioem::calculateCCFFT(int iRefMap, int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, myfloat_t sumC, myfloat_t sumsquareC, mycomplex_t* localConvFFT, mycomplex_t* localCCT, myfloat_t* lCC)
{
//***************************************************************************************
//***** Calculating cross correlation in FFTALGOrithm *****
......@@ -946,7 +956,7 @@ inline void bioem::calculateCCFFT(int iRefMap, int iOrient, int iConv, myfloat_t
myfftw_execute_dft_c2r(param.fft_plan_c2r_backward, localCCT, lCC);
doRefMapFFT(iRefMap, iOrient, iConv, lCC, sumC, sumsquareC, pProb, param.param_device, RefMap);
doRefMapFFT(iRefMap, iOrient, iConv, amp, pha, env, lCC, sumC, sumsquareC, pProb, param.param_device, RefMap);
#ifdef PILAR_DEBUG
if (param.param_device.writeCC)
......@@ -1084,7 +1094,7 @@ int bioem::createProjection(int iMap, mycomplex_t* mapFFT)
{
if (DebugOutput >= 0) cout << "WARNING:::: Model Point out of Projection map: " << i << ", " << j << "\n";
// continue;
exit(1);
if(not param.ignorepointsout)exit(1);
}
localproj[i * param.param_device.NumberPixels + j] += Model.points[n].density;//Model.NormDen;
......@@ -1107,7 +1117,7 @@ int bioem::createProjection(int iMap, mycomplex_t* mapFFT)
cout << "WARNING: Angle orient " << n << " " << param.angles[iMap].pos[0] << " " << param.angles[iMap].pos[1] << " " << param.angles[iMap].pos[2] << " out " << i << " " << j << "\n";
cout << "WARNING: MPI rank " << mpi_rank <<"\n";
// continue;
exit(1);
if(not param.ignorepointsout)exit(1);
}
......
......@@ -141,12 +141,12 @@ __global__ void multComplexMap(const mycomplex_t* convmap, const mycomplex_t* re
}
}
__global__ void cuDoRefMapsFFT(const int iOrient, const int iConv, const myfloat_t* lCC, const myfloat_t sumC, const myfloat_t sumsquareC, bioem_Probability pProb, const bioem_param_device param, const bioem_RefMap RefMap, const int maxRef, const int Offset)
__global__ void cuDoRefMapsFFT(const int iOrient, const int iConv, const myfloat_t amp, const myfloat_t pha, const myfloat_t env, const myfloat_t* lCC, const myfloat_t sumC, const myfloat_t sumsquareC, bioem_Probability pProb, const bioem_param_device param, const bioem_RefMap RefMap, const int maxRef, const int Offset)
{
if (myBlockIdxX * myBlockDimX + myThreadIdxX >= maxRef) return;
const int iRefMap = myBlockIdxX * myBlockDimX + myThreadIdxX + Offset;
const myfloat_t* mylCC = &lCC[(myBlockIdxX * myBlockDimX + myThreadIdxX) * param.NumberPixels * param.NumberPixels];
doRefMapFFT(iRefMap, iOrient, iConv, mylCC, sumC, sumsquareC, pProb, param, RefMap);
doRefMapFFT(iRefMap, iOrient, iConv, amp, pha, env, mylCC, sumC, sumsquareC, pProb, param, RefMap);
}
template <class T> static inline T divup(T num, T divider) {return((num + divider - 1) / divider);}
......@@ -162,7 +162,7 @@ static inline int ilog2 (int value)
static inline int ilog2(int value) {return 31 - __builtin_clz(value);}
#endif
int bioem_cuda::compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap)
int bioem_cuda::compareRefMaps(int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap)
{
if (startMap)
{
......@@ -199,7 +199,7 @@ int bioem_cuda::compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map
cout << "Error running CUFFT " << cufftGetErrorStrung(err) << "\n";
exit(1);
}
cuDoRefMapsFFT<<<divup(num, CUDA_THREAD_COUNT), CUDA_THREAD_COUNT, 0, cudaStream[j & 1]>>>(iOrient, iConv, pFFTtmp[j & 1], sumC, sumsquareC, pProb_device, param.param_device, *gpumap, num, i);
cuDoRefMapsFFT<<<divup(num, CUDA_THREAD_COUNT), CUDA_THREAD_COUNT, 0, cudaStream[j & 1]>>>(iOrient, iConv, amp, pha, env, pFFTtmp[j & 1], sumC, sumsquareC, pProb_device, param.param_device, *gpumap, num, i);
}
checkCudaErrors(cudaGetLastError());
if (GPUDualStream)
......@@ -260,7 +260,7 @@ int bioem_cuda::compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map
}
if (GPUWorkload < 100)
{
bioem::compareRefMaps(iOrient, iConv, conv_map, localmultFFT, sumC, sumsquareC, maxRef);
bioem::compareRefMaps(iOrient, iConv, amp, pha, env, conv_map, localmultFFT, sumC, sumsquareC, maxRef);
}
if (GPUAsync)
{
......
......@@ -25,14 +25,14 @@ public:
int doProjections(int iMap);
int createConvolutedProjectionMap(int iOreint, int iMap, mycomplex_t* lproj, myfloat_t* Mapconv, mycomplex_t* localmultFFT, myfloat_t& sumC, myfloat_t& sumsquareC);
virtual int compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap = 0);
virtual int compareRefMaps(int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap = 0);
virtual void* malloc_device_host(size_t size);
virtual void free_device_host(void* ptr);
int createProjection(int iMap, mycomplex_t* map);
int calcross_cor(myfloat_t* localmap, myfloat_t& sum, myfloat_t& sumsquare);
void calculateCCFFT(int iMap, int iOrient, int iConv, myfloat_t sumC, myfloat_t sumsquareC, mycomplex_t* localConvFFT, mycomplex_t* localCCT, myfloat_t* lCC);
void calculateCCFFT(int iMap, int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, myfloat_t sumC, myfloat_t sumsquareC, mycomplex_t* localConvFFT, mycomplex_t* localCCT, myfloat_t* lCC);
bioem_Probability pProb;
......
......@@ -17,7 +17,7 @@ public:
bioem_cuda();
virtual ~bioem_cuda();
virtual int compareRefMaps(int iOrient, int iConv, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap = 0);
virtual int compareRefMaps(int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, const myfloat_t* conv_map, mycomplex_t* localmultFFT, myfloat_t sumC, myfloat_t sumsquareC, const int startMap = 0);
virtual void* malloc_device_host(size_t size);
virtual void free_device_host(void* ptr);
......
......@@ -21,6 +21,8 @@ public:
myfloat_t Ntotpi;
myfloat_t volu;
myfloat_t sigmaPriorbctf;
// If to write Probabilities of Angles from Model
bool writeAngles;
bool writeCC;
......@@ -28,6 +30,7 @@ public:
bool debugterm;
int CCdisplace;
bool CCwithBayes;
bool tousepsf;
};
......@@ -54,6 +57,7 @@ public:
bool notsqure;
bool notnormmap;
bool usepsf;
bool ignorepointsout;
myfloat_t elecwavel;
......
......@@ -54,6 +54,8 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
if(readMultMRC)
{
cout << "Opening File with MRC list names: " << filemap << "\n";
ifstream input(filemap);
if (!input.good())
......@@ -87,13 +89,9 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
{
indifile=strline.c_str();
size_t foundpos= strline.find(".mrc");
size_t foundpos= strline.find("mrc");
size_t endpos = strline.find_last_not_of(" \t");
if(foundpos > endpos){
cout << "Warining:::: .mrc extension NOT dectected in file name::" << filemap <<" \n";
cout << "Warining:::: Are you sure you want to read an MRC? \n";
}
//Reading Multiple MRC
read_MRC(indifile,param);
......@@ -110,11 +108,11 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
string strfilename(filemap);
size_t foundpos= strfilename.find(".mrc");
size_t foundpos= strfilename.find("mrc");
size_t endpos = strfilename.find_last_not_of(" \t");
if(foundpos > endpos){
cout << "Warining:::: .mrc extension NOT dectected in file name::" << filemap <<" \n";
cout << "Warining:::: mrc extension NOT dectected in file name::" << filemap <<" \n";
cout << "Warining:::: Are you sure you want to read an MRC? \n";
}
......
This diff is collapsed.
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