Metadata-Version: 2.4
Name: pyrateshield
Version: 3.2rc1
Summary: Radiation shielding calculation tool for hospital environments
License: 
                                         Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: DISCLAIMER.md
License-File: LIMITATIONS.md
License-File: THIRD_PARTY_NOTICES.md
License-File: SOURCE_OFFER.md
License-File: SBOM.spdx.json
License-File: licenses/CC-BY-4.0.txt
License-File: licenses/LGPL-3.0.txt
License-File: licenses/OFL-1.1.txt
License-File: licenses/PYINSTALLER-COPYING.txt
Requires-Dist: PySide6>=6.6
Requires-Dist: pydantic>=2.0
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: pandas>=2.0
Requires-Dist: imageio>=2.28
Requires-Dist: pyyaml>=6.0
Requires-Dist: qtawesome>=1.3
Requires-Dist: packaging>=23.0
Requires-Dist: psutil>=5.9
Requires-Dist: matplotlib>=3.7
Requires-Dist: scikit-image>=0.21
Requires-Dist: openpyxl>=3.1
Dynamic: license-file

# PyrateShield 3

A radiation shielding dose-rate calculator for hospital environments
(radiology and nuclear medicine).

> [!WARNING]
> PyrateShield is unverified decision-support software provided without
> warranty. Results must be independently checked by appropriately qualified
> professionals and must not be used as the sole basis for shielding,
> construction, safety, clinical, or financial decisions. See the full
> [Safety and liability notice](DISCLAIMER.md) and the documented
> [calculation limitations](LIMITATIONS.md).

![mainscreen](img/mainscreen.png)

---

## Introduction

PyrateShield is a Python application that performs radiation shielding
calculations for nuclear medicine and radiology departments in hospitals.
The application has a user-friendly graphical interface; no Python coding or
command-line interaction is needed.

The application is intended to calculate the (necessary) radiation shielding
in entire radiology and nuclear medicine departments. Nuclear medicine sources,
CT sources, and X-ray sources can be defined and positioned on a floorplan in
the GUI. Walls with defined thickness and material can be drawn and radiation 
dose rate can be visualised as a colour heatmap with isodose contour lines on 
the floorplan. Critical points can be added to calculate the exact dose rate at 
specific locations. Critical point results can be exported to Excel.


## Intended users

Medical physicists and radiation protection officers working at a nuclear
medicine or radiology department in a hospital.

---

## Installation

Compiled binaries and a PyPI package are planned for a future release. For
now, install from source:

```bash
git clone https://codeberg.org/MedPhysNL/Pyrateshield.git
cd Pyrateshield
pip install .
pyrateshield
```

Requires Python 3.10+.

---

## Using PyrateShield

### Toolbar

At the top of PyrateShield is a toolbar with icons. File operations, editing
actions, and item placement are all started from the toolbar.

![toolbar](img/toolbar.png)

| Item | Description |
|------|-------------|
| New | Start a new, blank PyrateShield project |
| Open | Load a PyrateShield project file (`.zip`) from disk |
| Save | Save the current project to disk |
| Save As | Save the current project to disk under a new filename |
| Load Image | Load a bitmap image as the floorplan background |
| Snapshot | Export the current canvas view (with dosemap overlay) as a PNG or JPEG image |
| Undo | Undo the last action (Ctrl+Z) |
| Redo | Redo the last undone action (Ctrl+Y / Ctrl+Shift+Z) |
| Delete | Delete the selected item(s) from the floorplan and project |
| Show/hide labels | Toggle source and ruler name labels on the canvas (**L**) |
| Wall | Draw a new wall on the floorplan (click and drag) |
| NM Source | Click on the floorplan to place a new nuclear medicine source |
| CT Source | Click on the floorplan to place a new CT source |
| X-ray Source | Click on the floorplan to place a new X-ray source |
| Critical Point | Click on the floorplan to place a new critical evaluation point |
| Ruler | Draw a ruler over a known distance for scale calibration |
| Calculator | Shielding transmission calculator — inspect a single material/thickness quickly |
| Isotopes | Open the Isotope Browser (decay data, gamma spectra, transmission curves) |
| YAML editor | View and edit the current project as raw YAML text |
| Notes | Open the project notes editor (supports Markdown preview) |
| About / Help | Open the About / Help window — version info, safety notice, user manual, keyboard shortcuts, physics parameters, limitations, and licences (**F1**) |

**Canvas navigation:**
- **Pointer button** (lower right) — select and move canvas items
- **Hand button** (lower right) — activate persistent click-and-drag panning
- **Area-zoom button** (lower right) — drag a rectangle to fit that region
- **Scroll wheel** — zoom in/out (anchored to mouse cursor)
- **Two-finger trackpad scroll** — pan
- **Trackpad pinch** — zoom in/out on macOS and supported Wayland compositors
- **Ctrl+scroll** — fine zoom
- **Space+drag** or **Alt+drag** — temporary pan in any mode
- **Middle mouse drag** — pan
- **L** — toggle labels

### Left panel — item properties

On the left side of the interface a panel displays all PyrateShield objects.
Select an object in the list to inspect or modify its properties.

![toolbox](img/toolbox.png)

#### Scale

A typical project starts with loading a floorplan image. Floorplan images
are loaded as bitmap images and carry no scale information. The pixel size
(real-world length in cm per pixel) must be set before placing objects.

**Set manually:** enter the pixel size directly in the Scale panel and click
Confirm.

**Ruler calibration:** draw a ruler over a feature of known length, then
enter the known distance in the Scale panel to compute the pixel size
automatically.

Any change to the pixel size only takes effect after clicking Confirm.

#### NM Sources

Click the **NM Source** toolbar button and then click on the floorplan to
place a new nuclear medicine source.

| Property | Description |
|----------|-------------|
| Name | Name of the source |
| Isotope | Radionuclide |
| Activity (MBq) | Source activity in MBq |
| Duration (h) | Duration for which the source (or patient) is present in the room |
| No. of exams/week | Number of exams performed per week |
| Apply decay correction | Correct for physical decay during the exam duration |
| Clearance model | Biological clearance model (see Clearance section) |
| Self-shielding | Patient self-shielding: None, Body (MCNP water sphere), or Factor |
| SS factor | Manual self-shielding correction factor (shown when Self-shielding is set to Factor) |
| Occupancy factor | Fractional occupancy correction (use 1 to apply no correction) |
| Enabled | When unchecked the source is excluded from all calculations |

The **Activity graph ↗** button opens a graph showing the source activity as a
function of time, including the effect of physical decay, biological clearance,
and the decay correction toggle. A vertical line marks the configured Duration.

The **View isotope spectrum ↗** button opens the Isotope Browser focused on the
selected isotope.

#### Clearance

Clearance models are optional and are mainly used to represent therapy
patients who stay overnight in a nuclear medicine therapy facility. The model
corrects for biological excretion of radioactivity.

The model can be mono-exponential or bi-exponential. Physical decay is always
applied (if the decay correction option is checked on the NM source). The two
exponentials can be split by fraction or by time. When split by fraction and
the fractions do not sum to 1, the remainder is assumed to be cleared only by
physical decay. When split by time, the first exponential is integrated from
zero to the split time and the second from the split time onward; integration
always ends at the source duration. By default a set of clearance models is
included as prescribed by the Dutch guidelines (*Werken met therapeutische
hoeveelheden radionucliden*).

| Property | Description |
|----------|-------------|
| Name | Name of the clearance model |
| Fraction 1 | Fraction (0–1) for the first exponential |
| Half-life 1 (h) | Biological half-life for the first exponential |
| Fraction 2 | Fraction (0–1) for the second exponential |
| Half-life 2 (h) | Biological half-life for the second exponential |
| Split fractions by time | Time at which the two exponentials split; when enabled, both fractions are treated as 1 |

#### CT Sources

CT scatter dose is calculated using the scatter model from Wallace et al. (2012),
extended with direction-dependent scatter fractions. Three angular sectors are
defined relative to the gantry orientation:

| Sector | Angle from front | Body (μGy/(mGy·cm)) | Head (μGy/(mGy·cm)) |
|--------|-----------------|---------------------|---------------------|
| Front (patient table side) | 0–70° | 0.36 | 0.14 |
| Gantry ring (lateral) | 70–130° | 0.04 | 0.014 |
| Rear (electronics) | 130–180° | 0.30 | 0.14 |

