Xmipp  v3.23.11-Nereus
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ProgRecFourierGPU Class Reference

#include <reconstruct_fourier_gpu.h>

Inheritance diagram for ProgRecFourierGPU:
Inheritance graph
[legend]
Collaboration diagram for ProgRecFourierGPU:
Collaboration graph
[legend]

Public Member Functions

void run ()
 
void finishComputations (const FileName &out_name)
 
virtual void setIO (const FileName &fn_in, const FileName &fn_out)
 
- Public Member Functions inherited from ProgReconsBase
virtual ~ProgReconsBase ()
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void show () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Protected Member Functions

void checkDefines ()
 
void mirrorAndCropTempSpaces ()
 
void getGPUData ()
 
void forceHermitianSymmetry ()
 
void processWeights ()
 
void createWorkThread (int gpuStream, int startIndex, int endIndex, RecFourierWorkThread &thread)
 
void readParams ()
 
void defineParams ()
 
void show ()
 
void produceSideinfo ()
 
void processImages (int firstImageIndex, int lastImageIndex)
 
void releaseTempSpaces ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Protected Attributes

RecFourierWorkThreadworkThreads
 
MetaDataDb SF
 
FileName fn_out
 
FileName fn_in
 
int maxVolumeIndexYZ
 
int maxVolumeIndexX
 
std::complex< float > *** tempVolume = NULL
 
float *** tempWeights = NULL
 
float * tempVolumeGPU = NULL
 
float * tempWeightsGPU = NULL
 
int noOfThreads
 
int device
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Additional Inherited Members

- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Detailed Description

Definition at line 60 of file reconstruct_fourier_gpu.h.

Member Function Documentation

◆ checkDefines()

void ProgRecFourierGPU::checkDefines ( )
protected

Method checks that there is no logical problem in the defines used by program. If found, error is thrown.

Definition at line 147 of file reconstruct_fourier_gpu.cpp.

147  {
148  if (!((TILE == 1) || (BLOCK_DIM % TILE == 0))) { //
149  REPORT_ERROR(ERR_PARAM_INCORRECT,"TILE has to be set to 1(one) or BLOCK_DIM has to be a multiple of TILE");
150  }
151  if ((SHARED_IMG == 1) && (TILE != 1)) {
152  REPORT_ERROR(ERR_PARAM_INCORRECT,"TILE cannot be used while SHARED_IMG is active");
153  }
154  if (TILE >= BLOCK_DIM) {
155  REPORT_ERROR(ERR_PARAM_INCORRECT,"TILE must be smaller than BLOCK_DIM");
156  }
157  if ((SHARED_BLOB_TABLE == 1) && (PRECOMPUTE_BLOB_VAL == 0)) {
158  REPORT_ERROR(ERR_PARAM_INCORRECT,"PRECOMPUTE_BLOB_VAL must be set to 1(one) when SHARED_BLOB_TABLE is active");
159  }
160 }
Parameter incorrect.
Definition: xmipp_error.h:181
constexpr int BLOCK_DIM
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
constexpr int SHARED_IMG
constexpr int TILE
constexpr int SHARED_BLOB_TABLE
constexpr int PRECOMPUTE_BLOB_VAL

◆ createWorkThread()

void ProgRecFourierGPU::createWorkThread ( int  gpuStream,
int  startIndex,
int  endIndex,
RecFourierWorkThread thread 
)
protected

Method will create thread used for loading and processing images Thread starts the work immediately gpuStream - stream to use startIndex - index of the first projection to process endIndex - index of the last projection to process thread - used for referencing the thread

Definition at line 198 of file reconstruct_fourier_gpu.cpp.

198  {
199  thread.parent = this;
200  thread.startImageIndex = startIndex;
201  thread.endImageIndex = endIndex;
202  thread.gpuStream = gpuStream;
203  pthread_create( &thread.id , NULL, threadRoutine, (void *)(&thread) );
204 }
ProgRecFourierGPU * parent

◆ defineParams()

void ProgRecFourierGPU::defineParams ( )
protectedvirtual

Specify supported command line arguments

Reimplemented from XmippProgram.

Definition at line 42 of file reconstruct_fourier_gpu.cpp.

43 {
44  //usage
45  addUsageLine("Generate 3D reconstructions from projections using direct Fourier interpolation with arbitrary geometry.");
46  addUsageLine("Kaisser-windows are used for interpolation in Fourier space.");
47  //params
48  addParamsLine(" -i <md_file> : Metadata file with input projections");
49  addParamsLine(" [-o <volume_file=\"rec_fourier.vol\">] : Filename for output volume");
50  addParamsLine(" [--sym <symfile=c1>] : Enforce symmetry in projections");
51  addParamsLine(" [--padding <proj=2.0> <vol=2.0>] : Padding used for projections and volume");
52  addParamsLine(" [--max_resolution <p=0.5>] : Max resolution (Nyquist=0.5)");
53  addParamsLine(" [--weight] : Use weights stored in the image metadata");
54  addParamsLine(" [--blob <radius=1.9> <order=0> <alpha=15>] : Blob parameters");
55  addParamsLine(" : radius in pixels, order of Bessel function in blob and parameter alpha");
56  addParamsLine(" [--thr <threads=all>] : Number of concurrent threads (and GPU streams). All threads are used by default");
57  addParamsLine(" [--device <dev=0>] : GPU device to use. 0th by default");
58  addParamsLine(" [--fast] : Do the blobing at the end of the computation.");
59  addParamsLine(" : Gives slightly different results, but is faster.");
60  addParamsLine(" [--fftOnGPU] : Perform the FFT conversion of the input images on GPU.");
61  addParamsLine(" : Requires more memory on GPU (see also --bufferSize).");
62  addParamsLine(" [--useCTF] : Use CTF information if present");
63  addParamsLine(" [--sampling <Ts=1>] : sampling rate of the input images in Angstroms/pixel");
64  addParamsLine(" : It is only used when correcting for the CTF");
65  addParamsLine(" [--phaseFlipped] : Give this flag if images have been already phase flipped");
66  addParamsLine(" [--minCTF <ctf=0.01>] : Minimum value of the CTF that will be inverted");
67  addParamsLine(" : CTF values (in absolute value) below this one will not be corrected");
68  addParamsLine(" [--bufferSize <size=25>] : Number of projection loaded in memory (will be actually 2x as much.");
69  addParamsLine(" : This will require up to 4*size*projSize*projSize*16B, e.g.");
70  addParamsLine(" : 100MB for projection of 256x256 or 400MB for projection of 512x512");
71  addExampleLine("For reconstruct enforcing i3 symmetry and using stored weights:", false);
72  addExampleLine(" xmipp_reconstruct_fourier -i reconstruction.sel --sym i3 --weight");
73 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ finishComputations()

void ProgRecFourierGPU::finishComputations ( const FileName out_name)

Method will take data stored in tempVolume and tempWeights (which should be cropped in X axis), calculate IFFT and store result to final destination.

Definition at line 879 of file reconstruct_fourier_gpu.cpp.

880 {
881  if (useFast) {
882  tempVolume = applyBlob(tempVolume, blob.radius, blobTableSqrt, iDeltaSqrt);
883  tempWeights = applyBlob(tempWeights, blob.radius, blobTableSqrt, iDeltaSqrt);
884  }
885 
887  processWeights();
890  allocateVoutFourier(VoutFourier);
891  convertToExpectedSpace(tempVolume, maxVolumeIndexYZ, VoutFourier);
893 
894  // Output volume
895  Image<double> Vout;
896  Vout().initZeros(paddedImgSize,paddedImgSize,paddedImgSize);
897  FourierTransformer transformerVol;
898  transformerVol.setThreadsNumber(noOfThreads);
899  transformerVol.fReal = &(Vout.data);
900  transformerVol.setFourierAlias(VoutFourier);
901  transformerVol.recomputePlanR2C();
902 
903  transformerVol.inverseFourierTransform();
904  transformerVol.clear();
905  CenterFFT(Vout(),false);
906 
907  // Correct by the Fourier transform of the blob
908  Vout().setXmippOrigin();
909  Vout().selfWindow(FIRST_XMIPP_INDEX(imgSize),FIRST_XMIPP_INDEX(imgSize),
910  FIRST_XMIPP_INDEX(imgSize),LAST_XMIPP_INDEX(imgSize),
911  LAST_XMIPP_INDEX(imgSize),LAST_XMIPP_INDEX(imgSize));
912  double pad_relation= ((double)padding_factor_proj/padding_factor_vol);
913  pad_relation = (pad_relation * pad_relation * pad_relation);
914 
915  MultidimArray<double> &mVout=Vout();
916  double ipad_relation=1.0/pad_relation;
917  double meanFactor2=0;
919  {
920  double radius=sqrt((double)(k*k+i*i+j*j));
921  double aux=radius*iDeltaFourier;
922  double factor = Fourier_blob_table(ROUND(aux));
923  double factor2=(pow(Sinc(radius/(2*imgSize)),2));
924  A3D_ELEM(mVout,k,i,j) /= (ipad_relation*factor2*factor);
925  meanFactor2+=factor2;
926  }
927  meanFactor2/=MULTIDIM_SIZE(mVout);
929  A3D_ELEM(mVout,k,i,j) *= meanFactor2;
930  Vout.write(out_name);
931  Vout.clear();
932 }
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
void setThreadsNumber(int tNumber)
Definition: xmipp_fftw.h:119
#define MULTIDIM_SIZE(v)
void sqrt(Image< double > &op)
void setFourierAlias(T &V)
Definition: xmipp_fftw.h:215
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
MultidimArray< double > * fReal
Definition: xmipp_fftw.h:64
void CenterFFT(MultidimArray< T > &v, bool forward)
Definition: xmipp_fft.h:291
#define A3D_ELEM(V, k, i, j)
MultidimArray< T > data
Definition: xmipp_image.h:55
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
#define ROUND(x)
Definition: xmipp_macros.h:210
#define j
double Sinc(double Argument)
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
std::complex< float > *** tempVolume
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
void clear()
Definition: xmipp_image.h:144

◆ forceHermitianSymmetry()

void ProgRecFourierGPU::forceHermitianSymmetry ( )
protected

Method will enforce Hermitian symmetry, i.e will make sure that the values in temporal space at X=0 are complex conjugate of in respect to center of the space

Definition at line 732 of file reconstruct_fourier_gpu.cpp.

732  {
733  int x = 0;
734  for (int z = 0; z <= maxVolumeIndexYZ; z++) {
735  for (int y = 0; y <= maxVolumeIndexYZ/2; y++) {
736  int newPos[3];
737  // mirror against center of the volume, e.g. [0,0,0]->[size,size,size]. It will fit as the input space is one voxel biger
738  newPos[0] = x;
739  newPos[1] = maxVolumeIndexYZ - y;
740  newPos[2] = maxVolumeIndexYZ - z;
741  std::complex<float> tmp1 = 0.5f * (tempVolume[newPos[2]][newPos[1]][newPos[0]] + conj(tempVolume[z][y][x]));
742  float tmp2 = 0.5f * (tempWeights[newPos[2]][newPos[1]][newPos[0]] + tempWeights[z][y][x]);
743 
744  tempVolume[newPos[2]][newPos[1]][newPos[0]] = tmp1;
745  tempVolume[z][y][x] = conj(tmp1);
746  tempWeights[newPos[2]][newPos[1]][newPos[0]] = tempWeights[z][y][x] = tmp2;
747  }
748  }
749 }
alglib::complex conj(const alglib::complex &z)
Definition: ap.cpp:4988
static double * y
doublereal * x
double z
std::complex< float > *** tempVolume

◆ getGPUData()

void ProgRecFourierGPU::getGPUData ( )
protected

Method will fill temporal spaces with data stored at the GPU.

Definition at line 683 of file reconstruct_fourier_gpu.cpp.

683  {
684  if (NULL == tempVolume) {
685  allocate(tempVolume, maxVolumeIndexYZ + 1, maxVolumeIndexYZ + 1,
686  maxVolumeIndexYZ + 1);
687  }
688  if (NULL == tempWeights) {
689  allocate(tempWeights, maxVolumeIndexYZ + 1, maxVolumeIndexYZ + 1,
690  maxVolumeIndexYZ + 1);
691  }
695 }
void copyTempVolumes(std::complex< float > ***tempVol, float ***tempWeights, float *tempVolGPU, float *tempWeightsGPU, int size)
void releaseTempVolumeGPU(float *&ptr)
std::complex< float > *** tempVolume

◆ mirrorAndCropTempSpaces()

void ProgRecFourierGPU::mirrorAndCropTempSpaces ( )
protected

Method will take temp spaces (containing complex conjugate values in the 'right X side'), transfer them to 'left X side' and remove the 'right X side'. As a result, the X dimension of the temp spaces will be half of the original.

Definition at line 697 of file reconstruct_fourier_gpu.cpp.

697  {
698  maxVolumeIndexX = maxVolumeIndexYZ/2; // just half of the space is necessary, the rest is complex conjugate
699  mirrorAndCrop(tempWeights, &identity<float>);
700  mirrorAndCrop(tempVolume, &conjugate);
701 }
std::complex< float > *** tempVolume

◆ processImages()

void ProgRecFourierGPU::processImages ( int  firstImageIndex,
int  lastImageIndex 
)
protected

Method will initialize temporal storage (if necessary), processes images in given interval (including boundary indexes) and store results in temporal storage (

See also
tempVolume and tempWeights)

Definition at line 832 of file reconstruct_fourier_gpu.cpp.

833 {
834 
836 
837 // initialize GPU
838  if (NULL == tempVolumeGPU) {
839  allocateTempVolumeGPU(tempVolumeGPU, maxVolumeIndexYZ+1, sizeof(std::complex<float>));
840  }
841  if (NULL == tempWeightsGPU) {
843  }
846  blob.radius, blob.alpha, iDeltaSqrt, iw0, 1.f/getBessiOrderAlpha(blob));
847  if ( ! useFast) {
848  copyBlobTable(blobTableSqrt, BLOB_TABLE_SIZE_SQRT);
849  }
850 
851  // create threads
852  int imgPerThread = ceil((lastImageIndex-firstImageIndex+1) / (float)noOfThreads);
854  barrier_init( &barrier, noOfThreads + 1 ); // + main thread
855  for (int i = 0; i < noOfThreads; i++) {
856  int sIndex = firstImageIndex + i*imgPerThread;
857  int eIndex = std::min(lastImageIndex, sIndex + imgPerThread-1);
858  createWorkThread(i, sIndex, eIndex, workThreads[i]);
859  }
860 
861  // Waiting for threads to finish
862  barrier_wait( &barrier );
863 
864  // clean threads and GPU
865  for (int i = 0; i < noOfThreads; i++) {
866  pthread_join(workThreads[i].id, NULL);
867  }
869  delete[] workThreads;
870  releaseBlobTable(); // this also ensures that all work on GPU is done (synchronous call)
871  deleteStreams(noOfThreads);
872 }
int barrier_init(barrier_t *barrier, int needed)
void min(Image< double > &op1, const Image< double > &op2)
double alpha
Smoothness parameter.
Definition: blobs.h:121
void copyBlobTable(float *blobTableSqrt, int blobTableSize)
static void setDevice(int device)
Definition: gpu.cpp:135
void createWorkThread(int gpuStream, int startIndex, int endIndex, RecFourierWorkThread &thread)
int barrier_destroy(barrier_t *barrier)
#define i
void deleteStreams(int count)
#define BLOB_TABLE_SIZE_SQRT
RecFourierWorkThread * workThreads
Barrier * barrier
void copyConstants(int maxVolIndexX, int maxVolIndexYZ, float blobRadius, float blobAlpha, float iDeltaSqrt, float iw0, float oneOverBessiOrderAlpha)
float * allocateTempVolumeGPU(float *&ptr, int size, int typeSize)
void createStreams(int count)
int barrier_wait(barrier_t *barrier)
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115

