Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
baa5fd0
Bug Fix for sidecar flag on ecat2bids (#358)
bendhouseart Jul 10, 2025
02ecbfa
Dockerfile for PET2BIDS (#359)
ramroomh Jul 15, 2025
9542eca
accept changes to avoid double [[ ]]
CPernet Aug 11, 2025
1d290c0
Adding header information for ecat71 (#362)
mathesong Aug 19, 2025
a75839a
Enhance README with spreadsheet usage instructions
CPernet Aug 24, 2025
7275c27
Merge pull request #364 from openneuropet/CPernet-patch-1
CPernet Aug 24, 2025
cb85f61
add dcm2niix binaries
bendhouseart Sep 8, 2025
3265c00
install pytest for testing helps
bendhouseart Sep 8, 2025
3c415d3
windows tweak
bendhouseart Sep 8, 2025
a3b050f
no cache only uv
bendhouseart Sep 8, 2025
a730bf8
remove dcm2niix install, add window and osx to phantoms
bendhouseart Sep 9, 2025
0fe561f
install uv for windows
bendhouseart Sep 9, 2025
7bd3ebc
only run matlab on the linux runner
bendhouseart Sep 9, 2025
5178e0b
wget does not windows
bendhouseart Sep 9, 2025
7a3334b
runner.os was inconsistent with multiple conditions?
bendhouseart Sep 9, 2025
7811f5f
sure {{}}}
bendhouseart Sep 9, 2025
b6c8661
hurray for actions
bendhouseart Sep 9, 2025
339a51f
update workflow file
bendhouseart Sep 9, 2025
c6478cd
codespell
bendhouseart Sep 9, 2025
9220d95
always windows
bendhouseart Sep 9, 2025
701a816
place debugging step in wf
bendhouseart Sep 9, 2025
5de5f67
update workflow to extract archive to the righ place
bendhouseart Sep 9, 2025
d40007d
powershell yay
bendhouseart Sep 9, 2025
cf5e017
love it
bendhouseart Sep 9, 2025
9467b92
windows
bendhouseart Sep 9, 2025
0fef6a6
iheartwindows
bendhouseart Sep 9, 2025
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
83 changes: 36 additions & 47 deletions .github/workflows/phantoms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest, macOS-latest]
python: ["3.12"]
fail-fast: false

Expand All @@ -36,14 +36,14 @@ jobs:
uses: actions/checkout@v2

- name: Cache Node Posix
if: runner.os != 'Windows' && !env.ACT
if: runner.os != 'Windows' && env.ACT != 'true'
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ env.cache-name }}

- name: Cache Phantoms
if: ${{ !env.ACT }}
if: env.ACT != 'true'
id: phantom-cache
uses: actions/cache@v4
env:
Expand All @@ -55,41 +55,21 @@ jobs:
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-

- name: Install dcm2niix posix
if: runner.os != 'Windows'
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
mkdir dcm2niix_install/ && cd dcm2niix_install/
curl -fLO https://github.com/rordenlab/dcm2niix/releases/download/v1.0.20230411/dcm2niix_lnx.zip
unzip dcm2niix*.zip
echo "${{ github.workspace }}/dcm2niix_install/" >> $GITHUB_PATH
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install dcm2niix
fi


- name: Check dcm2niix is installed and on path
if: runner.os != 'Windows'
run:
dcm2niix -h

- name: Install dcm2niix windows
if: runner.os == 'Windows'
run: |
curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_win.zip
powershell -command "Expand-Archive dcm2niix_win.zip"

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: |
pypet2bids/pyproject.toml

- name: Install UV
- name: Install UV (Linux/macOS)
if: runner.os != 'Windows'
run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Install UV (Windows)
if: runner.os == 'Windows'
run: |
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
echo "$env:USERPROFILE\.cargo\bin" >> $env:GITHUB_PATH

- name: Install Python Dependencies
run: |
cd pypet2bids
Expand All @@ -108,30 +88,43 @@ jobs:
- name: Install BIDS Validator
run: npm install -g [email protected]

