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

Fix parsing failure in import of ngff zarr datasets with translation transforms #6621

Merged
merged 2 commits into from
Nov 10, 2022
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.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