diff --git a/CyXTraX/simulation/__init__.py b/CyXTraX/simulation/__init__.py index c36a20e59544eb827c5d5010196a0b8e66ca6443..320873fc56954f7ef06fb39d6212e32369f54dc5 100644 --- a/CyXTraX/simulation/__init__.py +++ b/CyXTraX/simulation/__init__.py @@ -1 +1 @@ -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 diff --git a/README.md b/README.md index f8710b368308854c05ffad2c072c9dec08a1edaa..ceb674e2a9791581f475d5e06bccdf9b22a860c1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 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](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. + + diff --git a/scripts/04_mapping.py b/scripts/04_mapping.py index f63d84e8cce06da83bfc7bc73ebc1b282738cb56..c0dc75e7f61a7fe588129c5c03b18fa72cccfa03 100644 --- a/scripts/04_mapping.py +++ b/scripts/04_mapping.py @@ -1,11 +1,10 @@ -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') diff --git a/temp/mapping.png b/temp/mapping.png new file mode 100644 index 0000000000000000000000000000000000000000..cc0c91510288b5aac100e77d47e7ecf87072de28 Binary files /dev/null and b/temp/mapping.png differ