diff --git a/tests/conftest.py b/tests/conftest.py index 7cd8ce960..84f273942 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -181,6 +181,11 @@ def FBP3d_tomobar(): return "docs/source/pipelines_full/FBP3d_tomobar.yaml" +@pytest.fixture +def LPRec3d_tomobar(): + return "docs/source/pipelines_full/LPRec3d_tomobar.yaml" + + @pytest.fixture def FBP2d_astra(): return "docs/source/pipelines_full/FBP2d_astra.yaml" @@ -310,6 +315,12 @@ def FBP3d_tomobar_distortion_i13_179623_npz(): ) +@pytest.fixture +def LPRec3d_tomobar_i12_119647_npz(): + # 10 slices numpy array + return np.load("tests/test_data/raw_data/i12/LPRec3d_tomobar_i12_119647.npz") + + @pytest.fixture def pipeline_sweep_FBP3d_tomobar_i13_177906_tiffs(): # several tiff files diff --git a/tests/test_pipeline_big.py b/tests/test_pipeline_big.py index c305374a4..8e2558cf4 100644 --- a/tests/test_pipeline_big.py +++ b/tests/test_pipeline_big.py @@ -377,6 +377,73 @@ def test_pipe_FBP3d_tomobar_i12_119647_preview( # ######################################################################## +@pytest.mark.full_data +def test_pipe_LPRec3d_tomobar_i12_119647_preview( + get_files: Callable, + cmd, + i12_119647, + LPRec3d_tomobar, + LPRec3d_tomobar_i12_119647_npz, + output_folder, +): + + change_value_parameters_method_pipeline( + LPRec3d_tomobar, + method=[ + "standard_tomo", + ], + key=[ + "preview", + ], + value=[ + {"detector_y": {"start": 900, "stop": 1200}}, + ], + ) + + cmd.pop(4) #: don't save all + cmd.insert(5, i12_119647) + cmd.insert(7, LPRec3d_tomobar) + cmd.insert(8, output_folder) + + subprocess.check_output(cmd) + + files = get_files(output_folder) + + #: check the generated reconstruction (hdf5 file) + h5_files = list(filter(lambda x: ".h5" in x, files)) + assert len(h5_files) == 1 + + # load the pre-saved numpy array for comparison bellow + data_gt = LPRec3d_tomobar_i12_119647_npz["data"] + axis_slice = LPRec3d_tomobar_i12_119647_npz["axis_slice"] + (slices, sizeX, sizeY) = np.shape(data_gt) + + step = axis_slice // (slices + 2) + # store for the result + data_result = np.zeros((slices, sizeX, sizeY), dtype=np.float32) + + path_to_data = "data/" + h5_file_name = "LPRec3d_tomobar" + for file_to_open in h5_files: + if h5_file_name in file_to_open: + h5f = h5py.File(file_to_open, "r") + index_prog = step + for i in range(slices): + data_result[i, :, :] = h5f[path_to_data][:, index_prog, :] + index_prog += step + h5f.close() + else: + message_str = f"File name with {h5_file_name} string cannot be found." + raise FileNotFoundError(message_str) + + residual_im = data_gt - data_result + res_norm = np.linalg.norm(residual_im.flatten()).astype("float32") + assert res_norm < 0.02 + + +# ######################################################################## + + @pytest.mark.full_data def test_pipe_FBP2d_astra_i12_119647_preview( get_files: Callable,