Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel stream geometryToFilledRoi #49

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,27 @@ public List<PathObject> convertToObjects(Parameters<Mat, Mat> params, Mat output
roisToPathObjectsFunction = getTwoClassBiFunction(classes, rng);
}

List<PathObject> cells;
if (geomMaps.size() == 1) {
// One-channel detected, represent using detection objects
return geomMaps.get(0).values().stream()
.map(geom -> roisToPathObjectsFunction.apply(geometryToFilledROI(geom, plane), null))
cells = geomMaps.get(0).values().parallelStream()
.map(geom -> roisToPathObjectsFunction.
apply(geometryToFilledROI(geom, plane), null))
.collect(Collectors.toList());
} else {
// Two channels detected, represent using cell objects
// We assume that the labels are matched - and we can't have a nucleus without a cell
Map<Number, Geometry> childGeoms = geomMaps.get(0);
Map<Number, Geometry> parentGeoms = geomMaps.get(1);
List<PathObject> cells = new ArrayList<>();
for (var entry : parentGeoms.entrySet()) {
cells = parentGeoms.entrySet().parallelStream().map(entry -> {
var parent = geometryToFilledROI(entry.getValue(), plane);
var child = geometryToFilledROI(childGeoms.getOrDefault(entry.getKey(), null), plane);
var outputObject = roisToPathObjectsFunction.apply(parent, child);
cells.add(outputObject);
}
return cells;
return roisToPathObjectsFunction.apply(parent, child);

}).collect(Collectors.toList());
}
return cells;

}

private static ROI geometryToFilledROI(Geometry geom, ImagePlane plane) {
Expand Down
Loading