Skip to content

Commit

Permalink
Clean up some logging calls
Browse files Browse the repository at this point in the history
  • Loading branch information
minnerbe committed Dec 1, 2023
1 parent 2567a0c commit 72308c1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public XYDistanceWeightFunction(final BlockData<?, ?> block, final double resolu
final Collection<Integer> matchedZLayers = results.getMatchedZLayers();
if (matchedZLayers.isEmpty()) {
final List<String> tileIds = results.getTileIds().stream().sorted().collect(Collectors.toList());
LOG.warn("XYDistanceWeightFunction ctor: block {} results with no matchedZLayers has {} tileIds: {}",
LOG.error("XYDistanceWeightFunction ctor: block {} results with no matchedZLayers has {} tileIds: {}",
block, tileIds.size(), tileIds);
throw new IllegalStateException("block " + block + " has no matched z layers");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ private static RenderSetup setupSolve(
// a HashMap where int is the z section, and string is the description (problem, restart, ...)
runParams.zToGroupIdMap = new HashMap<>();
for (final String groupId : Arrays.asList("restart", "problem")) { // NOTE: "problem" groupId is for future use
LOG.debug( "Querying: " + groupId );
if (LOG.isDebugEnabled())
LOG.debug("Querying: {}", groupId);
try {
final ResolvedTileSpecCollection groupTileSpecs =
runParams.renderDataClient.getResolvedTiles(stack,
Expand All @@ -174,8 +175,9 @@ private static RenderSetup setupSolve(

final List<Integer> challengeListZ = runParams.zToGroupIdMap.keySet().stream().sorted().collect(Collectors.toList());

LOG.debug("setup: minZ={}, maxZ={}, challenge layers are {}",
minZ.intValue(), maxZ.intValue(), challengeListZ);
if (LOG.isDebugEnabled())
LOG.debug("setup: minZ={}, maxZ={}, challenge layers are {}",
minZ.intValue(), maxZ.intValue(), challengeListZ);

return runParams;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void solveAlternating(final AffineBlockSolverSetup parameters) throws IO
final int nRuns = parameters.alternatingRuns.nRuns;

for (int runNumber = 1; runNumber <= nRuns; runNumber++) {
LOG.info("solveAlternating: run {} of {}", runNumber, nRuns);
LOG.info("solveAlternating: run {} of {}; parameters={}", runNumber, nRuns, parameters);

parameters.targetStack.stack = getStackName(targetStackName, runNumber, nRuns);
DistributedAffineBlockSolver.run(parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public AffineAlignBlockWorker(

// 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 && parameters.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.");
final String msg = "Since you choose to stitch first, you must pre-align with Translation or Rigid.";
LOG.error(msg);
throw new RuntimeException(msg);
}

this.coreTileSpecIds = new HashSet<>(); // will be populated by call to assembleMatchData
Expand Down Expand Up @@ -391,8 +392,8 @@ private static <M extends Model<M> & Affine2D<M>, S extends Model<S> & Affine2D<
for (final Tile<M> groupedTile : groupedTiles) {
final List<Tile<M>> imageTiles = solveItem.groupedTileToTiles().get(groupedTile);

if (groupedTiles.size() > 1)
LOG.info("assignConstantAffineModel: z={} grouped tile [{}] contains {} image tiles.",
if (groupedTiles.size() > 1 && LOG.isDebugEnabled())
LOG.debug("assignConstantAffineModel: z={} grouped tile [{}] contains {} image tiles.",
z, groupedTile, imageTiles.size());

// create pointmatches from the edges of each image in the grouped tile to the respective edges in the metadata
Expand Down Expand Up @@ -424,7 +425,7 @@ private static <M extends Model<M> & Affine2D<M>, S extends Model<S> & Affine2D<
}
LOG.info("assignConstantAffineModel: Error={}", (sumError / matches.size()));
} catch (final Exception e) {
LOG.info("assignConstantAffineModel: Caught exception: ", e);
LOG.warn("assignConstantAffineModel: Caught exception: ", e);
}
}
}
Expand Down Expand Up @@ -463,8 +464,8 @@ private static <M extends Model<M> & Affine2D<M>, S extends Model<S> & Affine2D<
for (final Tile<M> groupedTile : groupedTiles) {
final List<Tile<M>> imageTiles = solveItem.groupedTileToTiles().get(groupedTile);

if (groupedTiles.size() > 1)
LOG.info("assignStabilizingModel: z={} grouped tile [{}] contains {} image tiles.",
if (groupedTiles.size() > 1 && LOG.isDebugEnabled())
LOG.debug("assignStabilizingModel: z={} grouped tile [{}] contains {} image tiles.",
z, groupedTile, imageTiles.size());

// create pointmatches from the edges of each image in the grouped tile to the respective edges in the metadata
Expand Down Expand Up @@ -634,12 +635,12 @@ protected void stitchSectionsAndCreateGroupedTiles(
final TileConfiguration tileConfig = new TileConfiguration();
tileConfig.addTiles( set );

// we always prealign (not sure how far off the current alignment in renderer is)
// we always pre-align (not sure how far off the current alignment in renderer is)
// a simple preAlign suffices for Translation and Rigid as it doesn't matter which Tile is fixed during alignment
try {
tileConfig.preAlign();
} catch (final NotEnoughDataPointsException | IllDefinedDataPointsException e) {
LOG.info("stitchSectionsAndCreateGroupedTiles: block {}: Could not solve prealign for z={}, cause: ",
LOG.warn("stitchSectionsAndCreateGroupedTiles: block {}: Could not solve pre-align for z={}, cause: ",
blockData, z, e);
}

Expand Down Expand Up @@ -667,7 +668,7 @@ protected void stitchSectionsAndCreateGroupedTiles(
LOG.info("stitchSectionsAndCreateGroupedTiles: block {}: Solve z={} avg={}, min={}, max={}",
blockData, z, tileConfig.getError(), tileConfig.getMinError(), tileConfig.getMaxError());
} catch (final Exception e) {
LOG.info("stitchSectionsAndCreateGroupedTiles: block {}: Could not solve stitiching for z={}, cause: ",
LOG.warn("stitchSectionsAndCreateGroupedTiles: block {}: Could not solve stitching for z={}, cause: ",
blockData, z, e);
}
}
Expand All @@ -686,8 +687,10 @@ protected void stitchSectionsAndCreateGroupedTiles(
solveItem.groupedTileToTiles().putIfAbsent( groupedTile, new ArrayList<>() );
solveItem.groupedTileToTiles().get( groupedTile ).add( solveItem.idToTileMap().get( tileId ) );

LOG.info("stitchSectionsAndCreateGroupedTiles: block {}: TileId {} Model= {}", blockData, tileId, affine);
LOG.info("stitchSectionsAndCreateGroupedTiles: block {}: TileId {} prev Model={}", blockData, tileId, solveItem.idToPreviousModel().get(tileId));
if (LOG.isDebugEnabled()) {
LOG.debug("stitchSectionsAndCreateGroupedTiles: block {}: TileId {} Model= {}", blockData, tileId, affine);
LOG.debug("stitchSectionsAndCreateGroupedTiles: block {}: TileId {} prev Model={}", blockData, tileId, solveItem.idToPreviousModel().get(tileId));
}
}

// Hack: show a section after alignment
Expand All @@ -705,7 +708,7 @@ protected void stitchSectionsAndCreateGroupedTiles(
final ImagePlus imp1 = VisualizeTools.renderTS(models, blockData.rtsc().getTileIdToSpecMap(), 0.15);
imp1.setTitle( "z=" + z );
} catch (final NoninvertibleModelException e) {
LOG.info("stitchSectionsAndCreateGroupedTiles: Could not show section: ", e);
LOG.warn("stitchSectionsAndCreateGroupedTiles: Could not show section: ", e);
}
}
}
Expand All @@ -724,7 +727,8 @@ protected void stitchSectionsAndCreateGroupedTiles(
solveItem.groupedTileToTiles().putIfAbsent( groupedTile, new ArrayList<>() );
solveItem.groupedTileToTiles().get( groupedTile ).add( solveItem.idToTileMap().get( tileId ) );

LOG.info("stitchSectionsAndCreateGroupedTiles: block {}: Single TileId {}", blockData, tileId);
if (LOG.isDebugEnabled())
LOG.debug("stitchSectionsAndCreateGroupedTiles: block {}: Single TileId {}", blockData, tileId);
}
}
}
Expand All @@ -735,7 +739,7 @@ protected void stitchSectionsAndCreateGroupedTiles(
final Set<String> solveItemOnlyTileIds = new HashSet<>(solveItemTileIdsForConsistencyCheck);
solveItemOnlyTileIds.removeAll(blockResults.getTileIds());
if (blockOnlyTileIds.isEmpty() && solveItemOnlyTileIds.isEmpty()) {
LOG.debug("stitchSectionsAndCreateGroupedTiles: exit, tileIds are consistent");
LOG.info("stitchSectionsAndCreateGroupedTiles: exit, tileIds are consistent");
} else {
// log error in worker thread before throwing exception that will get logged in main/driver thread
final String errorMsg = "inconsistent tileIds for block " + blockData.toDetailsString() +
Expand Down Expand Up @@ -936,18 +940,18 @@ protected void solve(
tileIdToGroupModel.put(tileId, model.createAffineModel2D());
}

Collections.sort( tileIds );

for (final String tileId : tileIds )
{
final AffineModel2D affine = solveItem.idToStitchingModel().get( tileId ).copy();
Collections.sort(tileIds);

affine.preConcatenate( tileIdToGroupModel.get( tileId ) );
for (final String tileId : tileIds) {
final AffineModel2D stitchingModel = solveItem.idToStitchingModel().get(tileId).copy();
final AffineModel2D groupModel = tileIdToGroupModel.get(tileId);

LOG.info("solve: block {}: grouped model for tile {} is {}", blockData, tileId, tileIdToGroupModel.get(tileId));
stitchingModel.preConcatenate(groupModel);
blockResults.recordModel(tileId, stitchingModel);

blockResults.recordModel(tileId, affine);
LOG.info("solve: block {}: tile {} model from grouped tile is {}", blockData, tileId, affine);
if (LOG.isDebugEnabled())
LOG.debug("solve: block {}: grouped model for tile {} is {}, final model is {}",
blockData, tileId, groupModel, stitchingModel);
}
}

Expand Down Expand Up @@ -981,7 +985,7 @@ private void preAlign(
}
// TODO: else they should be in the right position
} catch (final NotEnoughDataPointsException | IllDefinedDataPointsException e) {
LOG.info("block {}: prealign failed: ", inputSolveItem.blockData(), e);
LOG.warn("block {}: pre-align failed: ", inputSolveItem.blockData(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public AffineIntensityCorrectionBlockWorker(
public List<BlockData<ArrayList<AffineModel1D>, FIBSEMIntensityCorrectionParameters<M>>> call()
throws IOException, ExecutionException, InterruptedException, NoninvertibleModelException {

LOG.info("AffineIntensityCorrectionBlockWorker: entry, blockData={}", blockData);
fetchResolvedTiles();
final List<TileSpec> wrappedTiles = AdjustBlock.sortTileSpecs(blockData.rtsc());

Expand Down

0 comments on commit 72308c1

Please sign in to comment.