Skip to main content

# RadFiled3D

Project description

RadFiled3D

Tests

This Repository holds the Fileformat and API according to the Paper: "RadField3D: A Data Generator and Data Format for Deep Learning in Radiation-Protection Dosimetry for Medical Applications".

The aim of this library is, to provide a simple to use API for a structured, binary file format, that can store all relevant information from a three dimensional radiation field calculated by applications that use algorithms like Monte-Carlo radiation transport simulations. Such a binary file format is useful, when one needs to process a huge amount of radiation field files like when training a neural network. With that use-case in mind, RadFiled3D also provides a python interface with a pyTorch integration.

Building and Installing

Installing from PyPi

Prebuilt versions of this module for python 3.11 and 3.12 for Windows and most Linuxsystems can be installed directly by using pip.

pip install RadFiled3D

Installing from Source

You can build and install this library and python module from source by using CMake and a C++ compiler. The CMake Project will be built automatically, but will take some time.

Prerequisites

  • C++ Compiler
    • g++ or clang for Linux
    • MSVC or clang from Visual Studio 2022 for Windows
  • CMake >= 3.30
  • Python >= 3.11

CMake

In order to use the module directly from another C++ Project, you can integrate it by adding the local location of this repository via add_submodule() and then link against the target libRadFiled3D. All classes are then available from the namespace RadFiled3D. Check the Example or the First Test File as a first reference.

Python

In order to use the Module from Python, we provide a setup.py file that handles the compilation and integration automatically from the python setuptools.

Installing locally

python -m pip install .

Building a wheel

python -m build --wheel

Getting Started

From C++

Simple example on how to create and store a radiation field. Find more in the example file: Example

#include <RadFiled3D/storage/RadiationFieldStore.hpp>
#include <RadFiled3D/RadiationField.hpp>

using namespace RadFiled3D;
using namespace RadFiled3D::Storage;

void main() {
    auto field = std::make_shared<CartesianRadiationField>(glm::vec3(2.5f), glm::vec3(0.05f)); // field extents: 2.5 m x 2.5 m x 2.5 m and voxel extents: 5 cm x 5 cm x 5 cm

    auto metadata = std::make_shared<RadFiled3D::Storage::V1::RadiationFieldMetadata>(
        // learn about the existing data fields from the example file in ./examples/cxx/examples01.cpp
    )

    FieldStore::store(field, metadata, "test_field.rf3", StoreVersion::V1);

    auto field2 = FieldStore::load("test_field.rf3");
}

From Python

Simple example on how to create and store a radiation field. Find more in the example file: Example

from RadFiled3D.RadFiled3D import CartesianRadiationField, FieldStore, StoreVersion, DType

# Creating a cartesian radiation field
field = CartesianRadiationField(vec3(2.5, 2.5, 2.5), vec3(0.05, 0.05, 0.05))
# defining a channel and a layer on it
field.get_channel("channel1").add_layer("layer1", "unit1", DType.FLOAT32)

# accessing the voxels by using numpy arrays
array = field.get_channel("channel1").get_layer_as_ndarray("layer1")
assert array.shape == (50, 50, 50)
# modify voxels content by using numpy array as no data is copied, just referenced
array[2:5, 2:5, 2:5] = 2.0

# addressing a voxel by providing a point in space
voxel = field.get_channel("channel1").get_voxel_by_coord("layer1", 0.1, 2.4, 5)

# Store changes to a file
metadata = RadiationFieldMetadataV1(...)
FieldStore.store(field, metadata, "test01.rf3", StoreVersion.V1)

# load data
field2 = FieldStore.load("test01.rf3")
metadata2 = FieldStore.load_metadata("test01.rf3")

Integrating with pyTorch

RadFiled3D comes with a submodule at RadFiled3D.pytorch. This module provides some dataset classes to support the usage. Datasets can be loaded from folders or .zip-Files.

