53 addUsageLine(
"Sorts the input images for identifying junk particles");
54 addUsageLine(
"+The program associates to each image four vectors.");
55 addUsageLine(
"+One vector is composed by descriptors that encodes the particle shape.");
56 addUsageLine(
"+Another two vectors give information about the SNR of the objects.");
57 addUsageLine(
"+Finally, the last vector provides information of the particle histogram");
59 addUsageLine(
"+These vector are then scored according to a multivariate Gaussian distribution");
61 addUsageLine(
"+You can reject erroneous particles choosing a threshold, you must take into account");
63 addUsageLine(
"+For univariate and mulivariate Gaussian distributions, 99% of the individuals");
65 addUsageLine(
"+Additionally, you can discard bad particles selecting an inaccurate particle percentage");
69 addParamsLine(
" : rootname.xmd contains the list of sorted images with their Z-score");
70 addParamsLine(
" : rootname_vectors.xmd (if verbose>=2) contains the vectors associated to each image");
71 addParamsLine(
" : If no rootname is given, these two files are not created");
72 addParamsLine(
" [-t <selfile=\"\">]: : Train on selfile with good particles");
73 addParamsLine(
" [--zcut <float=-1>] : Cut-off for Z-scores (negative for no cut-off) ");
74 addParamsLine(
" : Images whose Z-score is larger than the cutoff are disabled");
75 addParamsLine(
" [--addFeatures] : Add calculated features to the output metadata");
76 addParamsLine(
" [--percent <float=0>] : Cut-off for particles (zero for no cut-off) ");
77 addParamsLine(
" : Percentage of images with larger Z-scores are disabled");
78 addParamsLine(
" [--addToInput] : Add columns also to input MetaData");
79 addParamsLine(
" [--dim <d=50>] : Scale images to this size if they are larger.");
95 tempPcaAnalyzer0.
clear();
97 tempPcaAnalyzer1.
clear();
98 tempPcaAnalyzer2.
clear();
99 tempPcaAnalyzer3.
clear();
101 tempPcaAnalyzer4.
clear();
105 int numDescriptors0=numNorm;
106 int numDescriptors1=0;
107 int numDescriptors2=4;
108 int numDescriptors3=11;
109 int numDescriptors4=10;
115 std::vector<double> v04;
116 std::vector<std::vector<double> > v04all;
121 std::cout <<
" Sorting particle set by new xmipp method..." << std::endl;
124 int nr_imgs = SF.
size();
129 int imgno = 0, imgnoPCA=0;
135 size_t Xdim, Ydim, Zdim, Ndim;
172 if ( temp < (Xdim/2))
181 for (
size_t objId : SF.
ids())
203 numDescriptors1 =
XSIZE(mI)/2;
206 v04.reserve(numDescriptors0+numDescriptors1+numDescriptors2+numDescriptors3+numDescriptors4);
210 normalize(transformer,mI,tempI,modI,0,var,mask);
213 nI = sign*tempI*(modI*modI);
220 while (index < numNorm)
222 normalize(transformer,mI,tempI,modI,0,var,mask);
225 nI += sign*tempI*(modI*modI);
226 tempM += (modI*modI);
227 A1D_ELEM(v0,index) = (tempM*ROI).sum();
245 for (
int n = 0;
n < numDescriptors1; ++
n)
256 String name =
"000010@Images/Extracted/run_001/extra/KLH_Dataset_I_Training_0028.stk";
259 std::cout << img.
name() << std::endl;
261 if (img.
name()==name2)
265 fpName =
"test_2.txt";
267 fpName =
"test_3.txt";
269 fpName =
"test_4.txt";
284 double x0=0,
y0=0,majorAxis=0,minorAxis=0,ellipAng=0;
288 A1D_ELEM(v2,0)=majorAxis/(img().xdim);
289 A1D_ELEM(v2,1)=minorAxis/(img().xdim);
290 A1D_ELEM(v2,2)= (fabs((img().xdim)/2-x0)+fabs((img().ydim)/2-
y0))/((img().xdim)/2);
291 A1D_ELEM(v2,3)=area/( (double)((img().xdim)/2)*((img().ydim)/2) );
293 for (
int n=0 ;
n < numDescriptors2 ;
n++)
305 autoCorr.
window(smallAutoCorr,-5,-5, 5, 5);
306 smallAutoCorr.
copy(temp);
309 for (
int n = 0;
n < numDescriptors3; ++
n)
322 for (
int n=0 ;
n <= numDescriptors4-1 ;
n++)
330 v04all.push_back(v04);
334 if (img.
name()==name1)
338 fpName =
"test3.txt";
345 if (imgno % c == 0 &&
verbose>0)
352 std::size_t beg =
fn.find_last_of(
"@") + 1;
353 std::size_t end =
fn.find_last_of(
"/") + 1;
355 +
"_tmpPca0").c_str(), numDescriptors0);
357 +
"_tmpPca1").c_str(), numDescriptors1);
359 +
"_tmpPca2").c_str(), numDescriptors2);
361 +
"_tmpPca3").c_str(), numDescriptors3);
363 +
"_tmpPca4").c_str(), numDescriptors4);
402 ZscoreShape1.resizeNoCopy(finalZscore);
403 ZscoreShape2.resizeNoCopy(finalZscore);
404 ZscoreSNR1.resizeNoCopy(finalZscore);
405 ZscoreSNR2.resizeNoCopy(finalZscore);
406 ZscoreHist.resizeNoCopy(finalZscore);
407 sortedZscoreShape1.resizeNoCopy(finalZscore);
408 sortedZscoreShape2.resizeNoCopy(finalZscore);
409 sortedZscoreSNR1.resizeNoCopy(finalZscore);
410 sortedZscoreSNR2.resizeNoCopy(finalZscore);
411 sortedZscoreHist.resizeNoCopy(finalZscore);
416 for (
size_t objId:
SF.
ids())
432 for (
int num = 0; num < numPCAs; ++num)
468 std::ofstream fh_zind;
480 for (
int imgno = 0; imgno < nr_imgs; imgno++)
544 sortedShapeSF1,sortedShapeSF2,sortedSNR1SF,sortedSNR2SF,sortedHistSF;
546 sortedZscoreShape1.
indexSort(sortedShape1);
547 sortedZscoreShape2.indexSort(sortedShape2);
548 sortedZscoreSNR1.indexSort(sortedSNR1);
549 sortedZscoreSNR2.indexSort(sortedSNR2);
550 sortedZscoreHist.indexSort(sortedHist);
553 for (
size_t numPar =
SF.
size()-1; numPar > (
SF.
size()-numPartReject); --numPar)
563 ZscoreShape1.indexSort(sortedShapeSF1);
564 ZscoreShape2.indexSort(sortedShapeSF2);
565 ZscoreSNR1.indexSort(sortedSNR1SF);
566 ZscoreSNR2.indexSort(sortedSNR2SF);
567 ZscoreHist.indexSort(sortedHistSF);
585 for (
const auto& row : SFsorted)
588 SFout.
addRow(dynamic_cast<const MDRowVec&>(row));
No active object in MetaData.
void fitEllipse(Matrix1D< double > &xPts, Matrix1D< double > &yPts, double &x0, double &y0, double &majorAxis, double &minorAxis, double &ellipseAngle)
void init_progress_bar(long total)
void binarizeRange(double valMin=0, double valMax=255, MultidimArray< int > *mask=NULL)
#define A2D_ELEM(v, i, j)
void addVector(const MultidimArray< float > &_v)
Add vector.
double getDoubleParam(const char *param, int arg=0)
__host__ __device__ float2 floor(const float2 v)
#define REPORT_ERROR(nerr, ErrormMsg)
void resizeNoCopy(const MultidimArray< T1 > &v)
void sqrt(Image< double > &op)
void setValue(const MDObject &object) override
void processInputPrepareSPTH(MetaData &SF, bool trained)
void maxIndex(int &jmax) const
void abs(Image< double > &op)
const FileName & name() const
double percentil(double percent_mass)
void auto_correlation_matrix(const MultidimArray< double > &Img, MultidimArray< double > &R, CorrelationAux &aux)
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams ¶ms=DefaultApplyGeoParams)
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
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
T & getValue(MDLabel label)
#define DIRECT_A1D_ELEM(v, i)
void window(MultidimArray< T1 > &result, int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T1 init_value=0) const
const char * getParam(const char *param, int arg=0)
void compute_hist(const MultidimArrayGeneric &array, Histogram1D &hist, int no_steps)
void binarize(double val=0, double accuracy=XMIPP_EQUAL_ACCURACY, MultidimArray< int > *mask=NULL)
void evaluateZScore(int NPCA, int Niter, bool trained=false, const char *filename="temp.txt", int numdesc=0)
void progress_bar(long rlen)
void write(const FileName &fn) const
void computeDoubleMinMax(double &minval, double &maxval) const
quaternion_type< T > normalize(quaternion_type< T > q)
int verbose
Verbosity level.
void svdcmp(const Matrix2D< T > &a, Matrix2D< double > &u, Matrix1D< double > &w, Matrix2D< double > &v)
const char * name() const
std::vector< PCAMahalanobisAnalyzer > pcaAnalyzer
TYPE distance(struct Point_T *p, struct Point_T *q)
int labelImage2D(const MultidimArray< double > &I, MultidimArray< double > &label, int neighbourhood)
FileName withoutExtension() const
String formatString(const char *format,...)
void copy(Matrix2D< T > &op1) const
bool checkParam(const char *param)
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
int getIntParam(const char *param, int arg=0)
void indexSort(MultidimArray< int > &indx) const
void addParamsLine(const String &line)
void statisticsAdjust(U avgF, U stddevF)