#pragma once#include"vnl/vnl_vector.h"#include"vnl/algo/vnl_symmetric_eigensystem.h"#include"vnl/vnl_matrix.h"#include"vnl/vnl_vector_fixed.h"#include"vnl/algo/vnl_matrix_inverse.h"#include<Eigen/Eigen>#include<iostream>#include<fstream>#include<vector>#include<string>#include<cstdio>#include"itkParticlePositionReader.h"#include"itkParticlePositionWriter.h"#include"Shapeworks.h"#include"ParticleSystem.h"namespaceshapeworks{classParticleShapeStatistics{public:constexprstaticintVDimension=3;ParticleShapeStatistics(){}~ParticleShapeStatistics(){}intDoPCA(std::vector<std::vector<Point>>global_pts,intdomainsPerShape=1);intDoPCA(ParticleSystemparticleSystem,intdomainsPerShape=1);itkStaticConstMacro(Dimension,unsignedint,VDimension);intImportPoints(std::vector<vnl_vector<double>>points,std::vector<int>group_ids);intReadPointFiles(conststd::string&s);intReloadPointFiles();intWriteCSVFile(conststd::string&s);intWriteCSVFile2(conststd::string&s);intComputeModes();intPrincipalComponentProjections();intFisherLinearDiscriminant(unsignedintnumModes);constintSampleSize(){returnm_numSamples;}constintGroup1SampleSize(){returnm_numSamples1;}constintGroup2SampleSize(){returnm_numSamples2;}constintNumberOfDimensions(){returnm_numDimensions;}constintGroupID(unsignedinti){returnm_groupIDs[i];}conststd::vector<int>&GroupID(){returnm_groupIDs;}constvnl_matrix<double>&Eigenvectors(){returnm_eigenvectors;}conststd::vector<double>&Eigenvalues(){returnm_eigenvalues;}constvnl_vector<double>&Mean(){returnm_mean;}constvnl_vector<double>&Group1Mean(){returnm_mean1;}constvnl_vector<double>&Group2Mean(){returnm_mean2;}// Returns group2 - group1 meanconstvnl_vector<double>&NormalizedGroupDifference(){returnm_groupdiffnorm;}constvnl_vector<double>&GroupDifference(){returnm_groupdiff;}intComputeMedianShape(constintID);doubleL1Norm(unsignedinta,unsignedintb);Eigen::MatrixXd&PCALoadings(){returnm_principals;}constvnl_vector<double>&FishersLDA(){returnm_fishersLD;}constvnl_matrix<double>&ShapeMatrix(){returnm_shapes;}constvnl_matrix<double>&RecenteredShape(){returnm_pointsMinusMean;}std::vector<double>PercentVarByMode(){returnm_percentVarByMode;}intSimpleLinearRegression(conststd::vector<double>&y,conststd::vector<double>&x,double&a,double&b)const;Eigen::VectorXdget_compactness(std::function<void(float)>progress_callback);Eigen::VectorXdget_specificity(std::function<void(float)>progress_callback);Eigen::VectorXdget_generalization(std::function<void(float)>progress_callback);Eigen::MatrixXdget_group1_matrix();Eigen::MatrixXdget_group2_matrix();private:unsignedintm_numSamples1;unsignedintm_numSamples2;unsignedintm_numSamples;unsignedintm_domainsPerShape;unsignedintm_numDimensions;std::vector<int>m_groupIDs;vnl_matrix<double>m_pooled_covariance;vnl_matrix<double>m_eigenvectors;std::vector<double>m_eigenvalues;vnl_vector<double>m_mean;vnl_vector<double>m_mean1;vnl_vector<double>m_mean2;vnl_matrix<double>m_pointsMinusMean;vnl_matrix<double>m_shapes;vnl_matrix<double>m_projectedPMM1;vnl_matrix<double>m_projectedPMM2;vnl_vector<double>m_projectedMean1;vnl_vector<double>m_projectedMean2;std::vector<double>m_fishersProjection;std::vector<double>m_percentVarByMode;vnl_vector<double>m_fishersLD;Eigen::MatrixXdm_principals;vnl_vector<double>m_groupdiff;vnl_vector<double>m_groupdiffnorm;// used to keep the points' files that needs to be reloaded when new updates come in.std::vector<std::string>m_pointsfiles;Eigen::MatrixXdm_Matrix;Eigen::MatrixXdm_group_1_matrix;Eigen::MatrixXdm_group_2_matrix;};}// shapeworks