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

added plot for example

parent 1a6e5ee6
No related branches found
No related tags found
No related merge requests found
from .artist_bridge import CylindricalProjection, load_mesh
\ No newline at end of file
from .artist_bridge import CylindricalProjection, load_mesh, SAVEMODES, utility
\ No newline at end of file
# Cy(lindrical)X(ray)Tra(nsform with Ja)X
![](./temp/mapping.png)
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](https://github.com/jax-ml/jax).
As simulation backend [aRTist](https://artist.bam.de/) is used with the [THD API](https://github.com/wittlsn/aRTist-PythonLib).
......@@ -9,3 +11,5 @@ As simulation backend [aRTist](https://artist.bam.de/) is used with the [THD API
The local cylindrical xray transform maps are stored as `.h5` file.
from CyXTraX.simulation import CylindricalProjection, load_mesh
from CyXTraX.simulation import CylindricalProjection, load_mesh, SAVEMODES, utility
from CyXTraX.io import load_atlas
from CyXTraX.mapping import map_geometry_2_projection, map_source_2_cylinder
from pathlib import Path
from jax import numpy as jnp
from jax.scipy.spatial.transform import Rotation
from artistlib import SAVEMODES, utility
from matplotlib import pyplot as plt
from matplotlib import pyplot as plt, figure
# Just get the temp folder to store the atlas
......@@ -57,16 +56,48 @@ def main():
cyl_proj.x_resolution_mm)
for i in range(values_calc.shape[0]):
print(values_calc[i], mapped_values[i])
map_ = maps[:, :, i]
value = map_[int(angles_calc[0, i]), int(angles_calc[1, i])]
print(f'Step {i}: Value Cylinder {values_calc[i]:2.2f} \t/\t Value Projection {mapped_values[i]:2.2f}')
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.imshow(projection)
ax1.scatter(uv_px[0], uv_px[1])
plt.show()
fig = plt.figure(figsize=(25, 10))
subfig1: figure.Figure
subfig2: figure.Figure
subfig1, subfig2 = fig.subfigures(1, 2)
ax1 = subfig1.add_subplot(111)
ax1.set_title('Projection Mapping')
im = ax1.imshow(projection, vmin=maps.min(), vmax=maps.max())
counter = 0
number_of_maps = maps.shape[2]
color = jnp.linspace(0, 1, 9)[:number_of_maps]
cmap = plt.get_cmap('hsv')
colors = cmap(color)
ax1.scatter(uv_px[0, :9], uv_px[1, :9], c=colors)
ax1.set_xlabel(r'$u$ / px')
ax1.set_ylabel(r'$v$ / px')
subfig1.colorbar(im, ax=ax1, orientation='vertical', label='Ray Length / mm')
ax2 = subfig2.add_subplot(111)
ax2.set_title('Cylindrical Mapping')
ax2.axis(False)
for i in range(3):
for j in range(3):
if counter >= number_of_maps:
continue
ax = subfig2.add_subplot(3, 3, counter+1)
ax.imshow(maps[:, :, counter], vmin=maps.min(), vmax=maps.max())
ax.scatter(angles_calc[0, counter], angles_calc[1, counter], c=colors[counter])
ax.set_xlabel(r'$z$ / mm')
ax.set_ylabel(r'$\alpha$ / rad')
ax.set_xticks([])
ax.set_yticks([])
counter += 1
plt.tight_layout()
plt.savefig(TEMP_FOLDER / 'mapping.png')
......
temp/mapping.png

382 KiB

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