- name: Collect Phantoms
if: ${{ steps.cache-phantoms.outputs.cache-hit != 'true' }} && ${{ !env.ACT }}
- name: Collect Phantoms (Linux/macOS)
if: steps.cache-phantoms.outputs.cache-hit != 'true' && !env.ACT && runner.os != 'Windows'
run: wget -O PHANTOMS.zip https://openneuropet.s3.amazonaws.com/US-sourced-OpenNeuroPET-Phantoms.zip

- name: Collect Phantoms (Windows)
if: steps.cache-phantoms.outputs.cache-hit != 'true' && !env.ACT && runner.os == 'Windows'
run: Invoke-WebRequest -Uri "https://openneuropet.s3.amazonaws.com/US-sourced-OpenNeuroPET-Phantoms.zip" -OutFile "PHANTOMS.zip"

- name: Debug
uses: mxschmitt/action-tmate@v3
if: github.event_name == 'workflow_dispatch' && inputs.debug_enabled
timeout-minutes: 15
with:
limit-access-to-actor: true

- name: Decompress phantoms windows
if: steps.cache-phantoms.outputs.cache-hit != 'true' && !env.ACT && runner.os == 'Windows'
run: powershell -command "Expand-Archive PHANTOMS.zip"
run: |
powershell -command "Expand-Archive PHANTOMS.zip"
# Move contents from PHANTOMS/OpenNeuroPET-Phantoms/ to OpenNeuroPET-Phantoms/
mv PHANTOMS/OpenNeuroPET-Phantoms .

- name: Decompress phantoms posix
if: steps.cache-phantoms.outputs.cache-hit != 'true' && !env.ACT && runner.os != 'Windows'
run: unzip PHANTOMS.zip

- name: Copy Conversion Scripts from Version Control
- name: Copy Conversion Scripts from Version Control (Linux/macOS)
if: runner.os != 'Windows'
run: |
mkdir -p OpenNeuroPET-Phantoms/code/
cp scripts/matlab_conversions.m OpenNeuroPET-Phantoms/code/matlab_conversions.m
cp scripts/python_conversions.sh OpenNeuroPET-Phantoms/code/python_conversions.sh

- name: Debug
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 15
with:
limit-access-to-actor: true
- name: Copy Conversion Scripts from Version Control (Windows)
if: runner.os == 'Windows'
run: |
cp scripts/python_conversions.sh OpenNeuroPET-Phantoms/code/python_conversions.sh

- name: Run Python Conversion Script on Phantoms
run: |
Expand Down Expand Up @@ -160,20 +153,16 @@ jobs:
matlab_conversions

- name: Check Parity
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python scripts/compare_jsons.py OpenNeuroPET-Phantoms/python OpenNeuroPET-Phantoms/matlab

- name: Validate Python Conversion
run: |
bids-validator OpenNeuroPET-Phantoms/python

- name: Debug
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 15
with:
limit-access-to-actor: true

- name: Validate Matlab Conversion
if: ${{ matrix.os == 'ubuntu-latest'}}
run: |
bids-validator OpenNeuroPET-Phantoms/matlab
63 changes: 63 additions & 0 deletions .github/workflows/test-included-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Test Included Binaries
on:
push:
branches:
- main
- add-dcm2niix-binaries
pull_request:
branches:
- main
- add-dcm2niix-binaries
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run with tmate debugging enabled'
required: false
default: false

jobs:
test-included-binaries:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.12']
fail-fast: false

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install UV
if: matrix.os != 'windows-latest'
run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Install UV (Windows)
if: matrix.os == 'windows-latest'
run: |
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
echo "$env:USERPROFILE\.cargo\bin" >> $env:GITHUB_PATH

- name: Install dependencies
run: |
cd pypet2bids
uv add --dev pytest
uv sync

- name: Debug Session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 15
with:
limit-access-to-actor: true

- name: Run Tests
run: |
cd pypet2bids
uv run pytest tests/test_included_binaries.py -v
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ ecat_testing/**/*.nii*

matlab/SiemensHRRTparameters.txt

