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] 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 +```