Skip to content

Commit

Permalink
first run of a solve of one block
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPreibisch committed Aug 15, 2023
1 parent dd01461 commit b8eee7d
Showing 1 changed file with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;

import org.janelia.render.client.newsolver.blockfactories.BlockFactory;
import org.janelia.render.client.newsolver.blockfactories.ZBlockFactory;
import org.janelia.render.client.newsolver.blocksolveparameters.FIBSEMAlignmentParameters;
import org.janelia.render.client.newsolver.setup.AffineSolverSetup;
Expand All @@ -16,6 +15,7 @@
import mpicbg.models.Affine2D;
import mpicbg.models.AffineModel2D;
import mpicbg.models.Model;
import mpicbg.models.NoninvertibleModelException;

public class AffineDistributedSolver
{
Expand Down Expand Up @@ -45,7 +45,7 @@ public static void main( final String[] args ) throws IOException
"--stack", "v5_acquire_trimmed",
"--targetStack", "v5_acquire_trimmed_test",
// "--minZ", "1234",
// "--maxZ", "1234",
"--maxZ", "3001",

// "--completeTargetStack",
// "--visualizeResults",
Expand All @@ -62,9 +62,9 @@ public static void main( final String[] args ) throws IOException
"--minStitchingInliers", "100000000",// do not stitch first
"--maxNumMatches", "0", // no limit, default
"--threadsWorker", "1",
"--threadsGlobal", "60",
"--maxPlateauWidthGlobal", "50",
"--maxIterationsGlobal", "10000",
//"--threadsGlobal", "60",
//"--maxPlateauWidthGlobal", "50",
//"--maxIterationsGlobal", "10000",
};
cmdLineSetup.parse(testArgs);
} else {
Expand All @@ -76,10 +76,21 @@ public static void main( final String[] args ) throws IOException
// Note: different setups can be used if specific things need to be done for the solve or certain blocks
final AffineDistributedSolver solverSetup = new AffineDistributedSolver( cmdLineSetup, renderSetup );

solverSetup.setupSolve( cmdLineSetup.blockModel(), cmdLineSetup.stitchingModel() );
final ArrayList< ? extends AffineAlignBlockWorker<?, ?, ZBlockFactory > > workers =
solverSetup.setupSolve( cmdLineSetup.blockModel(), cmdLineSetup.stitchingModel() );

try
{
workers.get( 0 ).run();
System.out.println( workers.get( 0 ).getBlockDataList().size() );
} catch (IOException | ExecutionException | InterruptedException | NoninvertibleModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public < M extends Model< M > & Affine2D< M >, S extends Model< S > & Affine2D< S > > void setupSolve(
public < M extends Model< M > & Affine2D< M >, S extends Model< S > & Affine2D< S > >
ArrayList< AffineAlignBlockWorker<M, S, ZBlockFactory > > setupSolve(
final M blockModel,
final S stitchingModel )
{
Expand All @@ -103,18 +114,13 @@ public < M extends Model< M > & Affine2D< M >, S extends Model< S > & Affine2D<
//
// create workers
//
final ArrayList< AffineAlignBlockWorker<M, S, ZBlockFactory > > workers = new ArrayList<>();

for ( final BlockData< M, AffineModel2D, FIBSEMAlignmentParameters< M, S >, ZBlockFactory > block : col.allBlocks() )
{
workers.add( new AffineAlignBlockWorker<>( block, col.maxId() + 1, cmdLineSetup.threadsWorker ) );
}
return createWorkers( col );
}

protected ZBlockFactory setupBlockFactory()
{
final int minZ = (int)Math.round( renderSetup.minZ );
final int maxZ = 5000;//(int)Math.round( runParameters.maxZ );
final int maxZ = (int)Math.round( renderSetup.maxZ );
final int blockSize = cmdLineSetup.blockSize;
final int minBlockSize = cmdLineSetup.minBlockSize;

Expand Down Expand Up @@ -162,4 +168,17 @@ protected < M extends Model< M > & Affine2D< M >, S extends Model< S > & Affine2

return col;
}

protected < M extends Model< M > & Affine2D< M >, S extends Model< S > & Affine2D< S > > ArrayList< AffineAlignBlockWorker<M, S, ZBlockFactory > > createWorkers(
final BlockCollection< M, AffineModel2D, FIBSEMAlignmentParameters< M, S >, ZBlockFactory > col )
{
final ArrayList< AffineAlignBlockWorker<M, S, ZBlockFactory > > workers = new ArrayList<>();

for ( final BlockData< M, AffineModel2D, FIBSEMAlignmentParameters< M, S >, ZBlockFactory > block : col.allBlocks() )
{
workers.add( new AffineAlignBlockWorker<>( block, col.maxId() + 1, cmdLineSetup.threadsWorker ) );
}

return workers;
}
}

0 comments on commit b8eee7d

Please sign in to comment.