From af4fa95340aa7196cd3e202a4bc45fd0bdde01af Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:14:01 +0100 Subject: [PATCH 01/37] Adds _version.py --- nii2dcm/_version.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 nii2dcm/_version.py diff --git a/nii2dcm/_version.py b/nii2dcm/_version.py new file mode 100644 index 0000000..1f5b08c --- /dev/null +++ b/nii2dcm/_version.py @@ -0,0 +1 @@ +__version__ = '0.1.2dev1' From d86e897fa560c99b4afa84a605cdec2dd9b9a564 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:14:26 +0100 Subject: [PATCH 02/37] Correctly name pyproject.toml --- pyprojects.toml => pyproject.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pyprojects.toml => pyproject.toml (100%) diff --git a/pyprojects.toml b/pyproject.toml similarity index 100% rename from pyprojects.toml rename to pyproject.toml From c76f1bf1de27430d6b1036e3f72b2d5cff39eac3 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:47:42 +0100 Subject: [PATCH 03/37] Replaces setup.py with setup.cfg --- setup.cfg | 23 +++++++++++++++++++++++ setup.py | 30 ------------------------------ 2 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..7f217d6 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,23 @@ +[metadata] +name = nii2dcm +version = attr: nii2dcm._version.__version__ +description= nii2dcm: NIfTI to DICOM creation with Python +url = https://github.com/tomaroberts/nii2dcm +author = Tom Roberts +author_email = t.roberts@kcl.ac.uk +long_description = file:README.md +long_description_content_type = text/markdown + +[options] +packages = find: +python_requires = <3.11 +install_requires = + numpy + matplotlib + nibabel + pydicom +include_package_data=True + +[options.entry_points] +console_scripts = + nii2dcm = nii2dcm.__main__:cli \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index cada10e..0000000 --- a/setup.py +++ /dev/null @@ -1,30 +0,0 @@ -from setuptools import setup, find_packages -from pathlib import Path - - -# import README.md for long_description -this_directory = Path(__file__).parent -long_description = (this_directory / "README.md").read_text() - -setup( - name="nii2dcm", - version="0.1.1", - description='nii2dcm: NIfTI to DICOM creation with Python', - author='Tom Roberts', - url='https://github.com/tomaroberts/nii2dcm', - long_description=long_description, - long_description_content_type="text/markdown", - packages=find_packages(include=['nii2dcm', 'nii2dcm.*']), - install_requires=[ - 'numpy', - 'matplotlib', - 'nibabel', - 'pydicom' - ], - setup_requires=['flake8'], - entry_points={ - "console_scripts": [ - "nii2dcm = nii2dcm.__main__:cli" - ] - }, -) \ No newline at end of file From 11c72e02026a1cc83180075d434b680f04c9a023 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:48:09 +0100 Subject: [PATCH 04/37] Strips back pyproject.toml so package contents in setup.cfg --- pyproject.toml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9446c82..1d284e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,3 @@ [build-system] requires = ["setuptools>=64.0.0", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "nii2dcm" -version = "0.1.0" -description = "NIfTI file to DICOM conversion" -readme = "README.md" -authors = [{ name = "Tom Roberts", email = "t.roberts@kcl.ac.uk" }] - -[project.scripts] -nii2dcm = "nii2dcm.__main__:cli" \ No newline at end of file +build-backend = "setuptools.build_meta" \ No newline at end of file From 57fa9d383f2b6bcfb528c1f662760bb12c063738 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:48:24 +0100 Subject: [PATCH 05/37] Updates main to use _version.py --- nii2dcm/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nii2dcm/__main__.py b/nii2dcm/__main__.py index 994afe2..de57792 100644 --- a/nii2dcm/__main__.py +++ b/nii2dcm/__main__.py @@ -6,6 +6,7 @@ import argparse from pathlib import Path from nii2dcm.run import run_nii2dcm +from nii2dcm._version import __version__ def cli(args=None): @@ -24,7 +25,7 @@ def cli(args=None): parser.add_argument("output_dir", type=str, help="[directory] output DICOM path") parser.add_argument("-d", "--dicom_type", type=str, help="[string] type of DICOM. e.g. MR, CT, US, XR, etc.") parser.add_argument("-r", "--ref_dicom", type=str, help="[.dcm] Reference DICOM file for Attribute transfer") - parser.add_argument("-v", "--version", action="version", version="0.1.0") + parser.add_argument("-v", "--version", action="version", version=__version__) args = parser.parse_args() From 8959253500c62e8bf997f7ed529e5cee1887e770 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:57:51 +0100 Subject: [PATCH 06/37] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d7c3b9c..1a1bd68 100644 --- a/.gitignore +++ b/.gitignore @@ -88,5 +88,8 @@ _im* *.nii *.nii.gz +# Omit _version.py as required by setuptools_scm +!nii2dcm/_version.py + # Permit Test Data !tests/data/DicomMRISVR/t2-svr-atlas-35wk.nii.gz \ No newline at end of file From bf1e37126df66c377982a70fe67f67a881d0e5d1 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 16:59:45 +0100 Subject: [PATCH 07/37] Delete _version.py as setuptools_scm generates dynamically --- nii2dcm/_version.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 nii2dcm/_version.py diff --git a/nii2dcm/_version.py b/nii2dcm/_version.py deleted file mode 100644 index 1f5b08c..0000000 --- a/nii2dcm/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '0.1.2dev1' From 8738bc844c1b2b2c3fda82ea35766a42dcd9a38a Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 17:00:40 +0100 Subject: [PATCH 08/37] Bugfix: updates .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1a1bd68..b0f0c11 100644 --- a/.gitignore +++ b/.gitignore @@ -89,7 +89,7 @@ _im* *.nii.gz # Omit _version.py as required by setuptools_scm -!nii2dcm/_version.py +nii2dcm/_version.py # Permit Test Data !tests/data/DicomMRISVR/t2-svr-atlas-35wk.nii.gz \ No newline at end of file From 28c17576a13c4c9b5bf228cddc898afce318669b Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 17:01:25 +0100 Subject: [PATCH 09/37] Updates pyproject.toml to use setuptools_scm dynamic versioning --- pyproject.toml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1d284e0..f885137 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,10 @@ [build-system] -requires = ["setuptools>=64.0.0", "wheel"] -build-backend = "setuptools.build_meta" \ No newline at end of file +requires = ["setuptools>=64.0.0", "wheel", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "nii2dcm" +dynamic = ["version"] + +[tool.setuptools_scm] +write_to = "nii2dcm/_version.py" \ No newline at end of file From 451dd1873cc0346153a08026c44cf22c1e33c7f6 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 17:34:54 +0100 Subject: [PATCH 10/37] Use setuptools_scm "no-local-version" local_scheme for PyPI compatibility --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f885137..e06e019 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,5 @@ name = "nii2dcm" dynamic = ["version"] [tool.setuptools_scm] +local_scheme = "no-local-version" # required for PyPI and TestPyPI write_to = "nii2dcm/_version.py" \ No newline at end of file From ff83508b66c6de76830ab7aa2142d416c29cfdfc Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 17:35:21 +0100 Subject: [PATCH 11/37] Creates TestPyPI GitHub Action --- .github/workflows/publish_testpypi.yml | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/publish_testpypi.yml diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml new file mode 100644 index 0000000..697427d --- /dev/null +++ b/.github/workflows/publish_testpypi.yml @@ -0,0 +1,54 @@ +# Publish to TestPyPI +# +# This workflow publishes nii2dcm on TestPyPI prior to production release onto PyPI. The workflow is intended to catch +# any issues arising during the release procedure to prevent unnecessary versioning issues on PyPI +# +# This workflow will upload a Python Package using Twine when a release is created. For more information see: +# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Publish package to TestPyPI + +on: + pull_request + +permissions: + contents: read + +jobs: + testpypi-publish: + + name: Publish release to TestPyPI + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/nii2dcm + permissions: + id-token: write # IMPORTANT: this permission is mandatory for PyPI trusted publishing + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Build package + run: python -m build + + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TESTPYPI_API_TOKEN }} + verbose: true \ No newline at end of file From 945409af3eb63163db1eac6ef80ef8d39ffd85bf Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 18:10:06 +0100 Subject: [PATCH 12/37] Bugfix: adds TestPyPI repository-url to GHA --- .github/workflows/publish_testpypi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 697427d..0a687f8 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -51,4 +51,5 @@ jobs: with: user: __token__ password: ${{ secrets.TESTPYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ verbose: true \ No newline at end of file From af4242f110c57158e85e29efdda3b8f7d67e52b7 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 18:12:33 +0100 Subject: [PATCH 13/37] Trivial change to test GHA version incrementing --- .github/workflows/publish_testpypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 0a687f8..3ba8ad5 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -52,4 +52,4 @@ jobs: user: __token__ password: ${{ secrets.TESTPYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ - verbose: true \ No newline at end of file + verbose: true From f7b21a44f2db645f0b139bceb6f94c706f0c3377 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Tue, 22 Aug 2023 18:17:44 +0100 Subject: [PATCH 14/37] GHA Test: enable _version.py to be committed to see versioning on TestPyPI --- .gitignore | 3 --- nii2dcm/_version.py | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 nii2dcm/_version.py diff --git a/.gitignore b/.gitignore index b0f0c11..d7c3b9c 100644 --- a/.gitignore +++ b/.gitignore @@ -88,8 +88,5 @@ _im* *.nii *.nii.gz -# Omit _version.py as required by setuptools_scm -nii2dcm/_version.py - # Permit Test Data !tests/data/DicomMRISVR/t2-svr-atlas-35wk.nii.gz \ No newline at end of file diff --git a/nii2dcm/_version.py b/nii2dcm/_version.py new file mode 100644 index 0000000..91d9133 --- /dev/null +++ b/nii2dcm/_version.py @@ -0,0 +1,4 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '0.1.2.dev22' +__version_tuple__ = version_tuple = (0, 1, 2, 'dev22') From 503f3f1ee1c52882906df2f22a2a34c49e0cad82 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Wed, 23 Aug 2023 08:44:26 +0100 Subject: [PATCH 15/37] Add CLI version command test to GHA --- .github/workflows/build_and_test_cli.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_and_test_cli.yml b/.github/workflows/build_and_test_cli.yml index 7a9a5f9..d707658 100644 --- a/.github/workflows/build_and_test_cli.yml +++ b/.github/workflows/build_and_test_cli.yml @@ -56,6 +56,7 @@ jobs: - name: Test nii2dcm install run: | nii2dcm -h + nii2dcm -v - name: Test DicomMRISVR creation run: | From 3915849d203e84a364916b94d1635131a9172f92 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:03:23 +0100 Subject: [PATCH 16/37] GHA test: python build --sdist --wheel --- .github/workflows/publish_testpypi.yml | 2 +- nii2dcm/_version.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 3ba8ad5..f6e5813 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -41,7 +41,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build + pip install build --sdist --wheel --outdir dist/ - name: Build package run: python -m build diff --git a/nii2dcm/_version.py b/nii2dcm/_version.py index 91d9133..7419e0a 100644 --- a/nii2dcm/_version.py +++ b/nii2dcm/_version.py @@ -1,4 +1,4 @@ # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '0.1.2.dev22' -__version_tuple__ = version_tuple = (0, 1, 2, 'dev22') +__version__ = version = '0.1.2.dev27' +__version_tuple__ = version_tuple = (0, 1, 2, 'dev27') From 9ba81a288af9b4151def0f09a1b0719252e488e1 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:06:54 +0100 Subject: [PATCH 17/37] =?UTF-8?q?Fix=20error=20=E2=80=93=20re-run=20previo?= =?UTF-8?q?us=20GHA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish_testpypi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index f6e5813..67b2304 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -41,10 +41,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build --sdist --wheel --outdir dist/ + pip install build - name: Build package - run: python -m build + run: python -m build --sdist --wheel --outdir dist/ - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 From 5b3ee760c4fb99f9e8dfc17d7b1eba0703aa9eae Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:11:01 +0100 Subject: [PATCH 18/37] GHA test: adds skip-existing option when publishing on TestPyPI --- .github/workflows/publish_testpypi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 67b2304..bb9d7d6 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -53,3 +53,4 @@ jobs: password: ${{ secrets.TESTPYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ verbose: true + skip-existing: true From 79493b46210f2dbd0b74a0c0d61eccffe261fc63 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:25:14 +0100 Subject: [PATCH 19/37] GHA test: manual update of __version__ --- nii2dcm/_version.py | 3 +-- pyproject.toml | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nii2dcm/_version.py b/nii2dcm/_version.py index 7419e0a..dd19a1b 100644 --- a/nii2dcm/_version.py +++ b/nii2dcm/_version.py @@ -1,4 +1,3 @@ # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '0.1.2.dev27' -__version_tuple__ = version_tuple = (0, 1, 2, 'dev27') +__version__ = version = '0.1.dev2' diff --git a/pyproject.toml b/pyproject.toml index e06e019..e7cf0a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,10 +2,10 @@ requires = ["setuptools>=64.0.0", "wheel", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" -[project] -name = "nii2dcm" -dynamic = ["version"] - -[tool.setuptools_scm] -local_scheme = "no-local-version" # required for PyPI and TestPyPI -write_to = "nii2dcm/_version.py" \ No newline at end of file +# [project] +# name = "nii2dcm" +# dynamic = ["version"] +# +# [tool.setuptools_scm] +# local_scheme = "no-local-version" # required for PyPI and TestPyPI +# write_to = "nii2dcm/_version.py" \ No newline at end of file From 2b37c36e75f59e1dce8514e1eb3e5759ab81ceec Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:44:20 +0100 Subject: [PATCH 20/37] Revert "GHA test: adds skip-existing option when publishing on TestPyPI" This reverts commit 5b3ee760c4fb99f9e8dfc17d7b1eba0703aa9eae. --- .github/workflows/publish_testpypi.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index bb9d7d6..67b2304 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -53,4 +53,3 @@ jobs: password: ${{ secrets.TESTPYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ verbose: true - skip-existing: true From 8269cae47c522bc48b63aced78de61868318a216 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:44:54 +0100 Subject: [PATCH 21/37] Test GHA: reinstate setuptools-scm --- pyproject.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e7cf0a3..e06e019 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,10 +2,10 @@ requires = ["setuptools>=64.0.0", "wheel", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" -# [project] -# name = "nii2dcm" -# dynamic = ["version"] -# -# [tool.setuptools_scm] -# local_scheme = "no-local-version" # required for PyPI and TestPyPI -# write_to = "nii2dcm/_version.py" \ No newline at end of file +[project] +name = "nii2dcm" +dynamic = ["version"] + +[tool.setuptools_scm] +local_scheme = "no-local-version" # required for PyPI and TestPyPI +write_to = "nii2dcm/_version.py" \ No newline at end of file From 029d4be7a688609bf53473702f35d5dfaea51489 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:45:37 +0100 Subject: [PATCH 22/37] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d7c3b9c..b0f0c11 100644 --- a/.gitignore +++ b/.gitignore @@ -88,5 +88,8 @@ _im* *.nii *.nii.gz +# Omit _version.py as required by setuptools_scm +nii2dcm/_version.py + # Permit Test Data !tests/data/DicomMRISVR/t2-svr-atlas-35wk.nii.gz \ No newline at end of file From 7bf1977ec2bcc240249f79f5f1f81026ddcd6a53 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 13:58:22 +0100 Subject: [PATCH 23/37] Test GHA: use fetch-depth 0 --- .github/workflows/publish_testpypi.yml | 2 ++ nii2dcm/_version.py | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 nii2dcm/_version.py diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 67b2304..380bf59 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -32,6 +32,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 diff --git a/nii2dcm/_version.py b/nii2dcm/_version.py deleted file mode 100644 index dd19a1b..0000000 --- a/nii2dcm/_version.py +++ /dev/null @@ -1,3 +0,0 @@ -# file generated by setuptools_scm -# don't change, don't track in version control -__version__ = version = '0.1.dev2' From aa7072bbb72c314cb032c85cc2fd5e275721ba17 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 14:13:34 +0100 Subject: [PATCH 24/37] GHA Test: display version in GHA for debugging --- .github/workflows/publish_testpypi.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 380bf59..eb67bb6 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -48,6 +48,11 @@ jobs: - name: Build package run: python -m build --sdist --wheel --outdir dist/ + - name: Display nii2dcm version + run: | + echo "nii2dcm version:" + nii2dcm -v + - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: From e4222b1f202e8c9c63cd8f3ac7b4a8a6cff6a996 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 14:16:49 +0100 Subject: [PATCH 25/37] Update publish_testpypi.yml --- .github/workflows/publish_testpypi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index eb67bb6..be6e3ed 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -50,6 +50,7 @@ jobs: - name: Display nii2dcm version run: | + pip install -e . echo "nii2dcm version:" nii2dcm -v From 3c87e59e01ceda75ba4f8fdfa779f46ba8bf96ad Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 14:26:08 +0100 Subject: [PATCH 26/37] Update setup.cfg install_requires pip install breaking otherwise - can't find matplotlib version --- setup.cfg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7f217d6..ecb4ce5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,10 +12,10 @@ long_description_content_type = text/markdown packages = find: python_requires = <3.11 install_requires = - numpy - matplotlib - nibabel - pydicom + numpy ~= 1.23.2 + matplotlib ~= 3.6.2 + nibabel ~= 5.0.0 + pydicom ~= 2.3.0 include_package_data=True [options.entry_points] From caf5051849d8c10a1de3dd76d0ba04462cc5466b Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 14:34:38 +0100 Subject: [PATCH 27/37] Fix dependency versions in setup.cfg --- setup.cfg | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index ecb4ce5..1a38b92 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,10 +12,11 @@ long_description_content_type = text/markdown packages = find: python_requires = <3.11 install_requires = - numpy ~= 1.23.2 - matplotlib ~= 3.6.2 - nibabel ~= 5.0.0 - pydicom ~= 2.3.0 + numpy==1.23.2 + matplotlib==3.6.2 + nibabel==5.0.0 + pydicom==2.3.0 + twine==4.0.2 include_package_data=True [options.entry_points] From 51e3cf4ce3b667afa91130140281a5f6dce562c6 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 15:02:26 +0100 Subject: [PATCH 28/37] GHA Test: verify TestPyPI build in fresh venv --- .github/workflows/publish_testpypi.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index be6e3ed..20ae570 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -49,10 +49,12 @@ jobs: run: python -m build --sdist --wheel --outdir dist/ - name: Display nii2dcm version + id: nii2dcm-version run: | pip install -e . echo "nii2dcm version:" nii2dcm -v + echo "{NII2DCM_VERSION}={nii2dcm -v}" >> "$GITHUB_OUTPUT" - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 @@ -61,3 +63,19 @@ jobs: password: ${{ secrets.TESTPYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ verbose: true + + - name: Wait to allow TestPyPI to update + uses: GuillaumeFalourd/wait-sleep-action@v1 + with: + time: '1m' + + - name: Install latest TestPyPI version in fresh venv + env: + NII2DCM_VERSION: ${{ steps.nii2dcm-version.outputs.NII2DCM_VERSION }} + run: | + deactivate + python -m venv n2d + source n2d/bin/activate + pip install --upgrade pip + pip install setuptools wheel + pip install --extra-url-index https://test.pypi.org/simple/ nii2dcm==$NII2DCM_VERSION From 1a411cd7204dfcdfd0f36c0c10d69226d4e32c77 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:08:01 +0100 Subject: [PATCH 29/37] Get and pass version nii2dcm version with bash echo --- .github/workflows/publish_testpypi.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 20ae570..25534a9 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -54,7 +54,6 @@ jobs: pip install -e . echo "nii2dcm version:" nii2dcm -v - echo "{NII2DCM_VERSION}={nii2dcm -v}" >> "$GITHUB_OUTPUT" - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 @@ -70,9 +69,8 @@ jobs: time: '1m' - name: Install latest TestPyPI version in fresh venv - env: - NII2DCM_VERSION: ${{ steps.nii2dcm-version.outputs.NII2DCM_VERSION }} run: | + NII2DCM_VERSION=`echo "$(nii2dcm -v)"` deactivate python -m venv n2d source n2d/bin/activate From 480dc4960fbd617da431bb85eb569aa0d67c6a19 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:10:17 +0100 Subject: [PATCH 30/37] Fixes yaml syntax error --- .github/workflows/publish_testpypi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 25534a9..cb1531a 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -65,8 +65,8 @@ jobs: - name: Wait to allow TestPyPI to update uses: GuillaumeFalourd/wait-sleep-action@v1 - with: - time: '1m' + with: + time: '1m' - name: Install latest TestPyPI version in fresh venv run: | From 668f0f42a4d140a107fd217347ccef577642f21b Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:15:25 +0100 Subject: [PATCH 31/37] Test GHA: remove erroneous deactivate line --- .github/workflows/publish_testpypi.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index cb1531a..caa2aae 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -71,9 +71,8 @@ jobs: - name: Install latest TestPyPI version in fresh venv run: | NII2DCM_VERSION=`echo "$(nii2dcm -v)"` - deactivate - python -m venv n2d - source n2d/bin/activate + python -m venv nii2dcm-temp + source nii2dcm-temp/bin/activate pip install --upgrade pip pip install setuptools wheel pip install --extra-url-index https://test.pypi.org/simple/ nii2dcm==$NII2DCM_VERSION From e39ef9029c9375e4079edbe56ec7baa9d351c8d7 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:21:21 +0100 Subject: [PATCH 32/37] Update publish_testpypi.yml --- .github/workflows/publish_testpypi.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index caa2aae..5d0c398 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -71,8 +71,9 @@ jobs: - name: Install latest TestPyPI version in fresh venv run: | NII2DCM_VERSION=`echo "$(nii2dcm -v)"` + echo $NII2DCM_VERSION python -m venv nii2dcm-temp source nii2dcm-temp/bin/activate pip install --upgrade pip pip install setuptools wheel - pip install --extra-url-index https://test.pypi.org/simple/ nii2dcm==$NII2DCM_VERSION + pip install --index-url https://test.pypi.org/simple/ nii2dcm==$NII2DCM_VERSION From 03371218877a64c692878e0e115bbdc3489800ed Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:25:22 +0100 Subject: [PATCH 33/37] Pull nii2dcm from TestPyPI / allow dependencies from PyPI --- .github/workflows/publish_testpypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 5d0c398..75c0496 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -76,4 +76,4 @@ jobs: source nii2dcm-temp/bin/activate pip install --upgrade pip pip install setuptools wheel - pip install --index-url https://test.pypi.org/simple/ nii2dcm==$NII2DCM_VERSION + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nii2dcm==$NII2DCM_VERSION From d0ab098f23f33776fe6674a7ec028788eae2c9e2 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:29:05 +0100 Subject: [PATCH 34/37] Add nii2dcm -h test to verify working --- .github/workflows/publish_testpypi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 75c0496..f59f938 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -77,3 +77,4 @@ jobs: pip install --upgrade pip pip install setuptools wheel pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nii2dcm==$NII2DCM_VERSION + nii2dcm -h From 95b8f1551f83c38c1b72adcaa5d9b8a213775b45 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:36:50 +0100 Subject: [PATCH 35/37] Fixes some linting warnings --- .github/workflows/publish_testpypi.yml | 2 ++ nii2dcm/modules/image_pixel.py | 6 +++--- nii2dcm/nii.py | 2 +- scripts/create_3d_dicom.py | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index f59f938..84190e0 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -78,3 +78,5 @@ jobs: pip install setuptools wheel pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nii2dcm==$NII2DCM_VERSION nii2dcm -h + echo "nii2dcm version:" + nii2dcm -v diff --git a/nii2dcm/modules/image_pixel.py b/nii2dcm/modules/image_pixel.py index 4e94052..bf91e29 100644 --- a/nii2dcm/modules/image_pixel.py +++ b/nii2dcm/modules/image_pixel.py @@ -29,14 +29,14 @@ def __init__(self): self.ds.BitsAllocated = 1 self.ds.BitsStored = '' self.ds.HighBit = '' - + # PixelRepresentation # Enumerated values either: unsigned integer or two's complement # Setting = 0, as observed in real DICOM self.ds.PixelRepresentation = 0 - + self.ds.SmallestImagePixelValue = '' self.ds.LargestImagePixelValue = '' - + # PixelData written in dcm_writer via Pydicom self.ds.PixelData = '' diff --git a/nii2dcm/nii.py b/nii2dcm/nii.py index a7ab1e8..7aa11ca 100644 --- a/nii2dcm/nii.py +++ b/nii2dcm/nii.py @@ -39,7 +39,7 @@ def fnT1N(A, N): sliceIndices = np.repeat(range(1, nZ+1), nF) voxelSpacing = dimZ zLocLast = (voxelSpacing * nZ) - voxelSpacing - sliceLoca = np.repeat( np.linspace(0, zLocLast, num=nZ), nF) + sliceLoca = np.repeat(np.linspace(0, zLocLast, num=nZ), nF) # Windowing & Signal Intensity maxI = np.amax(nii_img) diff --git a/scripts/create_3d_dicom.py b/scripts/create_3d_dicom.py index c742db9..1814162 100644 --- a/scripts/create_3d_dicom.py +++ b/scripts/create_3d_dicom.py @@ -14,8 +14,8 @@ NII2DCM_DIR = r'/Users/tr17/code/nii2dcm' -INPUT_DIR = r'/Users/tr17/code/nii2dcm/input/' -OUTPUT_DIR = r'/Users/tr17/code/nii2dcm/output' +INPUT_DIR = r'/Users/tr17/code/nii2dcm/input/' +OUTPUT_DIR = r'/Users/tr17/code/nii2dcm/output' if not os.path.isdir(OUTPUT_DIR): os.makedirs(OUTPUT_DIR) From eba4901e93b021e68dca391e30a90ad889c8620b Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:43:03 +0100 Subject: [PATCH 36/37] Increase wait time for TestPyPI to update --- .github/workflows/publish_testpypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 84190e0..6387e14 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -66,7 +66,7 @@ jobs: - name: Wait to allow TestPyPI to update uses: GuillaumeFalourd/wait-sleep-action@v1 with: - time: '1m' + time: '90' # seconds - name: Install latest TestPyPI version in fresh venv run: | From 2d728806e49ab2d4bf4a59063895256e837adaf0 Mon Sep 17 00:00:00 2001 From: Tom Roberts Date: Thu, 24 Aug 2023 16:51:07 +0100 Subject: [PATCH 37/37] Increase TestPyPI wait time to 2.5 mins --- .github/workflows/publish_testpypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_testpypi.yml b/.github/workflows/publish_testpypi.yml index 6387e14..79b4420 100644 --- a/.github/workflows/publish_testpypi.yml +++ b/.github/workflows/publish_testpypi.yml @@ -66,7 +66,7 @@ jobs: - name: Wait to allow TestPyPI to update uses: GuillaumeFalourd/wait-sleep-action@v1 with: - time: '90' # seconds + time: '150' # seconds - name: Install latest TestPyPI version in fresh venv run: |