diff --git a/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnisotropyWrapper.java b/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnisotropyWrapper.java index 7f65abe9..a9b6bb1d 100644 --- a/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnisotropyWrapper.java +++ b/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnisotropyWrapper.java @@ -62,6 +62,8 @@ import net.imagej.ops.special.hybrid.BinaryHybridCFI1; import net.imagej.ops.special.hybrid.Hybrids; import net.imagej.ops.stats.regression.leastSquares.Quadric; +import net.imagej.table.DefaultResultsTable; +import net.imagej.table.ResultsTable; import net.imagej.units.UnitService; import net.imglib2.RandomAccessibleInterval; import net.imglib2.type.NativeType; @@ -87,12 +89,13 @@ import org.joml.Quaterniondc; import org.joml.Vector3d; import org.joml.Vector3dc; -import org.scijava.ItemVisibility; +import org.scijava.ItemIO; import org.scijava.app.StatusService; import org.scijava.command.Command; import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.table.DoubleColumn; import org.scijava.ui.DialogPrompt.Result; import org.scijava.ui.UIService; import org.scijava.widget.NumberWidget; @@ -127,7 +130,6 @@ public class AnisotropyWrapper & NativeType> extends Bo private static UnaryFunctionOp, Matrix4dc> solveQuadricOp; private final Function degreeOfAnisotropy = ellipsoid -> 1.0 - (1.0/(ellipsoid.getC() * ellipsoid.getC())) / (1.0/(ellipsoid.getA() * ellipsoid.getA())); - @SuppressWarnings("unused") @Parameter(validater = "validateImage") private ImgPlus inputImage; @@ -170,9 +172,14 @@ public class AnisotropyWrapper & NativeType> extends Bo private boolean printEigens; @Parameter(label = "Display MIL vectors", - description = "Show the vectors of the mean intercept lengths", + description = "Show the vectors of the mean intercept lengths in the 3D Viewer", required = false) private boolean displayMILVectors; + + @Parameter(label = "Print MIL vectors", + description = "Write the vectors of the mean intercept lengths to a table", + required = false) + private boolean printMILVectorsToTable; @Parameter private LogService logService; @@ -184,6 +191,10 @@ public class AnisotropyWrapper & NativeType> extends Bo private UIService uiService; @Parameter private UnitService unitService; + + @Parameter(type = ItemIO.OUTPUT, label = "MIL Vectors") + private ResultsTable milVectorTable; + private static BinaryHybridCFI1 rotateOp; private double milLength; @@ -262,6 +273,24 @@ private void addResults(final List> subspaces, addResult(subspace, anisotropy, ellipsoid); } } + + private void printMILVectors(final List pointCloud) { + if (!printMILVectorsToTable || pointCloud == null || pointCloud.isEmpty()) { + return; + } + + final List columns = Arrays.asList( + new DoubleColumn("x"), new DoubleColumn("y"), new DoubleColumn("z")); + + for (int i = 0; i < pointCloud.size(); i++) { + final Vector3dc vector = pointCloud.get(i); + columns.get(0).add(vector.x()); + columns.get(1).add(vector.y()); + columns.get(2).add(vector.z()); + } + milVectorTable = new DefaultResultsTable(); + milVectorTable.addAll(columns); + } @SuppressWarnings("unused") private void initializeIncrement() { @@ -338,6 +367,9 @@ private Ellipsoid milEllipsoid(final RandomAccessibleInterval interval) if (displayMILVectors) { Visualiser.display3DPoints(pointCloud, "MIL points"); } + if (printMILVectorsToTable) { + printMILVectors(pointCloud); + } return ellipsoid.get(); } catch (final ExecutionException | InterruptedException e) {