The CT marker on the canvas is a T-shaped symbol: the **stem** indicates the
front of the scanner (patient table side) and points in the direction of the
gantry angle; the **crossbar** represents the rear of the gantry ring.

Click the **CT Source** toolbar button and then click on the floorplan to
place a source.

| Property | Description |
|----------|-------------|
| Name | Name of the source |
| kVp | Tube voltage (120 or 140 kVp) |
| Body part | CTDI phantom: Body or Head |
| Patients/week | Number of patients scanned per week |
| DLP/exam (mGy·cm) | Dose–length product per exam |
| Occupancy factor | Fractional occupancy correction |
| Gantry angle (°) | Direction the patient table faces, measured counter-clockwise from East (+X). Adjustable via spinbox or slider; the T marker on the canvas updates in real time |
| Enabled | When unchecked the source is excluded from all calculations |

All Archer-equation parameters and scatter fractions are visible in the
**Physics Parameters** tab of the About / Help window, with full literature
references.

#### X-ray Sources

X-ray scatter dose is calculated using the secondary scatter model from
NCRP Report 147, Figure C.1.

| Property | Description |
|----------|-------------|
| Name | Name of the source |
| kVp | Tube voltage |
| Patients/week | Number of patients per week |
| DAP/exam (Gy·cm²) | Dose–area product per exam |
| Scatter fraction | Fraction of primary dose converted to scatter at 1 m, 90° |
| Occupancy factor | Fractional occupancy correction |
| Enabled | When unchecked the source is excluded from all calculations |

#### Walls

Draw a wall by clicking the **Wall** toolbar button, then click-and-drag on
the floorplan. Each wall has a shielding preset assigned to it.

| Property | Description |
|----------|-------------|
| Name | Name of the wall |
| Shielding | The shielding preset assigned to this wall |
| X1, Y1, X2, Y2 | End-point coordinates in cm |
| Enabled | When unchecked the wall is excluded from all calculations |

When multiple walls are selected, the multi-wall panel shows additional
bulk actions: **Apply shielding to all selected**, **Enable all**, and
**Disable all**.

Right-clicking on a selected wall endpoint opens a context menu with
additional options:

| Action | Description |
|--------|-------------|
| Delete | Delete the selected wall |
| Continue wall here | Continue drawing from this wall endpoint |
| Snap to | Snap this endpoint to the nearest wall endpoint within range |

**Endpoint snapping:** wall and ruler endpoints automatically snap to nearby
endpoints within 14 px; a green ring indicator appears when snapping is active.

**Grid snapping:** press **G** to toggle snap-to-grid with a configurable pitch
(set in the Settings dialog).

#### Shieldings

Shieldings are presets consisting of one or two material layers with defined
thicknesses. They are assigned to walls. Changing a shielding definition
updates all walls that use it immediately.

| Property | Description |
|----------|-------------|
| Name | Name of the shielding |
| Material 1 | First material (set to None to disable) |
| Thickness 1 (cm) | Thickness of the first material layer |
| Material 2 | Second material (set to None to disable) |
| Thickness 2 (cm) | Thickness of the second material layer |
| Colour | Display colour for walls with this shielding |
| Linewidth (pt) | Display line width for walls with this shielding |

Click **Add** to create a new shielding definition or **Delete** to remove
the selected one. A shielding can only be deleted when no walls are
currently using it.

#### Materials

The Materials section shows the properties of all available materials and how
they are mapped to the two calculation engines. Materials can be added or
modified to a limited extent.

| Property | Description |
|----------|-------------|
| Name | Name of the material |
| Density (g/cm³) | Material density |
| Att. table | Attenuation table (µ/ρ) used by the Point Kernel engine — dropdown listing available sheets from `attenuation.xlsx` |
| Buildup table | Buildup factor table used by the Point Kernel engine — dropdown listing available sheets from `buildup.xlsx` |
| MCNP material | Material used by the Pre-computed (MCNP) engine — dropdown listing the materials available in the LUT |
| CT material | Lead or Concrete Archer reference used for CT barriers; None makes this material transparent to CT |
| X-ray material | Lead, Concrete, or Gypsum Archer reference used for X-ray barriers; None makes this material transparent to X-ray |

