From 5a97a7b8314e21ad21402c5fb7ef4a2936a66bd1 Mon Sep 17 00:00:00 2001 From: "kai.schleicher@unibas.ch" Date: Mon, 18 Aug 2025 10:43:15 +0200 Subject: [PATCH 1/6] Fix function to not split time points by default --- src/imcflibs/imagej/bdv.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 5cc7b412..af592c8f 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -846,6 +846,12 @@ def define_dataset_auto( hdf5_chunk_sizes = "hdf5_chunk_sizes=" + hdf5_chunk_sizes + " " else: hdf5_chunk_sizes = "" + if timepoints_per_partition > 0: + split_timepoints = "split_hdf5 timepoints_per_partition=" + str( + timepoints_per_partition + ) + else: + split_timepoints = "" if bf_series_type == "Angles": angle_rotation = "apply_angle_rotation " @@ -883,9 +889,7 @@ def define_dataset_auto( + angle_rotation + subsampling_factors + hdf5_chunk_sizes - + "split_hdf5 " - + "timepoints_per_partition=" - + str(timepoints_per_partition) + + split_timepoints + " " + "setups_per_partition=0 " + "use_deflate_compression " From adfb659874aef4ebd4746470e585fdcce8c65754 Mon Sep 17 00:00:00 2001 From: Kai Schleicher Date: Wed, 14 Jan 2026 15:16:36 +0100 Subject: [PATCH 2/6] Set default timepoints per partition to 0 --- 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 af592c8f..75904b3a 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -789,7 +789,7 @@ def define_dataset_auto( file_path, bf_series_type, dataset_save_path=None, - timepoints_per_partition=1, + timepoints_per_partition=0, resave="Re-save as multiresolution HDF5", subsampling_factors=None, hdf5_chunk_sizes=None, From 60d87565aca99cc61ee0b475d9928ca7481492af Mon Sep 17 00:00:00 2001 From: Kai Schleicher Date: Wed, 14 Jan 2026 15:17:16 +0100 Subject: [PATCH 3/6] Clarify file splitting behavior in the docstring --- src/imcflibs/imagej/bdv.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 75904b3a..88553892 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -812,8 +812,9 @@ def define_dataset_auto( Defines how Bio-Formats interprets the series. timepoints_per_partition : int, optional Split the output dataset by timepoints. Use `0` for no split, resulting - in a single HDF5 file containing all timepoints. By default `1`, - resulting in a HDF5 per timepoints. + in a single HDF5 file containing all timepoints. Otherwise, choose the + number of timepoints per file. By default `0`. + resave : str, optional Allow the function to either re-save the images or simply create a merged xml. Use `Load raw data` to avoid re-saving, by default `Re-save From d653d5ae3f9f69b81abcdccf5a920622cc7d128d Mon Sep 17 00:00:00 2001 From: Kai Schleicher Date: Wed, 21 Jan 2026 14:52:53 +0100 Subject: [PATCH 4/6] Remove unexpected lines due to new default value --- tests/bdv/test_define_dataset_auto.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/bdv/test_define_dataset_auto.py b/tests/bdv/test_define_dataset_auto.py index c10b973c..2ffab068 100644 --- a/tests/bdv/test_define_dataset_auto.py +++ b/tests/bdv/test_define_dataset_auto.py @@ -95,6 +95,17 @@ def test_define_dataset_auto_tile(tmp_path, caplog): + result_folder + "] " + "check_stack_sizes " + + "setups_per_partition=0 " + + "use_deflate_compression " + ) + + # Construct the final call to ImageJ + final_call = "IJ.run(cmd=[%s], params=[%s])" % (cmd, options) + + # Define the dataset using the "Auto-Loader" option + bdv.define_dataset_auto(project_filename, file_info["path"], bf_series_type) + # Check if the final call is in the log + assert final_call == caplog.messages[0] + "split_hdf5 " + "timepoints_per_partition=1 " + "setups_per_partition=0 " @@ -160,8 +171,6 @@ def test_define_dataset_auto_angle(tmp_path, caplog): + "] " + "check_stack_sizes " + "apply_angle_rotation " - + "split_hdf5 " - + "timepoints_per_partition=1 " + "setups_per_partition=0 " + "use_deflate_compression " ) From 22353f440bcf922163bc3735133ee2828a2c1a0a Mon Sep 17 00:00:00 2001 From: Kai Schleicher Date: Wed, 21 Jan 2026 14:53:44 +0100 Subject: [PATCH 5/6] Add new test for splitting timepoints --- tests/bdv/test_define_dataset_auto.py | 53 ++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tests/bdv/test_define_dataset_auto.py b/tests/bdv/test_define_dataset_auto.py index 2ffab068..b8bf97eb 100644 --- a/tests/bdv/test_define_dataset_auto.py +++ b/tests/bdv/test_define_dataset_auto.py @@ -106,6 +106,57 @@ def test_define_dataset_auto_tile(tmp_path, caplog): bdv.define_dataset_auto(project_filename, file_info["path"], bf_series_type) # Check if the final call is in the log assert final_call == caplog.messages[0] + + +def test_define_dataset_auto_tile_split_timepoints(tmp_path, caplog): + """Test automatic dataset definition method for tile series. + + Parameters + ---------- + tmp_path : pytest.fixture + Temporary path for the test. + caplog : pytest.fixture + Log capturing fixture. + """ + + # Set the logging level to capture warnings + caplog.set_level(logging.WARNING) + # Clear the log + caplog.clear() + + # Define the project and file names + project_filename = "proj_name" + file_path = tmp_path + file_info = pathtools.parse_path(file_path) + + # Define the result and dataset save paths + result_folder = pathtools.join2(file_info["path"], project_filename) + + # Default settings + + # Define the type of Bio-Formats series + bf_series_type = "Tiles" + + # Define the ImageJ command + cmd = "Define Multi-View Dataset" + + # Set the default values for dataset definitions + options = set_default_values(project_filename, file_info["path"]) + + # Construct the options for dataset definitions + options = ( + options + + "how_to_store_input_images=[" + + "Re-save as multiresolution HDF5" + + "] " + + "load_raw_data_virtually " + + "metadata_save_path=[" + + result_folder + + "] " + + "image_data_save_path=[" + + result_folder + + "] " + + "check_stack_sizes " + "split_hdf5 " + "timepoints_per_partition=1 " + "setups_per_partition=0 " @@ -116,7 +167,7 @@ def test_define_dataset_auto_tile(tmp_path, caplog): final_call = "IJ.run(cmd=[%s], params=[%s])" % (cmd, options) # Define the dataset using the "Auto-Loader" option - bdv.define_dataset_auto(project_filename, file_info["path"], bf_series_type) + bdv.define_dataset_auto(project_filename, file_info["path"], bf_series_type, timepoints_per_partition=1) # Check if the final call is in the log assert final_call == caplog.messages[0] From 8a2c29579ced73de548e10fd7a6bdc35efc361e1 Mon Sep 17 00:00:00 2001 From: Kai Schleicher Date: Wed, 21 Jan 2026 14:59:23 +0100 Subject: [PATCH 6/6] Move space position to conditional to avoid duplication --- src/imcflibs/imagej/bdv.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index a6d083ab..63815b27 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -868,7 +868,7 @@ def define_dataset_auto( if timepoints_per_partition > 0: split_timepoints = "split_hdf5 timepoints_per_partition=" + str( timepoints_per_partition - ) + ) + " " else: split_timepoints = "" @@ -909,7 +909,6 @@ def define_dataset_auto( + subsampling_factors + hdf5_chunk_sizes + split_timepoints - + " " + "setups_per_partition=0 " + "use_deflate_compression " )