Skip to content

Enable hdf5 mapping in isosurface computation #4531

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

Merged
merged 8 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- Added support for ID mapping of segmentation layer based on HDF5 agglomerate files. [#4469](https://github.com/scalableminds/webknossos/pull/4469)
- Added option to hide all unmapped segments to segmentation tab. [#4510](https://github.com/scalableminds/webknossos/pull/4510)
- When wK changes datasource-properties.json files of datasets, now it creates a backup log of previous versions. [#4534](https://github.com/scalableminds/webknossos/pull/4534)
- Isosurface generation now also supports hdf5-style mappings. [#4531](https://github.com/scalableminds/webknossos/pull/4531)

### Changed
- Reported datasets can now overwrite existing ones that are reported as missing, this ignores the isScratch precedence. [#4465](https://github.com/scalableminds/webknossos/pull/4465)
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/admin/admin_rest_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ export function computeIsosurface(
segmentId,
// Name of mapping to apply before building isosurface (optional)
mapping: layer.activeMapping,
mappingType: layer.activeMappingType,
// "size" of each voxel (i.e., only every nth voxel is considered in each dimension)
voxelDimensions,
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/javascripts/oxalis/model/data_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DataLayer {
pushQueue: PushQueue;
mappings: Mappings;
activeMapping: ?string;
activeMappingType: MappingType = "JSON";
layerRenderingManager: LayerRenderingManager;
resolutions: Array<Vector3>;
fallbackLayer: ?string;
Expand Down Expand Up @@ -73,6 +74,7 @@ class DataLayer {
progressCallback?: ProgressCallback,
): void {
this.activeMapping = mappingName;
this.activeMappingType = mappingType;
this.mappings.activateMapping(mappingName, mappingType, progressCallback);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,15 @@ class BinaryDataController @Inject()(
(dataSource, dataLayer) <- getDataSourceAndDataLayer(organizationName, dataSetName, dataLayerName)
segmentationLayer <- tryo(dataLayer.asInstanceOf[SegmentationLayer]).toFox ?~> Messages(
"dataLayer.mustBeSegmentation")
isosurfaceRequest = IsosurfaceRequest(dataSource,
segmentationLayer,
request.body.cuboid(dataLayer),
request.body.segmentId,
request.body.voxelDimensions,
request.body.mapping)
isosurfaceRequest = IsosurfaceRequest(
dataSource,
segmentationLayer,
request.body.cuboid(dataLayer),
request.body.segmentId,
request.body.voxelDimensions,
request.body.mapping,
request.body.mappingType
)
// The client expects the isosurface as a flat float-array. Three consecutive floats form a 3D point, three
// consecutive 3D points (i.e., nine floats) form a triangle.
// There are no shared vertices between triangles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ case class WebKnossosIsosurfaceRequest(
cubeSize: Point3D,
segmentId: Long,
voxelDimensions: Vector3I,
mapping: Option[String] = None
mapping: Option[String] = None,
mappingType: Option[String] = None
) {
def cuboid(dataLayer: DataLayer) =
Cuboid(new VoxelPosition(position.x, position.y, position.z, dataLayer.lookUpResolution(zoomStep)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ case class IsosurfaceRequest(
cuboid: Cuboid,
segmentId: Long,
voxelDimensions: Vector3I,
mapping: Option[String] = None
mapping: Option[String] = None,
mappingType: Option[String] = None
)

case class DataTypeFunctors[T, B](
Expand Down Expand Up @@ -59,6 +60,7 @@ class IsosurfaceService @Inject()(
extends FoxImplicits {

val binaryDataService: BinaryDataService = dataServicesHolder.binaryDataService
val agglomerateService: AgglomerateService = binaryDataService.agglomerateService

implicit val timeout: Timeout = Timeout(config.Braingames.Binary.isosurfaceTimeout)

Expand Down Expand Up @@ -95,9 +97,33 @@ class IsosurfaceService @Inject()(
def applyMapping(data: Array[T]): Fox[Array[T]] =
request.mapping match {
case Some(mappingName) =>
mappingService.applyMapping(DataServiceMappingRequest(request.dataSource, request.dataLayer, mappingName),
data,
dataTypeFunctors.fromLong)
request.mappingType match {
case Some("JSON") =>
mappingService.applyMapping(DataServiceMappingRequest(request.dataSource, request.dataLayer, mappingName),
data,
dataTypeFunctors.fromLong)
case _ => Fox.successful(data)
}
case _ =>
Fox.successful(data)
}

def applyAgglomerate(data: Array[Byte]): Fox[Array[Byte]] =
request.mapping match {
case Some(mappingName) =>
request.mappingType match {
case Some("HDF5") =>
val dataRequest = DataServiceDataRequest(
request.dataSource,
request.dataLayer,
request.mapping,
request.cuboid,
DataServiceRequestSettings(halfByte = false, request.mapping, None),
Vector3I(1, 1, 1))
agglomerateService.applyAgglomerate(dataRequest)(data)
case _ =>
Fox.successful(data)
}
case _ =>
Fox.successful(data)
}
Expand Down Expand Up @@ -168,7 +194,8 @@ class IsosurfaceService @Inject()(

for {
data <- binaryDataService.handleDataRequest(dataRequest)
typedData = convertData(data)
agglomerateMappedData <- applyAgglomerate(data)
typedData = convertData(agglomerateMappedData)
mappedData <- applyMapping(typedData)
mappedSegmentId <- applyMapping(Array(typedSegmentId)).map(_.head)
neighbors = findNeighbors(mappedData, dataDimensions, mappedSegmentId)
Expand Down