Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ RUN mkdir -p /home/vscode/.local/share/CMakeTools \
&& chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json

# Install the yardl tool
ARG YARDL_VERSION=0.6.2
ARG YARDL_VERSION=0.6.3
RUN wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
&& tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
&& mv yardl "/opt/conda/envs/${CONDA_ENVIRONMENT_NAME}/bin/" \
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ jobs:
with:
activate-environment: yardl
environment-file: temp-ci-environment.yml
miniforge-version: latest
- name: Install yardl
run: |
rm temp-ci-environment.yml
YARDL_DIR=${{github.workspace}}/yardl
mkdir ${YARDL_DIR}
YARDL_VERSION=0.6.2
YARDL_VERSION=0.6.3
wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" -C "${YARDL_DIR}"
rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
Expand All @@ -48,12 +49,6 @@ jobs:
cd PETSIRD/model
yardl generate

- name: Python
run: |
pip install ./PETSIRD/python
cd python
python start.py

- name: Cpp
run: |
cd cpp && mkdir -p build && cd build
Expand Down
2 changes: 1 addition & 1 deletion PETSIRD
Submodule PETSIRD updated 57 files
+0 −2 .clang-format
+1 −1 .devcontainer/Dockerfile
+123 −105 .devcontainer/devcontainer.json
+3 −0 .flake8
+1 −1 .gitattributes
+1 −1 .github/PULL_REQUEST_TEMPLATE.md
+23 −8 .github/workflows/ci.yml
+1 −0 .gitignore
+59 −0 .pre-commit-config.yaml
+1 −1 CONTRIBUTING.md
+1 −1 LICENSE.txt
+8 −7 README.md
+7 −6 cpp/CMakeLists.txt
+12 −0 cpp/helpers/CMakeLists.txt
+144 −0 cpp/helpers/include/petsird_helpers.h
+80 −0 cpp/helpers/include/petsird_helpers/create.h
+109 −0 cpp/helpers/include/petsird_helpers/geometry.h
+206 −0 cpp/helpers/petsird_analysis.cpp
+115 −74 cpp/helpers/petsird_generator.cpp
+0 −103 cpp/petsird_analysis.cpp
+0 −81 cpp/petsird_helpers.h
+6 −4 environment.yml
+37 −0 justfile
+1 −0 matlab/.gitignore
+27 −0 matlab/README.md
+3 −0 matlab/build-toolbox.sh
+41 −0 matlab/buildfile.m
+89 −0 matlab/toolbox/+petsird/+helpers/analysis.m
+18 −0 matlab/toolbox/+petsird/+helpers/expand_detection_bin.m
+13 −0 matlab/toolbox/+petsird/+helpers/expand_detection_bins.m
+250 −0 matlab/toolbox/+petsird/+helpers/generator.m
+49 −0 matlab/toolbox/+petsird/+helpers/get_detection_efficiency.m
+13 −0 matlab/toolbox/+petsird/+helpers/get_num_detecting_elements.m
+15 −0 matlab/toolbox/+petsird/+helpers/get_num_detection_bins.m
+18 −0 matlab/toolbox/+petsird/+helpers/make_detection_bin.m
+13 −0 matlab/toolbox/+petsird/+helpers/make_detection_bins.m
+3 −0 matlab/toolbox/.gitignore
+3 −6 model/CoincidenceEvent.yml
+73 −33 model/DetectionEfficiencies.yml
+43 −12 model/DetectorInformation.yml
+3 −0 model/ExamInformation.yml
+0 −3 model/GeometryInformation.yml
+92 −21 model/Protocol.yml
+86 −25 model/ScannerInformation.yml
+7 −6 model/TripleEvent.yml
+3 −0 model/_package.yml
+5 −4 python/README.md
+137 −0 python/petsird/helpers/__init__.py
+140 −0 python/petsird/helpers/analysis.py
+302 −0 python/petsird/helpers/generator.py
+80 −0 python/petsird/helpers/geometry.py
+53 −0 python/petsird/helpers/plot_scanner.py
+0 −70 python/petsird_analysis.py
+0 −264 python/petsird_generator.py
+0 −86 python/petsird_helpers.py
+0 −107 python/petsird_plot_scanner.py
+2 −3 python/pyproject.toml
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# PETSIRD template for use cases
# PETSIRD template for C++ use cases

The purpose of this repo is to provide a starting point for developing software that uses PETSIRD.
It is currently mostly needed/useful for C++ development, but is also useful for Python developers
who want to experiment with development of PETSIRD itself.
It is currently mostly needed/useful for C++ development.

