Bug Fix for sidecar flag on ecat2bids #397
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: phantoms | |
| on: | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| - switch-phantoms-to-s3 | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| workflow_dispatch: | |
| inputs: | |
| debug_enabled: | |
| type: boolean | |
| description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
| required: false | |
| default: false | |
| jobs: | |
| phantoms: | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| DCM2NIIX_WIN_PATH: dcm2niix_win/dcm2niix.exe | |
| MATLAB_CODE_PATH: ${{ github.workspace }}/matlab/ | |
| METADATA_PATH: ${{ github.workspace }}/metadata/ | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| python: ["3.12"] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v2 | |
| - name: Cache Node Posix | |
| if: runner.os != 'Windows' && !env.ACT | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: npm-${{ runner.os }}-${{ env.cache-name }} | |
| - name: Cache Phantoms | |
| if: ${{ !env.ACT }} | |
| id: phantom-cache | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-phantoms | |
| with: | |
| path: PHANTOMS.zip | |
| key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('PHANTOMS.zip') }} | |
| restore-keys: | | |
| ${{ 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 | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install Python Dependencies | |
| run: | | |
| cd pypet2bids | |
| pip install -e .[dev] | |
| - name: Install UV Build Package | |
| run: | | |
| make installuv | |
| make buildpackage | |
| cd pypet2bids && uv pip install dist/pypet2bids-*.whl --system | |
| dcm2niix4pet -h | |
| - name: Set Up Node | |
| uses: actions/setup-node@v4 | |
| - name: Install BIDS Validator | |
| run: npm install -g [email protected] | |
| - name: Collect Phantoms | |
| if: ${{ steps.cache-phantoms.outputs.cache-hit != 'true' }} && ${{ !env.ACT }} | |
| run: wget -O PHANTOMS.zip https://openneuropet.s3.amazonaws.com/US-sourced-OpenNeuroPET-Phantoms.zip | |
| - name: Decompress phantoms windows | |
| if: steps.cache-phantoms.outputs.cache-hit != 'true' && !env.ACT && runner.os == 'Windows' | |
| run: powershell -command "Expand-Archive PHANTOMS.zip" | |
| - 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 | |
| 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: Run Python Conversion Script on Phantoms | |
| run: | | |
| cd OpenNeuroPET-Phantoms/code | |
| bash python_conversions.sh | |
| - name: SetupMatlab | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| uses: matlab-actions/setup-matlab@v1 | |
| # note matlab-actions/setup-matlab@v2 breaks this script, don't update unless you're forced to | |
| #with: | |
| #release: 'R2023a' | |
| #cache: true | |
| - name: Run Matlab Conversion Script on Phantoms | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| uses: matlab-actions/run-command@v1 | |
| with: | |
| command: | | |
| addpath('${{ github.workspace }}/OpenNeuroPET-Phantoms/code') | |
| addpath('${{ env.MATLAB_CODE_PATH }}'); | |
| addpath('${{ env.MATLAB_CODE_PATH }}/unit_tests'); | |
| addpath('${{ env.MATLAB_CODE_PATH }}/template_txt'); | |
| addpath('${{ env.SMALLER_ECAT_PATH }}'); | |
| addpath('${{ env.METADATA_PATH }}'); | |
| matlab_conversions | |
| - name: Check Parity | |
| 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 | |
| run: | | |
| bids-validator OpenNeuroPET-Phantoms/matlab |