-
Notifications
You must be signed in to change notification settings - Fork 17
/
perform_image_reconstruction.py
60 lines (45 loc) · 2.33 KB
/
perform_image_reconstruction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# SPDX-FileCopyrightText: 2021 Division of Intelligent Medical Systems, DKFZ
# SPDX-FileCopyrightText: 2021 Janek Groehl
# SPDX-License-Identifier: MIT
import os
import numpy as np
import simpa as sp
from simpa import Tags
from simpa.utils.profiling import profile
from typing import Union
# FIXME temporary workaround for newest Intel architectures
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
path_manager = sp.PathManager()
PATH = path_manager.get_hdf5_file_save_path() + "/CompletePipelineExample_4711.hdf5"
def run_perform_image_reconstruction(SPACING: Union[int, float] = 0.5, path_manager=sp.PathManager(), visualise=True):
"""
:param SPACING: The simulation spacing between voxels
:param path_manager: the path manager to be used, typically sp.PathManager
:param visualise: If VISUALIZE is set to True, the reconstruction result will be plotted
:return: a run through of the example
"""
PATH = path_manager.get_hdf5_file_save_path() + "/CompletePipelineExample_4711.hdf5"
settings = sp.load_data_field(PATH, Tags.SETTINGS)
settings[Tags.WAVELENGTH] = settings[Tags.WAVELENGTHS][0]
settings.set_reconstruction_settings({
Tags.RECONSTRUCTION_PERFORM_BANDPASS_FILTERING: False,
Tags.TUKEY_WINDOW_ALPHA: 0.5,
Tags.BANDPASS_CUTOFF_LOWPASS_IN_HZ: int(8e6),
Tags.BANDPASS_CUTOFF_HIGHPASS_IN_HZ: int(0.1e6),
Tags.RECONSTRUCTION_BMODE_METHOD: Tags.RECONSTRUCTION_BMODE_METHOD_HILBERT_TRANSFORM,
Tags.RECONSTRUCTION_APODIZATION_METHOD: Tags.RECONSTRUCTION_APODIZATION_BOX,
Tags.RECONSTRUCTION_MODE: Tags.RECONSTRUCTION_MODE_PRESSURE,
Tags.SPACING_MM: settings[Tags.SPACING_MM]
})
# TODO use the correct device definition here
device = sp.load_data_field(PATH, Tags.DIGITAL_DEVICE)
sp.DelayAndSumAdapter(settings).run(device)
reconstructed_image = sp.load_data_field(PATH, Tags.DATA_FIELD_RECONSTRUCTED_DATA, settings[Tags.WAVELENGTH])
reconstructed_image = np.squeeze(reconstructed_image)
if visualise:
sp.visualise_data(path_to_hdf5_file=PATH,
wavelength=settings[Tags.WAVELENGTH],
show_reconstructed_data=True,
show_xz_only=True)
if __name__ == "__main__":
run_perform_image_reconstruction(SPACING=0.5, path_manager=sp.PathManager(), visualise=True)