Skip to content

Commit 2641125

Browse files
add python api for morpho dev score
1 parent c1aa855 commit 2641125

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

Libs/Python/ShapeworksPython.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ using namespace pybind11::literals;
4545
#include "Variant.h"
4646
#include "VectorImage.h"
4747
#include "pybind_utils.h"
48-
48+
#include <Optimize/Function/EarlyStop/MorphologicalDeviationScore.h>
4949
namespace fs = boost::filesystem;
5050

5151
using namespace shapeworks;
@@ -1701,4 +1701,38 @@ PYBIND11_MODULE(shapeworks_py, m) {
17011701
"Return the variant string content")
17021702

17031703
; // Variant
1704+
1705+
py::class_<MorphologicalDeviationScore>(m, "MorphologicalDeviationScore")
1706+
.def(py::init<>(), "Create an instance for MorphologicalDeviationScore")
1707+
.def("SetControlShapes", &MorphologicalDeviationScore::SetControlShapes,
1708+
py::arg("X"),
1709+
R"pbdoc(
1710+
Fit PPCA model on control shapes.
1711+
1712+
Parameters
1713+
----------
1714+
X : numpy.ndarray
1715+
Matrix of control shapes (n_samples x n_features)
1716+
1717+
Returns
1718+
-------
1719+
bool
1720+
True if fitting was successful, False otherwise.
1721+
)pbdoc")
1722+
1723+
.def("GetMorphoDevScore",
1724+
&MorphologicalDeviationScore::GetMorphoDevScore, py::arg("X"),
1725+
R"pbdoc(
1726+
Compute Mahalanobis-based deviation score for test samples.
1727+
1728+
Parameters
1729+
----------
1730+
X : numpy.ndarray
1731+
Matrix of test samples (n_samples x n_features)
1732+
1733+
Returns
1734+
-------
1735+
numpy.ndarray
1736+
Vector of Mahalanobis distances for each sample.
1737+
)pbdoc");
17041738
} // PYBIND11_MODULE(shapeworks_py)

0 commit comments

Comments
 (0)