## Background
The [Emission Tomography Standardization Initiative (ETSI)](https://etsinitiative.org/)
Expand All @@ -18,7 +17,14 @@ These instructions will use `YourRepoName` for the name of your new repository.
Easiest is to start from GitHub:
1. Navigate to the URL of this repo: https://github.com/ETSInitiative/PETSIRDUseCaseTemplate
2. Click on the `Use this template` button and create your own repo
3. Pull it to your own local machine and modify

### Using your repo

1. Open ***your*** repo in [GitHub Codespaces](https://code.visualstudio.com/docs/remote/codespaces) or
in a [VS Code devcontainer](https://code.visualstudio.com/docs/devcontainers/containers).
This codespace/container will contain all necessary tools, including `yardl` itself, as well as your repository.<br>
(Alternatively, clone to your local computer with `git clone --recurse-submodules <repository_url>`, download `yardl`, install dependencies etc.)
2. Start with basic house-keeping
1. Search-and-replace all occurences of `PETSIRDUseCaseTemplate` with `YourRepoName`
2. Update the README.md to remove references to this template and write something about what your repo is going to do
3. Update the `environment.yml`to include what you need. For instance, if you need ROOT, add something like `- root=6.28.0`
Expand All @@ -27,19 +33,17 @@ Easiest is to start from GitHub:
git commit -a -m "Updated template to YourRepoName"
git push
```

### Using your repo

1. Open ***your*** repo in [GitHub Codespaces](https://code.visualstudio.com/docs/remote/codespaces) or
in a [VS Code devcontainer](https://code.visualstudio.com/docs/devcontainers/containers).
This codespace/container will contain all necessary tools, including `yardl` itself, as well as your repository.
2. Use `yardl` to generate C++ and Python code for the model:
```sh
cd YourRepoName
cd PETSIRD/model
yardl generate
cd ../..
```
3. Start working in either the [`cpp`](cpp/README.md) and/or [`python`](python/README.md) directories.
3. Start working in the [`cpp`](cpp/README.md) directory.
4. Edit the [`justfile`](justfile), e.g. to add a `@run` target
5. type `just build` (or `just run`)

Note: if you don't want to use `just`, you will have to use `yardl` to generate C++ and Python
code for the model:
```sh
cd YourRepoName
cd PETSIRD/model
yardl generate
cd ../..
```


25 changes: 22 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
cmake_minimum_required(VERSION 3.12.0) # older would work, but could give warnings on policy CMP0074
project(PETSIRDUseCaseTemplate VERSION 0.2.0)
project(PETSIRDUseCaseTemplate VERSION 0.7.2)

set(CMAKE_CXX_STANDARD 17)

#Set the build type to Release if not specified
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif ()

if(WIN32)
add_compile_options(/W3 /WX)
else()
add_compile_options(-Wall -Wextra -pedantic)
endif()

set(PETSIRD_dir ../PETSIRD/cpp/generated)
add_subdirectory(${PETSIRD_dir} PETSIRD_generated)

# Add any packages, below is an example for ROOT (unlikely you'll need that one though!)
# find_package(ROOT REQUIRED COMPONENTS Tree)

# Example lines for a new executable
# add_executable(my_prog my_prog.cpp)
# target_include_directories(my_prog PUBLIC ${PETSIRD_dir})
# needed for helpers
# target_include_directories(my_prog PUBLIC ${PETSIRD_dir}/..)
# target_include_directories(my_prog PUBLIC ${PETSIRD_dir}/../helpers/include)
# target_link_libraries(my_prog PUBLIC petsird_generated)
# install(TARGETS my_prog DESTINATION bin)

add_subdirectory(../PETSIRD/cpp/generated PETSIRD_generated)
# add any dependencies on packages here
# target_link_libraries(my_prog PUBLIC ROOT::Tree)

# install(TARGETS my_prog DESTINATION bin)
2 changes: 1 addition & 1 deletion cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This directory provides a skeleton for C++ example code to read/write PETSIRD data. You need to `yardl generate` in the `model` directory first.

Check the example in the PRDdefinition repo first.
Check the example in the PETSIRD repo first.

1. Compile the code:
```sh
Expand Down
12 changes: 4 additions & 8 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ dependencies:
- bash-completion>=2.11
- cmake>=3.21.3
- fmt>=8.1.1
- compilers
- h5py>=3.7.0
- cxx-compiler
- hdf5>=1.12.1
- howardhinnant_date>=3.0.1
- ipykernel>=6.19.2
- just=1.36.0
- ninja>=1.11.0
- nlohmann_json>=3.11.2
- numpy>=1.24.3
- python>=3.11.3
- matplotlib
- shellcheck>=0.8.0
- xtensor-fftw>=0.2.5
- xtensor>=0.24.2
- xtensor>=0.24.2, <0.26.0
- xtensor-blas
19 changes: 19 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set shell := ['bash', '-ceuo', 'pipefail']

default: run

@ensure-build-dir:
mkdir -p cpp/build

@generate:
cd PETSIRD/model; \
yardl generate

@configure: generate ensure-build-dir
cd cpp/build; \
cmake -GNinja ..

@build: generate configure
cd cpp/build; \
ninja

9 changes: 0 additions & 9 deletions python/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions python/start.py

This file was deleted.

Loading