From e52100f0bc931ade7a57461bb78ea3c3a0f7a136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Coussat?= Date: Wed, 15 Apr 2026 14:09:33 +0200 Subject: [PATCH 1/2] BUG: Fix pctpairprotons crashing when uproot returns a numpy.ndarray --- applications/pctpairprotons/pctpairprotons.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/applications/pctpairprotons/pctpairprotons.py b/applications/pctpairprotons/pctpairprotons.py index 147f401..07d4c9a 100644 --- a/applications/pctpairprotons/pctpairprotons.py +++ b/applications/pctpairprotons/pctpairprotons.py @@ -95,7 +95,15 @@ def load_tree_as_df(root_file, tree_name): tree = uproot.open(root_file)[tree_name] branches = tree.arrays(library="np") - dtype = [(name, branch.dtype) for name, branch in branches.items()] + # Some versions of uproot return a dictionnary, and some others a numpy.ndarray + # We handle both cases here to generate the dtype + if isinstance(branches, dict): + dtype = [(name, branch.dtype) for name, branch in branches.items()] + elif isinstance(branches, np.ndarray): + dtype = branches.dtype.descr + else: + raise NotImplementedError + ps = np.rec.recarray((len(branches["RunID"]),), dtype=dtype) for branch_name, _ in dtype: ps[branch_name] = branches[branch_name] From dfdd9ad6aeab908838b184171b4e6702cc267b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Coussat?= Date: Wed, 15 Apr 2026 14:10:56 +0200 Subject: [PATCH 2/2] DOC: Add documentation about installation of uproot --- documentation/docs/installation.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/documentation/docs/installation.md b/documentation/docs/installation.md index 9571195..39cd4e0 100644 --- a/documentation/docs/installation.md +++ b/documentation/docs/installation.md @@ -89,3 +89,10 @@ in the user's `.bashrc` file. This allows to run PCT applications from anywhere pip install opengate ``` An example of proton CT GATE simulation can be found in [`gate/protonct.py`](https://github.com/RTKConsortium/PCT/blob/main/gate/protonct.py). + +### Uproot + +[Uproot](https://uproot.readthedocs.io/) is a library for reading and writing ROOT files in pure Python and NumPy. Some applications of PCT require Uproot, such as `pctpairprotons` and `pctweplfit`. The simplest way to install Uproot is by running +```bash +pip install uproot +```