Skip to content

Commit

Permalink
catch the case where StitchFirst is combined with no PreAlign
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPreibisch committed Aug 14, 2023
1 parent 4f0b6b7 commit faec005
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.janelia.render.client.newsolver.BlockData;
import org.janelia.render.client.newsolver.blockfactories.BlockFactory;
import org.janelia.render.client.newsolver.blocksolveparameters.FIBSEMAlignmentParameters;
import org.janelia.render.client.newsolver.blocksolveparameters.FIBSEMAlignmentParameters.PreAlign;
import org.janelia.render.client.newsolver.solvers.Worker;
import org.janelia.render.client.solver.ConstantAffineModel2D;
import org.janelia.render.client.solver.DistributedSolveWorker;
Expand Down Expand Up @@ -129,6 +130,13 @@ public AffineAlignBlockWorker(
this.stitchFirst = blockData.solveTypeParameters().minStitchingInliersSupplier() != null;
this.pairs = new ArrayList<>();
this.zToPairs = new HashMap<>();

// NOTE: if you choose to stitch first, you need to pre-align, otherwise, it's OK to use the initial alignment for each tile
if ( stitchFirst && inputSolveItem.blockData().solveTypeParameters().preAlign() == PreAlign.NONE )
{
LOG.error( "Since you choose to stitch first, you must pre-align with Translation or Rigid." );
throw new RuntimeException( "Since you choose to stitch first, you must pre-align with Translation or Rigid." );
}
}

@Override
Expand Down Expand Up @@ -156,7 +164,7 @@ public void run() throws IOException, ExecutionException, InterruptedException,
{
if ( !assignRegularizationModel( solveItem ) )
throw new RuntimeException( "Couldn't regularize. Please check." );
solve( solveItem, zRadiusRestarts, dynamicLambdaFactor, numThreads );
solve( solveItem, zRadiusRestarts, numThreads );
}

for ( final AffineBlockDataWrapper< M, S, F > solveItem : solveItems )
Expand Down Expand Up @@ -831,9 +839,8 @@ else if ( graphs.size() == 1 )
}

protected void solve(
final SolveItem< G,M,S > solveItem,
final AffineBlockDataWrapper< M, S, F > solveItem,
final int zRadiusRestarts,
final double dynamicLambdaFactor,
final int numThreads
) throws InterruptedException, ExecutionException
{
Expand All @@ -842,14 +849,14 @@ protected void solve(
// new HashSet because all tiles link to their common group tile, which is therefore present more than once
tileConfig.addTiles( new HashSet<>( solveItem.tileToGroupedTile().values() ) );

LOG.info("block " + solveItem.getId() + ": run: optimizing {} tiles", solveItem.groupedTileToTiles().keySet().size() );
LOG.info("block " + solveItem.blockData().getId() + ": run: optimizing {} tiles", solveItem.groupedTileToTiles().keySet().size() );

final HashMap< Tile< ? >, Double > tileToDynamicLambda = SolveTools.computeMetaDataLambdas( tileConfig.getTiles(), solveItem, zRadiusRestarts, excludeFromRegularization, dynamicLambdaFactor );

if ( rigidPreAlign )
LOG.info( "block " + solveItem.getId() + ": prealigning with rigid and no dynamic lambda" );
LOG.info( "block " + solveItem.blockData().getId() + ": prealigning with rigid" );
else
LOG.info( "block " + solveItem.getId() + ": prealigning with translation and no dynamic lambda" );
LOG.info( "block " + solveItem.blockData().getId() + ": prealigning with translation" );

for (final Tile< ? > tile : tileConfig.getTiles() )
{
Expand Down Expand Up @@ -882,15 +889,15 @@ protected void solve(
}
catch (final NotEnoughDataPointsException | IllDefinedDataPointsException e)
{
LOG.info( "block " + solveItem.getId() + ": prealign failed: " + e );
LOG.info( "block " + solveItem.blockData().getId() + ": prealign failed: " + e );
e.printStackTrace();
}

LOG.info( "block " + solveItem.getId() + ": lambda's used (rigid, translation):" );
LOG.info( "block " + solveItem.blockData().getId() + ": lambda's used (rigid, translation):" );

for ( int l = 0; l < blockOptimizerLambdasRigid.size(); ++l )
{
LOG.info( "block " + solveItem.getId() + ": l=" + blockOptimizerLambdasRigid.get( l ) + ", " + blockOptimizerLambdasTranslation.get( l ) );
LOG.info( "block " + solveItem.blockData().getId() + ": l=" + blockOptimizerLambdasRigid.get( l ) + ", " + blockOptimizerLambdasTranslation.get( l ) );
}

for ( int s = 0; s < blockOptimizerIterations.size(); ++s )
Expand Down

0 comments on commit faec005

Please sign in to comment.