diff --git a/docs/source/benchmarking.md b/docs/source/benchmarking.md index dbfa1d8f..669ccfc1 100644 --- a/docs/source/benchmarking.md +++ b/docs/source/benchmarking.md @@ -45,7 +45,7 @@ Please put this in the conversation of the pull request, and not add it to the f ## Default Values If no options are provided for initial spacing, final spacing, or step size, the script uses the following default values: -- **Initial Spacing**: 0.15mm +- **Initial Spacing**: 0.2mm - **Final Spacing**: 0.25mm - **Step Size**: 0.05mm diff --git a/simpa_examples/benchmarking/performance_check.py b/simpa_examples/benchmarking/performance_check.py index 2f969837..f933f2de 100644 --- a/simpa_examples/benchmarking/performance_check.py +++ b/simpa_examples/benchmarking/performance_check.py @@ -28,10 +28,10 @@ def run_benchmarking_tests(spacing=0.4, profile: str = "TIME", savefolder: str = import simpa_examples - examples = [simpa_examples.run_linear_unmixing, simpa_examples.run_minimal_optical_simulation, - simpa_examples.run_minimal_optical_simulation_uniform_cube, simpa_examples.run_msot_invision_simulation, + examples = [simpa_examples.run_minimal_optical_simulation, + simpa_examples.run_minimal_optical_simulation_uniform_cube, simpa_examples.run_optical_and_acoustic_simulation, - simpa_examples.run_perform_iterative_qPAI_reconstruction, simpa_examples.run_segmentation_loader] + simpa_examples.run_segmentation_loader] for example in examples: example(spacing=spacing, path_manager=None, visualise=False) diff --git a/simpa_examples/benchmarking/run_benchmarking.sh b/simpa_examples/benchmarking/run_benchmarking.sh index b9757194..0659d932 100644 --- a/simpa_examples/benchmarking/run_benchmarking.sh +++ b/simpa_examples/benchmarking/run_benchmarking.sh @@ -8,7 +8,7 @@ echo "For further details see readme" echo "Number of examples can be selected in performance_check.py" echo "For comparable benchmarks, please use default" echo "Options:" -echo " -i, --init First spacing to benchmark: default = 0.15mm" +echo " -i, --init First spacing to benchmark: default = 0.2mm" echo " -c, --cease Final spacing to benchmark: default = 0.25mm" echo " -s, --step Step between spacings: default = 0.05mm" echo " -f, --file Where to store the output files: default save in current directory; 'print' prints it in console" @@ -59,7 +59,7 @@ shift 1 done if [ "$start" == 0 ]; then - start=0.15 + start=0.2 fi if [ "$stop" == 0 ]; then diff --git a/simpa_examples/msot_invision_simulation.py b/simpa_examples/msot_invision_simulation.py index b1159c57..d7eb2cb6 100644 --- a/simpa_examples/msot_invision_simulation.py +++ b/simpa_examples/msot_invision_simulation.py @@ -152,7 +152,7 @@ def get_settings(): } acoustic_settings = { - Tags.ACOUSTIC_SIMULATION_3D: True, + Tags.ACOUSTIC_SIMULATION_3D: False, Tags.ACOUSTIC_MODEL_BINARY_PATH: path_manager.get_matlab_binary_path(), Tags.KWAVE_PROPERTY_ALPHA_POWER: 0.00, Tags.KWAVE_PROPERTY_SENSOR_RECORD: "p", diff --git a/simpa_examples/segmentation_loader.py b/simpa_examples/segmentation_loader.py index 92c38d08..685240a8 100644 --- a/simpa_examples/segmentation_loader.py +++ b/simpa_examples/segmentation_loader.py @@ -7,6 +7,7 @@ import numpy as np from skimage.data import shepp_logan_phantom from scipy.ndimage import zoom +from skimage.transform import resize # FIXME temporary workaround for newest Intel architectures import os @@ -19,11 +20,12 @@ @profile -def run_segmentation_loader(spacing: float | int = .1, path_manager=None, +def run_segmentation_loader(spacing: float | int = 1.0, input_spacing: float | int = 0.2, path_manager=None, visualise: bool = True): """ - :param spacing: The simulation spacing between voxels + :param spacing: The simulation spacing between voxels in mm + :param input_spacing: The input spacing between voxels in mm :param path_manager: the path manager to be used, typically sp.PathManager :param visualise: If VISUALIZE is set to True, the reconstruction result will be plotted :return: a run through of the example @@ -34,10 +36,9 @@ def run_segmentation_loader(spacing: float | int = .1, path_manager=None, label_mask = shepp_logan_phantom() label_mask = np.digitize(label_mask, bins=np.linspace(0.0, 1.0, 11), right=True) + label_mask = label_mask[100:300, 100:300] + label_mask = np.reshape(label_mask, (label_mask.shape[0], 1, label_mask.shape[1])) - label_mask = np.reshape(label_mask, (400, 1, 400)) - - input_spacing = 0.2 segmentation_volume_tiled = np.tile(label_mask, (1, 128, 1)) segmentation_volume_mask = np.round(zoom(segmentation_volume_tiled, input_spacing/spacing, order=0)).astype(int) @@ -67,9 +68,9 @@ def segmentation_class_mapping(): settings[Tags.RANDOM_SEED] = 1234 settings[Tags.WAVELENGTHS] = [700] settings[Tags.SPACING_MM] = spacing - settings[Tags.DIM_VOLUME_X_MM] = 400 / (spacing / input_spacing) - settings[Tags.DIM_VOLUME_Y_MM] = 128 / (spacing / input_spacing) - settings[Tags.DIM_VOLUME_Z_MM] = 400 / (spacing / input_spacing) + settings[Tags.DIM_VOLUME_X_MM] = segmentation_volume_mask.shape[0] * spacing + settings[Tags.DIM_VOLUME_Y_MM] = segmentation_volume_mask.shape[1] * spacing + settings[Tags.DIM_VOLUME_Z_MM] = segmentation_volume_mask.shape[2] * spacing settings.set_volume_creation_settings({ Tags.INPUT_SEGMENTATION_VOLUME: segmentation_volume_mask, @@ -105,9 +106,11 @@ def segmentation_class_mapping(): if __name__ == "__main__": parser = ArgumentParser(description='Run the segmentation loader example') - parser.add_argument("--spacing", default=0.2, type=float, help='the voxel spacing in mm') + parser.add_argument("--spacing", default=1, type=float, help='the voxel spacing in mm') + parser.add_argument("--input_spacing", default=0.2, type=float, help='the input spacing in mm') parser.add_argument("--path_manager", default=None, help='the path manager, None uses sp.PathManager') parser.add_argument("--visualise", default=True, type=bool, help='whether to visualise the result') config = parser.parse_args() - run_segmentation_loader(spacing=config.spacing, path_manager=config.path_manager, visualise=config.visualise) + run_segmentation_loader(spacing=config.spacing, input_spacing=config.input_spacing, + path_manager=config.path_manager, visualise=config.visualise)