◆ processWeights()

void ProgRecFourierGPU::processWeights ( )
protected

Method will in effect do the point-wise division of tempVolume and tempWeights (i.e. correct Fourier coefficients by proper weight)

Definition at line 751 of file reconstruct_fourier_gpu.cpp.

751  {
752  // Get a first approximation of the reconstruction
753  float corr2D_3D=pow(padding_factor_proj,2.)/
754  (imgSize* pow(padding_factor_vol,3.));
755  for (int z = 0; z <= maxVolumeIndexYZ; z++) {
756  for (int y = 0; y <= maxVolumeIndexYZ; y++) {
757  for (int x = 0; x <= maxVolumeIndexX; x++) {
758  float weight = tempWeights[z][y][x];
759 
760  if (weight > ACCURACY)
761  tempVolume[z][y][x] *= corr2D_3D / weight;
762  else
763  tempVolume[z][y][x] = 0;
764  }
765  }
766  }
767 }
static double * y
doublereal * x
#define ACCURACY
double z
std::complex< float > *** tempVolume

◆ produceSideinfo()

void ProgRecFourierGPU::produceSideinfo ( )
protected

Method will fill other help structures and variables

Definition at line 207 of file reconstruct_fourier_gpu.cpp.

208 {
209  // Translate the maximum resolution to digital frequency
210  // maxResolution=sampling_rate/maxResolution;
211  maxResolutionSqr=maxResolution*maxResolution;
212 
213  // Read the input images
214  SF.read(fn_in);
215  SF.removeDisabled();
217 
218  // Ask for memory for the output volume and its Fourier transform
219  size_t objId = SF.firstRowId();
220  FileName fnImg;
221  SF.getValue(MDL_IMAGE,fnImg,objId);
222  Image<double> I;
223  I.read(fnImg, HEADER);
224  int Ydim=YSIZE(I());
225  int Xdim=XSIZE(I());
226  if (Ydim!=Xdim)
227  REPORT_ERROR(ERR_MULTIDIM_SIZE,"This algorithm only works for squared images");
228  imgSize=Xdim;
229  paddedImgSize = Xdim*padding_factor_vol;
230  auto conserveRows = (size_t) ceil((double) paddedImgSize * maxResolution * 2.0);
231  conserveRows = (size_t) ceil((double) conserveRows / 2.0);
232  maxVolumeIndexX = maxVolumeIndexYZ = 2 * conserveRows;
233 
234  // Build a table of blob values
235  Fourier_blob_table.resize(BLOB_TABLE_SIZE_SQRT);
236 
237  struct blobtype blobFourier,blobnormalized;
238  blobFourier=blob;
239  blobFourier.radius/=(padding_factor_vol*Xdim);
240  blobnormalized=blob;
241  blobnormalized.radius/=((double)padding_factor_proj/padding_factor_vol);
242  double deltaSqrt = (blob.radius*blob.radius) /(BLOB_TABLE_SIZE_SQRT-1);
243  double deltaFourier = (sqrt(3.)*Xdim/2.)/(BLOB_TABLE_SIZE_SQRT-1);
244 
245  // The interpolation kernel must integrate to 1
246  iw0 = 1.0 / blob_Fourier_val(0.0, blobnormalized);
247  double padXdim3 = padding_factor_vol * Xdim;
248  padXdim3 = padXdim3 * padXdim3 * padXdim3;
249  double blobTableSize = blob.radius*sqrt(1./ (BLOB_TABLE_SIZE_SQRT-1));
250  for (int i = 0; i < BLOB_TABLE_SIZE_SQRT; i++)
251  {
252  //use a r*r sample instead of r
253  //DIRECT_VEC_ELEM(blob_table,i) = blob_val(delta*i, blob) *iw0;
254  blobTableSqrt[i] = blob_val(blobTableSize*sqrt((double)i), blob) *iw0;
255  //***
256  //DIRECT_VEC_ELEM(fourierBlobTableSqrt,i) =
257  // blob_Fourier_val(fourierBlobTableSize*sqrt(i), blobFourier)*padXdim3 *iw0;
258  VEC_ELEM(Fourier_blob_table,i) =
259  blob_Fourier_val(deltaFourier*i, blobFourier)*padXdim3 *iw0;
260  //#define DEBUG
261 #ifdef DEBUG
262 
263  std::cout << VEC_ELEM(Fourier_blob_table,i)
264  << " " << VEC_ELEM(fourierBlobTableSqrt,i)
265  << std::endl;
266 #endif
267  #undef DEBUG
268 
269  }
270  //iDelta = 1/delta;
271  iDeltaSqrt = 1/deltaSqrt;
272  iDeltaFourier = 1/deltaFourier;
273 
274  // Get symmetries
275  Matrix2D<double> Identity(3,3);
276  Identity.initIdentity();
277  R_repository.push_back(Identity);
278  if (fn_sym != "")
279  {
280  SymList SL;
281  SL.readSymmetryFile(fn_sym);
282  for (int isym = 0; isym < SL.symsNo(); isym++)
283  {
284  Matrix2D<double> L(4, 4), R(4, 4);
285  SL.getMatrices(isym, L, R);
286  R.resize(3, 3);
287  R_repository.push_back(R);
288  }
289  }
290 }
#define YSIZE(v)
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
void getMatrices(int i, Matrix2D< double > &L, Matrix2D< double > &R, bool homogeneous=true) const
Definition: symmetries.cpp:348
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void sqrt(Image< double > &op)
bool getValue(MDObject &mdValueOut, size_t id) const override
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
Definition: symmetries.cpp:33
Incorrect MultidimArray size.
Definition: xmipp_error.h:174
int symsNo() const
Definition: symmetries.h:268
#define i
#define BLOB_TABLE_SIZE_SQRT
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
#define XSIZE(v)
#define blob_Fourier_val(w, blob)
Definition: blobs.h:174
MDSql * getDatabase()
Definition: metadata_db.h:182
bool activateThreadMuting(void)
size_t firstRowId() const override
virtual void removeDisabled()
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=NULL, bool decomposeStack=true) override
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
#define blob_val(r, blob)
Definition: blobs.h:139
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
Name of an image (std::string)

