Commit 9768552f authored by Pilar Cossio's avatar Pilar Cossio
Browse files

Correcting bug accessing ilegal memory in CC mat & tidying up

parent 19bc6d4d
......@@ -6,7 +6,7 @@ option (INCLUDE_CUDA "Build BioEM with CUDA support" ON)
option (INCLUDE_OPENMP "Build BioEM with OpenMP support" ON)
option (INCLUDE_MPI "Build BioEM with MPI support" ON)
option (PRINT_CMAKE_VARIABLES "List all CMAKE Variables" OFF)
option (CUDA_FORCE_GCC "Force GCC as host compiler for CUDA part (If standard host compiler is incompatible with CUDA)" OFF)
option (CUDA_FORCE_GCC "Force GCC as host compiler for CUDA part (If standard host compiler is incompatible with CUDA)" ON)
###Set up general variables
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
......@@ -60,7 +60,7 @@ if (CUDA_FOUND)
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_20,code=sm_21")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_30,code=sm_30")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_35,code=sm_35")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_52,code=sm_52")
add_definitions(-DWITH_CUDA)
set (BIOEM_CUDA_STATUS "Found")
endif()
......@@ -105,20 +105,21 @@ else()
add_executable(bioEM ${BIOEM_SOURCE_FILES})
endif()
#Additional CXX Flags not used by CUDA compiler
#Additional CXX Flags not used by CUDA compiler
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-vla -Wno-unused-result -Wno-unused-local-typedefs -pedantic")
endif()
if (NOT OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla -Wno-long-long -Wall -pedantic")
endif()
###Add Libraries
if (CUDA_FOUND)
cuda_add_cufft_to_target(bioEM)
#set(CUDA_LIBRARIES "/afs/ipp/.cs/cuda/6.5-gtx9/amd64_sles11/lib64/stubs/libcuda.so")
#cuda_add_library()
target_link_libraries(bioEM ${CUDA_CUDA_LIBRARY})
# target_link_libraries(bioEM ${CUDA_LIBRARIES})
endif()
if (FFTWF_LIBRARIES)
......@@ -137,6 +138,8 @@ message(STATUS "Build Status")
message(STATUS "FFTW library: ${FFTW_LIBDIR}")
message(STATUS "Boost directory: ${Boost_LIBRARY_DIRS}")
message(STATUS "FFTW includedir: ${FFTW_INCLUDEDIR}")
message(STATUS "CUDA libraries: ${CUDA_CUDA_LIBRARY}")
message(STATUS "CUDA libraries: ${CUDA_LIBRARIES}")
message(STATUS "CUDA: ${BIOEM_CUDA_STATUS}")
message(STATUS "OpenMP: ${BIOEM_OPENMP_STATUS}")
message(STATUS "MPI: ${BIOEM_MPI_STATUS}")
......
This diff is collapsed.
......@@ -23,9 +23,14 @@
template <int GPUAlgo>
__device__ static inline void update_prob(const myfloat_t logpro, const int iRefMap, const int iOrient, const int iConv, const int cent_x, const int cent_y, bioem_Probability& pProb, bool doAngle, myfloat_t* buf3 = NULL, int* bufint = NULL)
{
//**************** Routine to perform the numerical BioEM intergal ***********
// ******* Summing total Probabilities *************
// ******* Need a constant because of numerical divergence*****
bioem_Probability_map& pProbMap = pProb.getProbMap(iRefMap);
// ******* Need a constant because of numerical divergence*****
if(pProbMap.Constoadd < logpro)
{
pProbMap.Total = pProbMap.Total * exp(-logpro + pProbMap.Constoadd);
......@@ -53,7 +58,6 @@ __device__ static inline void update_prob(const myfloat_t logpro, const int iRef
{
bioem_Probability_angle& pProbAngle = pProb.getProbAngle(iRefMap, iOrient);
// printf("Here\n");
//Summing probabilities for each orientation
if(pProbAngle.ConstAngle < logpro)
{
......@@ -67,6 +71,10 @@ __device__ static inline void update_prob(const myfloat_t logpro, const int iRef
__device__ static inline myfloat_t calc_logpro(const bioem_param_device& param, const myfloat_t sum, const myfloat_t sumsquare, const myfloat_t crossproMapConv, const myfloat_t sumref, const myfloat_t sumsquareref)
{
// ********** Routine to calculate the log posterior of Eq. of Pmw in SI of JSB paper
// Related to Reference calculated Projection
const myfloat_t ForLogProb = (sumsquare * param.Ntotpi - sum * sum);
......@@ -78,15 +86,16 @@ __device__ static inline myfloat_t calc_logpro(const bioem_param_device& param,
// As in fortran code: logpro=(3-Ntotpi)*0.5*log(firstele/pConvMap[iOrient].ForLogProbfromConv[iConv])+(Ntotpi*0.5-2)*log(Ntotpi-2)-0.5*log(pConvMap[iOrient].ForLogProbfromConv[iConv])+0.5*log(PI)+(1-Ntotpi*0.5)*(log(2*PI)+1);
const myfloat_t logpro = (3 - param.Ntotpi) * 0.5 * log(firstele) + (param.Ntotpi * 0.5 - 2) * log((param.Ntotpi - 2) * ForLogProb);
// if(param.debugterm){
// printf("Separate cc: %f c: %f oo: %f o: %f co: %f logP: %f\n",sumsquare,sum,sumsquareref,sumref,crossproMapConv, logpro );
// }
return(logpro);
}
__device__ static inline void calProb(int iRefMap, int iOrient, int iConv, myfloat_t amp, myfloat_t pha, myfloat_t env, myfloat_t sumC, myfloat_t sumsquareC, myfloat_t value, int disx, int disy, bioem_Probability& pProb, const bioem_param_device& param, const bioem_RefMap& RefMap)
{
// MOST IMPORTANT ROUTINE
// ********************************************************
// *********** Calculates the BioEM probability ***********
// ********************************************************
......@@ -103,12 +112,12 @@ __device__ static inline void calProb(int iRefMap, int iOrient, int iConv, myflo
logpro = logpro - envF * envF / 2. / param.sigmaPriorbctf / param.sigmaPriorbctf ;
}
//GCC is too stupid to inline properly, so the code is copied here
//update_prob<-1>(logpro, iRefMap, iOrient, iConv, disx, disy, pProb, param.writeAngles);
bioem_Probability_map& pProbMap = pProb.getProbMap(iRefMap);
// printf("Separate PtotBef: %f Const: %f logProb %f %d %d %d \n",pProbMap.Total,pProbMap.Constoadd,logpro,iRefMap,iOrient,iConv);
if(pProbMap.Constoadd < logpro)
{
pProbMap.Total = pProbMap.Total * exp(-logpro + pProbMap.Constoadd);
......@@ -124,18 +133,11 @@ __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 %f %f \n",pProbMap.Total,pProbMap.Constoadd,logpro,pProbMap.max.max_prob_norm,pProbMap.max.max_prob_mu);
}
// printf("Separate Ptot: %f Const: %f logProb %f %f %f \n",amp,pha,env,logpro,param.sigmaPriorbctf);
// cout << amp,pha,env,logpro,sumC;
if (param.writeAngles)
{
bioem_Probability_angle& pProbAngle = pProb.getProbAngle(iRefMap, iOrient);
// if(iConv==0 && disx==0 && disy==0)
// if(iOrient==1)printf("Separate Ptot: %f Const: %f logProb %f param: %d %d %d \n",logpro,pProbAngle.ConstAngle,pProbAngle.forAngles,disx,disx,iOrient);
// if(iOrient==1)printf("Separate Ptot: %f Const: %f logProb %f param: %d %d %d \n",logpro,pProbAngle.ConstAngle,pProbAngle.forAngles,disx,disx,iOrient);
if(pProbAngle.ConstAngle < logpro)
{
......@@ -150,6 +152,9 @@ __device__ static inline void calProb(int iRefMap, int iOrient, int iConv, myflo
__device__ static inline void doRefMapFFT(const int iRefMap, 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)
{
//******************* Get cross-crollation of Ical to Iobs *******************
//*********** Routine to get the Cross-Corellation from lCC for the interested center displacement *************
for (int cent_x = 0; cent_x <= param.maxDisplaceCenter; cent_x = cent_x + param.GridSpaceCenter)
{
for (int cent_y = 0; cent_y <= param.maxDisplaceCenter; cent_y = cent_y + param.GridSpaceCenter)
......@@ -161,21 +166,22 @@ __device__ static inline void doRefMapFFT(const int iRefMap, const int iOrient,
calProb(iRefMap, iOrient, iConv,amp, pha, env, sumC, sumsquareC, (myfloat_t) lCC[cent_x * param.NumberPixels + cent_y] / (myfloat_t) (param.NumberPixels * param.NumberPixels), cent_x, cent_y - param.NumberPixels, pProb, param, RefMap);
}
}
for (int cent_x = param.NumberPixels - param.maxDisplaceCenter; cent_x < param.NumberPixels; cent_x = cent_x + param.GridSpaceCenter)
{
for (int cent_y = 0; cent_y < param.maxDisplaceCenter; cent_y = cent_y + param.GridSpaceCenter)
{
calProb(iRefMap, iOrient, iConv,amp, pha, env, sumC, sumsquareC, (myfloat_t) lCC[cent_x * param.NumberPixels + cent_y] / (myfloat_t) (param.NumberPixels * param.NumberPixels), cent_x - param.NumberPixels, cent_y, pProb, param, RefMap);
}
for (int cent_y = param.NumberPixels - param.maxDisplaceCenter; cent_y <= param.NumberPixels; cent_y = cent_y + param.GridSpaceCenter)
for (int cent_y = param.NumberPixels - param.maxDisplaceCenter ; cent_y < param.NumberPixels; cent_y = cent_y + param.GridSpaceCenter)
{
calProb(iRefMap, iOrient, iConv, amp, pha, env, sumC, sumsquareC, (myfloat_t) lCC[cent_x * param.NumberPixels + cent_y] / (myfloat_t) (param.NumberPixels * param.NumberPixels), cent_x - param.NumberPixels, cent_y - param.NumberPixels, pProb, param, RefMap);
}
}
// printf("HERE!!!");
if (param.writeCC)
{
// If the Cross-correlation is to be written out and stored using Bayesian analysis
int cc=0;
for (int cent_x = 0; cent_x < param.NumberPixels ; cent_x = cent_x + param.CCdisplace)
{
......@@ -219,10 +225,11 @@ __device__ static inline void doRefMapFFT(const int iRefMap, const int iOrient,
}
template <int GPUAlgo, class RefT>
__device__ static inline void compareRefMap(const int iRefMap, const int iOrient, const int iConv, const myfloat_t* Mapconv, bioem_Probability& pProb, const bioem_param_device& param, const RefT& RefMap,
__device__ static inline void compareRefMap(const int iRefMap, const int iOrient, const int iConv, const myfloat_t* Mapconv, bioem_Probability& pProb, const bioem_param_device& param, const RefT& RefMap,
const int cent_x, const int cent_y, const int myShift = 0, const int nShifts2 = 0, const int myRef = 0, const bool threadActive = true)
{
//********************* Non FOURIER ALGORITHMS (refer to David) ***********
// ********************** Calculating BioEM Probability ********************************
// ************************* Loop of center displacement here ***************************
......@@ -477,7 +484,7 @@ __device__ static inline void compareRefMap(const int iRefMap, const int iOrient
}
template <int GPUAlgo, class RefT>
__device__ static inline void compareRefMapShifted(const int iRefMap, const int iOrient, const int iConv, const myfloat_t* Mapconv, bioem_Probability& pProb, const bioem_param_device& param, const RefT& RefMap)
__device__ static inline void compareRefMapShifted(const int iRefMap, const int iOrient, const int iConv, const myfloat_t* Mapconv, bioem_Probability& pProb, const bioem_param_device& param, const RefT& RefMap)
{
for (int cent_x = -param.maxDisplaceCenter; cent_x <= param.maxDisplaceCenter; cent_x = cent_x + param.GridSpaceCenter)
{
......
......@@ -5,6 +5,12 @@
See license statement for terms of distribution.
Note: This program contains subroutine "read_MRC" of the Situs 2.7.2 program.
Ref: Willy Wriggers. Using Situs for the Integration of Multi-Resolution Structures.
Biophysical Reviews, 2010, Vol. 2, pp. 21-27.
with a GPL lisences version XX.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <fstream>
......@@ -35,6 +41,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
int allocsize = 0;
if (param.loadMap)
{
//************** Loading Map from Binary file *******
FILE* fp = fopen("maps.dump", "rb");
if (fp == NULL)
{
......@@ -50,11 +57,13 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
}
else if(readMRC)
{
//************** Reading MRC file *******
ntotRefMap=0;
if(readMultMRC)
{
//************** Reading Multiple MRC files *************
cout << "Opening File with MRC list names: " << filemap << "\n";
ifstream input(filemap);
......@@ -89,8 +98,8 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
{
indifile=strline.c_str();
size_t foundpos= strline.find("mrc");
size_t endpos = strline.find_last_not_of(" \t");
// size_t foundpos= strline.find("mrc");
// size_t endpos = strline.find_last_not_of(" \t");
//Reading Multiple MRC
......@@ -123,6 +132,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
}
else
{
//************** Reading Text file *************
int nummap = -1;
int lasti = 0;
int lastj = 0;
......@@ -221,7 +231,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
cout << "Particle Maps read from Standard File: " << ntotRefMap << "\n";
}
//Dumping Maps
//************* If Dumping Maps *********************
if (param.dumpMap)
{
FILE* fp = fopen("maps.dump", "w+b");
......@@ -235,6 +245,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
fclose(fp);
}
//*********** To Debug with few Maps ********************
if (getenv("BIOEM_DEBUG_NMAPS"))
{
......@@ -250,7 +261,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
int bioem_RefMap::PreCalculateMapsFFT(bioem_param& param)
{
// **************************************************************************************
// ********** Routine that pre-calculates Kernels for Convolution **********************
// ********** Routine that pre-calculates Reference maps FFT for Convolution/ Comparison **********************
// ************************************************************************************
RefMapsFFT = new mycomplex_t[ntotRefMap * param.FFTMapSize];
......@@ -320,17 +331,19 @@ int bioem_RefMap::precalculate(bioem_param& param, bioem& bio)
void bioem_Probability::init(size_t maps, size_t angles, size_t cc, bioem& bio)
{
//********** Initializing pointers *******************
nMaps = maps;
nAngles = angles;
nCC = cc;
ptr = bio.malloc_device_host(get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC));
cout << "Allocation #Maps " << maps << " #Angles " << angles << " #cross.cor " << cc << "\n";
//<< " == " << get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC)<< "\n";
//<< " == " << get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC)<< "\n";
set_pointers();
}
void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio)
{
bioem_Probability_map& pProbMap = getProbMap(0);
bioem_Probability_map& pProbMapFrom = from->getProbMap(0);
memcpy(&pProbMap, &pProbMapFrom, from->nMaps * sizeof(bioem_Probability_map));
......@@ -358,6 +371,12 @@ void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio)
int bioem_RefMap::read_MRC(const char* filename,bioem_param& param)
{
/* subroutine "read_MRC" of the Situs 2.7.2 program.
Ref: Willy Wriggers. Using Situs for the Integration of Multi-Resolution Structures.
Biophysical Reviews, 2010, Vol. 2, pp. 21-27.*/
myfloat_t st,st2;
unsigned long count;
FILE *fin;
......
......@@ -37,13 +37,15 @@ int bioem_model::readModel(bioem_param& param, const char* filemodel)
ofstream exampleReadCoor;
exampleReadCoor.open ("COORDREAD");
exampleReadCoor << "Text --- Number ---- x ---- y ---- z ---- radius ---- density\n";
exampleReadCoor << "Text --- Number ---- x ---- y ---- z ---- radius ---- number of electron\n";
int allocsize = 0;
std::ifstream input(filemodel);
if(readPDB)
{
//************** Reading PDB files **********************
ifstream input(filemodel);
if (!input.good())
{
......@@ -153,7 +155,7 @@ int bioem_model::readModel(bioem_param& param, const char* filemodel)
}
else //Reading model from FILE FORMAT x,y,z,rad,density
{
//**************** Reading Text FILES ***********************
char line[128];
int numres = 0;
......@@ -209,7 +211,7 @@ int bioem_model::readModel(bioem_param& param, const char* filemodel)
cout << "\n+++++++++++++++++++++++++++++++++++++++++ \n";
exampleReadCoor.close();
//Moving to Model to its center of density mass:
//******************** Moving to Model to its center of density mass:
myfloat3_t r_cm;
if(not(param.nocentermass)){ //by default it is normally done
......
......@@ -26,6 +26,9 @@ using namespace std;
bioem_param::bioem_param()
{
//**************** Initializing Variables and defaults ****************
//Number of Pixels
param_device.NumberPixels = 0;
param_device.NumberFFTPixels1D = 0;
......@@ -71,7 +74,7 @@ int bioem_param::readParameters(const char* fileinput)
bool yesPSFpha=false;
bool yesquatgrid=false;
//Default VALUES
//***************** Default VALUES
param_device.flipped=false;
param_device.debugterm=false;
param_device.writeCC=false;
......@@ -90,8 +93,6 @@ int bioem_param::readParameters(const char* fileinput)
yespriorAngles=false;
ignorepointsout=false;
//Storing angle file name if existing.
//f(notuniformangles)inanglef=std::string(fileangles);
NotUn_angles=0;
priorMod=1; //Default
shiftX=0;
......@@ -341,12 +342,6 @@ int bioem_param::readParameters(const char* fileinput)
param_device.debugterm = true;
cout << "Debugging Individual Probability Terms \n";
}
/* else if (strcmp(token, "NOT_UNIFORM_TOTAL_ANGS") == 0)//Number of Euler angle tripplets in non uniform Euler angle sampling
{
token = strtok(NULL, " ");
NotUn_angles=int(atoi(token));
cout << "Not uniform total angel: " << NotUn_angles<< "\n";
}*/
else if (strcmp(token, "WRITE_CTF_PARAM") == 0)//Number of Euler angle tripplets in non uniform Euler angle sampling
{
writeCTF=true;
......@@ -407,7 +402,8 @@ int bioem_param::readParameters(const char* fileinput)
}
input.close();
// Checks for ALL INPUT
//************** Checks/Controlls for INPUT
if( not ( yesPixSi ) ){ cout << "**** INPUT MISSING: Please provide PIXEL_SIZE\n" ; exit (1);};
if( not ( yesNumPix ) ){ cout << "**** INPUT MISSING: Please provide NUMBER_PIXELS \n" ; exit (1);};
if(!notuniformangles){
......@@ -420,7 +416,6 @@ int bioem_param::readParameters(const char* fileinput)
}
if( not ( yesMDC ) ) { cout << "**** INPUT MISSING: Please provide GRID Displacement 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(param_device.writeAngles){cout << "Calculate Cross-cor and write prob angles are mutualy exclusive options\n"; exit(1);}
......@@ -439,7 +434,7 @@ int bioem_param::readParameters(const char* fileinput)
// Asigning values of phase according to defocus
startGridCTF_phase= startDefocus * M_PI * 2.f * 10000 * elecwavel ;
endGridCTF_phase= endDefocus * M_PI * 2.f * 10000 * elecwavel ;
//Asigning values of envelope according to b-envelope no b-factor
//Asigning values of envelope according to b-envelope (not b-factor)
startGridEnvelop = startBfactor ;// 2.f;
endGridEnvelop = endBfactor ; // / 2.f;
}
......@@ -453,13 +448,6 @@ int bioem_param::readParameters(const char* fileinput)
cout << "Writing CTF is only valid when integrating over the PSF\n"; exit(1);
}
//Does currently not work with custom alignment on GPU
/*if (FFTMapSize % Alignment)
{
FFTMapSize += Alignment - FFTMapSize % Alignment;
}
cout << "Using MAP Size " << FFTMapSize << " (Alignment " << Alignment << ", Unaligned Size " << param_device.NumberPixels * param_device.NumberFFTPixels1D << ")\n";*/
cout << " +++++++++++++++++++++++++++++++++++++++++ \n";
return(0);
......@@ -491,7 +479,7 @@ int bioem_param::forprintBest(const char* fileinput)
shiftY=0;
//**** Different keywords! For printing MAP ************
if (!input.good())
{
cout << "Failed to open Best Parameter file: " << fileinput << "\n";
......@@ -554,7 +542,6 @@ int bioem_param::forprintBest(const char* fileinput)
cout << "Best Gamma " << angles[0].pos[2] << "\n";
}
else if (strcmp(token, "USE_QUATERNIONS") == 0)
// else if (token=="USE_QUATERNIONS")
{
cout << "Orientations with Quaternions. \n";
doquater= true;
......@@ -707,6 +694,7 @@ int bioem_param::forprintBest(const char* fileinput)
void bioem_param::PrepareFFTs()
{
//********** PREPARING THE PLANS FOR THE FFTS ******************
if (mpi_rank == 0) cout << "Preparing FFTs\n";
releaseFFTPlans();
mycomplex_t *tmp_map, *tmp_map2;
......@@ -770,16 +758,13 @@ void bioem_param::releaseFFTPlans()
int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERNIONS
{
// **************************************************************************************
// **************** Routine that pre-calculates Euler angle grids **********************
// **************** Routine that pre-calculates Orientation Grids**********************
// ************************************************************************************
// myfloat_t voluang;
// Euler angle GRID
if(!doquater){
//*********** With Euler angles *******************
cout << "Analysis Using Default Euler Angles\n";
if(!notuniformangles){
......@@ -823,6 +808,7 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
} else{
//************ Reading Euler Angles From File **************************
ifstream input(fileangles);
if (!input.good())
......@@ -832,7 +818,7 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
}
char line[512] = {0};
// char saveline[512];
// char saveline[512];
int n=0;
......@@ -868,36 +854,6 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
if(n< NotUn_angles){
/*
myfloat_t or1,or2,or3,or4,prior;
input.getline(line, 511);
strcpy(saveline, line);
char *token = strtok(line, " ");
if (token == NULL || line[0] == '#' || strlen(token) == 0)
{
// comment or blank line
}
else if (strcmp(token, "ORIENT") == 0)
{
token = strtok(NULL, " ");
or1 = atof(token);
token = strtok(NULL, " ");
or2 = atof(token);
token = strtok(NULL, " ");
or3 = atof(token);
token = strtok(NULL, " ");
or4 = atof(token);
cout << "TT " << n << " " << or1 << " " << or2 << " " << or3 << " " << or4 << "\n ";
angles[n].pos[0] = or1;
angles[n].pos[1] = or2;
angles[n].pos[2] = or3;
angles[n].quat4 =0.0;
n++;
}*/
float a=0.,b=0.,g=0.,pp=0.;
char tmpVals[60] = {0};
......@@ -922,16 +878,15 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
angles[n].pos[1] = (myfloat_t) b;
angles[n].pos[2] = (myfloat_t) g;
angles[n].quat4 =0.0;//just to be sure */
#ifdef PILAR_DEBUG
if(yespriorAngles) cout << "check orient: " << n << " " << " " << angles[n].pos[0] << " " << angles[n].pos[1] << " " << angles[n].pos[2] << " prior: " << angprior[n]<< "\n";
#endif
}
n++;
if(NotUn_angles+1 < n) {
cout << "Not properly defined total Euler angles " << n << " instead of " << NotUn_angles << "\n";
exit(1);
}
}
nTotGridAngles = NotUn_angles;
voluang= 1./ (myfloat_t) NotUn_angles * priorMod;
......@@ -939,13 +894,14 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
}
} else {
// Analysis with Quaternions
//************** Analysis with Quaternions
if(!notuniformangles){
//************* Grid of Quaternions *******************
cout << "Calculating Grids in Quaterions\n ";
if(yespriorAngles){
cout << "This option is not valid with prior for orientations\n Please provide separate file with angles and priors";
cout << "This option is not valid with prior for orientations\n It is necessary to provide a separate file with the angles and priors";
exit(1);
}
......@@ -1011,10 +967,8 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
} else{
// ifstream input(quatfile);
//******** Reading Quaternions From a File ***************************
ifstream input(fileangles);
// ifstream input("QUATERNION_LIST");
if (!input.good())
{
......@@ -1083,7 +1037,9 @@ int bioem_param::CalculateGridsParam(const char* fileangles) //TO DO FOR QUATERN
sscanf (tmpVals, "%f", &pp);
if(pp <0.0000001)cout << "Sure you're input is correct? Very small prior.\n";
angprior[n] = pp;
#ifdef PILAR_DEBUG
if(yespriorAngles) cout << "check orient: " << n << " " << angles[n].pos[0] << " " << angles[n].pos[1] << " " << angles[n].pos[2] << " prior: " << angprior[n] << "\n";
#endif
}
}
n++;
......@@ -1194,6 +1150,20 @@ int bioem_param::CalculateRefCTF()
//Complex CTF
mycomplex_t* curRef = &refCTF[n * FFTMapSize];
// Initialzing everything to zero just to be sure
for(int i = 0; i < param_device.NumberPixels * param_device.NumberFFTPixels1D; i++ ){
curRef[i][0] =0.f;
curRef[i][1] =0.f;
}
for(int i = 0; i < param_device.NumberPixels; i++)
{
for(int j = 0; j < param_device.NumberPixels; j++)
{
localCTF[i * param_device.NumberPixels + j]=0.f;
}
}
if(usepsf){
normctf=0.0;
......@@ -1268,10 +1238,7 @@ int bioem_param::CalculateRefCTF()
}
}
/*for(int i = 0; i < param_device.NumberFFTPixels1D * param_device.NumberPixels; i++ ){
curRef[i][0] = curRef[i][0] / normctf ;
curRef[i][1] = 0;
}*/
// for(int i = 0; i < param_device.NumberPixels * param_device.NumberFFTPixels1D; i++ )curRef[i][0]/= normctf;
}
......@@ -1308,7 +1275,7 @@ int bioem_param::CalculateRefCTF()
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 = (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