Skip to content

Commit

Permalink
Fix parsing failure during import of ngff zarr datasets with translat…
Browse files Browse the repository at this point in the history
…ion transforms (#6621)
  • Loading branch information
fm3 authored Nov 10, 2022
1 parent b18635a commit 35c3673
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
### Fixed
- Fixed importing a dataset from disk. [#6615](https://github.com/scalableminds/webknossos/pull/6615)
- Fixed a bug in the dataset import view, where the layer name text field would lose focus after each key press. [#6615](https://github.com/scalableminds/webknossos/pull/6615)
- Fixed importing NGFF Zarr datasets with non-scale transforms. [#6621](https://github.com/scalableminds/webknossos/pull/6621)

### Removed

Expand Down
7 changes: 4 additions & 3 deletions app/models/binary/explore/NgffExplorer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ class NgffExplorer extends RemoteLayerExplorer {
private def extractAndCombineScaleTransforms(coordinateTransforms: List[NgffCoordinateTransformation],
axisOrder: AxisOrder): Vec3Double = {
val filtered = coordinateTransforms.filter(_.`type` == "scale")
val xFactors = filtered.map(_.scale(axisOrder.x))
val yFactors = filtered.map(_.scale(axisOrder.y))
val zFactors = filtered.map(_.scale(axisOrder.z))
val scalesFromTransforms = filtered.flatMap(_.scale)
val xFactors = scalesFromTransforms.map(_(axisOrder.x))
val yFactors = scalesFromTransforms.map(_(axisOrder.y))
val zFactors = scalesFromTransforms.map(_(axisOrder.z))
Vec3Double(xFactors.product, yFactors.product, zFactors.product)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import play.api.libs.json.{Json, OFormat}

import scala.concurrent.ExecutionContext

case class NgffCoordinateTransformation(`type`: String = "scale", scale: List[Double])
case class NgffCoordinateTransformation(`type`: String = "scale", scale: Option[List[Double]])

object NgffCoordinateTransformation {
implicit val jsonFormat: OFormat[NgffCoordinateTransformation] = Json.format[NgffCoordinateTransformation]
Expand Down Expand Up @@ -90,9 +90,9 @@ object NgffMetadata {
def fromNameScaleAndMags(dataLayerName: String, dataSourceScale: Vec3Double, mags: List[Vec3Int]): NgffMetadata = {
val datasets = mags.map(
mag =>
NgffDataset(
path = mag.toMagLiteral(allowScalar = true),
List(NgffCoordinateTransformation(scale = List[Double](1.0) ++ (dataSourceScale * Vec3Double(mag)).toList))))
NgffDataset(path = mag.toMagLiteral(allowScalar = true),
List(NgffCoordinateTransformation(
scale = Some(List[Double](1.0) ++ (dataSourceScale * Vec3Double(mag)).toList)))))
NgffMetadata(multiscales = List(NgffMultiscalesItem(name = Some(dataLayerName), datasets = datasets)))
}

Expand Down

0 comments on commit 35c3673

Please sign in to comment.