From 4a9ab996cba502d980072dfd07bd87c20d657377 Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Tue, 1 Aug 2023 10:39:10 -0400 Subject: [PATCH] add main class, keep implementing re-do FIBSEM align --- .../render/client/newsolver/BlockData.java | 7 +- .../client/newsolver/DistributedSolver.java | 85 +++++++++++++++++++ .../BlockDataSolveParameters.java | 4 +- .../FIBSEMSolveParameters.java | 12 +-- 4 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/DistributedSolver.java diff --git a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/BlockData.java b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/BlockData.java index 632dacaff..88629bfd5 100644 --- a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/BlockData.java +++ b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/BlockData.java @@ -7,7 +7,6 @@ import org.janelia.render.client.newsolver.blocksolveparameters.BlockDataSolveParameters; import org.janelia.render.client.solver.MinimalTileSpec; -import mpicbg.models.AffineModel2D; import mpicbg.models.Model; /** @@ -23,7 +22,10 @@ public class BlockData< M extends Model< M > > implements Serializable private int id; - // contains solve-specific paramters and models + // the BlockFactory that created this BlockData + final BlockFactory factory; + + // contains solve-specific parameters and models final BlockDataSolveParameters solveTypeParameters; // used for global solve outside @@ -41,6 +43,7 @@ public BlockData( final int id ) { this.id = id; + this.factory = factory; this.solveTypeParameters = solveTypeParameters; } diff --git a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/DistributedSolver.java b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/DistributedSolver.java new file mode 100644 index 000000000..d7bc50c56 --- /dev/null +++ b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/DistributedSolver.java @@ -0,0 +1,85 @@ +package org.janelia.render.client.newsolver; + +import java.io.IOException; +import java.io.Serializable; +import java.util.function.Function; + +import org.janelia.render.client.newsolver.blockfactories.ZBlock; +import org.janelia.render.client.newsolver.blocksolveparameters.FIBSEMSolveParameters; +import org.janelia.render.client.solver.DistributedSolveParameters; +import org.janelia.render.client.solver.RunParameters; + +import mpicbg.models.Affine2D; + +public class DistributedSolver +{ + public static void main( String[] args ) throws IOException + { + final DistributedSolveParameters parameters = new DistributedSolveParameters(); + + // TODO: remove testing hack ... + if (args.length == 0) { + final String[] testArgs = { + "--baseDataUrl", "http://tem-services.int.janelia.org:8080/render-ws/v1", + "--owner", "Z0720_07m_BR", //"flyem", //"cosem", //"Z1217_33m_BR", + "--project", "Sec24", //"Z0419_25_Alpha3", //"jrc_hela_2", //"Sec10", + "--matchCollection", "Sec24_v1", //"Sec32_v1", //"Z0419_25_Alpha3_v1", //"jrc_hela_2_v1", //"Sec10_multi", + + "--stack", "v5_acquire_trimmed", + "--targetStack", "v5_acquire_trimmed_test", +// "--minZ", "1234", +// "--maxZ", "1234", + +// "--completeTargetStack", +// "--visualizeResults", + + // note: prealign is with translation only + "--blockOptimizerLambdasRigid", "1.0,1.0,0.9,0.3,0.01", + "--blockOptimizerLambdasTranslation", "1.0,0.0,0.0,0.0,0.0", + "--blockOptimizerIterations", "100,100,50,25,25", + "--blockMaxPlateauWidth", "25,25,15,10,10", + //"--blockOptimizerIterations", "1000,1000,500,250,250", + //"--blockMaxPlateauWidth", "250,250,150,100,100", + + //"--blockSize", "100", + "--minStitchingInliers", "100000000",// do not stitch first + "--maxNumMatches", "0", // no limit, default + "--threadsWorker", "1", + "--threadsGlobal", "60", + "--maxPlateauWidthGlobal", "50", + "--maxIterationsGlobal", "10000", + }; + parameters.parse(testArgs); + } else { + parameters.parse(args); + } + + RunParameters runParameters = DistributedSolveParameters.setupSolve( parameters ); + + // + // setup Z BlockFactory + // + final int minZ = (int)Math.round( runParameters.minZ ); + final int maxZ = (int)Math.round( runParameters.maxZ ); + final int blockSize = parameters.blockSize; + final int minBlockSize = parameters.minBlockSize; + + final BlockFactory blockFactory = new ZBlock( minZ, maxZ, blockSize, minBlockSize ); + + // + // setup FIB-SEM solve parameters + // + final boolean rigidPreAlign = false; + + FIBSEMSolveParameters solveParams = new FIBSEMSolveParameters( + null, //parameters.blockModel(), + (Function< Integer, Affine2D > & Serializable )(z) -> parameters.stitchingModel(), + (Function< Integer, Integer > & Serializable )(z) -> parameters.minStitchingInliers, + parameters.blockOptimizerLambdasRigid, + parameters.blockOptimizerLambdasTranslation, + parameters.blockOptimizerIterations, + parameters.blockMaxPlateauWidth, + parameters.blockMaxAllowedError, + rigidPreAlign ); + } +} diff --git a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/BlockDataSolveParameters.java b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/BlockDataSolveParameters.java index 06d80cc32..72a7ae34c 100644 --- a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/BlockDataSolveParameters.java +++ b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/BlockDataSolveParameters.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import mpicbg.models.Model; +import mpicbg.models.CoordinateTransform; /** * @@ -10,7 +10,7 @@ * * @param - the result model type */ -public class BlockDataSolveParameters< M extends Model > implements Serializable +public class BlockDataSolveParameters< M extends CoordinateTransform > implements Serializable { private static final long serialVersionUID = -813404780882760053L; diff --git a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/FIBSEMSolveParameters.java b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/FIBSEMSolveParameters.java index 969a89717..3c7e87cc5 100644 --- a/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/FIBSEMSolveParameters.java +++ b/render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/blocksolveparameters/FIBSEMSolveParameters.java @@ -17,9 +17,6 @@ public class FIBSEMSolveParameters< B extends Model< B > & Affine2D< B >, S exte { private static final long serialVersionUID = 4247180309556813829L; - final int minZ; - final int maxZ; - final private B blockSolveModel; final private Function< Integer, S > stitchingModelSupplier; final private Function< Integer, Integer > minStitchingInliersSupplier; // if it is less, it is not stitched first @@ -41,9 +38,7 @@ public FIBSEMSolveParameters( final List blockOptimizerIterations, final List blockMaxPlateauWidth, final double blockMaxAllowedError, - final boolean rigidPreAlign, - final int minZ, - final int maxZ ) + final boolean rigidPreAlign ) { this.blockSolveModel = blockSolveModel.copy(); this.stitchingModelSupplier = stitchingModelSupplier; @@ -54,13 +49,8 @@ public FIBSEMSolveParameters( this.blockMaxPlateauWidth = blockMaxPlateauWidth; this.blockMaxAllowedError = blockMaxAllowedError; this.rigidPreAlign = rigidPreAlign; - this.minZ = minZ; - this.maxZ = maxZ; } - public int minZ() { return minZ; } - public int maxZ() { return maxZ; } - public B blockSolveModelInstance() { return blockSolveModel.copy(); } public S stitchingSolveModelInstance( final int z ) { return stitchingModelSupplier.apply( z ); }