Cy(lindrical)X(ray)Tra(nsform with Ja)X
This repo uses aRTist to generate local cylindrical xray transform maps / atlases of meshes.
It also defines the used .h5
dataformata for the other projects, and I/O util function for the use with the autograd JAX.
As simulation backend aRTist is used with the THD API.
Dataformat
The local cylindrical xray transform maps are stored as .h5
file.
Installation
This project ist tested with uv on win and linux. To run a file just:
uv venv
uv run scripts/01_aRTist_bridge.py
Examples
Example files are from the scripts
folder and directly included and updated via CODE-EMBEDDER.
Generate a Cylindrical Projection
# Create the cylindrical projection interface
cyl_proj = CylindricalProjection()
# Load the test object 'olaf'. It is automatically installed to your site-packages
print(f'STL Path: {scones_mesh.object_path}')
# Obect are loaded in a dataclass: MeshObject.
print(f'Mesh is a MeshObject: {isinstance(scones_mesh, MeshObject)}')
scones_mesh.position_mm = np.array([0, 0, 0])
scones_mesh.orientation_quat = np.array([0., -0., 0., 0.1])
# The `load_mesh` function load a list of MeshObject
load_mesh(cyl_proj, [scones_mesh])
# Set local position of cylindrical projection
map_position = np.array([0, 0, 0])
# Generate local cylindrical projection
half_rays = cyl_proj.compute_projection(map_position, output_full_ray_projection=False)
full_rays = cyl_proj.compute_projection(map_position, output_full_ray_projection=True)
Generate a Cylindrical Projection Atlas
# Create the cylindrical projection interface
cyl_proj = CylindricalProjection()
load_mesh(cyl_proj, [olaf_mesh])
# make an atlas
save_path = record_atlas(cyl_proj, [olaf_mesh], 'test', TEMP_FOLDER,
map_bounding_box=[-10, 20], number_of_maps=2)
Load Atlas
files = list(TEMP_FOLDER.glob('*.h5'))
if not files:
raise FileNotFoundError('No .h5 files in temp folder. Run Example 02!')
maps, points, mesh_object_list = load_atlas(files[-1])