From 263dd332354a4f7e032bed1a10399b6fde072cdc Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Mon, 19 Jan 2026 11:06:58 +0100 Subject: [PATCH 1/3] fix(bdv): correct channel_source default value and error handling * Set default value of channel_source to 0 in duplicate_transformations function. * Update error handling to raise ValueError instead of exiting the program. * Adjust logic to handle channel_source correctly when generating source string. --- src/imcflibs/imagej/bdv.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 5cc7b412..02efdd5d 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -21,7 +21,6 @@ from .. import pathtools from ..log import LOG as log - # internal template strings used in string formatting (note: the `"""@private"""` # pseudo-decorator is there to instruct [pdoc] to omit those variables when generating # API documentation): @@ -1373,7 +1372,7 @@ def interest_points_registration( def duplicate_transformations( project_path, transformation_type="channel", - channel_source=None, + channel_source=0, tile_source=None, transformation_to_use="[Replace all transformations]", ): @@ -1412,7 +1411,10 @@ def duplicate_transformations( if transformation_type == "channel": apply = "[One channel to other channels]" target = "[All Channels]" - source = str(channel_source - 1) + if channel_source > 0: + source = str(channel_source - 1) + else: + source = "0" if tile_source: tile_apply = "apply_to_tile=[Single tile (Select from List)] " tile_process = "processing_tile=[tile " + str(tile_source) + "] " @@ -1422,7 +1424,7 @@ def duplicate_transformations( apply = "[One tile to other tiles]" target = "[All Tiles]" source = str(tile_source) - if channel_source: + if channel_source > 0: chnl_apply = "apply_to_channel=[Single channel (Select from List)] " chnl_process = ( "processing_channel=[channel " + str(channel_source - 1) + "] " @@ -1430,7 +1432,7 @@ def duplicate_transformations( else: chnl_apply = "apply_to_channel=[All channels] " else: - sys.exit("Issue with transformation duplication") + raise ValueError("Issue with transformation duplication") options = ( "apply=" From d02ebcfb74d7349965f8aa8f1d3579e18d5604fb Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Mon, 19 Jan 2026 13:31:55 +0100 Subject: [PATCH 2/3] Update error message for invalid transformation type --- src/imcflibs/imagej/bdv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 02efdd5d..c8c4232b 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -1432,7 +1432,7 @@ def duplicate_transformations( else: chnl_apply = "apply_to_channel=[All channels] " else: - raise ValueError("Issue with transformation duplication") + raise ValueError("Invalid transformation type: %s" % transformation_type) options = ( "apply=" From ec9ab9e0ac3a1e17773f077e1f245bd574310e13 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Mon, 19 Jan 2026 13:44:55 +0100 Subject: [PATCH 3/3] Merge back readability changes from commit b8ff579 --- src/imcflibs/imagej/bdv.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 573f298b..d18b2b3d 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -1427,10 +1427,8 @@ def duplicate_transformations( target = "[All Tiles]" source = str(tile_source) if channel_source > 0: - chnl_apply = "apply_to_channel=[Single channel (Select from List)] " - chnl_process = ( - "processing_channel=[channel " + str(channel_source - 1) + "] " - ) + ch_apply = "apply_to_channel=[Single channel (Select from List)] " + ch_process = "processing_channel=[channel " + str(channel_source - 1) + "] " else: ch_apply = "apply_to_channel=[All channels] " else: