-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_plotting_PLSHypTest.py
63 lines (50 loc) · 1.4 KB
/
test_plotting_PLSHypTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
##
import copy
import sys
#sys.path.append('/Users/hmatth5/Documents/Projects/python_shape_stats/')
import numpy as np
#
from python_shape_stats import helpers, procrustes
from python_shape_stats.statistical_shape_models import ShapePCA,ShapePLSHypothesisTest
import glob
import os
import pickle
import numpy as np
import pandas as pd
from matplotlib.colors import LinearSegmentedColormap
# import pathlib
# import glob
import pyvista as pv
# from python_shape_stats import procrustes
# # #
# paths = glob.glob(helpers.get_path_to_simulated_faces()+'/*.obj')
# vs,poly = helpers.load_shapes_to_array(paths)
# vs,_ = procrustes.do_generalized_procrustes_analysis(vs)
# PCA = ShapePCA()
# PCA.fit_transform(vs)
# PCA.reference_polydata = poly[0]
# pickle.dump(PCA,open(helpers.get_path_to_pickled_shape_pca(),'wb'))
##
vars = ['Sex','BMI','Age']
mod = helpers.load_shape_hypothesis_test()
PCA = helpers.load_shape_pca()
#%%
mod.fit(mod.x.copy(),PCA,method='pls',n_comp=3)
v = mod._get_point_r_squared(vars)
mod.plot_coefficients(vars,title=vars,clim=None)
mod.plot_r_squared(vars,title=vars)
mod.run_permutation_test(n_reps = 100)
mod.plot_p_values(vars,title=vars)
##
Y = PCA.transformed_training_data
X = MD.to_array()
##
##
# vecs
sc = mod._get_point_regression_coefs('normal', vars, reverse=True)
pl = pv.Plotter()
pl.add_mesh(PCA.average_polydata.copy(True),scalars = sc[0],cmap = parula_map)
#pl.show()
##
##
##