◆ readParams()

void ProgRecFourierGPU::readParams ( )
protectedvirtual

Read arguments from command line

Reimplemented from XmippProgram.

Definition at line 76 of file reconstruct_fourier_gpu.cpp.

77 {
78  fn_in = getParam("-i");
79  fn_out = getParam("-o");
80  fn_sym = getParam("--sym");
81  do_weights = checkParam("--weight");
82  padding_factor_proj = getDoubleParam("--padding", 0);
83  padding_factor_vol = getDoubleParam("--padding", 1);
84  blob.radius = getDoubleParam("--blob", 0);
85  blob.order = getIntParam("--blob", 1);
86  blob.alpha = getDoubleParam("--blob", 2);
87  useFast = checkParam("--fast");
88  parseNoOfThreads();
89  device = getIntParam("--device");
90  fftOnGPU = checkParam("--fftOnGPU");
91  maxResolution = getDoubleParam("--max_resolution");
92  useCTF = checkParam("--useCTF");
93  isPhaseFlipped = checkParam("--phaseFlipped");
94  minCTF = getDoubleParam("--minCTF");
95  if (useCTF)
96  iTs = 1 / getDoubleParam("--sampling");
97  bufferSize = getIntParam("--bufferSize");
98 }
double alpha
Smoothness parameter.
Definition: blobs.h:121
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
int order
Derivation order and Bessel function order.
Definition: blobs.h:118
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115

