Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codacy warning fixes #65

Merged
merged 2 commits into from Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def point_cloud_3D_all(dict_of_data_handlers):
"""
generates a single plot with pointclouds of generated LOR-positions, original source-positions and tolerance-whiskers for all sources
Args:
dict_of_data_handlers (dictionary containing objects of type ROOTConsistencyDataHandler): dictionary of objects containing all relevant data for the plot
dict_of_data_handlers (dict[int, ROOTConsistencyDataHandler]): dictionary of objects containing all relevant data for the plot
"""

fig = plt.figure(figsize=(10, 10))
Expand Down
71 changes: 31 additions & 40 deletions examples/ROOT_files/ROOT_STIR_consistency/README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,57 @@
# TOF consistency checks for STIR

## Authors: Elise Emond & Robert Twyman

Copyright (C) 2022, University College London
This file is part of STIR.
Copyright (C) 2022, 2024 University College London
This file is part of STIR.
SPDX-License-Identifier: Apache-2.0
See STIR/LICENSE.txt for details

These files were included to :
* Test non-TOF ROOT and STIR consistency, particularly the rotation.
* Test the TOF STIR implementation is correct.
These files are included to :

- Test non-TOF ROOT and STIR consistency, particularly the rotation.
- Test the TOF STIR implementation is correct.

See src/recon_test/test_consistency_with_GATE.cxx. This test is run
automatically when using ctest.
See src/recon_test/test_consistency_with_GATE.cxx. This test is run automatically when using ctest.

Directories
-----
## Directories

- `SourceFiles/`: Contains 8 `generate_image` parameter files and GATE macro files for the emission source positions. One pair of files for each simulation.
- `Gate_macros/`: Contains the GATE macro files for generating the data.
- `DebugScripts/`: Contains scripts for better understanding the tests.


FILES
----
## FILES

- `README.md`: This file.
- `root_header_test_template.hroot`: Template file for generating root header files for each of the test list mode data files that are generated by GATE.
- `run_pretest_script.sh`: The main script for generating the data (requires GATE). This script runs GATE simulations for each test emission and generates the root header files for them.

---

______
## Methodology

Methodology
----
1. Get the ROOT data: either
- Run `./run_pretest_script.sh` in the terminal to generate the ROOT files (requires Gate) for different point sources, or
- Download the ROOT data and proceed without Gate simulation. This is done
by ctest when the STIR build was configured with `DOWNLOAD_ZENODO_TEST_DATA=ON`.

2. Run the STIR test: `src/recon_test/test_consistency_with_GATE` (Best via ctest).
This test should tell you whether it failed or not by testing if the LOR passes by,
or close to, the original point source position.
3. Run the python scripts in `DebugScripts` to better understand errors and to give a more in-depth analysis.
1. Get the ROOT data: either
- Run `./run_pretest_script.sh` in the terminal to generate the ROOT files (requires Gate) for different point sources, or
- Download the ROOT data and proceed without Gate simulation. This is done by ctest when the STIR build was configured with `DOWNLOAD_ZENODO_TEST_DATA=ON`.
2. Run the STIR test: `src/recon_test/test_consistency_with_GATE` (Best via ctest). This test should tell you whether it failed or not by testing if the LOR passes by, or close to, the original point source position.
3. Run the python scripts in `DebugScripts` to better understand errors and to give a more in-depth analysis.

---

_____
## SOURCE POSITION CONFIGURATION

SOURCE POSITION CONFIGURATION
-----
In GATE coordinates (`mm`), the point sources positions are as follows:

| ID | x | y | z | comment |
| :---: | :---: | :----: | :---: | :---: |
| **1** | 0 | 0 | 0 | center scanner |
| **2** | 190 | 0 | 0 | +x |
| **3** | 0 | 190 | 0 | +y |
| **4** | 95 | 95 | 0 | +x +y |
| **5** | 0 | 0 | 70 | +z |
| **6** | 190 | 0 | 70 | +x +z |
| **7** | 0 | 190 | 70 | +y +z |
| **8** | 95 | 95 | 70 | +x +y +z |
| ID | x | y | z | comment |
| :---: | :-: | :-: | :-: | :------------: |
| **1** | 0 | 0 | 0 | center scanner |
| **2** | 190 | 0 | 0 | +x |
| **3** | 0 | 190 | 0 | +y |
| **4** | 95 | 95 | 0 | +x +y |
| **5** | 0 | 0 | 70 | +z |
| **6** | 190 | 0 | 70 | +x +z |
| **7** | 0 | 190 | 70 | +y +z |
| **8** | 95 | 95 | 70 | +x +y +z |

_Note_: The activity of testIDs 5-8 are 10x that of 1-4 because of the large z-shift.

Expand All @@ -70,9 +62,8 @@ This is given by:

```
stir_z = (L-d)/2 + gate_z
```
```

where `L` is the scanner z-length (`157.16 mm`) and `d = 6.54mm` is the distance between rings .
For the data currently used in this test, `(L-d)/2 = 75.31mm`.
There are no translations in x or y.

There are no translations in x or y.
4 changes: 2 additions & 2 deletions src/recon_test/test_consistency_with_GATE.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class GATEConsistencyTests : public RunTests
//! The number of nonTOF LORs that failed the closest approach test.
int num_failed_nonTOF_lor_events = 0;
//! The threshold distance for the closest approach test.
double nonTOF_distance_threshold;
double nonTOF_distance_threshold = 0.f;

/// TOF VARIABLES
//! A vector to store the coordinates of the maximum voxels for each LOR.
Expand Down Expand Up @@ -226,7 +226,7 @@ setup()
num_events_tested = 0;

// Find threshold for failure
nonTOF_distance_threshold = 1.5 * norm(grid_spacing); // Using norm(grid_spacing) as a nonTOF_distance_threshold
nonTOF_distance_threshold = 1.5 * norm(grid_spacing);
{
// With the default files, we found that 3.3*norm(grid_spacing) is a reasonable limit.
// We try to generalise this to other data (although it will likely need further
Expand Down