diff --git a/simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py b/simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py index 749e0f19..249ab9e4 100644 --- a/simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py +++ b/simpa/core/device_digital_twins/pa_devices/ithera_msot_acuity.py @@ -11,7 +11,7 @@ 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 +from simpa.utils.libraries.tissue_library import TissueLibrary import numpy as np @@ -174,7 +174,7 @@ def update_settings_for_use_of_model_based_volume_creator(self, global_settings: Tags.STRUCTURE_END_MM: [0, 0, heavy_water_layer_height_mm + mediprene_layer_height_mm + us_gel_thickness], Tags.CONSIDER_PARTIAL_VOLUME: consider_partial_volume, - Tags.MOLECULE_COMPOSITION: TISSUE_LIBRARY.ultrasound_gel(), + Tags.MOLECULE_COMPOSITION: TissueLibrary.ultrasound_gel(), Tags.STRUCTURE_TYPE: Tags.HORIZONTAL_LAYER_STRUCTURE }) @@ -185,7 +185,7 @@ def update_settings_for_use_of_model_based_volume_creator(self, global_settings: Tags.STRUCTURE_START_MM: [0, 0, heavy_water_layer_height_mm], Tags.STRUCTURE_END_MM: [0, 0, heavy_water_layer_height_mm + mediprene_layer_height_mm], Tags.CONSIDER_PARTIAL_VOLUME: consider_partial_volume, - Tags.MOLECULE_COMPOSITION: TISSUE_LIBRARY.mediprene(), + Tags.MOLECULE_COMPOSITION: TissueLibrary.mediprene(), Tags.STRUCTURE_TYPE: Tags.HORIZONTAL_LAYER_STRUCTURE }) @@ -214,7 +214,7 @@ def update_settings_for_use_of_model_based_volume_creator(self, global_settings: np.array([width_shift_for_structures_mm, 0, probe_size_mm])) background_settings = Settings({ - Tags.MOLECULE_COMPOSITION: TISSUE_LIBRARY.heavy_water(), + Tags.MOLECULE_COMPOSITION: TissueLibrary.heavy_water(), Tags.STRUCTURE_TYPE: Tags.BACKGROUND }) volume_creator_settings[Tags.STRUCTURES][Tags.BACKGROUND] = background_settings diff --git a/simpa/core/processing_components/monospectral/iterative_qPAI_algorithm.py b/simpa/core/processing_components/monospectral/iterative_qPAI_algorithm.py index fda821a9..7f1b3e1c 100644 --- a/simpa/core/processing_components/monospectral/iterative_qPAI_algorithm.py +++ b/simpa/core/processing_components/monospectral/iterative_qPAI_algorithm.py @@ -15,7 +15,7 @@ MCXAdapter from simpa.utils import Settings from simpa.io_handling import save_data_field, load_data_field -from simpa.utils import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.core.processing_components import ProcessingComponentBase import os @@ -368,7 +368,7 @@ def standard_optical_properties(self, image_data: np.ndarray) -> dict: if Tags.DATA_FIELD_SCATTERING_PER_CM in self.global_settings: scattering = float(self.global_settings[Tags.DATA_FIELD_SCATTERING_PER_CM]) * np.ones(shape) else: - background_dict = TISSUE_LIBRARY.muscle() + background_dict = TissueLibrary.muscle() scattering = float(MolecularComposition.get_properties_for_wavelength(background_dict, self.global_settings, wavelength=800)["mus"]) scattering = scattering * np.ones(shape) diff --git a/simpa/utils/__init__.py b/simpa/utils/__init__.py index c8484709..af96cad9 100644 --- a/simpa/utils/__init__.py +++ b/simpa/utils/__init__.py @@ -23,10 +23,8 @@ from .libraries.molecule_library import Molecule, MolecularCompositionGenerator from .libraries.molecule_library import MoleculeLibrary -from .libraries.molecule_library import MOLECULE_LIBRARY from .libraries.tissue_library import TissueLibrary -from .libraries.tissue_library import TISSUE_LIBRARY from .calculate import calculate_oxygenation from .calculate import calculate_gruneisen_parameter_from_temperature diff --git a/simpa/utils/libraries/molecule_library.py b/simpa/utils/libraries/molecule_library.py index b73a1668..09a3eba8 100644 --- a/simpa/utils/libraries/molecule_library.py +++ b/simpa/utils/libraries/molecule_library.py @@ -584,7 +584,6 @@ def air(volume_fraction: (float, torch.Tensor) = 1.0) -> Molecule: ) -MOLECULE_LIBRARY = MoleculeLibrary() class MolecularCompositionGenerator(object): diff --git a/simpa/utils/libraries/tissue_library.py b/simpa/utils/libraries/tissue_library.py index 8c4393e1..10c4916e 100644 --- a/simpa/utils/libraries/tissue_library.py +++ b/simpa/utils/libraries/tissue_library.py @@ -6,9 +6,8 @@ from simpa.utils import OpticalTissueProperties, SegmentationClasses, StandardProperties, MolecularCompositionGenerator from simpa.utils import Molecule -from simpa.utils import MOLECULE_LIBRARY from simpa.utils import Spectrum -from simpa.utils.libraries.molecule_library import MolecularComposition +from simpa.utils.libraries.molecule_library import MolecularComposition, MoleculeLibrary from simpa.utils.libraries.spectrum_library import AnisotropySpectrumLibrary, ScatteringSpectrumLibrary from simpa.utils.calculate import randomize_uniform from simpa.utils.libraries.spectrum_library import AbsorptionSpectrumLibrary @@ -19,7 +18,8 @@ class TissueLibrary(object): A library, returning molecular compositions for various typical tissue segmentations. """ - def get_blood_volume_fractions(self, oxygenation: Union[float, int, np.ndarray] = 1e-10, + @staticmethod + def get_blood_volume_fractions(oxygenation: Union[float, int, np.ndarray] = 1e-10, blood_volume_fraction: Union[float, int, np.ndarray] = 1e-10)\ -> List[Union[int, float, np.ndarray]]: """ @@ -32,7 +32,8 @@ def get_blood_volume_fractions(self, oxygenation: Union[float, int, np.ndarray] """ return [blood_volume_fraction*oxygenation, blood_volume_fraction*(1-oxygenation)] - def constant(self, mua: Union[float, int, np.ndarray] = 1e-10, mus: Union[float, int, np.ndarray] = 1e-10, + @staticmethod + def constant(mua: Union[float, int, np.ndarray] = 1e-10, mus: Union[float, int, np.ndarray] = 1e-10, g: Union[float, int, np.ndarray] = 0) -> MolecularComposition: """ A function returning a molecular composition as specified by the user. Typically intended for the use of wanting @@ -48,10 +49,10 @@ def constant(self, mua: Union[float, int, np.ndarray] = 1e-10, mus: Union[float, mua_as_spectrum = AbsorptionSpectrumLibrary().CONSTANT_ABSORBER_ARBITRARY(mua) mus_as_spectrum = ScatteringSpectrumLibrary.CONSTANT_SCATTERING_ARBITRARY(mus) g_as_spectrum = AnisotropySpectrumLibrary.CONSTANT_ANISOTROPY_ARBITRARY(g) - return self.generic_tissue(mua_as_spectrum, mus_as_spectrum, g_as_spectrum, "constant_mua_mus_g") + return TissueLibrary.generic_tissue(mua_as_spectrum, mus_as_spectrum, g_as_spectrum, "constant_mua_mus_g") - def generic_tissue(self, - mua: Spectrum = AbsorptionSpectrumLibrary().CONSTANT_ABSORBER_ARBITRARY(1e-10), + @staticmethod + def generic_tissue(mua: Spectrum = AbsorptionSpectrumLibrary().CONSTANT_ABSORBER_ARBITRARY(1e-10), mus: Spectrum = AbsorptionSpectrumLibrary().CONSTANT_ABSORBER_ARBITRARY(1e-10), g: Spectrum = AbsorptionSpectrumLibrary().CONSTANT_ABSORBER_ARBITRARY(1e-10), molecule_name: Optional[str] = "generic_tissue") -> MolecularComposition: @@ -77,7 +78,8 @@ def generic_tissue(self, anisotropy_spectrum=g)) .get_molecular_composition(SegmentationClasses.GENERIC)) - def muscle(self, oxygenation: Union[float, int, np.ndarray] = 0.175, + @staticmethod + def muscle(oxygenation: Union[float, int, np.ndarray] = 0.175, blood_volume_fraction: Union[float, int, np.ndarray] = 0.06) -> MolecularComposition: """ Create a molecular composition mimicking that of muscle @@ -88,7 +90,7 @@ def muscle(self, oxygenation: Union[float, int, np.ndarray] = 0.175, :return: a settings dictionary containing all min and max parameters fitting for muscle tissue. """ - [fraction_oxy, fraction_deoxy] = self.get_blood_volume_fractions(oxygenation, blood_volume_fraction) + [fraction_oxy, fraction_deoxy] = TissueLibrary.get_blood_volume_fractions(oxygenation, blood_volume_fraction) # Get the water volume fraction water_volume_fraction = OpticalTissueProperties.WATER_VOLUME_FRACTION_HUMAN_BODY @@ -103,7 +105,7 @@ def muscle(self, oxygenation: Union[float, int, np.ndarray] = 0.175, raise AssertionError(f"Blood volume fraction too large, must be less than {1 - water_volume_fraction}" f"everywhere to leave space for water") - custom_water = MOLECULE_LIBRARY.water(water_volume_fraction) + custom_water = MoleculeLibrary.water(water_volume_fraction) custom_water.anisotropy_spectrum = AnisotropySpectrumLibrary.CONSTANT_ANISOTROPY_ARBITRARY( OpticalTissueProperties.STANDARD_ANISOTROPY - 0.005) custom_water.alpha_coefficient = 1.58 @@ -115,15 +117,16 @@ def muscle(self, oxygenation: Union[float, int, np.ndarray] = 0.175, # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.oxyhemoglobin(fraction_oxy)) - .append(MOLECULE_LIBRARY.deoxyhemoglobin(fraction_deoxy)) - .append(value=MOLECULE_LIBRARY.muscle_scatterer( + .append(MoleculeLibrary.oxyhemoglobin(fraction_oxy)) + .append(MoleculeLibrary.deoxyhemoglobin(fraction_deoxy)) + .append(value=MoleculeLibrary.muscle_scatterer( volume_fraction=1 - fraction_oxy - fraction_deoxy - water_volume_fraction), key="muscle_scatterers") .append(custom_water) .get_molecular_composition(SegmentationClasses.MUSCLE)) - def soft_tissue(self, oxygenation: Union[float, int, np.ndarray] = OpticalTissueProperties.BACKGROUND_OXYGENATION, + @staticmethod + def soft_tissue(oxygenation: Union[float, int, np.ndarray] = OpticalTissueProperties.BACKGROUND_OXYGENATION, blood_volume_fraction: Union[float, int, np.ndarray] = OpticalTissueProperties.BLOOD_VOLUME_FRACTION_MUSCLE_TISSUE) -> MolecularComposition: """ IMPORTANT! This tissue is not tested and it is not based on a specific real tissue type. @@ -136,7 +139,7 @@ def soft_tissue(self, oxygenation: Union[float, int, np.ndarray] = OpticalTissue :return: a settings dictionary containing all min and max parameters fitting for generic soft tissue. """ - [fraction_oxy, fraction_deoxy] = self.get_blood_volume_fractions(oxygenation, blood_volume_fraction) + [fraction_oxy, fraction_deoxy] = TissueLibrary.get_blood_volume_fractions(oxygenation, blood_volume_fraction) # Get the water volume fraction water_volume_fraction = OpticalTissueProperties.WATER_VOLUME_FRACTION_HUMAN_BODY @@ -151,7 +154,7 @@ def soft_tissue(self, oxygenation: Union[float, int, np.ndarray] = OpticalTissue raise AssertionError(f"Blood volume fraction too large, must be less than {1 - water_volume_fraction}" f"everywhere to leave space for water") - custom_water = MOLECULE_LIBRARY.water(water_volume_fraction) + custom_water = MoleculeLibrary.water(water_volume_fraction) custom_water.anisotropy_spectrum = AnisotropySpectrumLibrary.CONSTANT_ANISOTROPY_ARBITRARY( OpticalTissueProperties.STANDARD_ANISOTROPY - 0.005) custom_water.alpha_coefficient = 0.08 @@ -163,15 +166,16 @@ def soft_tissue(self, oxygenation: Union[float, int, np.ndarray] = OpticalTissue # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.oxyhemoglobin(fraction_oxy)) - .append(MOLECULE_LIBRARY.deoxyhemoglobin(fraction_deoxy)) - .append(value=MOLECULE_LIBRARY.muscle_scatterer( + .append(MoleculeLibrary.oxyhemoglobin(fraction_oxy)) + .append(MoleculeLibrary.deoxyhemoglobin(fraction_deoxy)) + .append(value=MoleculeLibrary.muscle_scatterer( volume_fraction=1 - fraction_oxy - fraction_deoxy - water_volume_fraction), key="muscle_scatterers") .append(custom_water) .get_molecular_composition(SegmentationClasses.SOFT_TISSUE)) - def epidermis(self, melanin_volume_fraction: Union[float, int, np.ndarray] = 0.014) -> MolecularComposition: + @staticmethod + def epidermis(melanin_volume_fraction: Union[float, int, np.ndarray] = 0.014) -> MolecularComposition: """ Create a molecular composition mimicking that of dermis :param melanin_volume_fraction: the total volume fraction of melanin @@ -180,11 +184,12 @@ def epidermis(self, melanin_volume_fraction: Union[float, int, np.ndarray] = 0.0 # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.melanin(melanin_volume_fraction)) - .append(MOLECULE_LIBRARY.epidermal_scatterer(1 - melanin_volume_fraction)) + .append(MoleculeLibrary.melanin(melanin_volume_fraction)) + .append(MoleculeLibrary.epidermal_scatterer(1 - melanin_volume_fraction)) .get_molecular_composition(SegmentationClasses.EPIDERMIS)) - def dermis(self, oxygenation: Union[float, int, np.ndarray] = 0.5, + @staticmethod + def dermis(oxygenation: Union[float, int, np.ndarray] = 0.5, blood_volume_fraction: Union[float, int, np.ndarray] = 0.002) -> MolecularComposition: """ Create a molecular composition mimicking that of dermis @@ -196,17 +201,17 @@ def dermis(self, oxygenation: Union[float, int, np.ndarray] = 0.5, """ # Get the blood volume fractions for oxyhemoglobin and deoxyhemoglobin - [fraction_oxy, fraction_deoxy] = self.get_blood_volume_fractions(oxygenation, blood_volume_fraction) + [fraction_oxy, fraction_deoxy] = TissueLibrary.get_blood_volume_fractions(oxygenation, blood_volume_fraction) # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.oxyhemoglobin(fraction_oxy)) - .append(MOLECULE_LIBRARY.deoxyhemoglobin(fraction_deoxy)) - .append(MOLECULE_LIBRARY.dermal_scatterer(1.0 - blood_volume_fraction)) + .append(MoleculeLibrary.oxyhemoglobin(fraction_oxy)) + .append(MoleculeLibrary.deoxyhemoglobin(fraction_deoxy)) + .append(MoleculeLibrary.dermal_scatterer(1.0 - blood_volume_fraction)) .get_molecular_composition(SegmentationClasses.DERMIS)) - def subcutaneous_fat(self, - oxygenation: Union[float, int, np.ndarray] = OpticalTissueProperties.BACKGROUND_OXYGENATION, + @staticmethod + def subcutaneous_fat(oxygenation: Union[float, int, np.ndarray] = OpticalTissueProperties.BACKGROUND_OXYGENATION, blood_volume_fraction: Union[float, int, np.ndarray] = OpticalTissueProperties.BLOOD_VOLUME_FRACTION_MUSCLE_TISSUE) -> MolecularComposition: """ @@ -222,7 +227,7 @@ def subcutaneous_fat(self, water_volume_fraction = OpticalTissueProperties.WATER_VOLUME_FRACTION_HUMAN_BODY # Get the blood volume fractions for oxyhemoglobin and deoxyhemoglobin - [fraction_oxy, fraction_deoxy] = self.get_blood_volume_fractions( + [fraction_oxy, fraction_deoxy] = TissueLibrary.get_blood_volume_fractions( oxygenation, blood_volume_fraction) # Determine fat volume fraction @@ -230,15 +235,16 @@ def subcutaneous_fat(self, # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.oxyhemoglobin(fraction_oxy)) - .append(MOLECULE_LIBRARY.deoxyhemoglobin(fraction_deoxy)) - .append(MOLECULE_LIBRARY.fat(fat_volume_fraction)) - .append(MOLECULE_LIBRARY.soft_tissue_scatterer( + .append(MoleculeLibrary.oxyhemoglobin(fraction_oxy)) + .append(MoleculeLibrary.deoxyhemoglobin(fraction_deoxy)) + .append(MoleculeLibrary.fat(fat_volume_fraction)) + .append(MoleculeLibrary.soft_tissue_scatterer( 1 - (fat_volume_fraction + water_volume_fraction + fraction_oxy + fraction_deoxy))) - .append(MOLECULE_LIBRARY.water(water_volume_fraction)) + .append(MoleculeLibrary.water(water_volume_fraction)) .get_molecular_composition(SegmentationClasses.FAT)) - def blood(self, oxygenation: Union[float, int, np.ndarray, None] = None) -> MolecularComposition: + @staticmethod + def blood(oxygenation: Union[float, int, np.ndarray, None] = None) -> MolecularComposition: """ Create a molecular composition mimicking that of blood :param oxygenation: The oxygenation level of the blood(as a decimal). @@ -251,15 +257,16 @@ def blood(self, oxygenation: Union[float, int, np.ndarray, None] = None) -> Mole oxygenation = randomize_uniform(0.0, 1.0) # Get the blood volume fractions for oxyhemoglobin and deoxyhemoglobin - [fraction_oxy, fraction_deoxy] = self.get_blood_volume_fractions(oxygenation, 1.0) + [fraction_oxy, fraction_deoxy] = TissueLibrary.get_blood_volume_fractions(oxygenation, 1.0) # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.oxyhemoglobin(fraction_oxy)) - .append(MOLECULE_LIBRARY.deoxyhemoglobin(fraction_deoxy)) + .append(MoleculeLibrary.oxyhemoglobin(fraction_oxy)) + .append(MoleculeLibrary.deoxyhemoglobin(fraction_deoxy)) .get_molecular_composition(SegmentationClasses.BLOOD)) - def bone(self) -> MolecularComposition: + @staticmethod + def bone() -> MolecularComposition: """ Create a molecular composition mimicking that of bone :return: a settings dictionary fitting for bone. @@ -273,38 +280,42 @@ def bone(self) -> MolecularComposition: # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.bone(1 - water_volume_fraction)) - .append(MOLECULE_LIBRARY.water(water_volume_fraction)) + .append(MoleculeLibrary.bone(1 - water_volume_fraction)) + .append(MoleculeLibrary.water(water_volume_fraction)) .get_molecular_composition(SegmentationClasses.BONE)) - def mediprene(self) -> MolecularComposition: + @staticmethod + def mediprene() -> MolecularComposition: """ Create a molecular composition mimicking that of mediprene :return: a settings dictionary fitting for mediprene. """ return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.mediprene()) + .append(MoleculeLibrary.mediprene()) .get_molecular_composition(SegmentationClasses.MEDIPRENE)) - def heavy_water(self) -> MolecularComposition: + @staticmethod + def heavy_water() -> MolecularComposition: """ Create a molecular composition mimicking that of heavy water :return: a settings dictionary containing all min and max parameters fitting for heavy water. """ return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.heavy_water()) + .append(MoleculeLibrary.heavy_water()) .get_molecular_composition(SegmentationClasses.HEAVY_WATER)) - def ultrasound_gel(self) -> MolecularComposition: + @staticmethod + def ultrasound_gel() -> MolecularComposition: """ Create a molecular composition mimicking that of ultrasound gel :return: a settings dictionary fitting for generic ultrasound gel. """ return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.water()) + .append(MoleculeLibrary.water()) .get_molecular_composition(SegmentationClasses.ULTRASOUND_GEL)) - def lymph_node(self, oxygenation: Union[float, int, np.ndarray] = OpticalTissueProperties.LYMPH_NODE_OXYGENATION, + @staticmethod + def lymph_node(oxygenation: Union[float, int, np.ndarray] = OpticalTissueProperties.LYMPH_NODE_OXYGENATION, blood_volume_fraction: Union[float, int, np.ndarray] = OpticalTissueProperties.BLOOD_VOLUME_FRACTION_LYMPH_NODE) -> MolecularComposition: """ @@ -317,22 +328,21 @@ def lymph_node(self, oxygenation: Union[float, int, np.ndarray] = OpticalTissueP :return: a settings dictionary fitting for generic lymph node tissue. """ - [fraction_oxy, fraction_deoxy] = self.get_blood_volume_fractions(oxygenation, blood_volume_fraction) + [fraction_oxy, fraction_deoxy] = TissueLibrary.get_blood_volume_fractions(oxygenation, blood_volume_fraction) # Get the water volume fraction # water_volume_fraction = OpticalTissueProperties.WATER_VOLUME_FRACTION_HUMAN_BODY - lymphatic_fluid = MOLECULE_LIBRARY.water(1 - fraction_deoxy - fraction_oxy) + lymphatic_fluid = MoleculeLibrary.water(1 - fraction_deoxy - fraction_oxy) lymphatic_fluid.speed_of_sound = StandardProperties.SPEED_OF_SOUND_LYMPH_NODE + 1.22 lymphatic_fluid.density = StandardProperties.DENSITY_LYMPH_NODE - 2.30 lymphatic_fluid.alpha_coefficient = StandardProperties.ALPHA_COEFF_LYMPH_NODE + 0.36 # generate the tissue dictionary return (MolecularCompositionGenerator() - .append(MOLECULE_LIBRARY.oxyhemoglobin(fraction_oxy)) - .append(MOLECULE_LIBRARY.deoxyhemoglobin(fraction_deoxy)) + .append(MoleculeLibrary.oxyhemoglobin(fraction_oxy)) + .append(MoleculeLibrary.deoxyhemoglobin(fraction_deoxy)) .append(lymphatic_fluid) .get_molecular_composition(SegmentationClasses.LYMPH_NODE)) -TISSUE_LIBRARY = TissueLibrary() diff --git a/simpa_examples/create_custom_tissues.py b/simpa_examples/create_custom_tissues.py index 3e90ac37..741f37d1 100644 --- a/simpa_examples/create_custom_tissues.py +++ b/simpa_examples/create_custom_tissues.py @@ -39,11 +39,11 @@ def create_custom_tissue_type(): # Then append chromophores that you want tissue_settings_generator.append(key="oxyhemoglobin", - value=sp.MOLECULE_LIBRARY.oxyhemoglobin(oxygenation * blood_volume_fraction)) + value=sp.MoleculeLibrary.oxyhemoglobin(oxygenation * blood_volume_fraction)) tissue_settings_generator.append(key="deoxyhemoglobin", - value=sp.MOLECULE_LIBRARY.deoxyhemoglobin((1 - oxygenation) * blood_volume_fraction)) + value=sp.MoleculeLibrary.deoxyhemoglobin((1 - oxygenation) * blood_volume_fraction)) tissue_settings_generator.append(key="water", - value=sp.MOLECULE_LIBRARY.water(water_volume_fraction)) + value=sp.MoleculeLibrary.water(water_volume_fraction)) tissue_settings_generator.append(key="custom", value=create_custom_chromophore(custom_chromophore_volume_fraction)) diff --git a/simpa_examples/linear_unmixing.py b/simpa_examples/linear_unmixing.py index 0a2f5015..2ff9c7ef 100644 --- a/simpa_examples/linear_unmixing.py +++ b/simpa_examples/linear_unmixing.py @@ -43,14 +43,14 @@ def create_example_tissue(): and two blood vessels. """ background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(1e-4, 1e-4, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(1e-4, 1e-4, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND muscle_dictionary = sp.Settings() muscle_dictionary[Tags.PRIORITY] = 1 muscle_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 0] muscle_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 100] - muscle_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.muscle() + muscle_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.muscle() muscle_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True muscle_dictionary[Tags.ADHERE_TO_DEFORMATION] = True muscle_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE @@ -64,7 +64,7 @@ def create_example_tissue(): 12, 5] vessel_1_dictionary[Tags.STRUCTURE_RADIUS_MM] = 3 - vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.blood(oxygenation=0.99) + vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.blood(oxygenation=0.99) vessel_1_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_1_dictionary[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE @@ -77,7 +77,7 @@ def create_example_tissue(): 12, 5] vessel_2_dictionary[Tags.STRUCTURE_RADIUS_MM] = 2 - vessel_2_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.blood(oxygenation=0.75) + vessel_2_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.blood(oxygenation=0.75) vessel_2_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_2_dictionary[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE @@ -85,7 +85,7 @@ def create_example_tissue(): epidermis_dictionary[Tags.PRIORITY] = 8 epidermis_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 0] epidermis_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 0.1] - epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.epidermis() + epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.epidermis() epidermis_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True epidermis_dictionary[Tags.ADHERE_TO_DEFORMATION] = True epidermis_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE diff --git a/simpa_examples/minimal_optical_simulation.py b/simpa_examples/minimal_optical_simulation.py index 6f43eeb3..f5ed7e32 100644 --- a/simpa_examples/minimal_optical_simulation.py +++ b/simpa_examples/minimal_optical_simulation.py @@ -44,14 +44,14 @@ def create_example_tissue(): and a blood vessel. """ background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(1e-4, 1e-4, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(1e-4, 1e-4, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND muscle_dictionary = sp.Settings() muscle_dictionary[Tags.PRIORITY] = 1 muscle_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 10] muscle_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 100] - muscle_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.muscle() + muscle_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.muscle() muscle_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True muscle_dictionary[Tags.ADHERE_TO_DEFORMATION] = True muscle_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE @@ -65,7 +65,7 @@ def create_example_tissue(): 12, VOLUME_HEIGHT_IN_MM/2] vessel_1_dictionary[Tags.STRUCTURE_RADIUS_MM] = 3 - vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.blood() + vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.blood() vessel_1_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_1_dictionary[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE @@ -73,7 +73,7 @@ def create_example_tissue(): epidermis_dictionary[Tags.PRIORITY] = 8 epidermis_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 9] epidermis_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 10] - epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.epidermis() + epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.epidermis() epidermis_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True epidermis_dictionary[Tags.ADHERE_TO_DEFORMATION] = True epidermis_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE diff --git a/simpa_examples/minimal_optical_simulation_heterogeneous_tissue.py b/simpa_examples/minimal_optical_simulation_heterogeneous_tissue.py index 12e240c2..24044f79 100644 --- a/simpa_examples/minimal_optical_simulation_heterogeneous_tissue.py +++ b/simpa_examples/minimal_optical_simulation_heterogeneous_tissue.py @@ -40,16 +40,15 @@ def create_example_tissue(settings): and a blood vessel. """ dim_x, dim_y, dim_z = settings.get_volume_dimensions_voxels() - tissue_library = sp.TISSUE_LIBRARY background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = tissue_library.constant(1e-4, 1e-4, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(1e-4, 1e-4, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND muscle_dictionary = sp.Settings() muscle_dictionary[Tags.PRIORITY] = 1 muscle_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 10] muscle_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 100] - muscle_dictionary[Tags.MOLECULE_COMPOSITION] = tissue_library.muscle( + muscle_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.muscle( oxygenation=sp.BlobHeterogeneity(dim_x, dim_y, dim_z, SPACING, target_min=0.5, target_max=0.8).get_map(), blood_volume_fraction=sp.BlobHeterogeneity(dim_x, dim_y, dim_z, SPACING, @@ -67,7 +66,7 @@ def create_example_tissue(settings): 12, VOLUME_HEIGHT_IN_MM/2] vessel_1_dictionary[Tags.STRUCTURE_RADIUS_MM] = 3 - vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = tissue_library.blood( + vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.blood( oxygenation=sp.RandomHeterogeneity(dim_x, dim_y, dim_z, SPACING, target_min=0.9, target_max=1.0).get_map()) vessel_1_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True @@ -77,7 +76,7 @@ def create_example_tissue(settings): epidermis_dictionary[Tags.PRIORITY] = 8 epidermis_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 9] epidermis_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 10] - epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = tissue_library.epidermis( + epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.epidermis( melanin_volume_fraction=sp.RandomHeterogeneity(dim_x, dim_y, dim_z, SPACING, target_min=0.1, target_max=0.2).get_map()) epidermis_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_examples/minimal_optical_simulation_uniform_cube.py b/simpa_examples/minimal_optical_simulation_uniform_cube.py index 2e08796c..a94e9af0 100644 --- a/simpa_examples/minimal_optical_simulation_uniform_cube.py +++ b/simpa_examples/minimal_optical_simulation_uniform_cube.py @@ -49,7 +49,7 @@ def create_example_tissue(): It contains only a generic background tissue material. """ background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(1e-4, 1e-4, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(1e-4, 1e-4, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = sp.Settings() diff --git a/simpa_examples/optical_and_acoustic_simulation.py b/simpa_examples/optical_and_acoustic_simulation.py index 34887450..868638ec 100644 --- a/simpa_examples/optical_and_acoustic_simulation.py +++ b/simpa_examples/optical_and_acoustic_simulation.py @@ -43,33 +43,33 @@ def create_example_tissue(): and a blood vessel. """ background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(1e-10, 1e-10, 1.0) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(1e-10, 1e-10, 1.0) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = sp.Settings() tissue_dict[Tags.BACKGROUND] = background_dictionary tissue_dict["muscle"] = sp.define_horizontal_layer_structure_settings(z_start_mm=0, thickness_mm=100, - molecular_composition=sp.TISSUE_LIBRARY.constant( + molecular_composition=sp.TissueLibrary.constant( 0.05, 100, 0.9), priority=1, consider_partial_volume=True, adhere_to_deformation=True) tissue_dict["epidermis"] = sp.define_horizontal_layer_structure_settings(z_start_mm=1, thickness_mm=0.1, - molecular_composition=sp.TISSUE_LIBRARY.epidermis(), + molecular_composition=sp.TissueLibrary.epidermis(), priority=8, consider_partial_volume=True, adhere_to_deformation=True) tissue_dict["vessel_1"] = sp.define_circular_tubular_structure_settings( tube_start_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2 - 10, 0, 5], tube_end_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2 - 10, VOLUME_PLANAR_DIM_IN_MM, 5], - molecular_composition=sp.TISSUE_LIBRARY.blood(), + molecular_composition=sp.TissueLibrary.blood(), radius_mm=2, priority=3, consider_partial_volume=True, adhere_to_deformation=False ) tissue_dict["vessel_2"] = sp.define_circular_tubular_structure_settings( tube_start_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2, 0, 10], tube_end_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2, VOLUME_PLANAR_DIM_IN_MM, 10], - molecular_composition=sp.TISSUE_LIBRARY.blood(), + molecular_composition=sp.TissueLibrary.blood(), radius_mm=3, priority=3, consider_partial_volume=True, adhere_to_deformation=False ) diff --git a/simpa_examples/perform_iterative_qPAI_reconstruction.py b/simpa_examples/perform_iterative_qPAI_reconstruction.py index 7a299733..899485cf 100644 --- a/simpa_examples/perform_iterative_qPAI_reconstruction.py +++ b/simpa_examples/perform_iterative_qPAI_reconstruction.py @@ -48,14 +48,14 @@ def create_example_tissue(): and a blood vessel. """ background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(0.05, 30, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(0.05, 30, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND epidermis_structure = sp.Settings() epidermis_structure[Tags.PRIORITY] = 1 epidermis_structure[Tags.STRUCTURE_START_MM] = [0, 0, 2] epidermis_structure[Tags.STRUCTURE_END_MM] = [0, 0, 2.5] - epidermis_structure[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(2.2, 100.0, 0.9) + epidermis_structure[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(2.2, 100.0, 0.9) epidermis_structure[Tags.CONSIDER_PARTIAL_VOLUME] = True epidermis_structure[Tags.ADHERE_TO_DEFORMATION] = True epidermis_structure[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE @@ -68,7 +68,7 @@ def create_example_tissue(): VOLUME_PLANAR_DIM_IN_MM, VOLUME_HEIGHT_IN_MM / 2] vessel_structure_1[Tags.STRUCTURE_RADIUS_MM] = 1.75 vessel_structure_1[Tags.STRUCTURE_ECCENTRICITY] = 0.85 - vessel_structure_1[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(5.2, 100.0, 0.9) + vessel_structure_1[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(5.2, 100.0, 0.9) vessel_structure_1[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_structure_1[Tags.ADHERE_TO_DEFORMATION] = True vessel_structure_1[Tags.STRUCTURE_TYPE] = Tags.ELLIPTICAL_TUBULAR_STRUCTURE @@ -80,7 +80,7 @@ def create_example_tissue(): vessel_structure_2[Tags.STRUCTURE_END_MM] = [VOLUME_TRANSDUCER_DIM_IN_MM / 2, VOLUME_PLANAR_DIM_IN_MM, VOLUME_HEIGHT_IN_MM / 3] vessel_structure_2[Tags.STRUCTURE_RADIUS_MM] = 0.75 - vessel_structure_2[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(3.0, 100.0, 0.9) + vessel_structure_2[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(3.0, 100.0, 0.9) vessel_structure_2[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_structure_2[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE diff --git a/simpa_examples/segmentation_loader.py b/simpa_examples/segmentation_loader.py index a4d9cd39..9fa4174b 100644 --- a/simpa_examples/segmentation_loader.py +++ b/simpa_examples/segmentation_loader.py @@ -45,21 +45,21 @@ def run_segmentation_loader(spacing: float | int = 1.0, input_spacing: float | i def segmentation_class_mapping(): ret_dict = dict() - ret_dict[0] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[1] = sp.TISSUE_LIBRARY.blood() - ret_dict[2] = sp.TISSUE_LIBRARY.epidermis() - ret_dict[3] = sp.TISSUE_LIBRARY.muscle() - ret_dict[4] = sp.TISSUE_LIBRARY.mediprene() - ret_dict[5] = sp.TISSUE_LIBRARY.ultrasound_gel() - ret_dict[6] = sp.TISSUE_LIBRARY.heavy_water() + ret_dict[0] = sp.TissueLibrary.heavy_water() + ret_dict[1] = sp.TissueLibrary.blood() + ret_dict[2] = sp.TissueLibrary.epidermis() + ret_dict[3] = sp.TissueLibrary.muscle() + ret_dict[4] = sp.TissueLibrary.mediprene() + ret_dict[5] = sp.TissueLibrary.ultrasound_gel() + ret_dict[6] = sp.TissueLibrary.heavy_water() ret_dict[7] = (sp.MolecularCompositionGenerator() - .append(sp.MOLECULE_LIBRARY.oxyhemoglobin(0.01)) - .append(sp.MOLECULE_LIBRARY.deoxyhemoglobin(0.01)) - .append(sp.MOLECULE_LIBRARY.water(0.98)) + .append(sp.MoleculeLibrary.oxyhemoglobin(0.01)) + .append(sp.MoleculeLibrary.deoxyhemoglobin(0.01)) + .append(sp.MoleculeLibrary.water(0.98)) .get_molecular_composition(sp.SegmentationClasses.COUPLING_ARTIFACT)) - ret_dict[8] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[9] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[10] = sp.TISSUE_LIBRARY.heavy_water() + ret_dict[8] = sp.TissueLibrary.heavy_water() + ret_dict[9] = sp.TissueLibrary.heavy_water() + ret_dict[10] = sp.TissueLibrary.heavy_water() return ret_dict settings = sp.Settings() diff --git a/simpa_examples/three_vs_two_dimensional_simulation_example.py b/simpa_examples/three_vs_two_dimensional_simulation_example.py index 6df7845f..15458c57 100644 --- a/simpa_examples/three_vs_two_dimensional_simulation_example.py +++ b/simpa_examples/three_vs_two_dimensional_simulation_example.py @@ -52,33 +52,33 @@ def create_example_tissue(): and a blood vessel. """ background_dictionary = sp.Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TISSUE_LIBRARY.constant(1e-10, 1e-10, 1.0) + background_dictionary[Tags.MOLECULE_COMPOSITION] = sp.TissueLibrary.constant(1e-10, 1e-10, 1.0) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = sp.Settings() tissue_dict[Tags.BACKGROUND] = background_dictionary tissue_dict["muscle"] = sp.define_horizontal_layer_structure_settings(z_start_mm=0, thickness_mm=100, - molecular_composition=sp.TISSUE_LIBRARY.constant( + molecular_composition=sp.TissueLibrary.constant( 0.05, 100, 0.9), priority=1, consider_partial_volume=True, adhere_to_deformation=True) tissue_dict["epidermis"] = sp.define_horizontal_layer_structure_settings(z_start_mm=1, thickness_mm=0.1, - molecular_composition=sp.TISSUE_LIBRARY.epidermis(), + molecular_composition=sp.TissueLibrary.epidermis(), priority=8, consider_partial_volume=True, adhere_to_deformation=True) tissue_dict["vessel_1"] = sp.define_circular_tubular_structure_settings( tube_start_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2 - 10, 0, 5], tube_end_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2 - 10, VOLUME_PLANAR_DIM_IN_MM, 5], - molecular_composition=sp.TISSUE_LIBRARY.blood(), + molecular_composition=sp.TissueLibrary.blood(), radius_mm=2, priority=3, consider_partial_volume=True, adhere_to_deformation=False ) tissue_dict["vessel_2"] = sp.define_circular_tubular_structure_settings( tube_start_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2, 0, 10], tube_end_mm=[VOLUME_TRANSDUCER_DIM_IN_MM/2, VOLUME_PLANAR_DIM_IN_MM, 10], - molecular_composition=sp.TISSUE_LIBRARY.blood(), + molecular_composition=sp.TissueLibrary.blood(), radius_mm=3, priority=3, consider_partial_volume=True, adhere_to_deformation=False ) diff --git a/simpa_tests/automatic_tests/structure_tests/test_boxes.py b/simpa_tests/automatic_tests/structure_tests/test_boxes.py index b2d0b1a3..7457d37e 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_boxes.py +++ b/simpa_tests/automatic_tests/structure_tests/test_boxes.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT import unittest -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils import Tags from simpa.utils.settings import Settings from simpa.utils.libraries.structure_library import RectangularCuboidStructure @@ -24,7 +24,7 @@ def setUp(self): self.box_settings[Tags.STRUCTURE_X_EXTENT_MM] = 1 self.box_settings[Tags.STRUCTURE_Y_EXTENT_MM] = 1 self.box_settings[Tags.STRUCTURE_Z_EXTENT_MM] = 1 - self.box_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.box_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.box_settings[Tags.ADHERE_TO_DEFORMATION] = True self.box_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/structure_tests/test_elliptical_tubes.py b/simpa_tests/automatic_tests/structure_tests/test_elliptical_tubes.py index e20681ee..0517c9c3 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_elliptical_tubes.py +++ b/simpa_tests/automatic_tests/structure_tests/test_elliptical_tubes.py @@ -4,7 +4,7 @@ import unittest import numpy as np -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils import Tags from simpa.utils.settings import Settings from simpa.utils.libraries.structure_library import EllipticalTubularStructure @@ -25,7 +25,7 @@ def setUp(self): self.elliptical_tube_settings[Tags.STRUCTURE_RADIUS_MM] = 1 self.elliptical_tube_settings[Tags.STRUCTURE_END_MM] = [0, 5, 0] self.elliptical_tube_settings[Tags.STRUCTURE_ECCENTRICITY] = 0 - self.elliptical_tube_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.elliptical_tube_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.elliptical_tube_settings[Tags.ADHERE_TO_DEFORMATION] = True self.elliptical_tube_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/structure_tests/test_layers.py b/simpa_tests/automatic_tests/structure_tests/test_layers.py index 451e3769..2710ec42 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_layers.py +++ b/simpa_tests/automatic_tests/structure_tests/test_layers.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT import unittest -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils.deformation_manager import create_deformation_settings from simpa.utils import Tags from simpa.utils.settings import Settings @@ -27,7 +27,7 @@ def setUp(self): self.layer_settings = Settings() self.layer_settings[Tags.STRUCTURE_START_MM] = [0, 0, 0] self.layer_settings[Tags.STRUCTURE_END_MM] = [0, 0, 0] - self.layer_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.layer_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.layer_settings[Tags.ADHERE_TO_DEFORMATION] = True self.layer_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/structure_tests/test_parallel_epipeds.py b/simpa_tests/automatic_tests/structure_tests/test_parallel_epipeds.py index fd59d218..7bd3a73a 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_parallel_epipeds.py +++ b/simpa_tests/automatic_tests/structure_tests/test_parallel_epipeds.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT import unittest -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils import Tags from simpa.utils.settings import Settings from simpa.utils.libraries.structure_library import ParallelepipedStructure @@ -24,7 +24,7 @@ def setUp(self): self.parallelepiped_settings[Tags.STRUCTURE_FIRST_EDGE_MM] = [1, 0, 0] self.parallelepiped_settings[Tags.STRUCTURE_SECOND_EDGE_MM] = [0, 1, 0] self.parallelepiped_settings[Tags.STRUCTURE_THIRD_EDGE_MM] = [0, 0, 1] - self.parallelepiped_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.parallelepiped_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.parallelepiped_settings[Tags.ADHERE_TO_DEFORMATION] = True self.parallelepiped_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/structure_tests/test_spheres.py b/simpa_tests/automatic_tests/structure_tests/test_spheres.py index 14a4388f..6f94c87a 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_spheres.py +++ b/simpa_tests/automatic_tests/structure_tests/test_spheres.py @@ -4,7 +4,7 @@ import unittest import numpy as np -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils import Tags from simpa.utils.settings import Settings from simpa.utils.libraries.structure_library import SphericalStructure @@ -23,7 +23,7 @@ def setUp(self): self.sphere_settings = Settings() self.sphere_settings[Tags.STRUCTURE_START_MM] = [0, 0, 0] self.sphere_settings[Tags.STRUCTURE_RADIUS_MM] = 1 - self.sphere_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.sphere_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.sphere_settings[Tags.ADHERE_TO_DEFORMATION] = True self.sphere_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/structure_tests/test_tubes.py b/simpa_tests/automatic_tests/structure_tests/test_tubes.py index 7805dd64..0ee26ad9 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_tubes.py +++ b/simpa_tests/automatic_tests/structure_tests/test_tubes.py @@ -4,7 +4,7 @@ import unittest import numpy as np -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils import Tags from simpa.utils.settings import Settings from simpa.utils.libraries.structure_library import CircularTubularStructure @@ -24,7 +24,7 @@ def setUp(self): self.tube_settings[Tags.STRUCTURE_START_MM] = [0, 0, 0] self.tube_settings[Tags.STRUCTURE_RADIUS_MM] = 1 self.tube_settings[Tags.STRUCTURE_END_MM] = [0, 5, 0] - self.tube_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.tube_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.tube_settings[Tags.ADHERE_TO_DEFORMATION] = True self.tube_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/structure_tests/test_vesseltree.py b/simpa_tests/automatic_tests/structure_tests/test_vesseltree.py index af3cbaf4..17958b81 100644 --- a/simpa_tests/automatic_tests/structure_tests/test_vesseltree.py +++ b/simpa_tests/automatic_tests/structure_tests/test_vesseltree.py @@ -6,7 +6,7 @@ import numpy as np import torch from skimage import measure -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils import Tags from simpa.utils.settings import Settings from simpa.utils.libraries.structure_library import VesselStructure @@ -29,7 +29,7 @@ def setUp(self): self.vesseltree_settings[Tags.STRUCTURE_BIFURCATION_LENGTH_MM] = 20 self.vesseltree_settings[Tags.STRUCTURE_RADIUS_VARIATION_FACTOR] = 0 self.vesseltree_settings[Tags.STRUCTURE_CURVATURE_FACTOR] = 0 - self.vesseltree_settings[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + self.vesseltree_settings[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() self.vesseltree_settings[Tags.ADHERE_TO_DEFORMATION] = True self.vesseltree_settings[Tags.CONSIDER_PARTIAL_VOLUME] = True diff --git a/simpa_tests/automatic_tests/test_calculation_utils.py b/simpa_tests/automatic_tests/test_calculation_utils.py index 02c34f34..49b5a12f 100644 --- a/simpa_tests/automatic_tests/test_calculation_utils.py +++ b/simpa_tests/automatic_tests/test_calculation_utils.py @@ -4,7 +4,7 @@ import unittest from simpa.utils import SegmentationClasses, MolecularCompositionGenerator -from simpa.utils.libraries.molecule_library import MOLECULE_LIBRARY +from simpa.utils.libraries.molecule_library import MoleculeLibrary from simpa.utils.calculate import calculate_oxygenation, calculate_bvf from simpa.utils.calculate import randomize_uniform from simpa.utils.calculate import calculate_gruneisen_parameter_from_temperature @@ -19,36 +19,36 @@ def test_oxygenation_calculation(self): # Neither oxy nor deoxy: mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) + mcg.append(MoleculeLibrary.fat(1.0)) oxy_value = calculate_oxygenation(mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC)) assert oxy_value is None mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(0.0)) + mcg.append(MoleculeLibrary.fat(1.0)) + mcg.append(MoleculeLibrary.oxyhemoglobin(0.0)) oxy_value = calculate_oxygenation(mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC)) assert oxy_value is None # FULLY OXYGENATED CASES: mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(1.0)) + mcg.append(MoleculeLibrary.fat(1.0)) + mcg.append(MoleculeLibrary.oxyhemoglobin(1.0)) fully_oxygenated = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) oxy_value = calculate_oxygenation(fully_oxygenated) assert abs(oxy_value-1.0) < 1e-5, ("oxy value was not 1.0 but " + str(oxy_value)) - mcg.append(MOLECULE_LIBRARY.deoxyhemoglobin(0.0)) + mcg.append(MoleculeLibrary.deoxyhemoglobin(0.0)) fully_oxygenated = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) oxy_value = calculate_oxygenation(fully_oxygenated) assert abs(oxy_value-1.0) < 1e-5, ("oxy value was not 1.0 but " + str(oxy_value)) # FULLY DEOXYGENATED CASES: mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) - mcg.append(MOLECULE_LIBRARY.deoxyhemoglobin(1.0)) + mcg.append(MoleculeLibrary.fat(1.0)) + mcg.append(MoleculeLibrary.deoxyhemoglobin(1.0)) fully_deoxygenated = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) oxy_value = calculate_oxygenation(fully_deoxygenated) assert abs(oxy_value) < 1e-5, ("oxy value was not 0.0 but " + str(oxy_value)) - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(0.0)) + mcg.append(MoleculeLibrary.oxyhemoglobin(0.0)) fully_deoxygenated = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) oxy_value = calculate_oxygenation(fully_deoxygenated) assert abs(oxy_value) < 1e-5, ("oxy value was not 0.0 but " + str(oxy_value)) @@ -58,9 +58,9 @@ def test_oxygenation_calculation(self): oxy = np.random.random() deoxy = np.random.random() mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) - mcg.append(MOLECULE_LIBRARY.deoxyhemoglobin(deoxy)) - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(oxy)) + mcg.append(MoleculeLibrary.fat(1.0)) + mcg.append(MoleculeLibrary.deoxyhemoglobin(deoxy)) + mcg.append(MoleculeLibrary.oxyhemoglobin(oxy)) sO2_value = calculate_oxygenation(mcg.get_molecular_composition( segmentation_type=SegmentationClasses.GENERIC)) @@ -70,34 +70,34 @@ def test_bvf_calculation(self): # Neither oxy nor deoxy: mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) + mcg.append(MoleculeLibrary.fat(1.0)) bvf_value = calculate_bvf(mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC)) assert bvf_value == 0 mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(1.0)) - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(0.0)) + mcg.append(MoleculeLibrary.fat(1.0)) + mcg.append(MoleculeLibrary.oxyhemoglobin(0.0)) bvf_value = calculate_bvf(mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC)) assert bvf_value == 0 # Just oxyhemoglobin CASES: mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(1.0)) + mcg.append(MoleculeLibrary.oxyhemoglobin(1.0)) oxy_hemo = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) bvf_value = calculate_bvf(oxy_hemo) assert bvf_value == 1.0 - mcg.append(MOLECULE_LIBRARY.deoxyhemoglobin(0.0)) + mcg.append(MoleculeLibrary.deoxyhemoglobin(0.0)) oxy_hemo = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) bvf_value = calculate_bvf(oxy_hemo) assert bvf_value == 1.0 # Just deoxyhemoglobin CASES: mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.deoxyhemoglobin(1.0)) + mcg.append(MoleculeLibrary.deoxyhemoglobin(1.0)) deoxy_hemo = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) bvf_value = calculate_bvf(deoxy_hemo) assert bvf_value == 1.0 - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(0.0)) + mcg.append(MoleculeLibrary.oxyhemoglobin(0.0)) deoxy_hemo = mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC) bvf_value = calculate_bvf(deoxy_hemo) assert bvf_value == 1.0 @@ -109,9 +109,9 @@ def test_bvf_calculation(self): fat = np.random.random() sum_oxy_deoxy_fat = oxy + deoxy + fat mcg = MolecularCompositionGenerator() - mcg.append(MOLECULE_LIBRARY.fat(fat/sum_oxy_deoxy_fat)) - mcg.append(MOLECULE_LIBRARY.deoxyhemoglobin(deoxy/sum_oxy_deoxy_fat)) - mcg.append(MOLECULE_LIBRARY.oxyhemoglobin(oxy/sum_oxy_deoxy_fat)) + mcg.append(MoleculeLibrary.fat(fat/sum_oxy_deoxy_fat)) + mcg.append(MoleculeLibrary.deoxyhemoglobin(deoxy/sum_oxy_deoxy_fat)) + mcg.append(MoleculeLibrary.oxyhemoglobin(oxy/sum_oxy_deoxy_fat)) bvf_value = calculate_bvf(mcg.get_molecular_composition(segmentation_type=SegmentationClasses.GENERIC)) assert abs(bvf_value - (oxy+deoxy)/sum_oxy_deoxy_fat) < 1e-10 diff --git a/simpa_tests/automatic_tests/test_io_handling.py b/simpa_tests/automatic_tests/test_io_handling.py index 2423362f..6280ed3e 100644 --- a/simpa_tests/automatic_tests/test_io_handling.py +++ b/simpa_tests/automatic_tests/test_io_handling.py @@ -8,7 +8,7 @@ from simpa.io_handling import save_hdf5 from simpa.utils import Tags from simpa.utils.settings import Settings -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY, AbsorptionSpectrumLibrary +from simpa.utils.libraries.tissue_library import TissueLibrary, AbsorptionSpectrumLibrary from simpa_tests.test_utils import assert_equals_recursive from simpa.core.device_digital_twins import * import os @@ -48,7 +48,7 @@ def test_write_and_read_structure_dictionary(self): save_dictionary[Tags.SETTINGS] = settings background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND structure_settings = Settings() structure_settings["background"] = background_dictionary diff --git a/simpa_tests/automatic_tests/test_noise_models.py b/simpa_tests/automatic_tests/test_noise_models.py index d6912cd4..c2e9df30 100644 --- a/simpa_tests/automatic_tests/test_noise_models.py +++ b/simpa_tests/automatic_tests/test_noise_models.py @@ -11,7 +11,7 @@ from simpa.utils import Tags, Settings from simpa.core.device_digital_twins import RSOMExplorerP50 from simpa.core.simulation import simulate -from simpa.utils import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.io_handling import load_data_field from simpa import ModelBasedAdapter @@ -22,7 +22,7 @@ class TestNoiseModels(unittest.TestCase): def create_background_parameters(background_value): background_structure_dictionary = dict() background_structure_dictionary[Tags.PRIORITY] = 0 - background_structure_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant( + background_structure_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant( mua=background_value, mus=background_value, g=0.5 ) background_structure_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND diff --git a/simpa_tests/automatic_tests/tissue_library/test_core_assumptions.py b/simpa_tests/automatic_tests/tissue_library/test_core_assumptions.py index 049d6540..1451cb4c 100644 --- a/simpa_tests/automatic_tests/tissue_library/test_core_assumptions.py +++ b/simpa_tests/automatic_tests/tissue_library/test_core_assumptions.py @@ -7,7 +7,7 @@ import numpy as np -from simpa.utils import Tags, Settings, TISSUE_LIBRARY +from simpa.utils import Tags, Settings from simpa.utils.calculate import calculate_bvf, calculate_oxygenation from simpa.utils.libraries.molecule_library import MolecularComposition from simpa.utils.libraries.tissue_library import TissueLibrary @@ -25,7 +25,7 @@ class TestCoreAssumptions(unittest.TestCase): def test_volume_fractions_sum_to_less_or_equal_one(self): for (method_name, method) in self.get_all_tissue_library_methods(): - molecular_composition = method(TISSUE_LIBRARY) + molecular_composition = method() tissue_composition = molecular_composition.get_properties_for_wavelength(TEST_SETTINGS, 800) total_volume_fraction = tissue_composition.volume_fraction self.assertTrue((np.abs(total_volume_fraction-1.0) < 1e-3).all(), @@ -50,20 +50,20 @@ def compare_input_with_calculations(test_tissue, oxy, bvf): bvf_values = [0., 1., 0., 1., np.random.random()] for oxy in oxy_values: # assert blood only with varying oxygenation_values - test_tissue = TISSUE_LIBRARY.blood(oxygenation=oxy) + test_tissue = TissueLibrary.blood(oxygenation=oxy) compare_input_with_calculations(test_tissue, oxy, 1.) # assert all other tissue classes with varying oxygenation- and bvf_values for bvf in bvf_values: for (_, method) in self.get_all_tissue_library_methods(): args = inspect.getfullargspec(method).args if "background_oxy" in args and "blood_volume_fraction" in args: - test_tissue = method(TISSUE_LIBRARY, background_oxy=oxy, blood_volume_fraction=bvf) + test_tissue = method(TissueLibrary, background_oxy=oxy, blood_volume_fraction=bvf) compare_input_with_calculations(test_tissue, oxy, bvf) @staticmethod def get_all_tissue_library_methods(): methods = [] for method in inspect.getmembers(TissueLibrary, predicate=inspect.isfunction): - if isinstance(method[1](TISSUE_LIBRARY), MolecularComposition): + if isinstance(method[1](), MolecularComposition): methods.append(method) return methods diff --git a/simpa_tests/automatic_tests/tissue_library/test_tissue_library.py b/simpa_tests/automatic_tests/tissue_library/test_tissue_library.py index b36a734b..d9b9b52d 100644 --- a/simpa_tests/automatic_tests/tissue_library/test_tissue_library.py +++ b/simpa_tests/automatic_tests/tissue_library/test_tissue_library.py @@ -5,7 +5,8 @@ import numpy as np import pytest -from simpa import Spectrum, SegmentationClasses, TISSUE_LIBRARY, Molecule +from simpa import Spectrum, SegmentationClasses, Molecule +from simpa.utils.libraries.tissue_library import TissueLibrary def test_if_optical_parameter_spectra_are_provided_correct_tissue_definition_is_returned_from_generic_tissue(): @@ -18,7 +19,7 @@ def test_if_optical_parameter_spectra_are_provided_correct_tissue_definition_is_ mus_spectrum = Spectrum("Mus", wavelengths_sample, mus_sample) g_spectrum = Spectrum("g", wavelengths_sample, g_sample) - actual_tissue = TISSUE_LIBRARY.generic_tissue(mua_spectrum, mus_spectrum, g_spectrum) + actual_tissue = TissueLibrary.generic_tissue(mua_spectrum, mus_spectrum, g_spectrum) assert actual_tissue.segmentation_type == SegmentationClasses.GENERIC assert len(actual_tissue) == 1 @@ -40,13 +41,13 @@ def test_if_generic_tissue_is_called_with_invalid_arguments_error_is_raised(): g_spectrum = Spectrum("g", wavelengths_sample, g_sample) with pytest.raises(AssertionError): - TISSUE_LIBRARY.generic_tissue(None, mus_spectrum, g_spectrum) + TissueLibrary.generic_tissue(None, mus_spectrum, g_spectrum) with pytest.raises(AssertionError): - TISSUE_LIBRARY.generic_tissue(mua_spectrum, None, g_spectrum) + TissueLibrary.generic_tissue(mua_spectrum, None, g_spectrum) with pytest.raises(AssertionError): - TISSUE_LIBRARY.generic_tissue(mua_spectrum, mus_spectrum, None) + TissueLibrary.generic_tissue(mua_spectrum, mus_spectrum, None) def test_if_optical_parameter_spectra_are_provided_correct_tissue_definition_is_returned_from_constant(): @@ -54,7 +55,7 @@ def test_if_optical_parameter_spectra_are_provided_correct_tissue_definition_is_ mus_sample = 3e-6 g_sample = 0.85 - actual_tissue = TISSUE_LIBRARY.constant(mua_sample, mus_sample, g_sample) + actual_tissue = TissueLibrary.constant(mua_sample, mus_sample, g_sample) assert actual_tissue.segmentation_type == SegmentationClasses.GENERIC assert len(actual_tissue) == 1 @@ -71,10 +72,10 @@ def test_if_constant_is_called_with_invalid_arguments_error_is_raised(): g_sample = 0.85 with pytest.raises(TypeError): - TISSUE_LIBRARY.constant(None, mus_sample, g_sample) + TissueLibrary.constant(None, mus_sample, g_sample) with pytest.raises(TypeError): - TISSUE_LIBRARY.constant(mua_sample, None, g_sample) + TissueLibrary.constant(mua_sample, None, g_sample) with pytest.raises(TypeError): - TISSUE_LIBRARY.constant(mua_sample, mus_sample, None) + TissueLibrary.constant(mua_sample, mus_sample, None) diff --git a/simpa_tests/automatic_tests/tissue_library/test_tissue_library_against_literature_values.py b/simpa_tests/automatic_tests/tissue_library/test_tissue_library_against_literature_values.py index d6717dd5..96570d43 100644 --- a/simpa_tests/automatic_tests/tissue_library/test_tissue_library_against_literature_values.py +++ b/simpa_tests/automatic_tests/tissue_library/test_tissue_library_against_literature_values.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT import unittest -from simpa.utils import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa_tests.test_utils.tissue_composition_tests import compare_molecular_composition_against_expected_values, \ get_epidermis_reference_dictionary, get_dermis_reference_dictionary, get_muscle_reference_dictionary, \ get_fully_oxygenated_blood_reference_dictionary, \ @@ -27,7 +27,7 @@ def tearDown(self) -> None: def test_epidermis_parameters(self): compare_molecular_composition_against_expected_values( - molecular_composition=TISSUE_LIBRARY.epidermis(0.014), + molecular_composition=TissueLibrary.epidermis(0.014), expected_values=get_epidermis_reference_dictionary(), visualise_values=VISUALISE, title="EPIDERMIS" @@ -35,7 +35,7 @@ def test_epidermis_parameters(self): def test_dermis_parameters(self): compare_molecular_composition_against_expected_values( - molecular_composition=TISSUE_LIBRARY.dermis(), + molecular_composition=TissueLibrary.dermis(), expected_values=get_dermis_reference_dictionary(), visualise_values=VISUALISE, title="DERMIS" @@ -43,7 +43,7 @@ def test_dermis_parameters(self): def test_muscle_parameters(self): compare_molecular_composition_against_expected_values( - molecular_composition=TISSUE_LIBRARY.muscle(), + molecular_composition=TissueLibrary.muscle(), expected_values=get_muscle_reference_dictionary(), visualise_values=VISUALISE, title="MUSCLE" @@ -51,7 +51,7 @@ def test_muscle_parameters(self): def test_blood_oxy_parameters(self): compare_molecular_composition_against_expected_values( - molecular_composition=TISSUE_LIBRARY.blood(1.0), + molecular_composition=TissueLibrary.blood(1.0), expected_values=get_fully_oxygenated_blood_reference_dictionary(only_use_NIR_values=True), visualise_values=VISUALISE, title="OXY BLOOD" @@ -59,7 +59,7 @@ def test_blood_oxy_parameters(self): def test_blood_deoxy_parameters(self): compare_molecular_composition_against_expected_values( - molecular_composition=TISSUE_LIBRARY.blood(0.0), + molecular_composition=TissueLibrary.blood(0.0), expected_values=get_fully_deoxygenated_blood_reference_dictionary(only_use_NIR_values=True), visualise_values=VISUALISE, title="DEOXY BLOOD" @@ -67,7 +67,7 @@ def test_blood_deoxy_parameters(self): def test_lymph_node_parameters(self): compare_molecular_composition_against_expected_values( - molecular_composition=TISSUE_LIBRARY.lymph_node(), + molecular_composition=TissueLibrary.lymph_node(), expected_values=get_lymph_node_reference_dictionary(only_use_NIR_values=True), visualise_values=VISUALISE, title="LYMPH NODE" diff --git a/simpa_tests/manual_tests/__init__.py b/simpa_tests/manual_tests/__init__.py index 2ff337b0..4391a361 100644 --- a/simpa_tests/manual_tests/__init__.py +++ b/simpa_tests/manual_tests/__init__.py @@ -4,7 +4,7 @@ import os import numpy as np from simpa.utils.path_manager import PathManager -from simpa.utils import Tags, Settings, TISSUE_LIBRARY +from simpa.utils import Tags, Settings, TissueLibrary from simpa.io_handling import load_data_field from simpa.core.device_digital_twins import MSOTAcuityEcho import matplotlib.pyplot as plt @@ -160,14 +160,14 @@ def create_example_tissue(self): and a blood vessel. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND muscle_dictionary = Settings() muscle_dictionary[Tags.PRIORITY] = 1 muscle_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 0] muscle_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 100] - muscle_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + muscle_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() muscle_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True muscle_dictionary[Tags.ADHERE_TO_DEFORMATION] = True muscle_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE @@ -179,7 +179,7 @@ def create_example_tissue(self): vessel_1_dictionary[Tags.STRUCTURE_END_MM] = [self.VOLUME_TRANSDUCER_DIM_IN_MM / 2, self.VOLUME_PLANAR_DIM_IN_MM, 10] vessel_1_dictionary[Tags.STRUCTURE_RADIUS_MM] = 3 - vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.blood() + vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.blood() vessel_1_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_1_dictionary[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE @@ -191,7 +191,7 @@ def create_example_tissue(self): self.VOLUME_PLANAR_DIM_IN_MM, 5] vessel_2_dictionary[Tags.STRUCTURE_RADIUS_MM] = 3 vessel_2_dictionary[Tags.STRUCTURE_ECCENTRICITY] = 0.9 - vessel_2_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.blood() + vessel_2_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.blood() vessel_2_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_2_dictionary[Tags.STRUCTURE_TYPE] = Tags.ELLIPTICAL_TUBULAR_STRUCTURE @@ -201,7 +201,7 @@ def create_example_tissue(self): vessel_3_dictionary[Tags.STRUCTURE_X_EXTENT_MM] = 8 vessel_3_dictionary[Tags.STRUCTURE_Y_EXTENT_MM] = 10 vessel_3_dictionary[Tags.STRUCTURE_Z_EXTENT_MM] = 16 - vessel_3_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.blood() + vessel_3_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.blood() vessel_3_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_3_dictionary[Tags.STRUCTURE_TYPE] = Tags.RECTANGULAR_CUBOID_STRUCTURE diff --git a/simpa_tests/manual_tests/acoustic_forward_models/KWaveAcousticForwardConvenienceFunction.py b/simpa_tests/manual_tests/acoustic_forward_models/KWaveAcousticForwardConvenienceFunction.py index de3e6f5d..0b6082d4 100644 --- a/simpa_tests/manual_tests/acoustic_forward_models/KWaveAcousticForwardConvenienceFunction.py +++ b/simpa_tests/manual_tests/acoustic_forward_models/KWaveAcousticForwardConvenienceFunction.py @@ -9,7 +9,7 @@ reconstruct_delay_and_sum_pytorch from simpa import MCXAdapter, ModelBasedAdapter, \ GaussianNoise -from simpa.utils import Tags, Settings, TISSUE_LIBRARY +from simpa.utils import Tags, Settings, TissueLibrary from simpa.core.simulation import simulate from simpa.io_handling import load_data_field import numpy as np @@ -157,14 +157,14 @@ def create_example_tissue(self): and a blood vessel. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(1e-10, 1e-10, 1.0) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(1e-10, 1e-10, 1.0) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND muscle_dictionary = Settings() muscle_dictionary[Tags.PRIORITY] = 1 muscle_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 0] muscle_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 100] - muscle_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(0.05, 100, 0.9) + muscle_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(0.05, 100, 0.9) muscle_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True muscle_dictionary[Tags.ADHERE_TO_DEFORMATION] = True muscle_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE @@ -176,7 +176,7 @@ def create_example_tissue(self): vessel_1_dictionary[Tags.STRUCTURE_END_MM] = [ self.VOLUME_TRANSDUCER_DIM_IN_MM/2, self.VOLUME_PLANAR_DIM_IN_MM, 10] vessel_1_dictionary[Tags.STRUCTURE_RADIUS_MM] = 3 - vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.blood() + vessel_1_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.blood() vessel_1_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_1_dictionary[Tags.ADHERE_TO_DEFORMATION] = False vessel_1_dictionary[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE @@ -188,7 +188,7 @@ def create_example_tissue(self): vessel_2_dictionary[Tags.STRUCTURE_END_MM] = [ self.VOLUME_TRANSDUCER_DIM_IN_MM/2 - 10, self.VOLUME_PLANAR_DIM_IN_MM, 5] vessel_2_dictionary[Tags.STRUCTURE_RADIUS_MM] = 2 - vessel_2_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.blood() + vessel_2_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.blood() vessel_2_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_2_dictionary[Tags.ADHERE_TO_DEFORMATION] = False vessel_2_dictionary[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE @@ -197,7 +197,7 @@ def create_example_tissue(self): epidermis_dictionary[Tags.PRIORITY] = 8 epidermis_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 1] epidermis_dictionary[Tags.STRUCTURE_END_MM] = [0, 0, 1.1] - epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.epidermis() + epidermis_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.epidermis() epidermis_dictionary[Tags.CONSIDER_PARTIAL_VOLUME] = True epidermis_dictionary[Tags.ADHERE_TO_DEFORMATION] = True epidermis_dictionary[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE diff --git a/simpa_tests/manual_tests/executables/MATLABAdditionalFlags.py b/simpa_tests/manual_tests/executables/MATLABAdditionalFlags.py index 2c006ac5..f9eba1b8 100644 --- a/simpa_tests/manual_tests/executables/MATLABAdditionalFlags.py +++ b/simpa_tests/manual_tests/executables/MATLABAdditionalFlags.py @@ -6,7 +6,8 @@ import numpy as np from simpa import MCXAdapter, ModelBasedAdapter, simulate, KWaveAdapter from simpa.core.device_digital_twins import PhotoacousticDevice, PencilBeamIlluminationGeometry, LinearArrayDetectionGeometry -from simpa.utils import Settings, Tags, TISSUE_LIBRARY, PathManager +from simpa.utils import Settings, Tags, PathManager +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa_tests.manual_tests import ManualIntegrationTestClass @@ -21,7 +22,7 @@ def create_example_tissue(self): """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(0.1, 100, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(0.1, 100, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = Settings() tissue_dict[Tags.BACKGROUND] = background_dictionary diff --git a/simpa_tests/manual_tests/executables/MCXAdditionalFlags.py b/simpa_tests/manual_tests/executables/MCXAdditionalFlags.py index b9e1768b..b6c210ba 100644 --- a/simpa_tests/manual_tests/executables/MCXAdditionalFlags.py +++ b/simpa_tests/manual_tests/executables/MCXAdditionalFlags.py @@ -6,7 +6,8 @@ import numpy as np from simpa import MCXAdapter, ModelBasedAdapter, simulate from simpa.core.device_digital_twins import PhotoacousticDevice, PencilBeamIlluminationGeometry -from simpa.utils import Settings, Tags, TISSUE_LIBRARY, PathManager +from simpa.utils import Settings, Tags, PathManager +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa_tests.manual_tests import ManualIntegrationTestClass @@ -18,7 +19,7 @@ def create_example_tissue(self): """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(0.1, 100, 0.9) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(0.1, 100, 0.9) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = Settings() tissue_dict[Tags.BACKGROUND] = background_dictionary diff --git a/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithInifinitesimalSlabExperiment.py b/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithInifinitesimalSlabExperiment.py index 3917e17d..7a7ecbcb 100644 --- a/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithInifinitesimalSlabExperiment.py +++ b/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithInifinitesimalSlabExperiment.py @@ -32,7 +32,7 @@ from simpa.core.device_digital_twins import PhotoacousticDevice, PencilBeamIlluminationGeometry from simpa.core.simulation import simulate from simpa.io_handling import load_data_field -from simpa.utils import Tags, Settings, PathManager, TISSUE_LIBRARY +from simpa.utils import Tags, Settings, PathManager, TissueLibrary from simpa_tests.manual_tests import ManualIntegrationTestClass # FIXME temporary workaround for newest Intel architectures os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" @@ -49,11 +49,11 @@ def create_example_tissue(self, slab_width, scattering_value=1e-30, absorption_v spacing = self.settings[Tags.SPACING_MM] background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(self.mua, self.mus, self.g) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(self.mua, self.mus, self.g) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND slab_dictionary = Settings() - slab_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(absorption_value, scattering_value, + slab_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(absorption_value, scattering_value, anisotropy_value) slab_dictionary[Tags.STRUCTURE_TYPE] = Tags.RECTANGULAR_CUBOID_STRUCTURE slab_dictionary[Tags.PRIORITY] = 9 diff --git a/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithinHomogenousMedium.py b/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithinHomogenousMedium.py index d3508b27..759e56a8 100644 --- a/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithinHomogenousMedium.py +++ b/simpa_tests/manual_tests/optical_forward_models/AbsorptionAndScatteringWithinHomogenousMedium.py @@ -32,7 +32,7 @@ from simpa.core.device_digital_twins import PhotoacousticDevice, PencilBeamIlluminationGeometry from simpa.core.simulation import simulate from simpa.io_handling import load_data_field -from simpa.utils import Tags, Settings, PathManager, TISSUE_LIBRARY +from simpa.utils import Tags, Settings, PathManager, TissueLibrary from simpa_tests.manual_tests import ManualIntegrationTestClass # FIXME temporary workaround for newest Intel architectures os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" @@ -47,7 +47,7 @@ def create_example_tissue(self, scattering_value=1e-30, absorption_value=1e-30, and two blood vessels. It is used for volume creation. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(absorption_value, + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(absorption_value, scattering_value, anisotropy_value) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND diff --git a/simpa_tests/manual_tests/optical_forward_models/CompareMCXResultsWithDiffusionTheory.py b/simpa_tests/manual_tests/optical_forward_models/CompareMCXResultsWithDiffusionTheory.py index e86b5a2a..de69515c 100644 --- a/simpa_tests/manual_tests/optical_forward_models/CompareMCXResultsWithDiffusionTheory.py +++ b/simpa_tests/manual_tests/optical_forward_models/CompareMCXResultsWithDiffusionTheory.py @@ -2,7 +2,8 @@ # SPDX-FileCopyrightText: 2021 Janek Groehl # SPDX-License-Identifier: MIT -from simpa.utils import Tags, PathManager, Settings, TISSUE_LIBRARY +from simpa.utils import Tags, PathManager, Settings +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.core.simulation import simulate from simpa import ModelBasedAdapter, MCXAdapter from simpa.core.device_digital_twins import PhotoacousticDevice, PencilBeamIlluminationGeometry @@ -24,7 +25,7 @@ def create_example_tissue(self): and two blood vessels. It is used for volume creation. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(self.mua, self.mus, self.g) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(self.mua, self.mus, self.g) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = Settings() tissue_dict[Tags.BACKGROUND] = background_dictionary diff --git a/simpa_tests/manual_tests/optical_forward_models/ComputeDiffuseReflectance.py b/simpa_tests/manual_tests/optical_forward_models/ComputeDiffuseReflectance.py index a748bd55..d4c4656a 100644 --- a/simpa_tests/manual_tests/optical_forward_models/ComputeDiffuseReflectance.py +++ b/simpa_tests/manual_tests/optical_forward_models/ComputeDiffuseReflectance.py @@ -2,7 +2,8 @@ # SPDX-FileCopyrightText: 2021 Janek Groehl # SPDX-License-Identifier: MIT -from simpa.utils import Tags, PathManager, Settings, TISSUE_LIBRARY +from simpa.utils import Tags, PathManager, Settings +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.core.simulation import simulate from simpa import ModelBasedAdapter, MCXReflectanceAdapter from simpa.core.device_digital_twins import PhotoacousticDevice, PencilBeamIlluminationGeometry @@ -25,7 +26,7 @@ def create_example_tissue(self): and two blood vessels. It is used for volume creation. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(self.mua, self.mus, self.g) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(self.mua, self.mus, self.g) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND tissue_dict = Settings() tissue_dict[Tags.BACKGROUND] = background_dictionary diff --git a/simpa_tests/manual_tests/processing_components/QPAIReconstruction.py b/simpa_tests/manual_tests/processing_components/QPAIReconstruction.py index d82f99f4..c140f069 100644 --- a/simpa_tests/manual_tests/processing_components/QPAIReconstruction.py +++ b/simpa_tests/manual_tests/processing_components/QPAIReconstruction.py @@ -9,7 +9,7 @@ from simpa.core.processing_components.monospectral.iterative_qPAI_algorithm import IterativeqPAI from simpa import MCXAdapter, ModelBasedAdapter, \ GaussianNoise -from simpa.utils import Tags, Settings, TISSUE_LIBRARY +from simpa.utils import Tags, Settings, TissueLibrary from simpa.core.simulation import simulate from simpa.io_handling import load_data_field from scipy.ndimage import zoom @@ -227,14 +227,14 @@ def create_example_tissue(self): and two blood vessels. It is used for volume creation. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(0.1, 100.0, 0.90) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(0.1, 100.0, 0.90) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND epidermis_structure = Settings() epidermis_structure[Tags.PRIORITY] = 1 epidermis_structure[Tags.STRUCTURE_START_MM] = [0, 0, 2] epidermis_structure[Tags.STRUCTURE_END_MM] = [0, 0, 2.5] - epidermis_structure[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(2.2, 100.0, 0.9) + epidermis_structure[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(2.2, 100.0, 0.9) epidermis_structure[Tags.CONSIDER_PARTIAL_VOLUME] = True epidermis_structure[Tags.ADHERE_TO_DEFORMATION] = True epidermis_structure[Tags.STRUCTURE_TYPE] = Tags.HORIZONTAL_LAYER_STRUCTURE @@ -247,7 +247,7 @@ def create_example_tissue(self): self.VOLUME_PLANAR_DIM_IN_MM, self.VOLUME_HEIGHT_IN_MM / 2] vessel_structure_1[Tags.STRUCTURE_RADIUS_MM] = 1.75 vessel_structure_1[Tags.STRUCTURE_ECCENTRICITY] = 0.85 - vessel_structure_1[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(5.2, 100.0, 0.9) + vessel_structure_1[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(5.2, 100.0, 0.9) vessel_structure_1[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_structure_1[Tags.ADHERE_TO_DEFORMATION] = True vessel_structure_1[Tags.STRUCTURE_TYPE] = Tags.ELLIPTICAL_TUBULAR_STRUCTURE @@ -259,7 +259,7 @@ def create_example_tissue(self): vessel_structure_2[Tags.STRUCTURE_END_MM] = [self.VOLUME_TRANSDUCER_DIM_IN_MM / 2, self.VOLUME_PLANAR_DIM_IN_MM, self.VOLUME_HEIGHT_IN_MM / 3] vessel_structure_2[Tags.STRUCTURE_RADIUS_MM] = 0.75 - vessel_structure_2[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(3.0, 100.0, 0.9) + vessel_structure_2[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(3.0, 100.0, 0.9) vessel_structure_2[Tags.CONSIDER_PARTIAL_VOLUME] = True vessel_structure_2[Tags.STRUCTURE_TYPE] = Tags.CIRCULAR_TUBULAR_STRUCTURE diff --git a/simpa_tests/manual_tests/test_with_experimental_measurements/ReproduceDISMeasurements.py b/simpa_tests/manual_tests/test_with_experimental_measurements/ReproduceDISMeasurements.py index 73e0fd78..072f048f 100644 --- a/simpa_tests/manual_tests/test_with_experimental_measurements/ReproduceDISMeasurements.py +++ b/simpa_tests/manual_tests/test_with_experimental_measurements/ReproduceDISMeasurements.py @@ -15,9 +15,10 @@ calculation of the total reflectance and transmission using he fluence map. """ -from simpa.utils import Tags, TISSUE_LIBRARY, SegmentationClasses +from simpa.utils import Tags, SegmentationClasses from simpa.core.simulation import simulate from simpa.utils.settings import Settings +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils.libraries.molecule_library import MolecularCompositionGenerator, Molecule from simpa.utils.libraries.spectrum_library import Spectrum, AnisotropySpectrumLibrary from simpa.io_handling import load_data_field @@ -101,7 +102,7 @@ def create_measurement_setup(sample_tickness_mm): and a blood vessel. """ background_dictionary = Settings() - background_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(1e-5, 1, 1.0) + background_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(1e-5, 1, 1.0) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND inclusion_tissue = Settings() @@ -121,7 +122,7 @@ def create_measurement_setup(sample_tickness_mm): air_tube[Tags.STRUCTURE_END_MM] = [self.VOLUME_LENGTH_MM / 2, self.VOLUME_LENGTH_MM/2, self.VOLUME_HEIGHT_IN_MM] air_tube[Tags.STRUCTURE_RADIUS_MM] = 5.0 - air_tube[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(1e-5, 1, 1.0) + air_tube[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(1e-5, 1, 1.0) air_tube[Tags.CONSIDER_PARTIAL_VOLUME] = True absorbing_layer = Settings() @@ -132,7 +133,7 @@ def create_measurement_setup(sample_tickness_mm): 0, 0, self.VOLUME_HEIGHT_IN_MM / 2 - sample_tickness_mm / 2 - self.SPACING] absorbing_layer[Tags.STRUCTURE_END_MM] = [ 0, 0, self.VOLUME_HEIGHT_IN_MM / 2 + sample_tickness_mm / 2 + self.SPACING] - absorbing_layer[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.constant(10000, 0.1, 0.0) + absorbing_layer[Tags.MOLECULE_COMPOSITION] = TissueLibrary.constant(10000, 0.1, 0.0) absorbing_layer[Tags.CONSIDER_PARTIAL_VOLUME] = True tissue_dict = Settings() diff --git a/simpa_tests/manual_tests/volume_creation/SegmentationLoader.py b/simpa_tests/manual_tests/volume_creation/SegmentationLoader.py index 559b9436..e4af5965 100644 --- a/simpa_tests/manual_tests/volume_creation/SegmentationLoader.py +++ b/simpa_tests/manual_tests/volume_creation/SegmentationLoader.py @@ -29,22 +29,22 @@ def setup(self): def segmentation_class_mapping(): ret_dict = dict() - ret_dict[0] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[1] = sp.TISSUE_LIBRARY.blood() - ret_dict[2] = sp.TISSUE_LIBRARY.epidermis() - ret_dict[3] = sp.TISSUE_LIBRARY.muscle() - ret_dict[4] = sp.TISSUE_LIBRARY.mediprene() - ret_dict[5] = sp.TISSUE_LIBRARY.ultrasound_gel() - ret_dict[6] = sp.TISSUE_LIBRARY.heavy_water() + ret_dict[0] = sp.TissueLibrary.heavy_water() + ret_dict[1] = sp.TissueLibrary.blood() + ret_dict[2] = sp.TissueLibrary.epidermis() + ret_dict[3] = sp.TissueLibrary.muscle() + ret_dict[4] = sp.TissueLibrary.mediprene() + ret_dict[5] = sp.TissueLibrary.ultrasound_gel() + ret_dict[6] = sp.TissueLibrary.heavy_water() ret_dict[7] = (sp.MolecularCompositionGenerator() - .append(sp.MOLECULE_LIBRARY.oxyhemoglobin(0.01)) - .append(sp.MOLECULE_LIBRARY.deoxyhemoglobin(0.01)) - .append(sp.MOLECULE_LIBRARY.water(0.98)) + .append(sp.MoleculeLibrary.oxyhemoglobin(0.01)) + .append(sp.MoleculeLibrary.deoxyhemoglobin(0.01)) + .append(sp.MoleculeLibrary.water(0.98)) .get_molecular_composition(sp.SegmentationClasses.COUPLING_ARTIFACT)) - ret_dict[8] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[9] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[10] = sp.TISSUE_LIBRARY.heavy_water() - ret_dict[11] = sp.TISSUE_LIBRARY.heavy_water() + ret_dict[8] = sp.TissueLibrary.heavy_water() + ret_dict[9] = sp.TissueLibrary.heavy_water() + ret_dict[10] = sp.TissueLibrary.heavy_water() + ret_dict[11] = sp.TissueLibrary.heavy_water() return ret_dict self.settings = sp.Settings() diff --git a/simpa_tests/test_utils/__init__.py b/simpa_tests/test_utils/__init__.py index 472e3f5f..8f3f8774 100644 --- a/simpa_tests/test_utils/__init__.py +++ b/simpa_tests/test_utils/__init__.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT import numpy as np -from simpa.utils import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary from simpa.utils.libraries.structure_library import Background, CircularTubularStructure from simpa.utils.settings import Settings from simpa.utils import Tags @@ -43,7 +43,7 @@ def assert_equals_recursive(a, b): def create_background(): background_structure_dictionary = dict() background_structure_dictionary[Tags.PRIORITY] = 0 - background_structure_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.muscle() + background_structure_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.muscle() background_structure_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND return background_structure_dictionary @@ -51,7 +51,7 @@ def create_background(): def create_vessel(): tubular_structure_dictionary = dict() tubular_structure_dictionary[Tags.PRIORITY] = 2 - tubular_structure_dictionary[Tags.MOLECULE_COMPOSITION] = TISSUE_LIBRARY.blood() + tubular_structure_dictionary[Tags.MOLECULE_COMPOSITION] = TissueLibrary.blood() tubular_structure_dictionary[Tags.STRUCTURE_START_MM] = [0, 0, 0] tubular_structure_dictionary[Tags.STRUCTURE_END_MM] = [10, 10, 10] tubular_structure_dictionary[Tags.STRUCTURE_RADIUS_MM] = 4 diff --git a/simpa_tests/test_utils/tissue_composition_tests.py b/simpa_tests/test_utils/tissue_composition_tests.py index 7adc8ca0..a7d5ea6c 100644 --- a/simpa_tests/test_utils/tissue_composition_tests.py +++ b/simpa_tests/test_utils/tissue_composition_tests.py @@ -6,7 +6,7 @@ from simpa.utils.libraries.molecule_library import MolecularComposition from simpa.utils.tissue_properties import TissueProperties from simpa.utils.constants import property_tags -from simpa.utils.libraries.tissue_library import TISSUE_LIBRARY +from simpa.utils.libraries.tissue_library import TissueLibrary import numpy as np import matplotlib.patches as patches import matplotlib.pyplot as plt @@ -958,32 +958,32 @@ def get_lymph_node_reference_dictionary(only_use_NIR_values=False): if __name__ == "__main__": - compare_molecular_composition_against_expected_values(molecular_composition=TISSUE_LIBRARY.epidermis(), + compare_molecular_composition_against_expected_values(molecular_composition=TissueLibrary.epidermis(), expected_values=get_epidermis_reference_dictionary(), visualise_values=True, title="Epidermis ") - compare_molecular_composition_against_expected_values(molecular_composition=TISSUE_LIBRARY.blood(1.0), + compare_molecular_composition_against_expected_values(molecular_composition=TissueLibrary.blood(1.0), expected_values=get_fully_oxygenated_blood_reference_dictionary(), visualise_values=True, title="100% sO2 Blood ") - compare_molecular_composition_against_expected_values(molecular_composition=TISSUE_LIBRARY.blood(0.0), + compare_molecular_composition_against_expected_values(molecular_composition=TissueLibrary.blood(0.0), expected_values=get_fully_deoxygenated_blood_reference_dictionary(), visualise_values=True, title="0% sO2 Blood ") - compare_molecular_composition_against_expected_values(molecular_composition=TISSUE_LIBRARY.dermis(), + compare_molecular_composition_against_expected_values(molecular_composition=TissueLibrary.dermis(), expected_values=get_dermis_reference_dictionary(), visualise_values=True, title="Dermis ") - compare_molecular_composition_against_expected_values(molecular_composition=TISSUE_LIBRARY.muscle(), + compare_molecular_composition_against_expected_values(molecular_composition=TissueLibrary.muscle(), expected_values=get_muscle_reference_dictionary(), visualise_values=True, title="Muscle ") - compare_molecular_composition_against_expected_values(molecular_composition=TISSUE_LIBRARY.lymph_node(), + compare_molecular_composition_against_expected_values(molecular_composition=TissueLibrary.lymph_node(), expected_values=get_lymph_node_reference_dictionary(), visualise_values=True, title="LymphNode ") diff --git a/simpa_tests/test_utils/tissue_models.py b/simpa_tests/test_utils/tissue_models.py index 77052e2e..b63e29fc 100644 --- a/simpa_tests/test_utils/tissue_models.py +++ b/simpa_tests/test_utils/tissue_models.py @@ -17,8 +17,8 @@ def create_simple_tissue_model(transducer_dim_in_mm: float, planar_dim_in_mm: fl v2_oxy = 0.0 background_dictionary = sp.Settings() background_dictionary[Tags.MOLECULE_COMPOSITION] = (sp.MolecularCompositionGenerator() - .append(sp.MOLECULE_LIBRARY.oxyhemoglobin(bg_oxy)) - .append(sp.MOLECULE_LIBRARY.deoxyhemoglobin(1 - bg_oxy)) + .append(sp.MoleculeLibrary.oxyhemoglobin(bg_oxy)) + .append(sp.MoleculeLibrary.deoxyhemoglobin(1 - bg_oxy)) .get_molecular_composition(sp.SegmentationClasses.BLOOD)) background_dictionary[Tags.STRUCTURE_TYPE] = Tags.BACKGROUND @@ -30,8 +30,8 @@ def create_simple_tissue_model(transducer_dim_in_mm: float, planar_dim_in_mm: fl tube_start_mm=[transducer_dim_in_mm / 2 - 10, 0, 5], tube_end_mm=[transducer_dim_in_mm / 2 - 10, planar_dim_in_mm, 5], molecular_composition=(sp.MolecularCompositionGenerator() - .append(sp.MOLECULE_LIBRARY.oxyhemoglobin(v1_oxy)) - .append(sp.MOLECULE_LIBRARY.deoxyhemoglobin(1 - v1_oxy)) + .append(sp.MoleculeLibrary.oxyhemoglobin(v1_oxy)) + .append(sp.MoleculeLibrary.deoxyhemoglobin(1 - v1_oxy)) .get_molecular_composition(sp.SegmentationClasses.BLOOD)), radius_mm=2, priority=3, consider_partial_volume=True, adhere_to_deformation=False @@ -40,8 +40,8 @@ def create_simple_tissue_model(transducer_dim_in_mm: float, planar_dim_in_mm: fl tube_start_mm=[transducer_dim_in_mm / 2, 0, 10], tube_end_mm=[transducer_dim_in_mm / 2, planar_dim_in_mm, 10], molecular_composition=(sp.MolecularCompositionGenerator() - .append(sp.MOLECULE_LIBRARY.oxyhemoglobin(v2_oxy)) - .append(sp.MOLECULE_LIBRARY.deoxyhemoglobin(1 - v2_oxy)) + .append(sp.MoleculeLibrary.oxyhemoglobin(v2_oxy)) + .append(sp.MoleculeLibrary.deoxyhemoglobin(1 - v2_oxy)) .get_molecular_composition(sp.SegmentationClasses.BLOOD)), radius_mm=3, priority=3, consider_partial_volume=True, adhere_to_deformation=False