dcm2niix
dcm2niix.exe
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM python:3.11-slim

LABEL maintainer="OpenNeuroPET team"
LABEL description="PET2BIDS"

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
unzip \
cmake \
build-essential \
pkg-config \
libturbojpeg0-dev \
libopenjp2-7-dev \
libjpeg-dev \
libcharls-dev \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /tmp
# Build and install dcm2niix
RUN git clone https://github.com/rordenlab/dcm2niix.git && \
cd dcm2niix && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON .. && \
make && \
make install && \
ldconfig && \
cd / && rm -rf /tmp/dcm2niix

# Verify dcm2niix installation and ensure it's in PATH
RUN which dcm2niix && dcm2niix -h
ENV PATH="/usr/local/bin:${PATH}"

WORKDIR /out
# Install pypet2bids
RUN pip install pypet2bids
3 changes: 2 additions & 1 deletion contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ some icons needs to be added or your name is not listed, please add it.
Murat Bilgel 💻 🐛 💡
Anthony Galassi 💻 📖 💬 🎨 💡 ⚠️
Melanie Ganz-Benjaminsen 🔍 💬 🤔 📋
Gabriel Gonzalez-Escamilla 💻 ⚠️ 🐛 👀
Gabriel Gonzalez-Escamilla 💻 ⚠️ 🐛 👀
Rami Hamati 💻 🐛
Gitte Knudsen 💡💵
Granville Matheson 📝 🐛 ✅
Martin Norgaard 💻 💬 🤔 ⚠️ 👀
Expand Down
Binary file added ecat_validation/ecat_info/ECAT71_headers.pdf
Binary file not shown.
9 changes: 7 additions & 2 deletions matlab/updatejsonpetfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,13 @@
for f = 1:length(shouldBarray)
if isfield(filemetadata,shouldBarray{f})
if isscalar(filemetadata.(shouldBarray{f}))
filemetadata.(shouldBarray{f}) = {filemetadata.(shouldBarray{f})};
updated = 1;
if ~iscell(filemetadata.(shouldBarray{f}))
filemetadata.(shouldBarray{f}) = {filemetadata.(shouldBarray{f})};
updated = 1;
elseif isnumeric(filemetadata.(shouldBarray{f}){1})
filemetadata.(shouldBarray{f}) = {filemetadata.(shouldBarray{f})};
updated = 1;
end
elseif all(size(filemetadata.(shouldBarray{f})) == 1)
if any(contains(filemetadata.(shouldBarray{f}),{'none'}))
filemetadata.(shouldBarray{f}) = {filemetadata.(shouldBarray{f})};
Expand Down
21 changes: 20 additions & 1 deletion pypet2bids/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ make installpoetry buildpackage installpackage
<details>
<summary>Run Directly From Source</summary>

Lastly, if one wishes run pypet2bids directly from the source code in this repository or to help contribute to the python portion of this project or any of the documentation they can do so via the following options:
If one wishes run pypet2bids directly from the source code in this repository or to help contribute to the python portion of this project or any of the documentation they can do so via the following options:

```bash
cd PET2BIDS/pypet2bids
Expand All @@ -100,6 +100,25 @@ python dcm2niix4pet.py --help

</details>

<details>
<summary>Run Using Docker</summary>
Lastly, we provide a Docker container that includes dcm2niix and pypet2bids. This can be installed using Docker. To build the docker file run:

```
docker build . -t openneuropet/pet2bids
```

Then mount and run conversions on your input folders like so:

```
docker run --rm -it \
-v /path/to/dicoms:/dicoms:ro \
-v /path/to/outputdir:/out \
openneuropet/pet2bids dcm2niix4pet /dicoms --destination-path /out
```
Please note the latest version of dcm2niix is pulled and installed at the time of building the Docker container.
</details>

**Note:**
*We recommend using dcm2niix v1.0.20220720 or newer; we rely on metadata included in these later releases. It's best to
collect releases from the [rorden lab/dcm2niix/releases](https://github.com/rordenlab/dcm2niix/releases) page. We have
Expand Down
Loading
Loading