◆ releaseTempSpaces()

void ProgRecFourierGPU::releaseTempSpaces ( )
protected

Method will release temporal spaces for weights and Fourier coefs.

Definition at line 874 of file reconstruct_fourier_gpu.cpp.

874  {
877 }
std::complex< float > *** tempVolume

◆ run()

void ProgRecFourierGPU::run ( )
virtual

Run the image processing. Method will load data, process them and store result to final destination.

Reimplemented from XmippProgram.

Definition at line 179 of file reconstruct_fourier_gpu.cpp.

180 {
181  show();
182  checkDefines(); // check that there is not a logical error in defines
183  produceSideinfo();
184  checkMemory();
185  if (verbose) {
187  }
188  //Computing interpolated volume
189  processImages(0, SF.size() - 1);
190  // Get data from GPU
191  getGPUData();
192  // remove complex conjugate of the intermediate result
194  //Saving the volume
196 }
void init_progress_bar(long total)
void finishComputations(const FileName &out_name)
void processImages(int firstImageIndex, int lastImageIndex)
int verbose
Verbosity level.
size_t size() const override

◆ setIO()

void ProgRecFourierGPU::setIO ( const FileName fn_in,
const FileName fn_out 
)
virtual

Functions of common reconstruction interface

Implements ProgReconsBase.

