Skip to content

Commit

Permalink
minor tweaks to Forrest's stack channel names solution
Browse files Browse the repository at this point in the history
  • Loading branch information
trautmane committed Oct 25, 2017
1 parent 60d66f5 commit eb66b5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.janelia.alignment.spec.stack;

import java.io.Serializable;
import java.util.Set;

import org.janelia.alignment.json.JsonUtils;
import org.janelia.alignment.spec.Bounds;
import java.util.ArrayList;

/**
* Derived stats for a stack.
Expand All @@ -23,7 +23,7 @@ public class StackStats
private final Integer maxTileWidth;
private final Integer minTileHeight;
private final Integer maxTileHeight;
private final ArrayList channels;
private final Set<String> channelNames;

// no-arg constructor needed for JSON deserialization
@SuppressWarnings("unused")
Expand All @@ -37,28 +37,9 @@ private StackStats() {
this.maxTileWidth = null;
this.minTileHeight = null;
this.maxTileHeight = null;
this.channels = null;
}
public StackStats(final Bounds stackBounds,
final Long sectionCount,
final Long nonIntegralSectionCount,
final Long tileCount,
final Long transformCount,
final Integer minTileWidth,
final Integer maxTileWidth,
final Integer minTileHeight,
final Integer maxTileHeight) {
this.stackBounds = stackBounds;
this.sectionCount = sectionCount;
this.nonIntegralSectionCount = nonIntegralSectionCount;
this.tileCount = tileCount;
this.transformCount = transformCount;
this.minTileWidth = minTileWidth;
this.maxTileWidth = maxTileWidth;
this.minTileHeight = minTileHeight;
this.maxTileHeight = maxTileHeight;
this.channels = null;
this.channelNames = null;
}

public StackStats(final Bounds stackBounds,
final Long sectionCount,
final Long nonIntegralSectionCount,
Expand All @@ -68,7 +49,7 @@ public StackStats(final Bounds stackBounds,
final Integer maxTileWidth,
final Integer minTileHeight,
final Integer maxTileHeight,
final ArrayList channels) {
final Set<String> channelNames) {
this.stackBounds = stackBounds;
this.sectionCount = sectionCount;
this.nonIntegralSectionCount = nonIntegralSectionCount;
Expand All @@ -78,7 +59,7 @@ public StackStats(final Bounds stackBounds,
this.maxTileWidth = maxTileWidth;
this.minTileHeight = minTileHeight;
this.maxTileHeight = maxTileHeight;
this.channels = channels;
this.channelNames = channelNames;
}

public Bounds getStackBounds() {
Expand Down Expand Up @@ -116,9 +97,11 @@ public Integer getMinTileHeight() {
public Integer getMaxTileHeight() {
return maxTileHeight;
}
public ArrayList getChannels() {
return channels;

public Set<String> getChannelNames() {
return channelNames;
}

@Override
public String toString() {
return toJson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -1115,9 +1116,9 @@ public StackMetaData ensureIndexesAndDeriveStats(final StackMetaData stackMetaDa
"The aggregation query was " + MongoUtil.fullName(tileCollection) +
".aggregate(" + pipeline + ") .");
}
ArrayList<String> channels = tileCollection.distinct("channels.name",String.class).into(new ArrayList<String>());


final List<String> channelNames = tileCollection.distinct("channels.name", String.class).into(new ArrayList<>());
Collections.sort(channelNames);

final Bounds stackBounds = new Bounds(aggregateResult.get(minXKey, Double.class),
aggregateResult.get(minYKey, Double.class),
Expand All @@ -1140,7 +1141,7 @@ public StackMetaData ensureIndexesAndDeriveStats(final StackMetaData stackMetaDa
maxTileWidth,
minTileHeight,
maxTileHeight,
channels);
new LinkedHashSet<>(channelNames));
stackMetaData.setStats(stats);

LOG.debug("ensureIndexesAndDeriveStats: completed stat derivation for {}, stats={}", stackId, stats);
Expand Down

0 comments on commit eb66b5f

Please sign in to comment.