Modifying density is the most common use case: both engines handle
user-defined densities by scaling the effective thickness. CT and X-ray each
scale the physical thickness directly from the project material density to the
density of their selected Archer reference.

The Materials pane also provides buttons to save unmodified copies of the
Point Kernel attenuation and buildup workbooks and the CT/X-ray Archer
`constants.yml` file for inspection and project documentation.

#### Rulers

Draw a ruler by clicking the **Ruler** toolbar button, then click-and-drag
on the floorplan. Rulers can be named and managed in the **Rulers** panel.
Use **Locate** beside the calibration ruler selector, or double-click a ruler
in the Rulers pane, to centre and temporarily highlight it on the canvas.
The same **Locate** button and double-click behaviour is available in the NM,
CT and X-ray source lists and in the Critical Points pane.

| Property | Description |
|----------|-------------|
| Name | Optional label shown on the canvas alongside the measurement |
| Length | Computed length in cm (read-only) |
| p1 x, p1 y | Start point coordinates in cm |
| p2 x, p2 y | End point coordinates in cm |

#### Critical points

Click the **Critical Point** toolbar button and then click on the floorplan to
place a critical evaluation point.

| Property | Description |
|----------|-------------|
| Name | Name of the critical point |
| Occupancy factor | Fractional occupancy correction (use 1 to apply no correction) |
| Position | Position in cm on the floorplan |
| Enabled | When unchecked the point is excluded from the critical point report |

### Right panel — calculation and display

The right panel controls the calculation engines, dosemap styling, and displays
results.

#### Engine selection and dosemap calculation

Select either **Pre-computed (MCNP)** or **Point Kernel** and click **Calculate**
to run the dosemap. Progress is reported live. Grid
resolution (nx × ny) and the number of parallel worker threads can be
configured in the **Settings** dialog.

#### Dosemap style

| Option | Description |
|--------|-------------|
| Colormap | Colour scale (jet, hot, viridis, plasma, inferno, YlOrRd, RdYlBu_r) |
| Min / Max (mSv) | Dose range for the colour scale |
| Log scale | Use a logarithmic colour scale |
| Opacity | Transparency of the dosemap overlay |
| Alpha gradient | Fade out low-dose regions for clarity |
| Show legend | Display the colour scale bar |
| Show contours | Overlay isodose contour lines |

#### Isodose contours

The contour table lets you define any number of isodose levels, each with its
own colour, line style (solid, dashed, dotted, dashdot), line width, and an
enable/disable toggle.

#### Critical point report

After running a calculation, the critical point table shows the interpolated
dose rate at each enabled critical point, including the occupancy-corrected
value. Click any row to see a per-source dose breakdown (using the currently
selected engine) in a summary label below the table. Selected rows can be
copied directly into a spreadsheet with **Ctrl+C** (**Cmd+C** on macOS), or
with the table's right-click **Copy** action. Use **Export to Excel** to save
the full report, which includes a **CP Breakdown** sheet with
per-source contributions at each critical point for both engines side by side.

> **Note:** the table does not update automatically. After modifying the
> project, recalculate explicitly by clicking **Calculate** again.

### Floating tool windows

The following tool windows can be opened from the toolbar and stay open
alongside the main window:

- **Isotope Browser** — decay data, gamma spectra, transmission curves through
  all shielding materials, and H*(10) dose rate constants for all supported
  isotopes. Both the Pre-computed (MCNP) and Point Kernel results are shown.
- **Shielding Calculator** — point-kernel transmission calculator for a
  user-defined stack of material layers; useful for quick checks and for
  comparing Point Kernel and Pre-computed (MCNP) results.
- **YAML editor** — view and live-edit the current project as raw YAML text.
  Changes are validated against the project schema before being applied.
  Useful for bulk edits and for copy-pasting configurations between projects.
- **Project Notes** — a free-text notes field (Markdown, with preview) attached
  to the project file.
