Skip to content

Commit

Permalink
Make scale parameter required (#116)
Browse files Browse the repository at this point in the history
* make scale parameter required and remove scale parameter from downsampling tool

* remove scale parameter from tests as well

* ensure an initial datasource-properties.json is written directly after cubing and refreshed again after downsampling

* do meta data generation test directly after cubing so that downsampling can access the datasource properties
  • Loading branch information
philippotto authored and normanrz committed Aug 12, 2019
1 parent 4859954 commit 537f13b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:
name: Test simple tiff cubing (no compression)
command: tests/scripts/simple_tiff_cubing_no_compression.sh

- run:
name: Test metadata generation
command: tests/scripts/meta_generation.sh

- run:
name: Test KNOSSOS conversion
command: tests/scripts/knossos_conversion.sh
Expand All @@ -89,10 +93,6 @@ jobs:
name: Test in-place compression
command: tests/scripts/in_place_compression.sh

- run:
name: Test metadata generation
command: tests/scripts/meta_generation.sh

- run:
name: Remove reference magnification data
command: rm -r testdata/tiff_mag_2_reference/
Expand Down
1 change: 0 additions & 1 deletion tests/scripts/anisotropic_downsampling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ docker run \
--max 16 \
--buffer_cube_size 128 \
--layer_name color \
--scale 11.24,11.24,25 \
/testoutput/tiff
[ -d testoutput/tiff/color/8-8-2 ]
[ -d testoutput/tiff/color/16-16-4 ]
Expand Down
1 change: 0 additions & 1 deletion tests/scripts/simple_anisotropic_tiff_cubing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ docker run \
--batch_size 8 \
--layer_name color \
--max 8 \
--scale 11.24,25,11.24 \
--name awesome_data \
/testdata/tiff /testoutput/tiff3
[ -d testoutput/tiff3/color ]
Expand Down
18 changes: 10 additions & 8 deletions wkcuber/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DEFAULT_EDGE_LEN,
)
from .compress import compress_mag_inplace
from .metadata import write_webknossos_metadata
from .metadata import write_webknossos_metadata, refresh_metadata
from .utils import add_isotropic_flag, setup_logging, add_scale_flag
from .mag import Mag

Expand Down Expand Up @@ -50,6 +50,14 @@ def create_parser():
args,
)

write_webknossos_metadata(
args.target_path,
args.name,
scale,
compute_max_id=False,
exact_bounding_box=bounding_box,
)

if not args.no_compress:
compress_mag_inplace(args.target_path, args.layer_name, Mag(1), args)

Expand Down Expand Up @@ -78,10 +86,4 @@ def create_parser():
args,
)

write_webknossos_metadata(
args.target_path,
args.name,
scale,
compute_max_id=False,
exact_bounding_box=bounding_box,
)
refresh_metadata(args.target_path)
25 changes: 10 additions & 15 deletions wkcuber/downsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
get_executor_for_args,
wait_and_ensure_success,
add_isotropic_flag,
add_scale_flag,
setup_logging,
)

Expand Down Expand Up @@ -109,7 +108,6 @@ def create_parser():
action="store_true",
)

add_scale_flag(parser)
add_verbose_flag(parser)
add_isotropic_flag(parser)
add_distribution_flags(parser)
Expand Down Expand Up @@ -604,9 +602,7 @@ def detect_larger_and_smaller_dimension(scale):

from_mag = Mag(args.from_mag)
max_mag = Mag(args.max)
scale = (
[float(x) for x in args.scale.split(",")] if hasattr(args, "scale") else None
)

if args.anisotropic_target_mag:
anisotropic_target_mag = Mag(args.anisotropic_target_mag)

Expand All @@ -621,16 +617,15 @@ def detect_larger_and_smaller_dimension(scale):
args,
)
elif not args.isotropic:
if scale is None:
try:
scale = read_datasource_properties(args.path)["scale"]
except Exception as exc:
logging.error(
"Could not determine scale which is necessary "
"to find target magnifications for anisotropic downsampling. "
"Does the provided dataset have a datasource-properties.json file?"
)
raise exc
try:
scale = read_datasource_properties(args.path)["scale"]
except Exception as exc:
logging.error(
"Could not determine scale which is necessary "
"to find target magnifications for anisotropic downsampling. "
"Does the provided dataset have a datasource-properties.json file?"
)
raise exc

downsample_mags_anisotropic(
args.path,
Expand Down
2 changes: 1 addition & 1 deletion wkcuber/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def add_scale_flag(parser):
"--scale",
"-s",
help="Scale of the dataset (e.g. 11.2,11.2,25). This is the size of one voxel in nm.",
default="1,1,1",
required=True,
)


Expand Down

0 comments on commit 537f13b

Please sign in to comment.