Skip to content
Snippets Groups Projects
Commit 4dda0165 authored by Simon Wittl's avatar Simon Wittl
Browse files

fixed overwrite

parent 860457cd
No related branches found
No related tags found
No related merge requests found
No preview for this file type
[project]
name = "h5schemas"
version = "0.1.16"
version = "0.1.17"
description = "Add your description here"
readme = "README.md"
authors = [
......
......@@ -5,8 +5,8 @@ from pathlib import Path
from h5schemas.header.overwrite_header import overwrite_header_at_index
def overwrite_image_at_index(h5_file: File | Group,
image: Path | np.ndarray,
index: int,
image: Path | np.ndarray,
uuid: str | None = None,
timestamp: int | None = None,
):
......@@ -15,6 +15,6 @@ def overwrite_image_at_index(h5_file: File | Group,
dst[index] = str(image)
else:
dst = h5_file["image_array"]
dst[index] = image
dst[index, :, :] = image
overwrite_header_at_index(h5_file["header"], index, uuid, timestamp)
\ No newline at end of file
......@@ -67,6 +67,8 @@ def add_projection_sample(
if __name__ == "__main__":
from h5schemas.projection.overwrite_projection import overwrite_projection_at_index
test_file = File("./examples/projection.h5", "w")
init_projection_dataset(test_file, False, (128, 128), (0.139, 0.139))
......@@ -88,3 +90,15 @@ if __name__ == "__main__":
voltage_kv=100,
)
print(test_file["/image/image_array"][...])
overwrite_projection_at_index(
test_file,
0,
1e5 * np.random.random((128, 128)),
[0.0, 1.0, 2.0],
[3.0, 4.0, 5.0, 6.0],
[7.0, 8.0, 9.0],
[10.0, 11.0, 12.0, 13],
current_ma=69.,
voltage_kv=420.
)
from h5py import File, Group
from pathlib import Path
import numpy as np
from h5schemas.header.add_header import check_uuid_time_stamp
from h5schemas.image.overwrite_image import overwrite_image_at_index
from h5schemas.projection_geometry.overwrite_projection_geometry import overwrite_projection_geometry_at_index
from h5schemas.source.overwrite_source import overwrite_source_at_index
def overwrite_projection_at_index(
h5_file: File,
index: int,
image: Path | np.ndarray,
detector_center_position_mm: tuple[float, float, float],
detector_center_orientation_quat: tuple[float, float, float, float],
focal_spot_position_mm: tuple[float, float, float],
focal_spot_orientation_quat: tuple[float, float, float, float] | None = None,
current_ma: float = 0,
voltage_kv: float = 0,
uuid: str | None = None,
timestamp: int | None = None,
):
uuid, timestamp = check_uuid_time_stamp(uuid, timestamp)
overwrite_image_at_index(h5_file["/image"], index, image, uuid, timestamp)
overwrite_projection_geometry_at_index(
h5_file["/projection_geometry"],
index,
detector_center_position_mm,
detector_center_orientation_quat,
focal_spot_position_mm,
focal_spot_orientation_quat,
uuid,
timestamp,
)
overwrite_projection_geometry_at_index(
h5_file["/projection_geometry_nominal"],
index,
detector_center_position_mm,
detector_center_orientation_quat,
focal_spot_position_mm,
focal_spot_orientation_quat,
uuid,
timestamp,
)
overwrite_source_at_index(h5_file["/source"], index, current_ma, voltage_kv)
from h5py import File, Group
def overwrite_source_at_index(
h5_file: File | Group, index: int, current_ma: float, voltage_kv: float):
dst = h5_file["current_ma"]
dst[index] = current_ma
dst = h5_file["voltage_kv"]
dst[index] = voltage_kv
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment