Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/imcflibs/imagej/bdv.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,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,
Expand All @@ -830,8 +830,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
Expand Down Expand Up @@ -864,6 +865,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 "
Expand Down Expand Up @@ -901,10 +908,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 "
)
Expand Down
66 changes: 63 additions & 3 deletions tests/bdv/test_define_dataset_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,68 @@ def test_define_dataset_auto_tile(tmp_path, caplog):
# 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 "
+ "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]


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
Expand All @@ -105,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]

Expand Down Expand Up @@ -160,8 +222,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 "
)
Expand Down
Loading