diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 56051458..ae4b2f16 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -13,8 +13,8 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.8" - - uses: psf/black@24.1.1 + python-version: "3.10" + - uses: psf/black@24.2.0 with: args: ". --check" @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.10" - uses: py-actions/flake8@v1 isort: @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.10" - uses: isort/isort-action@master mypy: @@ -42,10 +42,10 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.10" - name: Install Dependencies run: | - pip install -r requirements.txt - pip install -e . + curl -sSL https://install.python-poetry.org | python3 - + poetry install - name: mypy run: ./run-mypy \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2ec7b0a0..28c0848c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,8 +17,7 @@ jobs: python-version: "3.8" - name: Install Dependencies run: | - pip install -r requirements.txt - pip install -e . - # pip install + curl -sSL https://install.python-poetry.org | python3 - + poetry install - name: pytest - run: pytest tests \ No newline at end of file + run: poetry run pytest tests \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26e9ea01..012399ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,26 @@ repos: + - repo: https://github.com/python-poetry/poetry + rev: '1.7.0' + hooks: + - id: poetry-check + - id: poetry-lock + - id: poetry-export + args: ["-f", "requirements.txt", "-o", "requirements.txt", "--with", "docs", "--with", "dev"] + - repo: https://github.com/psf/black - rev: 24.1.1 + rev: 24.2.0 hooks: - id: black language_version: python3 - repo: https://github.com/pycqa/flake8.git - rev: 3.9.1 + rev: 7.0.0 hooks: - id: flake8 args: [--ignore=E741 W503 E203 E501 C901] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: ["--profile", "black", "--filter-files"] diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..96401768 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,15 @@ +# Required +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/source/conf.py + +# Optionally build your docs in additional formats such as PDF and ePub +formats: all + +# Optionally set the version of Python and requirements required to build your docs +python: + version: 3.10 + install: + - requirements: requirements.txt \ No newline at end of file diff --git a/README.md b/README.md index 2d7c480e..1f4c5e0b 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,111 @@ -[![CI-tests](https://github.com/GilesStrong/mode_muon_tomography/actions/workflows/tests.yml/badge.svg)](https://github.com/GilesStrong/mode_muon_tomography/actions) -[![CI-lints](https://github.com/GilesStrong/mode_muon_tomography/actions/workflows/linting.yml/badge.svg)](https://github.com/GilesStrong/mode_muon_tomography/actions) +[![CI-tests](https://github.com/GilesStrong/tomopt/actions/workflows/tests.yml/badge.svg)](https://github.com/GilesStrong/tomopt/actions) +[![CI-lints](https://github.com/GilesStrong/tomopt/actions/workflows/linting.yml/badge.svg)](https://github.com/GilesStrong/tomopt/actions) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![pypi tomopt version](https://img.shields.io/pypi/v/tomopt.svg)](https://pypi.python.org/pypi/tomopt) +[![tomopt python compatibility](https://img.shields.io/pypi/pyversions/tomopt.svg)](https://pypi.python.org/pypi/tomopt) [![tomopt license](https://img.shields.io/pypi/l/tomopt.svg)](https://pypi.python.org/pypi/tomopt) +[![Documentation Status](https://readthedocs.org/projects/tomopt/badge/?version=stable)](https://tomopt.readthedocs.io/en/stable/?badge=stable) + # TomOpt: Differential Muon Tomography Optimisation -## Installation +This repo provides a library for the differential optimisation of scattering muon tomography systems. For an overview, please read our first publication [here](https://arxiv.org/abs/2309.14027). +As a disclaimer, this is a library designed to be extended by users for their specific tasks: e.g. passive volume definition, inference methods, and loss functions. Additionally, optimisation in TomOpt can be unstable, and requires careful tuning by users. This is to say that it is not a polished product for the general public, but rather fellow researchers in the field of optimisation and muon tomography. -N.B. Whilst the repo is private, you will need to make sure that you have registered the public ssh key of your computer/instance with your [GitHub profile](https://github.com/settings/keys). Follow [these instructions](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/checking-for-existing-ssh-keys) to check for existing keys or [these](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) to generate a new key. After that follow [this](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) to associate the key. +If you are interested in using this library seriously, please contact us; we would love to here if you have a specific use-case you wish to work on. -Checkout package: -``` -git clone git@github.com:GilesStrong/mode_muon_tomography.git -cd mode_muon_tomography -``` +## Overview -*N.B.* For GPU usage, it is recommended to manually setup conda and install PyTorch according to system, e.g.: -``` -conda activate root -conda install nb_conda_kernels -conda create -n tomopt python=3.8 pip ipykernel -conda activate tomopt -pip install torch==1.8.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html -pip install -r requirements.txt -``` +The TomOpt library is designed to optimise the design of a muon tomography system. The detector system is defined by a set of parameters, which are used to define the geometry of the detectors. The optimisation is performed by minimising a loss function, which is defined by the user. The loss function is evaluated by simulating the muon scattering process through the detector system and passive volumes. The information recorded by the detectors is then passed through an inference system to arrive at a set of task-specific parameters. These are then compared to the ground truth, and the loss is calculated. The gradient of the loss with respect to the detector parameters is then used to update the detector parameters. -Minimum python version is 3.8. Recommend creating a virtual environment, e.g. assuming your are using [Anaconda](https://www.anaconda.com/products/individual)/[Miniconda](https://docs.conda.io/en/latest/miniconda.html) (if installing conda for the first time, remember to restart the shell before attemting to use conda, and that by default conda writes the setup commands to `.bashrc`): +The TomOpt library is designed to be modular, and to allow for the easy addition of new inference systems, loss functions, and passive volume definitions. The library is also designed to be easily extensible to new optimisation algorithms, and to allow for the easy addition of new constraints on the detector parameters. -``` -conda activate root -conda install nb_conda_kernels -conda env create -f environment.yml -conda activate tomopt -``` +TomOpt consists of several submodules: -Otherwise set up a suitable environment using your python distribution of choice using the contents of `environment.yml`. Remember to activate the correct environment each time, via e.g. `conda activate tomopt`. +- benchmarks: and ongoing collection of concrete implementations and task-specific extensions that are used to test the library on real-world problems. +- inference: provides classes that infer muon-trajectories from detector data, and infer properties of passive volumes from muon-trajectories. +- muon: provides classes for handling muon batches, and generating muons from literature flux-distributions +- optimisation: provides classes for handling the optimisation of detector parameters, and an extensive callback system to modify the optimisation process. +- plotting: various plotting utilities for visualising the detector system, the optimisation process, and results +- volume: contains classes for defining passive volumes and detector systems +- core: core objects used by all parts of the code +- utils: various utilities used throughout the codebase -Install package and dependencies -``` -pip install -r requirements.txt -pip install -e . -``` +## Installation -Install git-hooks: +### As a dependency -``` -pre-commit install +For dependency usage, `tomopt` can be installed via e.g. + +```bash +pip install tomopt ``` -### Windows usage +### For development -Apparently when using Windows, the environment must also be activated within ipython using: +Check out the repo locally: +```bash +git clone git@github.com:GilesStrong/tomopt.git +cd tomopt ``` -python -m ipykernel install --user --name tomopt --display-name "Python (tomopt)" + +For development usage, we use [`poetry`](https://python-poetry.org/docs/#installing-with-the-official-installer) to handle dependency installation. +Poetry can be installed via, e.g. + +```bash +curl -sSL https://install.python-poetry.org | python3 - +poetry self update ``` -## Testing +and ensuring that `poetry` is available in your `$PATH` -Testing is handled by `pytest` and is set up to run during pull requests. Tests can be manually ran locally via: +TomOpt requires `python >= 3.10`. This can be installed via e.g. [`pyenv`](https://github.com/pyenv/pyenv): -``` -pytest tests/ +```bash +curl https://pyenv.run | bash +pyenv update +pyenv install 3.10 +pyenv local 3.10 ``` -to run all tests, or, e.g.: +Install the dependencies: +```bash +poetry install +poetry self add poetry-plugin-export +poetry config warnings.export false +poetry run pre-commit install ``` -pytest tests/test_muon.py + +Finally, make sure everything is working as expected by running the tests: + +```bash +poetry run pytest tests ``` +For those unfamiliar with `poetry`, basically just prepend commands with `poetry run` to use the stuff installed within the local environment, e.g. `poetry run jupyter notebook` to start a jupyter notebook server. This local environment is basically a python virtual environment. To correctly set up the interpreter in your IDE, use `poetry run which python` to see the path to the correct python executable. + +## Examples + +A few examples are included to introduce users and developers to the TomOpt library. These take the form of Jupyter notebooks. In `examples/getting_started` there are four ordered notebooks: + +- `00_Hello_World.ipynb` aims to show the user the high-level classes in TomOpt and the general workflow. +- `01_Indepth_tutorial_single_cycle.ipynb` aims to show developers what is going on in a single update iteration. +- `02_Indepth_tutotial_optimisation_and_callbacks.ipynb` aims to show users and developers the workings of the callback system in TomOpt +- `03_fixed_budget_mode.ipynb` aims to show users and developers how to optimise such that the detector maintains a constant cost. + +In `examples/benchmarks` there is a single notebook that covers the optimisation performed in our first publication, in which we optimised a detector to estimate the fill-height of a ladle furnace at a steel plant. As a disclaimer, this notebook may not fully reproduce our result, and is designed to be used in an interactive manner by experienced users. + + ### Running notebooks in a remote cluster If you want to run notebooks on a remote cluster but access them on the browser of your local machine, you need to forward the notebook server from the cluster to your local machine. On the cluster, run: ``` -jupyter notebook --no-browser --port=8889 +poetry run jupyter notebook --no-browser --port=8889 ``` On your local computer, you need to set up a forwarding that picks the flux of data from the cluster via a local port, and makes it available on another port as if the server was in the local machine: @@ -98,7 +126,7 @@ ssh -N -f -L localhost:8890:localhost:8888 username@gateway_hostname # on your l ## External repos -N.B. Not currently public +N.B. Most are not currently public - [tomo_deepinfer](https://github.com/GilesStrong/mode_muon_tomo_inference) (contact @GilesStrong for access) separately handles training and model definition of GNNs used for passive volume inference. Models are exported as JIT-traced scripts, and loaded here using the `DeepVolumeInferer` class. We still need to find a good way to host the trained models for easy download. - [mode_muon_tomography_scattering](https://github.com/GilesStrong/mode_muon_tomography_scattering) (contact @GilesStrong for access) separately handles conversion of PGeant model from root to HDF5, and Geant validation data from csv to HDF5. @@ -106,4 +134,4 @@ N.B. Not currently public ## Authors -The TomOpt project, and its continued development and support, is the result of the combined work of many people, whose contributions are summarised in [the author list](https://github.com/GilesStrong/mode_muon_tomography/blob/main/AUTHORS.md) \ No newline at end of file +The TomOpt project, and its continued development and support, is the result of the combined work of many people, whose contributions are summarised in [the author list](https://github.com/GilesStrong/tomopt/blob/main/AUTHORS.md) \ No newline at end of file diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index 9cb68644..66a14fe0 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree index d5b7f512..435bfdd9 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/_build/doctrees/installation.doctree b/docs/_build/doctrees/installation.doctree index 57c4fd41..5612aaf3 100644 Binary files a/docs/_build/doctrees/installation.doctree and b/docs/_build/doctrees/installation.doctree differ diff --git a/docs/_build/doctrees/introduction.doctree b/docs/_build/doctrees/introduction.doctree new file mode 100644 index 00000000..7f6a594b Binary files /dev/null and b/docs/_build/doctrees/introduction.doctree differ diff --git a/docs/_build/doctrees/modules.doctree b/docs/_build/doctrees/modules.doctree index dc3bf432..17eb177d 100644 Binary files a/docs/_build/doctrees/modules.doctree and b/docs/_build/doctrees/modules.doctree differ diff --git a/docs/_build/doctrees/tomopt.benchmarks.doctree b/docs/_build/doctrees/tomopt.benchmarks.doctree index 0469d113..f8440dd5 100644 Binary files a/docs/_build/doctrees/tomopt.benchmarks.doctree and b/docs/_build/doctrees/tomopt.benchmarks.doctree differ diff --git a/docs/_build/doctrees/tomopt.benchmarks.ladle_furnace.doctree b/docs/_build/doctrees/tomopt.benchmarks.ladle_furnace.doctree index 7dad4413..65067f10 100644 Binary files a/docs/_build/doctrees/tomopt.benchmarks.ladle_furnace.doctree and b/docs/_build/doctrees/tomopt.benchmarks.ladle_furnace.doctree differ diff --git a/docs/_build/doctrees/tomopt.benchmarks.small_walls.doctree b/docs/_build/doctrees/tomopt.benchmarks.small_walls.doctree index 08de0c11..8d07ddce 100644 Binary files a/docs/_build/doctrees/tomopt.benchmarks.small_walls.doctree and b/docs/_build/doctrees/tomopt.benchmarks.small_walls.doctree differ diff --git a/docs/_build/doctrees/tomopt.benchmarks.u_lorry.doctree b/docs/_build/doctrees/tomopt.benchmarks.u_lorry.doctree index 08bbcba2..02f5356e 100644 Binary files a/docs/_build/doctrees/tomopt.benchmarks.u_lorry.doctree and b/docs/_build/doctrees/tomopt.benchmarks.u_lorry.doctree differ diff --git a/docs/_build/doctrees/tomopt.doctree b/docs/_build/doctrees/tomopt.doctree index d190038e..e9b9643c 100644 Binary files a/docs/_build/doctrees/tomopt.doctree and b/docs/_build/doctrees/tomopt.doctree differ diff --git a/docs/_build/doctrees/tomopt.inference.doctree b/docs/_build/doctrees/tomopt.inference.doctree index d8f96754..943517d5 100644 Binary files a/docs/_build/doctrees/tomopt.inference.doctree and b/docs/_build/doctrees/tomopt.inference.doctree differ diff --git a/docs/_build/doctrees/tomopt.muon.doctree b/docs/_build/doctrees/tomopt.muon.doctree index 6519cdd0..1636a345 100644 Binary files a/docs/_build/doctrees/tomopt.muon.doctree and b/docs/_build/doctrees/tomopt.muon.doctree differ diff --git a/docs/_build/doctrees/tomopt.optimisation.callbacks.doctree b/docs/_build/doctrees/tomopt.optimisation.callbacks.doctree index 0f85398f..e07eaad0 100644 Binary files a/docs/_build/doctrees/tomopt.optimisation.callbacks.doctree and b/docs/_build/doctrees/tomopt.optimisation.callbacks.doctree differ diff --git a/docs/_build/doctrees/tomopt.optimisation.data.doctree b/docs/_build/doctrees/tomopt.optimisation.data.doctree index ad2e426f..3633c258 100644 Binary files a/docs/_build/doctrees/tomopt.optimisation.data.doctree and b/docs/_build/doctrees/tomopt.optimisation.data.doctree differ diff --git a/docs/_build/doctrees/tomopt.optimisation.doctree b/docs/_build/doctrees/tomopt.optimisation.doctree index fb430d29..29dc32d4 100644 Binary files a/docs/_build/doctrees/tomopt.optimisation.doctree and b/docs/_build/doctrees/tomopt.optimisation.doctree differ diff --git a/docs/_build/doctrees/tomopt.optimisation.loss.doctree b/docs/_build/doctrees/tomopt.optimisation.loss.doctree index 4c87db5f..1c90cc42 100644 Binary files a/docs/_build/doctrees/tomopt.optimisation.loss.doctree and b/docs/_build/doctrees/tomopt.optimisation.loss.doctree differ diff --git a/docs/_build/doctrees/tomopt.optimisation.wrapper.doctree b/docs/_build/doctrees/tomopt.optimisation.wrapper.doctree index 637fda40..6a6d36cf 100644 Binary files a/docs/_build/doctrees/tomopt.optimisation.wrapper.doctree and b/docs/_build/doctrees/tomopt.optimisation.wrapper.doctree differ diff --git a/docs/_build/doctrees/tomopt.plotting.doctree b/docs/_build/doctrees/tomopt.plotting.doctree index f248829a..d3675cc8 100644 Binary files a/docs/_build/doctrees/tomopt.plotting.doctree and b/docs/_build/doctrees/tomopt.plotting.doctree differ diff --git a/docs/_build/doctrees/tomopt.volume.doctree b/docs/_build/doctrees/tomopt.volume.doctree index 10063067..ba81f180 100644 Binary files a/docs/_build/doctrees/tomopt.volume.doctree and b/docs/_build/doctrees/tomopt.volume.doctree differ diff --git a/docs/_build/html/.buildinfo b/docs/_build/html/.buildinfo index 42b449ac..7126dc3d 100644 --- a/docs/_build/html/.buildinfo +++ b/docs/_build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: a1d4bf3194fba8eeb8c569809446c981 +config: 93fb6211ea9420d8aaccbcb5bb4f12fc tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_build/html/_modules/index.html b/docs/_build/html/_modules/index.html index 3287f367..f2973c28 100644 --- a/docs/_build/html/_modules/index.html +++ b/docs/_build/html/_modules/index.html @@ -14,8 +14,6 @@ - - @@ -153,7 +151,7 @@
@@ -314,9 +312,6 @@[docs]class ULorryPassiveGenerator(AbsPassiveGenerator): - r""" + r""" Research tested only: no unit tests """ @@ -360,9 +358,6 @@
- - - diff --git a/docs/_build/html/_modules/tomopt/inference/scattering.html b/docs/_build/html/_modules/tomopt/inference/scattering.html index 70b80dcb..833c7cf5 100644 --- a/docs/_build/html/_modules/tomopt/inference/scattering.html +++ b/docs/_build/html/_modules/tomopt/inference/scattering.html @@ -14,8 +14,6 @@ - - @@ -256,7 +254,7 @@
[docs]class ScatterBatch:
- r"""
+ r"""
Class for computing scattering information from the hits via incoming/outgoing trajectory fitting.
Linear fits are performed separately to all hits associated with layer groups, as indicated by the `pos` attribute of the layers which recorded hits.
@@ -334,7 +332,7 @@ Source code for tomopt.inference.scattering
_dxy_unc: Optional[Tensor] = None
def __init__(self, mu: MuonBatch, volume: Volume):
- r"""
+ r"""
Initialise scatter batch from a muon batch.
During initialisation:
The muons will be filtered in-place via :meth:`~tomopt.inference.ScatterBatch._filter_scatters`
@@ -351,7 +349,7 @@ Source code for tomopt.inference.scattering
[docs] @staticmethod
def get_muon_trajectory(hits: Tensor, uncs: Tensor, lw: Tensor) -> Tuple[Tensor, Tensor]:
- r"""
+ r"""
Fits a linear trajectory to a group of hits, whilst considering their uncertainties on their xy positions.
No uncertainty is considered for z positions of hits.
The fit is performed via an analytical likelihood-maximisation.
@@ -400,7 +398,7 @@ Source code for tomopt.inference.scattering
return vec, start
[docs] def get_scatter_mask(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons) Boolean tensor where True indicates that the PoCA of the muon is located within the passive volume
"""
@@ -416,7 +414,7 @@ Source code for tomopt.inference.scattering
)
[docs] def plot_scatter(self, idx: int, savename: Optional[Path] = None) -> None:
- r"""
+ r"""
Plots representation of hits and fitted trajectories for a single muon.
Arguments:
@@ -526,7 +524,7 @@ Source code for tomopt.inference.scattering
@staticmethod
def _compute_theta_msc(p: Tensor, q: Tensor) -> Tensor:
- r"""
+ r"""
Computes the angle between sets of vectors p and q via the cosine dot-product.
Arguments:
@@ -541,7 +539,7 @@ Source code for tomopt.inference.scattering
@staticmethod
def _compute_theta(track: Tensor) -> Tensor:
- r"""
+ r"""
Computes the theta angles of vectors
Arguments:
@@ -561,7 +559,7 @@ Source code for tomopt.inference.scattering
@staticmethod
def _compute_phi(x: Tensor, y: Tensor) -> Tensor:
- r"""
+ r"""
Computes the phi angles from the xy components of vectors
Arguments:
@@ -590,7 +588,7 @@ Source code for tomopt.inference.scattering
@staticmethod
def _compute_dtheta_dphi_scatter(theta_in: Tensor, phi_in: Tensor, theta_out: Tensor, phi_out: Tensor) -> Dict[str, Tensor]:
- r"""
+ r"""
Computes dtheta and dphi variables under the assumption of small angular scatterings.
An assumption is necessary here, since there is a loss of information in the when the muons undergo scattering in theta and phi:
since theta is [0,pi] a negative scattering in theta will always results in a positive theta, but phi can become phi+pi.
@@ -634,7 +632,7 @@ Source code for tomopt.inference.scattering
return {"dtheta": dtheta[i, hypo, None], "dphi": dphi[i, hypo, None]}
def _extract_hits(self) -> None:
- r"""
+ r"""
Takes the dictionary of hits from the muons and combines them into single tensors of recorded and true hits.
"""
@@ -648,7 +646,7 @@ Source code for tomopt.inference.scattering
self._hit_effs = torch.cat((self.hits["above"]["eff"], self.hits["below"]["eff"]), dim=1) # muons, all panels, eff
def _compute_tracks(self) -> None:
- r"""
+ r"""
Computes tracks from hits according to the uncertainty and efficiency of the hits, computed as 1/(resolution*efficiency).
"""
@@ -656,7 +654,7 @@ Source code for tomopt.inference.scattering
self._track_out, self._track_start_out = self.get_muon_trajectory(self.below_hits, self.below_hit_uncs / self.below_hit_effs, self.volume.lw)
def _filter_scatters(self) -> None:
- r"""
+ r"""
Filters muons to avoid NaN/Inf gradients or values. This results in direct, in-place changes to the :class:`~tomopt.muon.muon_batch.MuonBatch`.
This might seem heavy-handed, but tracks with invalid/extreme parameters can have NaN gradients, which can spoil the grads of all other muons.
@@ -703,7 +701,7 @@ Source code for tomopt.inference.scattering
self._compute_tracks()
def _compute_scatters(self) -> None:
- r"""
+ r"""
Computes incoming and outgoing vectors, and the vector normal to them, from hits extracted from filtered muons.
.. important::
@@ -733,7 +731,7 @@ Source code for tomopt.inference.scattering
self._track_coefs = (lhs.inverse() @ rhs[:, :, None]).squeeze(-1)
def _compute_xyz_in(self) -> Tensor:
- r"""
+ r"""
Returns:
(muon,xyz) tensor the positions of the muons at the z-level of the top of the passive volume
"""
@@ -742,7 +740,7 @@ Source code for tomopt.inference.scattering
return self._track_start_in + ((dz / self._track_in[:, 2:3]) * self._track_in)
def _compute_xyz_out(self) -> Tensor:
- r"""
+ r"""
Returns:
(muon,xyz) tensor the positions of the muons at the z-level of the bottom of the passive volume
"""
@@ -751,7 +749,7 @@ Source code for tomopt.inference.scattering
return self._track_start_out - ((dz / self._track_out[:, 2:3]) * self._track_out)
def _compute_out_var_unc(self, var: Tensor) -> Tensor:
- r"""
+ r"""
Computes the uncertainty on variable computed from the recorded hits due to the uncertainties on the hits, via gradient-based error propagation.
This computation uses the triangle of the error matrix and does not assume zero-valued off-diagonal elements.
.. warning::
@@ -777,7 +775,7 @@ Source code for tomopt.inference.scattering
return unc_2.sum(-1).sqrt() # (mu,var)
def _set_dtheta_dphi_scatter(self) -> None:
- r"""
+ r"""
Simultaneously sets dtheta and dphi scattering variables under the assumption of small angular scatterings.
An assumption is necessary here, since there is a loss of information in the when the muons undergo scattering in theta and phi:
since theta is [0,pi] a negative scattering in theta will always results in a positive theta, but phi can become phi+pi.
@@ -793,7 +791,7 @@ Source code for tomopt.inference.scattering
@property
def hits(self) -> Dict[str, Dict[str, Tensor]]:
- r"""
+ r"""
Returns:
Dictionary of hits, as returned by :meth:`~tomopt.muon.muon_batch.MuonBatch.get_hits()`
"""
@@ -802,7 +800,7 @@ Source code for tomopt.inference.scattering
@property
def reco_hits(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of recorded hits
"""
@@ -811,7 +809,7 @@ Source code for tomopt.inference.scattering
@property
def gen_hits(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of true hits
"""
@@ -820,7 +818,7 @@ Source code for tomopt.inference.scattering
@property
def n_hits_above(self) -> Optional[int]:
- r"""
+ r"""
Returns:
Number of hits per muon in the "above" detectors
"""
@@ -829,7 +827,7 @@ Source code for tomopt.inference.scattering
@property
def n_hits_below(self) -> Optional[int]:
- r"""
+ r"""
Returns:
Number of hits per muon in the "below" detectors
"""
@@ -838,7 +836,7 @@ Source code for tomopt.inference.scattering
@property
def above_gen_hits(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of true hits in the "above" detectors
"""
@@ -850,7 +848,7 @@ Source code for tomopt.inference.scattering
@property
def below_gen_hits(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of true hits in the "below" detectors
"""
@@ -862,7 +860,7 @@ Source code for tomopt.inference.scattering
@property
def above_hits(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of recorded hits in the "above" detectors
"""
@@ -874,7 +872,7 @@ Source code for tomopt.inference.scattering
@property
def below_hits(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of recorded hits in the "below" detectors
"""
@@ -886,7 +884,7 @@ Source code for tomopt.inference.scattering
@property
def hit_uncs(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of uncertainties on hits
"""
@@ -895,7 +893,7 @@ Source code for tomopt.inference.scattering
@property
def hit_effs(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,eff) tensor of hit efficiencies
"""
@@ -904,7 +902,7 @@ Source code for tomopt.inference.scattering
@property
def above_hit_uncs(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of uncertainties on hits in the "above" detectors
"""
@@ -916,7 +914,7 @@ Source code for tomopt.inference.scattering
@property
def below_hit_uncs(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,xyz) tensor of uncertainties on hits in the "below" detectors
"""
@@ -928,7 +926,7 @@ Source code for tomopt.inference.scattering
@property
def above_hit_effs(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,effs) tensor of hit efficiencies in the "above" detectors
"""
@@ -940,7 +938,7 @@ Source code for tomopt.inference.scattering
@property
def below_hit_effs(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,hits,eff) tensor of hit efficiencies in the "below" detectors
"""
@@ -952,7 +950,7 @@ Source code for tomopt.inference.scattering
@property
def track_in(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,xyz) incoming xyz vector
"""
@@ -961,7 +959,7 @@ Source code for tomopt.inference.scattering
@property
def track_start_in(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,xyz) initial point of incoming xyz vector
"""
@@ -970,7 +968,7 @@ Source code for tomopt.inference.scattering
@property
def track_out(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,xyz) outgoing xyz vector
"""
@@ -979,7 +977,7 @@ Source code for tomopt.inference.scattering
@property
def track_start_out(self) -> Optional[Tensor]:
- r"""
+ r"""
Returns:
(muons,xyz) initial point of outgoing xyz vector
"""
@@ -988,7 +986,7 @@ Source code for tomopt.inference.scattering
@property
def poca_xyz(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) xyz location of PoCA
"""
@@ -1001,7 +999,7 @@ Source code for tomopt.inference.scattering
@property
def poca_xyz_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) uncertainty on poca_xyz
"""
@@ -1012,7 +1010,7 @@ Source code for tomopt.inference.scattering
@property
def dxy(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) distances in x & y from PoCA to incoming|outgoing muons
"""
@@ -1024,7 +1022,7 @@ Source code for tomopt.inference.scattering
@property
def dxy_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) uncertainty on dxy
"""
@@ -1035,7 +1033,7 @@ Source code for tomopt.inference.scattering
@property
def theta_in(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) theta of incoming muons
"""
@@ -1047,7 +1045,7 @@ Source code for tomopt.inference.scattering
@property
def theta_in_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on theta_in
"""
@@ -1058,7 +1056,7 @@ Source code for tomopt.inference.scattering
@property
def theta_out(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) theta of outgoing muons
"""
@@ -1070,7 +1068,7 @@ Source code for tomopt.inference.scattering
@property
def theta_out_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on theta_out
"""
@@ -1081,7 +1079,7 @@ Source code for tomopt.inference.scattering
@property
def phi_in(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) phi of incoming muons
"""
@@ -1093,7 +1091,7 @@ Source code for tomopt.inference.scattering
@property
def phi_in_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on phi_in
"""
@@ -1104,7 +1102,7 @@ Source code for tomopt.inference.scattering
@property
def phi_out(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) phi of outgoing muons
"""
@@ -1116,7 +1114,7 @@ Source code for tomopt.inference.scattering
@property
def phi_out_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on phi_out
"""
@@ -1127,7 +1125,7 @@ Source code for tomopt.inference.scattering
@property
def dtheta(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) delta theta between incoming & outgoing muons
"""
@@ -1138,7 +1136,7 @@ Source code for tomopt.inference.scattering
@property
def dtheta_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on dtheta
"""
@@ -1149,7 +1147,7 @@ Source code for tomopt.inference.scattering
@property
def dphi(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) delta phi between incoming & outgoing muons
"""
@@ -1160,7 +1158,7 @@ Source code for tomopt.inference.scattering
@property
def dphi_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on dphi
"""
@@ -1171,7 +1169,7 @@ Source code for tomopt.inference.scattering
@property
def total_scatter(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) theta_msc; the total amount of angular scattering
"""
@@ -1183,7 +1181,7 @@ Source code for tomopt.inference.scattering
@property
def total_scatter_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on total_scatter
"""
@@ -1194,7 +1192,7 @@ Source code for tomopt.inference.scattering
@property
def theta_msc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) theta_msc; the total amount of angular scattering
"""
@@ -1203,7 +1201,7 @@ Source code for tomopt.inference.scattering
@property
def theta_msc_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) uncertainty on total_scatter
"""
@@ -1211,7 +1209,7 @@ Source code for tomopt.inference.scattering
@property
def theta_xy_in(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) decomposed theta and phi of incoming muons in the zx and zy planes
"""
@@ -1223,7 +1221,7 @@ Source code for tomopt.inference.scattering
@property
def theta_xy_in_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) uncertainty on theta_xy_in
"""
@@ -1234,7 +1232,7 @@ Source code for tomopt.inference.scattering
@property
def theta_xy_out(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) decomposed theta and phi of outgoing muons in the zx and zy planes
"""
@@ -1246,7 +1244,7 @@ Source code for tomopt.inference.scattering
@property
def theta_xy_out_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) uncertainty on theta_xy_out
"""
@@ -1257,7 +1255,7 @@ Source code for tomopt.inference.scattering
@property
def dtheta_xy(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) delta theta_xy between incoming & outgoing muons in the zx and zy planes
"""
@@ -1269,7 +1267,7 @@ Source code for tomopt.inference.scattering
@property
def dtheta_xy_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xy) uncertainty on dtheta_xy
"""
@@ -1280,7 +1278,7 @@ Source code for tomopt.inference.scattering
@property
def xyz_in(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) inferred xy position of muon at the z-level of the top of the passive volume
"""
@@ -1292,7 +1290,7 @@ Source code for tomopt.inference.scattering
@property
def xyz_in_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) uncertainty on xyz_in
"""
@@ -1303,7 +1301,7 @@ Source code for tomopt.inference.scattering
@property
def xyz_out(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) inferred xy position of muon at the z-level of the bottom of the passive volume
"""
@@ -1315,7 +1313,7 @@ Source code for tomopt.inference.scattering
@property
def xyz_out_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) uncertainty on xyz_out
"""
@@ -1326,7 +1324,7 @@ Source code for tomopt.inference.scattering
[docs]class GenScatterBatch(ScatterBatch):
- r"""
+ r"""
Class for computing scattering information from the true hits via incoming/outgoing trajectory fitting.
.. warning::
@@ -1364,7 +1362,7 @@ Source code for tomopt.inference.scattering
"""
def _compute_tracks(self) -> None:
- r"""
+ r"""
Computes tracks from true muon positions.
"""
@@ -1416,9 +1414,6 @@ Source code for tomopt.inference.scattering
-
-
-
diff --git a/docs/_build/html/_modules/tomopt/inference/volume.html b/docs/_build/html/_modules/tomopt/inference/volume.html
index d89f4013..70978f8c 100644
--- a/docs/_build/html/_modules/tomopt/inference/volume.html
+++ b/docs/_build/html/_modules/tomopt/inference/volume.html
@@ -14,8 +14,6 @@
-
-
@@ -265,7 +263,7 @@ Source code for tomopt.inference.volume
[docs]class AbsVolumeInferrer(metaclass=ABCMeta):
- r"""
+ r"""
Abstract base class for volume inference.
Inheriting classes are expected to be fed multiple :class:`~tomopt.inference.scattering.ScatterBatch` s,
@@ -277,7 +275,7 @@ Source code for tomopt.inference.volume
"""
def __init__(self, volume: Volume):
- r"""
+ r"""
Initialises the inference class for the provided volume.
"""
@@ -294,7 +292,7 @@ Source code for tomopt.inference.volume
@abstractmethod
def _reset_vars(self) -> None:
- r"""
+ r"""
Inheriting classes must override this method to reset any variable/predictions made from the added scatter batches.
"""
@@ -302,7 +300,7 @@ Source code for tomopt.inference.volume
[docs] @abstractmethod
def compute_efficiency(self, scatters: ScatterBatch) -> Tensor:
- r"""
+ r"""
Inheriting classes must override this method to provide a computation of the per-muon efficiency, given the individual muon hit efficiencies.
"""
@@ -310,7 +308,7 @@ Source code for tomopt.inference.volume
[docs] @abstractmethod
def get_prediction(self) -> Optional[Tensor]:
- r"""
+ r"""
Inheriting classes must override this method to provide a prediction computed using the added scatter batches.
E.g. the sum of muon efficiencies.
"""
@@ -318,7 +316,7 @@ Source code for tomopt.inference.volume
pass
[docs] def add_scatters(self, scatters: ScatterBatch) -> None:
- r"""
+ r"""
Appends a new set of muon scatter variables.
When :meth:`~tomopt.inference.volume.AbsVolumeInferrer.get_prediction` is called, the prediction will be based on all
:class:`~tomopt.inference.scattering.ScatterBatch` s added up to that point
@@ -329,7 +327,7 @@ Source code for tomopt.inference.volume
[docs]class AbsX0Inferrer(AbsVolumeInferrer):
- r"""
+ r"""
Abstract base class for inferring the X0 of every voxel in the passive volume.
The inference is based on the PoCA approach of assigning the entirety of the muon scattering to a single point,
@@ -366,7 +364,7 @@ Source code for tomopt.inference.volume
_var_order_szs = [("poca", 3), ("tot_scatter", 1), ("theta_in", 1), ("theta_out", 1), ("mom", 1)]
def __init__(self, volume: Volume):
- r"""
+ r"""
Initialises the inference class for the provided volume.
"""
@@ -375,7 +373,7 @@ Source code for tomopt.inference.volume
[docs] @staticmethod
def x0_from_scatters(deltaz: float, total_scatter: Tensor, theta_in: Tensor, theta_out: Tensor, mom: Tensor) -> Tensor:
- r"""
+ r"""
Computes the X0 of a voxel, by inverting the PDG scattering model in terms of the scattering variables
.. important::
@@ -396,7 +394,7 @@ Source code for tomopt.inference.volume
return ((SCATTER_COEF_A / mom) ** 2) * deltaz / (total_scatter.pow(2) * cos_theta)
[docs] def get_prediction(self) -> Optional[Tensor]:
- r"""
+ r"""
Computes the predicted X0 per voxel as a (z,x,y) tensor via PDG scatter-model inversion for the provided scatter batches.
Returns:
@@ -410,7 +408,7 @@ Source code for tomopt.inference.volume
@staticmethod
def _weighted_rms(x: Tensor, wgt: Tensor) -> Tensor:
- r"""
+ r"""
Computes the weighted root mean squared value of the provided list of variable values
Arguments:
@@ -425,7 +423,7 @@ Source code for tomopt.inference.volume
@staticmethod
def _weighted_mean(x: Tensor, wgt: Tensor) -> Tensor:
- r"""
+ r"""
Computes the weighted mean value of the provided list of variable values
Arguments:
@@ -439,7 +437,7 @@ Source code for tomopt.inference.volume
return (x * wgt).sum(0) / wgt.sum(0)
def _reset_vars(self) -> None:
- r"""
+ r"""
Resets any variable/predictions made from the added scatter batches.
"""
@@ -452,7 +450,7 @@ Source code for tomopt.inference.volume
self._vox_zxy_x0_pred_uncs = None # (z,x,y)
def _set_var_dimensions(self) -> None:
- r"""
+ r"""
Configures the indexing of the dependent variable and uncertainty tensors
"""
@@ -469,7 +467,7 @@ Source code for tomopt.inference.volume
self._mom_dim = dims["mom"]
def _combine_scatters(self) -> None:
- r"""
+ r"""
Combines scatter data from all the batches added so far.
Any muons with NaN or Inf entries will be filtered out of the resulting tensors.
@@ -507,7 +505,7 @@ Source code for tomopt.inference.volume
self._n_mu = len(self._muon_scatter_vars)
def _get_voxel_zxy_x0_pred_uncs(self) -> Tensor:
- r"""
+ r"""
Computes the uncertainty on the predicted voxelwise X0s, via gradient-based error propagation.
.. warning::
@@ -533,7 +531,7 @@ Source code for tomopt.inference.volume
return pred_unc
def _get_voxel_zxy_x0_preds(self) -> Tensor:
- r"""
+ r"""
Computes the X0 predictions per voxel using the scatter batches added.
TODO: Implement differing x0 according to poca_xyz via Gaussian spread
@@ -571,7 +569,7 @@ Source code for tomopt.inference.volume
@property
def vox_zxy_x0_preds(self) -> Tensor:
- r"""
+ r"""
Returns:
(z,x,y) tensor of voxelwise X0 predictions
"""
@@ -583,7 +581,7 @@ Source code for tomopt.inference.volume
@property
def vox_zxy_x0_pred_uncs(self) -> Tensor:
- r"""
+ r"""
.. warning::
Not recommended for use: long calculation; not unit-tested
@@ -597,7 +595,7 @@ Source code for tomopt.inference.volume
@property
def muon_probs_per_voxel_zxy(self) -> Tensor: # (mu,z,x,y)
- r"""
+ r"""
.. warning::
Integration tested only
@@ -637,7 +635,7 @@ Source code for tomopt.inference.volume
@property
def n_mu(self) -> int:
- r"""
+ r"""
Returns:
Total number muons included in the inference
"""
@@ -648,7 +646,7 @@ Source code for tomopt.inference.volume
@property
def muon_poca_xyz(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) tensor of PoCA locations
"""
@@ -659,7 +657,7 @@ Source code for tomopt.inference.volume
@property
def muon_poca_xyz_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,xyz) tensor of PoCA location uncertainties
"""
@@ -670,7 +668,7 @@ Source code for tomopt.inference.volume
@property
def muon_total_scatter(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of total angular scatterings
"""
@@ -681,7 +679,7 @@ Source code for tomopt.inference.volume
@property
def muon_total_scatter_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of uncertainties on the total angular scatterings
"""
@@ -692,7 +690,7 @@ Source code for tomopt.inference.volume
@property
def muon_theta_in(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the thetas of the incoming muons
"""
@@ -703,7 +701,7 @@ Source code for tomopt.inference.volume
@property
def muon_theta_in_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the uncertainty on the theta of the incoming muons
"""
@@ -714,7 +712,7 @@ Source code for tomopt.inference.volume
@property
def muon_theta_out(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the thetas of the outgoing muons
"""
@@ -725,7 +723,7 @@ Source code for tomopt.inference.volume
@property
def muon_theta_out_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the uncertainty on the theta of the outgoing muons
"""
@@ -736,7 +734,7 @@ Source code for tomopt.inference.volume
@property
def muon_mom(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the momenta of the muons
"""
@@ -747,7 +745,7 @@ Source code for tomopt.inference.volume
@property
def muon_mom_unc(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the uncertainty on the momenta of the muons
"""
@@ -758,7 +756,7 @@ Source code for tomopt.inference.volume
@property
def muon_efficiency(self) -> Tensor:
- r"""
+ r"""
Returns:
(muons,1) tensor of the efficiencies of the muons
"""
@@ -769,7 +767,7 @@ Source code for tomopt.inference.volume
[docs]class PanelX0Inferrer(AbsX0Inferrer):
- r"""
+ r"""
Class for inferring the X0 of every voxel in the passive volume using hits recorded by :class:`~tomopt.volume.layer.PanelDetectorLayer` s.
The inference is based on the PoCA approach of assigning the entirety of the muon scattering to a single point,
@@ -799,7 +797,7 @@ Source code for tomopt.inference.volume
"""
[docs] def compute_efficiency(self, scatters: ScatterBatch) -> Tensor:
- r"""
+ r"""
Computes the per-muon efficiency, given the individual muon hit efficiencies,
as the probability of at least two hits above and below the passive volume.
@@ -979,7 +977,7 @@ Source code for tomopt.inference.volume
[docs]class DenseBlockClassifierFromX0s(AbsVolumeInferrer):
- r"""
+ r"""
Class for inferreing the presence of a small amount of denser material in the passive volume.
Transforms voxel-wise X0 preds into binary classification statistic under the hypothesis of a small, dense block against a light-weight background.
@@ -1023,7 +1021,7 @@ Source code for tomopt.inference.volume
ratio_offset: float = -1.0,
ratio_coef: float = 1.0,
):
- r"""
+ r"""
Initialises the inference class for the provided volume.
"""
@@ -1033,7 +1031,7 @@ Source code for tomopt.inference.volume
self.frac = n_block_voxels / self.volume.xyz_centres.numel()
[docs] def add_scatters(self, scatters: ScatterBatch) -> None:
- r"""
+ r"""
Appends a new set of muon scatter vairables.
When :meth:`~tomopt.inference.volume.DenseBlockClassifierFromX0s.get_prediction` is called, the prediction will be based on all
:class:`~tomopt.inference.scattering.ScatterBatch` s added up to that point
@@ -1042,7 +1040,7 @@ Source code for tomopt.inference.volume
self.x0_inferrer.add_scatters(scatters)
[docs] def compute_efficiency(self, scatters: ScatterBatch) -> Tensor:
- r"""
+ r"""
Compuates the per-muon efficiency according to the method implemented by the X0 inferrer.
Arguments:
@@ -1055,7 +1053,7 @@ Source code for tomopt.inference.volume
return self.x0_inferrer.compute_efficiency(scatters=scatters)
[docs] def get_prediction(self) -> Optional[Tensor]:
- r"""
+ r"""
Computes the test statistic for the volume, with values near 0 indicating that no relatively dense material is present,
and values nearer 1 indicating that it is present.
@@ -1082,7 +1080,7 @@ Source code for tomopt.inference.volume
return pred[None, None]
def _reset_vars(self) -> None:
- r"""
+ r"""
Resets any variable/predictions made from the added scatter batches.
"""
@@ -1090,7 +1088,7 @@ Source code for tomopt.inference.volume
[docs]class AbsIntClassifierFromX0(AbsVolumeInferrer):
- r"""
+ r"""
Abstract base class for inferring integer targets through multiclass classification from voxelwise X0 predictions.
Inheriting classes must provide a way to convert voxelwise X0s into class probabilities of the required dimension.
Requires a basic inferrer for providing the voxelwise X0 predictions.
@@ -1111,7 +1109,7 @@ Source code for tomopt.inference.volume