from RadFiled3D.pytorch import MetadataLoadMode, CartesianFieldSingleLayerDataset, DatasetBuilder
from RadFiled3D.pytorch.helpers import load_tensor_from_layer
from RadFiled3D.RadFiled3D import VoxelGrid
from torch import Tensor


# Extend one of the provided dataset classes to match the output to the current needs
# The argument type of 'field' may vary depending on the dataset type between RadiationField (Whole field), VoxelGridBuffer (Channel), VoxelGrid (Layer) and Voxel (Single Voxel)
# The argument idx will contain the requested index from the dataset just in case someone wants to alter the return value based on it.
class MyLayerDataset(CartesianFieldSingleLayerDataset):
    def transform_field(self, field: VoxelGrid, idx: int) -> Tensor:
        return load_tensor_from_layer(field)


# Pass the dataset class and other options to the DatasetBuilder
builder = DatasetBuilder(
    "./test_dataset.zip",
    train_ratio=0.7,
    val_ratio=0.15,
    test_ratio=0.15,
    dataset_class=MyLayerDataset
)
# Build and finalize the training dataset
train_ds = builder.build_train_dataset()
# define the channel and layer to load from each field and spare out all other data
train_ds.set_channel_and_layer("test_channel", "test_layer")
# Load the metadata header for each radiation field, but not the dynamic metadata to speed up the loading
train_ds.metadata_load_mode = MetadataLoadMode.HEADER

# iterate over the dataset
for field, metadata in train_ds:
    pass

Field Structure

RadFiled3D defines a field structure, that provides the user with the possibility to first define in which kind of space he wants to operate. Therefore one can choose between CartesianRadiationField and PolarRadiationField.

  • CartesianRadiationField: Segments a room defined by an extent of the room itself and each cuboid voxel into a set of voxels. Each voxel can be addressed by a 3D position (coordinate: x, y, z), a 3D index (number of the voxel in each dimension) or a flat 1D index.
  • PolarRadiationField: Segements the surface of a unit sphere into surface segments. Each segment (voxel) can be addressed by a 2D position (coordinate: theta, phi), a 2D index (number of the segment in each dimension) or a flat 1D index.

Fields are then partitioned into channels (VoxelGridBuffer/PolarSegmentsBuffer). All channels share the same size and resolution. A channel is again partitioned into layers (VoxelGrid/PolarSegment). Each layer holds the actual voxel data and can be constructed from various data types (int, float, double, uint32_t, uint64_t, glm::vec2, glm::vec3, glm::vec4, N-D-Histogram). Additionally, a layer has a unit string assigned to it as well as a statistical uncertainty to perserve those information.

Dependencies

RadFiled3D comes with a possibly low amount of dependencies. We integrated the OpenGL Math Library (GLM) just to provide those datatypes out of the box and as GLM is a head-only library we suspect no issues by doing so.

All C++ dependencies:

All python dependencies:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

