The application, written in R language, is devoted to image reconstruction for J-PET, using multivariate kernel density estimation (KDE).
Tested on Ubuntu 16.04 LTE with R version 3.4.4 installed. The script operates with a number of shell commands
(for example, readlink -f <incomplete_path_to_file>
), but. basically, all of them are standard.
Additional R packages are required:
- jsonlite
- data.table
- ks
- reshape2 (for ASCII format only)
- RColorBrewer (optional - for plotting images)
The application proceeds with GOJA output format
(16-column ASCII) as the input. The parameters of the reconstruction, as well as the geometry of the scanner,
are stored in JSON format: it is self-describing and easy to undersand. Please refer to the example/
directory
for the details.
The script is designed to work as quick as possible, hence, for data processing, R environments are utilised instead of classes:
SetMappingEnvironment.R
SetAnhPtsEnvironment.R
SetKDEEnvironment.R
In comparison, the performance is not crucial for the read of input parameters, so Reference classes are used for
controllers (wrapped into a list by InitParamsFromJSON.R
):
JSONReader.R
KDEController.R
More information on the performance of R classes and environments could be found here.
There are three main executables:
MapHitsToCentresOfStrips.R
- remaps all XY-coordinates of hits to the centres of strips and saves the result to file, according to the format chosen (ASCII or .RData). Only first 8 columns are saved (pairs of coordinates and times of hits)DetectAnnihilationPoints.R
- remaps XY-coordinates of hits to the centres of strips and estimates exact positions of annihilation points, using time-of-flight (estimated from times of hits). The result - three columns for (X,Y,Z) - is stored according to the format chosen (ASCII or .RData).EngageKDEReconstruction.R
- executes KDE on the data for annihilation points. Depends strongly on input JSON file and requiresDetectAnnihilationPoints.R
to run first.
A single shared argument, a .json
file with parameters is passed to all executables (see the example/
directory):
$ Rscript [--vanilla] MapHitsToCentresOfStrips.R <parameters.json>
$ Rscript [--vanilla] DetectAnnihilationPoints.R <parameters.json>
$ Rscript [--vanilla] EngageKDEReconstruction.R <parameters.json>
The option --vanilla
prevents Rscript from
reading R history, profile, or environment files, as well as reloading data or objects from previous sessions.