Skip to content
Open
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
10 changes: 9 additions & 1 deletion applications/pctpairprotons/pctpairprotons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions documentation/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions test/Baseline/pairs0000.mhd.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
56279220dd768a08402ebe3b72ea943f3ed8d26c4ed0f79cc37f21a459ca23bea15a5284df4586c12bcac2ab263543cdda8b07fb66864d78bf70c8b6d1071df7
1 change: 1 addition & 0 deletions test/Baseline/pairs0000.raw.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
586bad7576b71c55c8eb53176cf37b0e08d6ddff7d5194a40e3ec8fa69ad033c55eaf2a250283c870c11e5f357edf37093db93e37bce803b1835bbf6b3b3611a
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions test/Input/PhaseSpaceIn.root.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b59642aa82c4160815295e5fb142536c842589dce20e17cdc399245bc928a4cde1c860ba1c023de165e1ddb7a7ac1cfbd906796b80e12f024cf2ebb6f23bf862
1 change: 1 addition & 0 deletions test/Input/PhaseSpaceOut.root.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9fb1aafd39da55c1b8e9280a2040772f80c73f6490bcadb8a90c7670aaf3db730cfe0704f386d22c03848c3855ce74915969855d6725551be39dc10ecfd5536b
Loading