radfiled3d-1.0.4.tar.gz (12.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

RadFiled3D-1.0.4-cp313-cp313-win_amd64.whl (443.9 kB view details)

Uploaded CPython 3.13Windows x86-64

RadFiled3D-1.0.4-cp313-cp313-musllinux_1_2_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

RadFiled3D-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

RadFiled3D-1.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

RadFiled3D-1.0.4-cp312-cp312-win_amd64.whl (443.9 kB view details)

Uploaded CPython 3.12Windows x86-64

RadFiled3D-1.0.4-cp312-cp312-musllinux_1_2_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

RadFiled3D-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

RadFiled3D-1.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

RadFiled3D-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

RadFiled3D-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

RadFiled3D-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

File details

Details for the file radfiled3d-1.0.4.tar.gz.

File metadata

  • Download URL: radfiled3d-1.0.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for radfiled3d-1.0.4.tar.gz
Algorithm Hash digest
SHA256 70e9507ecaefc77e23aa805231144e17ae9b54489bc42769620f1f8d007197da
MD5 c7e01c4a0de4624dab32f9033386a4ee
BLAKE2b-256 060e06c320eb6ada43e23e425b717ea2c8c4bae6a896a5c7058ffa42a6dd04ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for radfiled3d-1.0.4.tar.gz:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: RadFiled3D-1.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 443.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for RadFiled3D-1.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d4e4a49f505e99f3639bd456dfdcff3324d169a638514ea3a50d96325473cbdd
MD5 9293e9a28d58bb67adf8f7cd56f927ff
BLAKE2b-256 f6b06ac3ac7cea52c83fe22f307d1bf69dd6fe851de51d7da14d571a51887674

See more details on using hashes here.

File details

Details for the file RadFiled3D-1.0.4-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 36520265b3cf94b61855a7ebce11b2fc10dabeaf8b05e2a54c803711c7d8576b
MD5 7ffe7fe2d3e2a16171e6bccd9ac0b2aa
BLAKE2b-256 d559e24fa70c6c8400327468b0bac4c3cc010e9baf075209b24a303685a27b9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d604124b73c0e36f9b44987a80e68472ee2342869633234a83d7e48594bd01c5
MD5 c82948602bf3d3e5db04f7844fb60f8b
BLAKE2b-256 3fe3ebb7ad836675d57d8693e3de93136e05b543cb9aa9b3efdea2660c709e0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52d937cc82b65492ddec494e364f450b5fcf5b85cd9bf5573abe10498627a9b1
MD5 8910bf083b3a62f457064398338cbfc2
BLAKE2b-256 b76ad6b69ea59c035f819b37f8ac8f845d934d9dbb174c10214f20bf64b24b7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: RadFiled3D-1.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 443.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for RadFiled3D-1.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2b60682c60397b1a02dcf520ec63012d698c21f51c0e675cc1ae94b34bf82fd1
MD5 8bcb742f0ff7e28ab250588b836e0064
BLAKE2b-256 51108897e74eb65d632539be6c9c63b22f6b6d8dc9c93bc1d764cf2eac374173

See more details on using hashes here.

File details

Details for the file RadFiled3D-1.0.4-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b913237b51279e5dbf941220a89a86b185cb94b2719984668c22e1f9bc447359
MD5 8a7fd76c1742dd254879d7a553cf07de
BLAKE2b-256 fe372746402eeacb5e8bf8ec543c688ce2ec790ddd0480fb6096d5888e1742e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e20841db9629d4b3b5505590aaeea5b0ba11370609d64f26bffcb3dd0a9260b1
MD5 e89f58c7712195798d3cd2444ad3251a
BLAKE2b-256 8c751248ea8aea0fb1a21ef73cd5e1e5599da27d246545b74931d8aa4bbe65d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aba8a8cd294504f78e3bcae58be3d0a50b96aa2e7ab319877ba98cda304a8683
MD5 4e4525fa5707d681571446c8ec1168b7
BLAKE2b-256 b7708f372a48015e19490273f448cf07211d5c5500c24c0e8c6d3e62c1e68ecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6d86931524e6236f7642751cc66af0b764a9c1d27ae193bedea01943385885b2
MD5 ee58684499544765078e041567cd4577
BLAKE2b-256 453ec299338f9604f2620256863809ee0df769171aad99ee05a69aa1b13a54a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7f320483f664ea344b8028c47f814dc7a00077d75b5e50ab18a8a8cf55600e28
MD5 c9e72796784c3a26c797bda50160c7ab
BLAKE2b-256 501bc6ca2f9a687b1555f8b413bd6dd28a87c0225ca05c1440adcd7fb37e8bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file RadFiled3D-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for RadFiled3D-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3d240a5e208924070a4e26fa24851360cc3eb192a3d2eee940b78cf020e5206
MD5 518cd47e224f45519d5e4c5f6d2bac63
BLAKE2b-256 64f46175ecdc99ce9832f1a94690d596918d9ec2b508eaeba126b18113cb3ecf

See more details on using hashes here.

Provenance

The following attestation bundles were made for RadFiled3D-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: package-test-publish.yml on Centrasis/RadFiled3D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page