Skip to content

Commit e330475

Browse files
rschwanholdbulldozer-boy[bot]
authored andcommitted
Allow providing a specific target mag for downsampling anisotropically (#143)
* provide possibility to downsample all magnifications until a target magnification * update description of the anisotropic_target_mag parameter * rename method
1 parent 3e68ab4 commit e330475

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

wkcuber/downsampling.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ def determine_buffer_edge_len(dataset):
3838
return min(DEFAULT_EDGE_LEN, dataset.header.file_len * dataset.header.block_len)
3939

4040

41+
def calculate_virtual_scale_for_target_mag(target_mag):
42+
"This scale is not the actual scale of the dataset"
43+
"The virtual scale is used for downsample_mags_anisotropic."
44+
max_target_value = max(list(target_mag.to_array()))
45+
scale_array = max_target_value / np.array(target_mag.to_array())
46+
return tuple(scale_array)
47+
48+
4149
class InterpolationModes(Enum):
4250
MEDIAN = 0
4351
MODE = 1
@@ -84,8 +92,8 @@ def create_parser():
8492

8593
group.add_argument(
8694
"--anisotropic_target_mag",
87-
help="Specify an explicit anisotropic target magnification which should be "
88-
"created (e.g., --anisotropic_target_mag 2-2-1). Consider using --anisotropic "
95+
help="Specify an explicit anisotropic target magnification (e.g., --anisotropic_target_mag 16-16-4)."
96+
"All magnifications until this target magnification will be created. Consider using --anisotropic "
8997
"instead which automatically creates multiple anisotropic magnifications depending "
9098
"on the dataset's scale",
9199
type=str,
@@ -645,11 +653,14 @@ def detect_larger_and_smaller_dimension(scale):
645653
if args.anisotropic_target_mag:
646654
anisotropic_target_mag = Mag(args.anisotropic_target_mag)
647655

648-
downsample_mag(
656+
scale = calculate_virtual_scale_for_target_mag(anisotropic_target_mag)
657+
658+
downsample_mags_anisotropic(
649659
args.path,
650660
args.layer_name,
651661
from_mag,
652662
anisotropic_target_mag,
663+
scale,
653664
args.interpolation_mode,
654665
not args.no_compress,
655666
args.buffer_cube_size,

wkcuber/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ def add_isotropic_flag(parser):
8282
action="store_true",
8383
)
8484

85-
parser.set_defaults(anisotropic=False)
86-
8785

8886
def add_interpolation_flag(parser):
8987
parser.add_argument(

0 commit comments

Comments
 (0)