- **About / Help** (**F1**) — tabbed reference window: About (version and
  developer contacts), Safety & Disclaimer, User Manual (this README
  rendered as HTML), Keyboard Shortcuts, Implementation notes, Physics
  Parameters (`constants.yml` — Archer-equation and scatter-fraction
  parameters for the CT and X-ray models, with full literature references),
  Limitations, and Open-source Licences.
- **Activity graph** — opened via the **Activity graph ↗** button in the NM
  Sources panel. Shows the source activity as a function of time for the
  selected source, including physical decay, biological clearance components,
  and the effect of the decay correction toggle.

## Developer notes

### Subprocess isolation — worker process state

Calculations run in persistent subprocesses managed by `ProcessPoolExecutor`
pools in `app/calc_worker.py`. Workers are started with the **spawn** context
(`multiprocessing.get_context("spawn")`) on all platforms. This means:

- Workers start as fresh Python interpreters — no inherited file descriptors,
  no fork-related issues on Linux, and consistent behaviour with Windows (which
  has always used spawn).
- Each worker process has its **own independent copy of every module's global
  state**, completely separate from the main process. This has one important
  consequence that is easy to miss:

**Any module-level configuration set in the main process is invisible to the
workers.**

The concrete case is `physics/isotope_data.py`, which exposes a `_config`
object (set by `configure()`) that controls spectrum filtering and line
grouping. Calling `configure()` in the main process does not affect the
workers — they start with default settings and never see changes unless
explicitly told.

The fix is to send a small task to each worker pool that calls `configure()`
and pre-warms the cache inside the worker process. This is implemented as
`_configure_isotopes_worker()` / `_push_isotope_config_to_workers()` in
`calc_worker.py`, called from `init_pool()` and from the settings-change
handlers in `main_window.py` and `right_panel.py`.

**Rule of thumb:** if you add global state to any module used by the engine,
and that state needs to match between the main process and the workers, you
must propagate it explicitly via a task submitted to every slot pool — the
same pattern used by `_push_isotope_config_to_workers`.

---

## References

[1] Shimizu A, Onda T, Sakamoto Y. Calculation of gamma-ray buildup factors
up to depths of 100 mfp by the method of invariant embedding, (III) Generation
of an improved data set. *J Nucl Sci Technol* 41: 413–424; 2004.

[2] Wallace AB et al. Establishment of scatter factors for use in shielding
calculations and risk assessment for computed tomography facilities.
*J Radiol Prot* 32(4): 389–402; 2012.

[3] NCRP Report No. 147. Structural Shielding Design for Medical X-Ray
Imaging Facilities. 2004.

[4] Simpkin DJ. Shielding requirements for CT facilities.
*Health Phys* 58(3): 363–367; 1990.

[5] Simpkin DJ. Transmission data for shielding diagnostic x-ray facilities.
*Health Phys* 68(5): 704–709; 1995.

[6] Harima Y, Sakamoto Y, Tanaka S, Kawai M. Data Library of Gamma-Ray
Buildup Factors and Its Application to Calculation of Transmission Function.
JAERI-M 87-210; 1988. Table 3.5.

[7] Stettner C, Hranitzky C, Poljanc K, Strebl F, Streli C. Catalogue of
dose rate constants for more than 400 radionuclides in terms of ambient
dose H* and comparison of figures to ambient dose equivalent H*(10).
*Appl Radiat Isot* 184: 110159; 2022.

---

## License and disclaimer

PyrateShield is licensed under the [Apache License 2.0](LICENSE) and is
provided without warranties or conditions of any kind. Before using the
software or its results, read the full [Safety and liability notice](DISCLAIMER.md).

Bundled dependencies and assets remain under their respective licences. See
the [third-party notices](THIRD_PARTY_NOTICES.md) and the
[LGPL corresponding-source offer](SOURCE_OFFER.md), particularly for Qt and
PySide6 redistribution information.

Maintainers preparing binaries must follow the legal inventory checklist in
[RELEASING.md](RELEASING.md).

---

## Contact

**Developers:**
Marcel Segbers (m.segbers@erasmusmc.nl)
Rob van Rooij (r.vanrooij-3@umcutrecht.nl)

**Special thanks:**
Maxime Imperatori — CT directional scatter model (maxime.imperatori@mumc.nl)
Claude (Anthropic) — v3 rewrite and code architecture
