Skip to content

Commit

Permalink
fix bug with extremely anisotropic volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
ylep committed May 17, 2018
1 parent e0cab41 commit 92264c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/neuroglancer_scripts/accessor.py
Expand Up @@ -86,8 +86,6 @@ class Accessor:
pre-computed dataset. It works with sequences of bytes, without
interpreting the file contents.
.. todo:: add I/O for auxiliary files (e.g. mesh fragments)
You can inherit from this class in order to implement a new accessor (see
:class:`~neuroglancer_scripts.file_accessor.FileAccessor`,
:class:`~neuroglancer_scripts.http_accessor.HttpAccessor`).
Expand Down
16 changes: 15 additions & 1 deletion src/neuroglancer_scripts/dyadic_pyramid.py
Expand Up @@ -10,7 +10,7 @@
import numpy as np
from tqdm import tqdm

from neuroglancer_scripts.utils import (LENGTH_UNITS, format_length)
from neuroglancer_scripts.utils import (LENGTH_UNITS, ceil_div, format_length)


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -99,8 +99,22 @@ def downscale_info(scale_level):
anisotropy_factors = [max(0, max_delay - delay - scale_level)
for delay in axis_level_delays]
sum_anisotropy_factors = sum(anisotropy_factors)

# Ensure that the smallest chunk size is 1 for extremely anisotropic
# datasets (i.e. reduce the anisotropy of chunk_size)
excess_anisotropy = sum_anisotropy_factors - 3 * target_chunk_exponent
if excess_anisotropy > 0:
anisotropy_reduction = ceil_div(excess_anisotropy,
sum(1 for f in anisotropy_factors
if f != 0))
anisotropy_factors = [max(f - anisotropy_reduction, 0)
for f in anisotropy_factors]
sum_anisotropy_factors = sum(anisotropy_factors)
assert sum_anisotropy_factors <= 3 * target_chunk_exponent

base_chunk_exponent = (
target_chunk_exponent - (sum_anisotropy_factors + 1) // 3)
assert base_chunk_exponent >= 0
scale_info["chunk_sizes"] = [
[2 ** (base_chunk_exponent + anisotropy_factor)
for anisotropy_factor in anisotropy_factors]]
Expand Down

0 comments on commit 92264c9

Please sign in to comment.