Skip to content

Conversation

@frisograce
Copy link
Collaborator

Please check the following before creating the pull request (PR):

  • Did you run automatic tests?
  • Did you run manual tests?
  • Is the code provided in the PR still backwards compatible to previous SIMPA versions?

Provide issue / feature request fixed by this PR

Fixes #348

@frisograce frisograce requested a review from kdreher July 12, 2024 12:37
@frisograce frisograce self-assigned this Jul 30, 2024
@frisograce frisograce linked an issue Jul 30, 2024 that may be closed by this pull request
frisograce and others added 6 commits August 8, 2024 14:14
…ions

# Conflicts:
#	simpa/core/device_digital_twins/__init__.py
#	simpa/core/device_digital_twins/detection_geometries/__init__.py
#	simpa/core/device_digital_twins/illumination_geometries/__init__.py
#	simpa/core/device_digital_twins/pa_devices/__init__.py
#	simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py
…ions

# Conflicts:
#	simpa/core/device_digital_twins/__init__.py
#	simpa/core/device_digital_twins/detection_geometries/__init__.py
#	simpa/core/device_digital_twins/illumination_geometries/__init__.py
#	simpa/core/device_digital_twins/pa_devices/__init__.py
#	simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py
jgroehl
jgroehl previously approved these changes Nov 18, 2025
Copy link
Collaborator

@jgroehl jgroehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look good to me!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for segmentation-based volume creation for the MSOT Acuity Echo device. It introduces a new method to handle volume settings when using segmentation-based volume creators, including the ability to automatically add layers of ultrasound gel, mediprene, and heavy water to match the physical device configuration.

Key Changes

  • Added new configuration tags (VOLUME_FRACTION, ADD_US_GEL, ADD_MEDIPRENE, ADD_HEAVY_WATER) for segmentation layer management
  • Implemented update_settings_for_use_of_segmentation_based_volume_creator() method across the device twin hierarchy
  • Added type hints to various device geometry classes for improved code clarity

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
simpa/utils/tags.py Added new tags for volume fraction and layer addition controls
simpa/core/device_digital_twins/pa_devices/photoacoustic_device.py Added empty abstract method for segmentation-based volume creator
simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py Implemented segmentation volume adjustment logic with layer addition
simpa/core/device_digital_twins/pa_devices/ithera_rsom.py Added type hints to constructor parameters
simpa/core/device_digital_twins/digital_device_twin_base.py Added abstract method for segmentation-based volume creator and type hints
simpa/core/device_digital_twins/illumination_geometries/*.py Added type hints and implemented segmentation-based volume creator methods
simpa/core/device_digital_twins/detection_geometries/*.py Added type hints and implemented segmentation-based volume creator methods
Comments suppressed due to low confidence (3)

simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py:325

  • Variable old_volume_fraction is not used.
                    old_volume_fraction = getattr(molecule, Tags.VOLUME_FRACTION)

simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py:336

  • Variable device_change_in_height is not used.
        device_change_in_height = mediprene_layer_height_mm + heavy_water_layer_height_mm

simpa/core/device_digital_twins/detection_geometries/detection_geometry_base.py:134

        deserialized_device = DetectionGeometryBase()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +222 to +224
add_layers: list = [Tags.ADD_US_GEL,
Tags.ADD_MEDIPRENE,
Tags.ADD_HEAVY_WATER],
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type hint list for add_layers is too restrictive. Since the parameter is used with in operator for membership testing (lines 253, 264, 273), it should accept any iterable. Consider using list[str] for better type safety or Iterable[str] if you want to support other iterables.

Copilot uses AI. Check for mistakes.
mediprene_layer_height_pix = int(round(mediprene_layer_height_mm/spacing_mm))
padding_dims = ((0, 0), (0, 0), (mediprene_layer_height_pix, 0))
segmentation_map = np.pad(segmentation_map, padding_dims, mode='constant', constant_values=128)
segmentation_class_mapping[128] = TISSUE_LIBRARY.mediprene()
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TISSUE_LIBRARY is undefined. The import on line 14 uses TissueLibrary (camelCase), not TISSUE_LIBRARY (uppercase). Change this to TissueLibrary.mediprene() to match the import.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

padded_vol_sos = np.pad(padded_up_sos, padding_width, mode='edge')
setattr(molecule, key, torch.tensor(padded_vol_sos, dtype=torch.float32))

device_change_in_height = mediprene_layer_height_mm + heavy_water_layer_height_mm
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable device_change_in_height is computed but never used. Consider removing it if it's not needed, or using it in the device position calculations if it was intended to be used.

Suggested change
device_change_in_height = mediprene_layer_height_mm + heavy_water_layer_height_mm

Copilot uses AI. Check for mistakes.
add_layers: list = [Tags.ADD_US_GEL,
Tags.ADD_MEDIPRENE,
Tags.ADD_HEAVY_WATER],
current_heavy_water_depth: (float, int) = 0,
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type hint (float, int) uses outdated tuple syntax. For consistency with the rest of the codebase (e.g., lines 17-19 in curved_array.py, line 18 in gaussian_beam_illumination.py), use Union[float, int] instead. You'll also need to add from typing import Union to the imports.

Copilot uses AI. Check for mistakes.
})
volume_creator_settings[Tags.STRUCTURES][Tags.BACKGROUND] = background_settings

def update_settings_for_use_of_segmentation_based_volume_creator(self, global_settings,
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing type hint for global_settings parameter. For consistency with other methods in this file and the abstract method signature in the base class (digital_device_twin_base.py line 87), add : Settings type hint.

Suggested change
def update_settings_for_use_of_segmentation_based_volume_creator(self, global_settings,
def update_settings_for_use_of_segmentation_based_volume_creator(self, global_settings: Settings,

Copilot uses AI. Check for mistakes.
Comment on lines +1576 to +1580
VOLUME_FRACTION = "volume_fraction"
"""
Identifier for the volume fraction for the simulation
Usage: simpa.core.digital_device_twins.pa_devices.ithera_msot_acuity
"""
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment to 'VOLUME_FRACTION' is unnecessary as it is redefined before this value is used.

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

Copilot uses AI. Check for mistakes.
jgroehl and others added 2 commits November 20, 2025 07:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Nov 20, 2025

@jgroehl I've opened a new pull request, #434, to work on those changes. Once the pull request is ready, I'll request review from you.

jgroehl and others added 3 commits November 20, 2025 07:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: jgroehl <7871475+jgroehl@users.noreply.github.com>
Fix TISSUE_LIBRARY undefined name error in MSOTAcuityEcho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let segmented volume be adapted for MSOT Acuity Echo

3 participants