Definition at line 934 of file reconstruct_fourier_gpu.cpp.

935 {
936  this->fn_in = fn_in;
937  this->fn_out = fn_out;
938 }

◆ show()

void ProgRecFourierGPU::show ( )
protected

Show basic info to standard output

Definition at line 101 of file reconstruct_fourier_gpu.cpp.

102 {
103  if (verbose > 0)
104  {
105  std::cout << " =====================================================================" << std::endl;
106  std::cout << " Direct 3D reconstruction method using Kaiser windows as interpolators" << std::endl;
107  std::cout << " =====================================================================" << std::endl;
108  std::cout << " Input selfile : " << fn_in << std::endl;
109  std::cout << " padding_factor_proj : " << padding_factor_proj << std::endl;
110  std::cout << " padding_factor_vol : " << padding_factor_vol << std::endl;
111  std::cout << " Output volume : " << fn_out << std::endl;
112  if (fn_sym != "")
113  std::cout << " Symmetry file for projections : " << fn_sym << std::endl;
114  if (do_weights)
115  std::cout << " Use weights stored in the image headers or doc file" << std::endl;
116  else
117  std::cout << " Do NOT use weights" << std::endl;
118  if (useCTF)
119  std::cout << "Using CTF information" << std::endl
120  << "Sampling rate: " << 1 / iTs << std::endl
121  << "Phase flipped: " << isPhaseFlipped << std::endl
122  << "Minimum CTF: " << minCTF << std::endl;
123  std::cout << "\n Interpolation Function"
124  << "\n blrad : " << blob.radius
125  << "\n blord : " << blob.order
126  << "\n blalpha : " << blob.alpha
127  << "\n max_resolution : " << maxResolution
128  << "\n -----------------------------------------------------------------" << std::endl;
129  }
130 }
double alpha
Smoothness parameter.
Definition: blobs.h:121
int verbose
Verbosity level.
int order
Derivation order and Bessel function order.
Definition: blobs.h:118
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115

