diff --git a/applications/pctpairprotons/pctpairprotons.py b/applications/pctpairprotons/pctpairprotons.py index 147f401..9eb341a 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 + 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 +``` diff --git a/test/Baseline/pairs0000.mhd.sha512 b/test/Baseline/pairs0000.mhd.sha512 new file mode 100644 index 0000000..35bd140 --- /dev/null +++ b/test/Baseline/pairs0000.mhd.sha512 @@ -0,0 +1 @@ +56279220dd768a08402ebe3b72ea943f3ed8d26c4ed0f79cc37f21a459ca23bea15a5284df4586c12bcac2ab263543cdda8b07fb66864d78bf70c8b6d1071df7 diff --git a/test/Baseline/pairs0000.raw.sha512 b/test/Baseline/pairs0000.raw.sha512 new file mode 100644 index 0000000..1d34edb --- /dev/null +++ b/test/Baseline/pairs0000.raw.sha512 @@ -0,0 +1 @@ +586bad7576b71c55c8eb53176cf37b0e08d6ddff7d5194a40e3ec8fa69ad033c55eaf2a250283c870c11e5f357edf37093db93e37bce803b1835bbf6b3b3611a diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d009dab..08948d4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,4 +32,12 @@ if(PCT_BUILD_APPLICATIONS) ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pctbinning -i DATA{Input/pairs0000.mhd,pairs0000.raw} -o ${ITK_TEST_OUTPUT_DIR}/projections.mhd --source 1000 --size=400,20,220 ) + itk_add_test(NAME pctapppairprotonstest + COMMAND itkTestDriver + --compare + DATA{Baseline/pairs0000.mhd,pairs0000.raw} + ${ITK_TEST_OUTPUT_DIR}/pairs.mhd + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pctpairprotons + -i DATA{Input/PhaseSpaceIn.root} -j DATA{Input/PhaseSpaceOut.root} -o ${ITK_TEST_OUTPUT_DIR}/pairs.mhd --plane-in -110 --plane-out 110 -v --psin PhaseSpaceIn --psout PhaseSpaceOut + ) endif() diff --git a/test/Input/PhaseSpaceIn.root.sha512 b/test/Input/PhaseSpaceIn.root.sha512 new file mode 100644 index 0000000..1f586a0 --- /dev/null +++ b/test/Input/PhaseSpaceIn.root.sha512 @@ -0,0 +1 @@ +b59642aa82c4160815295e5fb142536c842589dce20e17cdc399245bc928a4cde1c860ba1c023de165e1ddb7a7ac1cfbd906796b80e12f024cf2ebb6f23bf862 diff --git a/test/Input/PhaseSpaceOut.root.sha512 b/test/Input/PhaseSpaceOut.root.sha512 new file mode 100644 index 0000000..2d57ba9 --- /dev/null +++ b/test/Input/PhaseSpaceOut.root.sha512 @@ -0,0 +1 @@ +9fb1aafd39da55c1b8e9280a2040772f80c73f6490bcadb8a90c7670aaf3db730cfe0704f386d22c03848c3855ce74915969855d6725551be39dc10ecfd5536b