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

Use zarr string fill values #7017

Merged
merged 8 commits into from
May 2, 2023
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 @@ -18,6 +18,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Fixed
- Fixed that changing a segment color could lead to a crash. [#7000](https://github.com/scalableminds/webknossos/pull/7000)
- The fill_value property of zarr dataset is now used when it is not a number. [#7017](https://github.com/scalableminds/webknossos/pull/7017)
- Fixed rendering issues on some affected systems that led to "black holes". [#7018](https://github.com/scalableminds/webknossos/pull/7018)
- Fixed a bug that made downloads of public annotations fail occasionally. [#7025](https://github.com/scalableminds/webknossos/pull/7025)
- Added a workaround for a WebGL crash which could appear when a dataset contained many segmentation layers. [#6995](https://github.com/scalableminds/webknossos/pull/6995)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,32 @@ object ArrayDataType extends ExtendedEnumeration {
case ArrayDataType.i1 => 1
case ArrayDataType.u1 => 1
}

def maxValue(dataType: ArrayDataType): Number =
dataType match {
case ArrayDataType.f8 => Double.MaxValue
case ArrayDataType.f4 => Float.MaxValue
case ArrayDataType.i8 => Long.MaxValue
case ArrayDataType.u8 => Long.MaxValue // Max value for primitive datatypes
case ArrayDataType.i4 => Int.MaxValue
case ArrayDataType.u4 => Math.pow(2, 4 * 8).toLong - 1
case ArrayDataType.i2 => Char.MaxValue
case ArrayDataType.u2 => Math.pow(2, 2 * 8).toLong - 1
case ArrayDataType.i1 => Byte.MaxValue
case ArrayDataType.u1 => Math.pow(2, 1 * 8).toLong - 1
}

def minValue(dataType: ArrayDataType): Number =
dataType match {
case ArrayDataType.f8 => Double.MinValue
case ArrayDataType.f4 => Float.MinValue
case ArrayDataType.i8 => Long.MinValue
case ArrayDataType.u8 => 0
case ArrayDataType.i4 => Int.MinValue
case ArrayDataType.u4 => 0
case ArrayDataType.i2 => Char.MinValue
case ArrayDataType.u2 => 0
case ArrayDataType.i1 => Byte.MinValue
case ArrayDataType.u1 => 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait DatasetHeader {
lazy val fillValueNumber: Number =
fill_value match {
case Right(n) => n
case Left(_) => 0 // parsing fill value from string not currently supported
case Left(s) => parseFillValueFromString(s)
}

def boundingBox(axisOrder: AxisOrder): Option[BoundingBox] =
Expand All @@ -48,5 +48,13 @@ trait DatasetHeader {

def isSharded = false

private def parseFillValueFromString(s: String): Number =
s match {
case "NaN" => 0
case "Infinity" => ArrayDataType.maxValue(resolvedDataType)
case "-Infinity" => ArrayDataType.minValue(resolvedDataType)
case _ => 0 // Unsupported fill value does not throw exception
}

def voxelOffset: Array[Int]
}