Member Data Documentation

◆ device

int ProgRecFourierGPU::device
protected

CUDA device to use

Definition at line 134 of file reconstruct_fourier_gpu.h.

◆ fn_in

FileName ProgRecFourierGPU::fn_in
protected

Input file name

Definition at line 92 of file reconstruct_fourier_gpu.h.

◆ fn_out

FileName ProgRecFourierGPU::fn_out
protected

Output file name

Definition at line 89 of file reconstruct_fourier_gpu.h.

◆ maxVolumeIndexX

int ProgRecFourierGPU::maxVolumeIndexX
protected

maximal index in the temporal volumes, X axis

Definition at line 98 of file reconstruct_fourier_gpu.h.

◆ maxVolumeIndexYZ

int ProgRecFourierGPU::maxVolumeIndexYZ
protected

maximal index in the temporal volumes, Y and Z axis

Definition at line 95 of file reconstruct_fourier_gpu.h.

◆ noOfThreads

int ProgRecFourierGPU::noOfThreads
protected

Holds number of cores available at the host system

Definition at line 131 of file reconstruct_fourier_gpu.h.

◆ SF

MetaDataDb ProgRecFourierGPU::SF
protected

SelFile containing all projections

Definition at line 86 of file reconstruct_fourier_gpu.h.

◆ tempVolume

std::complex<float>*** ProgRecFourierGPU::tempVolume = NULL
protected

3D volume holding the cropped (without high frequencies) Fourier space. Lowest frequencies are in the center, i.e. Fourier space creates a sphere within a cube.

Definition at line 105 of file reconstruct_fourier_gpu.h.

◆ tempVolumeGPU

float* ProgRecFourierGPU::tempVolumeGPU = NULL
protected

3D volume holding the cropped (without high frequencies) Fourier space. Lowest frequencies are in the center, i.e. Fourier space creates a sphere within a cube. Valid for GPU, i.e. it is equivalent to tempVolume, which has been flattened Each two successive values represent one complex number

Definition at line 120 of file reconstruct_fourier_gpu.h.

◆ tempWeights

float*** ProgRecFourierGPU::tempWeights = NULL
protected

3D volume holding the weights of the Fourier coefficients stored in tempVolume.

Definition at line 111 of file reconstruct_fourier_gpu.h.

◆ tempWeightsGPU

float* ProgRecFourierGPU::tempWeightsGPU = NULL
protected

3D volume holding the weights of the Fourier coefficients stored in tempVolume. Valid for GPU, i.e. it is equivalent to tempWeights, which has been flattened

Definition at line 127 of file reconstruct_fourier_gpu.h.

◆ workThreads

RecFourierWorkThread* ProgRecFourierGPU::workThreads
protected

Thread used for loading input data

Definition at line 83 of file reconstruct_fourier_gpu.h.


The documentation for this class was generated from the following files: