Skip to content

Commit

Permalink
add excludePairsWithTileIdPattern parameter to match copy clients
Browse files Browse the repository at this point in the history
  • Loading branch information
trautmane committed Apr 30, 2024
1 parent 50571c9 commit be048a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import org.janelia.alignment.match.CanvasMatches;
import org.janelia.alignment.match.MatchAggregator;
Expand Down Expand Up @@ -57,7 +58,7 @@ private void copyMatches(final Parameters parameters)
final RenderDataClient sourceMatchClient = parameters.matchClient.getDataClient();
final RenderDataClient targetMatchClient = parameters.matchCopy.buildTargetMatchClient(sourceMatchClient);
final List<String> pGroupIds;
if ((parameters.matchCopy.pGroupIds == null) || (parameters.matchCopy.pGroupIds.size() == 0)) {
if ((parameters.matchCopy.pGroupIds == null) || parameters.matchCopy.pGroupIds.isEmpty()) {
pGroupIds = sourceMatchClient.getMatchPGroupIds();
} else {
pGroupIds = parameters.matchCopy.pGroupIds;
Expand All @@ -73,15 +74,31 @@ public static void copyMatches(final RenderDataClient sourceMatchClient,
final String pGroupId,
final MatchCopyParameters matchCopy) throws Exception {

final List<CanvasMatches> groupMatches =
sourceMatchClient.getMatchesWithPGroupId(pGroupId, false);
List<CanvasMatches> groupMatches = sourceMatchClient.getMatchesWithPGroupId(pGroupId, false);

if (groupMatches.size() > 0) {
if (! groupMatches.isEmpty()) {

if (matchCopy.removeExisting) {
targetMatchClient.deleteMatchesWithPGroupId(pGroupId);
}

if (matchCopy.excludePairsWithTileIdPattern != null) {
final Pattern excludePattern = Pattern.compile(matchCopy.excludePairsWithTileIdPattern);
final List<CanvasMatches> matchesToKeep = new ArrayList<>(groupMatches.size());
final long originalPairCount = groupMatches.size();
for (final CanvasMatches match : groupMatches) {
final String pTileId = match.getpId();
final String qTileId = match.getqId();
if (! excludePattern.matcher(pTileId).matches() && ! excludePattern.matcher(qTileId).matches()) {
matchesToKeep.add(match);
}
}
groupMatches = matchesToKeep;

LOG.info("copyMatches: reduced {} to {} pairs that do not include a tileId with the pattern {}",
originalPairCount, groupMatches.size(), matchCopy.excludePairsWithTileIdPattern);
}

if (matchCopy.isAggregationRequested()) {
final long originalMatchCount = countMatches(groupMatches);
aggregateMatches(groupMatches, matchCopy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public class MatchCopyParameters
description = "Pixel radius for cross layer match filtering")
public Double matchAggregationRadiusCross;

@Parameter(
names = "--excludePairsWithTileIdPattern",
description = "Do not copy match pairs that include at least one tile with an ID matching this pattern, " +
"e.g. .*_0000(01|02|03|04|07|08|12|13|16|17|18|19)_.*",
variableArity = true)
public String excludePairsWithTileIdPattern;

public MatchCopyParameters() {
}

Expand Down

0 comments on commit be048a7

Please sign in to comment.