diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 4c037308..89481a23 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -11,7 +11,7 @@ on: - "*" pull_request: branches: - - main + - "*" workflow_dispatch: jobs: diff --git a/recOrder/cli/apply_inverse_transfer_function.py b/recOrder/cli/apply_inverse_transfer_function.py index e9bbda37..46cac81a 100644 --- a/recOrder/cli/apply_inverse_transfer_function.py +++ b/recOrder/cli/apply_inverse_transfer_function.py @@ -109,9 +109,10 @@ def apply_inverse_transfer_function_cli( ) # Load data + tczyx_uint16_numpy = input_dataset.data.oindex[:, channel_indices] tczyx_data = torch.tensor( - input_dataset.data.oindex[:, channel_indices], dtype=torch.float32 - ) + np.int32(tczyx_uint16_numpy), dtype=torch.float32 + ) # convert to np.int32 (torch doesn't accept np.uint16), then convert to tensor float32 # Prepare background dataset if settings.birefringence is not None: @@ -164,7 +165,7 @@ def apply_inverse_transfer_function_cli( echo_headline("Reconstructing phase...") # check data shapes - if input_dataset.data.shape[1] != 1: + if tczyx_data.shape[1] != 1: raise ValueError( "You have requested a phase-only reconstruction, but the input dataset has more than one channel." ) @@ -385,10 +386,10 @@ def apply_inv_tf( """ Apply an inverse transfer function to a dataset using a configuration file. - See /examples/settings/ for example configuration files. + See /examples for example configuration files. Example usage:\n - $ recorder apply-inv-tf input.zarr/0/0/0 transfer-function.zarr -c /examples/settings/birefringence.yml -o output.zarr + $ recorder apply-inv-tf input.zarr/0/0/0 transfer-function.zarr -c /examples/birefringence.yml -o output.zarr """ apply_inverse_transfer_function_cli( input_data_path, transfer_function_path, config_path, output_path diff --git a/recOrder/cli/compute_transfer_function.py b/recOrder/cli/compute_transfer_function.py index 729531ff..80b740aa 100644 --- a/recOrder/cli/compute_transfer_function.py +++ b/recOrder/cli/compute_transfer_function.py @@ -211,9 +211,9 @@ def compute_tf(input_data_path, config_path, output_path): """ Compute a transfer function using a dataset and configuration file. - See /examples/settings/ for example configuration files. + See /examples/ for example configuration files. Example usage:\n - $ recorder compute-tf input.zarr/0/0/0 -c /examples/settings/birefringence.yml -o transfer_function.zarr + $ recorder compute-tf input.zarr/0/0/0 -c /examples/birefringence.yml -o transfer_function.zarr """ compute_transfer_function_cli(input_data_path, config_path, output_path) diff --git a/recOrder/cli/reconstruct.py b/recOrder/cli/reconstruct.py index 9844929d..8599a675 100644 --- a/recOrder/cli/reconstruct.py +++ b/recOrder/cli/reconstruct.py @@ -23,10 +23,10 @@ def reconstruct(input_data_path, config_path, output_path): convenience function for a `compute-tf` call followed by a `apply-inv-tf` call. - See /examples/settings/ for example configuration files. + See /examples for example configuration files. Example usage:\n - $ recorder reconstruct input.zarr/0/0/0 -c /examples/settings/birefringence.yml -o output.zarr + $ recorder reconstruct input.zarr/0/0/0 -c /examples/birefringence.yml -o output.zarr """ # Handle transfer function path diff --git a/recOrder/tests/cli_tests/test_compute_tf.py b/recOrder/tests/cli_tests/test_compute_tf.py index 0a6de72f..d4d56328 100644 --- a/recOrder/tests/cli_tests/test_compute_tf.py +++ b/recOrder/tests/cli_tests/test_compute_tf.py @@ -11,17 +11,19 @@ def test_compute_transfer(tmp_path, input_zarr): recon_settings = settings.ReconstructionSettings( - input_channel_names=[f"State{i}" for i in range(5)], - reconstruction_dimension=3, - birefringence=settings.BirefringenceSettings(), - phase=settings.PhaseSettings(), - ) + input_channel_names=[f"State{i}" for i in range(4)], + reconstruction_dimension=3, + birefringence=settings.BirefringenceSettings(), + phase=settings.PhaseSettings(), + ) config_path = tmp_path / "test.yml" utils.model_to_yaml(recon_settings, config_path) path, _ = input_zarr runner = CliRunner() - result = runner.invoke(cli, ["compute-tf", str(path), "-c", str(config_path)]) + result = runner.invoke( + cli, ["compute-tf", str(path), "-c", str(config_path)] + ) assert result.exit_code == 0 @@ -45,10 +47,10 @@ def test_compute_transfer_blank_output(): def test_compute_transfer_output_file(tmp_path, input_zarr): recon_settings = settings.ReconstructionSettings( - input_channel_names=["TEST"], - reconstruction_dimension=3, - phase=settings.PhaseSettings(), - ) + input_channel_names=["BF"], + reconstruction_dimension=3, + phase=settings.PhaseSettings(), + ) config_path = tmp_path / "test.yml" utils.model_to_yaml(recon_settings, config_path) diff --git a/recOrder/tests/cli_tests/test_reconstruct.py b/recOrder/tests/cli_tests/test_reconstruct.py index e6f584ca..cdf4f8c8 100644 --- a/recOrder/tests/cli_tests/test_reconstruct.py +++ b/recOrder/tests/cli_tests/test_reconstruct.py @@ -49,12 +49,14 @@ def test_reconstruct(tmp_path): tf_path = input_path.with_name("tf.zarr") runner.invoke( cli, - "compute-tf " - + str(input_path) - + " -c " - + str(config_path) - + " -o " - + str(tf_path), + [ + "compute-tf", + str(input_path), + "-c", + str(config_path), + "-o", + str(tf_path), + ], ) assert tf_path.exists() @@ -63,14 +65,15 @@ def test_reconstruct(tmp_path): result_inv = runner.invoke( cli, - "apply-inv-tf " - + str(input_path) - + " " - + str(tf_path) - + " -c " - + str(config_path) - + " -o " - + str(result_path), + [ + "apply-inv-tf", + str(input_path), + str(tf_path), + "-c", + str(config_path), + "-o", + str(result_path), + ], ) assert result_path.exists() assert result_inv.exit_code == 0 diff --git a/recOrder/tests/cli_tests/test_settings.py b/recOrder/tests/cli_tests/test_settings.py index 8276d3eb..4e37bc19 100644 --- a/recOrder/tests/cli_tests/test_settings.py +++ b/recOrder/tests/cli_tests/test_settings.py @@ -9,7 +9,7 @@ def test_reconstruction_settings(): s = settings.ReconstructionSettings( birefringence=settings.BirefringenceSettings() ) - assert len(s.input_channel_names) == 5 + assert len(s.input_channel_names) == 4 assert s.birefringence.apply_inverse.background_path == "" assert s.phase == None assert s.fluorescence == None diff --git a/recOrder/tests/conftest.py b/recOrder/tests/conftest.py index e34d4127..a6bd4275 100644 --- a/recOrder/tests/conftest.py +++ b/recOrder/tests/conftest.py @@ -12,9 +12,9 @@ def input_zarr(tmp_path): path, layout="fov", mode="w", - channel_names=["None"], + channel_names=[f"State{i}" for i in range(4)] + ["BF"], ) - dataset.create_zeros("0", (2, 1, 4, 5, 6), dtype=np.float32) + dataset.create_zeros("0", (2, 5, 4, 5, 6), dtype=np.uint16) yield path, dataset @@ -25,7 +25,10 @@ def birefringence_phase_recon_settings_function(tmp_path): phase=settings.PhaseSettings(), ) dataset = open_ome_zarr( - tmp_path, layout="fov", mode="w", channel_names=["None"] + tmp_path, + layout="fov", + mode="w", + channel_names=[f"State{i}" for i in range(4)], ) yield recon_settings, dataset @@ -37,6 +40,9 @@ def fluorescence_recon_settings_function(tmp_path): fluorescence=settings.FluorescenceSettings(), ) dataset = open_ome_zarr( - tmp_path, layout="fov", mode="w", channel_names=["None"] + tmp_path, + layout="fov", + mode="w", + channel_names=[f"State{i}" for i in range(4)], ) yield recon_settings, dataset diff --git a/setup.cfg b/setup.cfg index c7548797..d79769ee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ python_requires = >=3.9 setup_requires = setuptools_scm # add your package requirements here install_requires = - waveorder==2.0.0rc0 + waveorder==2.0.0rc1 pycromanager==0.27.2 click>=8.0.1 natsort>=7.1.1