Skip to content

Commit

Permalink
Extra logging fo the new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
frisograce committed Jul 15, 2024
1 parent 72fada5 commit 271d029
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import numpy as np
from typing import Union

from simpa import Settings
from simpa.core.device_digital_twins import DetectionGeometryBase
from simpa.utils import Tags
from simpa.utils import Settings, Tags


class LinearArrayDetectionGeometry(DetectionGeometryBase):
Expand Down
11 changes: 8 additions & 3 deletions simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from simpa.core.device_digital_twins import PhotoacousticDevice, \
CurvedArrayDetectionGeometry, MSOTAcuityIlluminationGeometry

from simpa.core.device_digital_twins.pa_devices import PhotoacousticDevice
from simpa.core.device_digital_twins.detection_geometries.curved_array import CurvedArrayDetectionGeometry
from simpa.utils.settings import Settings
from simpa.utils import Tags
from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY
Expand Down Expand Up @@ -246,7 +244,10 @@ def update_settings_for_use_of_segmentation_based_volume_creator(self, global_se
padding_dims = ((0, 0), (0, 0), (us_gel_thickness_pix, 0))
segmentation_map = np.pad(segmentation_map, padding_dims, mode='constant', constant_values=64)
segmentation_class_mapping[64] = TISSUE_LIBRARY.ultrasound_gel()
# Whilst it may seem strange, to avoid rounding differences through the pipline it is best to let the
# z dimension shift us the same rounding as the pixel thickness. (This is the same for all three layers)
z_dim_position_shift_mm += us_gel_thickness_pix * spacing_mm
self.logger.debug("Added a ultrasound gel layer to the segmentation map.")

if Tags.ADD_MEDIPRENE in add_layers:
mediprene_layer_height_mm = self.mediprene_membrane_height_mm
Expand All @@ -255,6 +256,7 @@ def update_settings_for_use_of_segmentation_based_volume_creator(self, global_se
segmentation_map = np.pad(segmentation_map, padding_dims, mode='constant', constant_values=128)
segmentation_class_mapping[128] = TISSUE_LIBRARY.mediprene()
z_dim_position_shift_mm += mediprene_layer_height_pix * spacing_mm
self.logger.debug("Added a mediprene layer to the segmentation map.")

if Tags.ADD_HEAVY_WATER in add_layers:
if heavy_water_tag is None:
Expand All @@ -268,6 +270,8 @@ def update_settings_for_use_of_segmentation_based_volume_creator(self, global_se
segmentation_map = np.pad(segmentation_map, padding_dims, mode='constant', constant_values=heavy_water_tag)
segmentation_class_mapping[heavy_water_tag] = TISSUE_LIBRARY.heavy_water()
z_dim_position_shift_mm += heavy_water_layer_height_pix * spacing_mm
self.logger.debug(f"Added a {heavy_water_layer_height_pix * spacing_mm}mm heavy water layer to the"
f"segmentation map.")

new_volume_height_mm = global_settings[Tags.DIM_VOLUME_Z_MM] + z_dim_position_shift_mm

Expand All @@ -289,7 +293,8 @@ def update_settings_for_use_of_segmentation_based_volume_creator(self, global_se
padding_width = ((left_shift_pixels, right_shift_pixels), (0, 0), (0, 0))
segmentation_map = np.pad(segmentation_map, padding_width, mode='edge')
global_settings[Tags.DIM_VOLUME_X_MM] = int(round(self.detection_geometry.probe_width_mm)) + spacing_mm
self.logger.debug(f"Changed Tags.DIM_VOLUME_X_MM to {global_settings[Tags.DIM_VOLUME_X_MM]}")
self.logger.debug(f"Changed Tags.DIM_VOLUME_X_MM to {global_settings[Tags.DIM_VOLUME_X_MM]}, and expanded"
f"the segmentation map accordingly using edge padding")

else:
width_shift_for_structures_mm = 0
Expand Down
6 changes: 6 additions & 0 deletions simpa/utils/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,12 @@ class Tags:
Identifier for the environment varibale that defines the path the the matlab executable.
"""

VOLUME_FRACTION = "volume_fraction"
"""
Identifier for the volume fraction for the simulation
Usage: simpa.core.digital_device_twins.pa_devices.ithera_msot_acuity
"""

ADD_US_GEL = "add_us_gel"
"""
Identifier to add ultrasound gel to the segmentation
Expand Down

0 comments on commit 271d029

Please sign in to comment.