diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a51fe36e..1e52d0f7 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -14,27 +14,22 @@ submodules: # Set the version of Python and other tools you might need build: - os: ubuntu-20.04 + os: ubuntu-22.04 tools: - python: "3.9" + python: "3.11" jobs: post_create_environment: + - cp -r metadata pypet2bids/pypet2bids/ # install poetry - # https://python-poetry.org/docs/#osx--linux--bashonwindows-install-instructions - - curl -sSL https://install.python-poetry.org | python3 - - # Tell poetry to not use a virtual environment - - $HOME/.local/bin/poetry config virtualenvs.create false + - pip install poetry + - poetry config virtualenvs.create false # just use poetry to export a requirements.txt as that worked much better than the previous attempts - - cd pypet2bids && $HOME/.local/bin/poetry export --with dev --without-hashes -o requirements.txt + - cd pypet2bids && poetry lock && poetry export --without-hashes --with dev --format=requirements.txt > requirements.txt # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py -# If using Sphinx, optionally build your docs in additional formats such as PDF -# formats: -# - pdf - # Optionally declare the Python requirements required to build your docs python: install: diff --git a/Makefile b/Makefile index ef1b26d9..7ad51dee 100644 --- a/Makefile +++ b/Makefile @@ -43,3 +43,6 @@ installpackage: testphantoms: @scripts/testphantoms + +html: + @cd docs && make html diff --git a/docs/index.rst b/docs/index.rst index e822c8b4..4e2415d8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,6 @@ Welcome to PET2BIDS's documentation! installation usage modules - matlab spreadsheets :maxdepth: 2 :caption: Contents: diff --git a/docs/installation.rst b/docs/installation.rst index 21e96932..6c2d54e4 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -40,10 +40,11 @@ If you wish to contribute, are unable to install from PyPi, or simply wish to ru reading the `Additional Install Notes`_ section below. Additional Install Notes -======================== +------------------------ -Matlab ------- +**Matlab** + +------------------------------------------------------------------------------------------------------------------------ **Dependencies** @@ -76,8 +77,7 @@ all arguments in although this is also possible). You can find templates of such ------------------------------------------------------------------------------------------------------------------------ -Python ------- +**Python** If you are unable to install this library from PyPi you can clone this repository to build and install the package as distributed on PyPi yourself with poetry. diff --git a/docs/matlab.rst b/docs/matlab.rst index fe5cb054..42d6786d 100644 --- a/docs/matlab.rst +++ b/docs/matlab.rst @@ -9,7 +9,7 @@ matlab .. mat:autofunction:: dcm2niix4pet -.. mat:autofunction:: updatjsonpetfile +.. mat:autofunction:: updatejsonpetfile .. mat:autofunction:: ecat2nii diff --git a/docs/modules.rst b/docs/modules.rst index 10bca7d0..b1b588c8 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -1,7 +1,8 @@ -pypet2bids -========== +Code +==== .. toctree:: :maxdepth: 4 pypet2bids + matlab \ No newline at end of file diff --git a/docs/pypet2bids.rst b/docs/pypet2bids.rst index 483e465a..5b1b5622 100644 --- a/docs/pypet2bids.rst +++ b/docs/pypet2bids.rst @@ -1,10 +1,7 @@ .. _pypet2bids-package: -pypet2bids package -================== - -Submodules ----------- +pypet2bids +========== pypet2bids.ecat\_cli module --------------------------- diff --git a/matlab/get_pet_metadata.m b/matlab/get_pet_metadata.m index 102fd1fd..b9abb0d9 100644 --- a/matlab/get_pet_metadata.m +++ b/matlab/get_pet_metadata.m @@ -1,5 +1,4 @@ function metadata = get_pet_metadata(varargin) - % Routine that outputs PET scanner metadata following % `BIDS `_. % @@ -16,8 +15,8 @@ % all info is necessarily needed\) % :param inputs: a series of key/value pairs are expected % :returns metadata: a structure with BIDS fields filled \(such structure is ready -% to be writen as json file using e.g. the bids matlab jsonwrite -% function, typically associated with the *_pet.nii file\) +% to be writen as json file using e.g. the bids matlab jsonwrite +% function, typically associated with the \*_pet.nii file\) % % :format: metadata = get_pet_metadata(key,value) % @@ -25,7 +24,7 @@ % % Mandatory inputs are as follows\: % -% - *Scanner* name of scanner, map to a *parameters.txt file e.g. 'Scanner', 'SiemensBiograph' +% - *Scanner* name of scanner, map to a \*parameters.txt file e.g. 'Scanner', 'SiemensBiograph' % - *TimeZero* when was the tracer injected e.g. 'TimeZero','11:05:01' % - *ModeOfAdministration* e.g. 'ModeOfAdministration', 'bolus' % - *TracerName* which tracer was used e.g. 'TracerName','DASB' @@ -55,7 +54,7 @@ % FrameTimesStart = 0; % % .. note:: -% TimeZero also can be [] or 'ScanStart' indicating that the scanning time +% TimeZero also can be [] or 'ScanStart' indicating that the scanning time % should be used as TimeZero. If TimeZero is not the scan time, we strongly % advice to input ScanStart and InjectionStart making sure timing is correct % diff --git a/pypet2bids/poetry.lock b/pypet2bids/poetry.lock index 4cbf664c..0dea1d18 100644 --- a/pypet2bids/poetry.lock +++ b/pypet2bids/poetry.lock @@ -24,13 +24,13 @@ files = [ [[package]] name = "babel" -version = "2.13.1" +version = "2.14.0" description = "Internationalization utilities" optional = false python-versions = ">=3.7" files = [ - {file = "Babel-2.13.1-py3-none-any.whl", hash = "sha256:7077a4984b02b6727ac10f1f7294484f737443d7e2e66c5e4380e41a3ae0b4ed"}, - {file = "Babel-2.13.1.tar.gz", hash = "sha256:33e0952d7dd6374af8dbf6768cc4ddf3ccfefc244f9986d4074704f2fbd18900"}, + {file = "Babel-2.14.0-py3-none-any.whl", hash = "sha256:efb1a25b7118e67ce3a259bed20545c29cb68be8ad2c784c83689981b7a57287"}, + {file = "Babel-2.14.0.tar.gz", hash = "sha256:6919867db036398ba21eb5c7a0f6b28ab8cbc3ae7a73a44ebe34ae74a4e7d363"}, ] [package.dependencies] @@ -219,16 +219,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "future" -version = "0.18.3" -description = "Clean single-source support for Python 3 and 2" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "future-0.18.3.tar.gz", hash = "sha256:34a17436ed1e96697a86f9de3d15a3b0be01d8bc8de9c1dffd59fb8234ed5307"}, -] - [[package]] name = "idna" version = "3.6" @@ -253,20 +243,20 @@ files = [ [[package]] name = "importlib-metadata" -version = "6.8.0" +version = "7.0.1" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-6.8.0-py3-none-any.whl", hash = "sha256:3ebb78df84a805d7698245025b975d9d67053cd94c79245ba4b3eb694abe68bb"}, - {file = "importlib_metadata-6.8.0.tar.gz", hash = "sha256:dbace7892d8c0c4ac1ad096662232f831d4e64f4c4545bd53016a3e9d4654743"}, + {file = "importlib_metadata-7.0.1-py3-none-any.whl", hash = "sha256:4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e"}, + {file = "importlib_metadata-7.0.1.tar.gz", hash = "sha256:f238736bb06590ae52ac1fab06a3a9ef1d8dce2b7a35b5ab329371d6c8f5d2cc"}, ] [package.dependencies] zipp = ">=0.5" [package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] perf = ["ipython"] testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] @@ -301,13 +291,13 @@ files = [ [[package]] name = "jinja2" -version = "3.1.2" +version = "3.1.3" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, - {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, + {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, + {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, ] [package.dependencies] @@ -423,32 +413,32 @@ files = [ [[package]] name = "nibabel" -version = "5.1.0" +version = "5.2.0" description = "Access a multitude of neuroimaging data formats" optional = false python-versions = ">=3.8" files = [ - {file = "nibabel-5.1.0-py3-none-any.whl", hash = "sha256:b3deb8130c835b9d26e80880b0d5e443d9e3f30972b3b0302dd2fafa3ca629f8"}, - {file = "nibabel-5.1.0.tar.gz", hash = "sha256:ce73ca5e957209e7219a223cb71f77235c9df2acf4d3f27f861ba38e9481ac53"}, + {file = "nibabel-5.2.0-py3-none-any.whl", hash = "sha256:77724af6e29fd9c4173702e4d031e7d8c45b5963887905a0f90edab880381b7f"}, + {file = "nibabel-5.2.0.tar.gz", hash = "sha256:3df8f1ab981d1bd92f4331d565528d126ab9717fdbd4cfe68f43fcd1c2bf3f52"}, ] [package.dependencies] importlib-resources = {version = ">=1.3", markers = "python_version < \"3.9\""} -numpy = ">=1.19" +numpy = ">=1.20" packaging = ">=17" [package.extras] -all = ["nibabel[dev,dicomfs,doc,minc2,spm,style,test,zstd]"] -dev = ["gitpython", "nibabel[style]", "twine"] +all = ["nibabel[dicomfs,minc2,spm,zstd]"] +dev = ["tox"] dicom = ["pydicom (>=1.0.0)"] dicomfs = ["nibabel[dicom]", "pillow"] -doc = ["matplotlib (>=1.5.3)", "numpydoc", "sphinx (>=5.3,<6.0)", "texext", "tomli"] -doctest = ["nibabel[doc,test]"] +doc = ["matplotlib (>=1.5.3)", "numpydoc", "sphinx", "texext", "tomli"] +doctest = ["tox"] minc2 = ["h5py"] spm = ["scipy"] -style = ["blue", "flake8", "isort"] -test = ["coverage", "pytest (!=5.3.4)", "pytest-cov", "pytest-doctestplus", "pytest-httpserver", "pytest-xdist"] -typing = ["importlib-resources", "mypy", "pydicom", "pytest", "pyzstd", "types-pillow", "types-setuptools"] +style = ["tox"] +test = ["pytest", "pytest-cov", "pytest-doctestplus", "pytest-httpserver", "pytest-xdist"] +typing = ["tox"] zstd = ["pyzstd (>=0.14.3)"] [[package]] @@ -603,13 +593,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydicom" -version = "2.4.3" +version = "2.4.4" description = "A pure Python package for reading and writing DICOM data" optional = false python-versions = ">=3.7" files = [ - {file = "pydicom-2.4.3-py3-none-any.whl", hash = "sha256:797e84f7b22e5f8bce403da505935b0787dca33550891f06495d14b3f6c70504"}, - {file = "pydicom-2.4.3.tar.gz", hash = "sha256:51906e0b9fb6e184a0f56298cb43ed716b7cf7edc00f6b71d5c769bc1f982402"}, + {file = "pydicom-2.4.4-py3-none-any.whl", hash = "sha256:f9f8e19b78525be57aa6384484298833e4d06ac1d6226c79459131ddb0bd7c42"}, + {file = "pydicom-2.4.4.tar.gz", hash = "sha256:90b4801d851ce65be3df520e16bbfa3d6c767cf2a3a3b1c18f6780e6b670b87a"}, ] [package.extras] @@ -665,15 +655,20 @@ hook-testing = ["execnet (>=1.5.0)", "psutil", "pytest (>=2.7.3)"] [[package]] name = "pyinstaller-hooks-contrib" -version = "2023.10" +version = "2023.12" description = "Community maintained hooks for PyInstaller" optional = false python-versions = ">=3.7" files = [ - {file = "pyinstaller-hooks-contrib-2023.10.tar.gz", hash = "sha256:4b4a998036abb713774cb26534ca06b7e6e09e4c628196017a10deb11a48747f"}, - {file = "pyinstaller_hooks_contrib-2023.10-py2.py3-none-any.whl", hash = "sha256:6dc1786a8f452941245d5bb85893e2a33632ebdcbc4c23eea41f2ee08281b0c0"}, + {file = "pyinstaller-hooks-contrib-2023.12.tar.gz", hash = "sha256:11a9d59d903723dd693e8c10b054f3ea1ecad390623c9fa527c731d715fc5b3f"}, + {file = "pyinstaller_hooks_contrib-2023.12-py2.py3-none-any.whl", hash = "sha256:6a601a0d783fa725327fc6ac712779475dc8979f639419c7fcd460dd8d0a6d2a"}, ] +[package.dependencies] +importlib-metadata = {version = ">=4.6", markers = "python_version < \"3.10\""} +packaging = ">=22.0" +setuptools = ">=42.0.0" + [[package]] name = "pyparsing" version = "3.1.1" @@ -690,13 +685,13 @@ diagrams = ["jinja2", "railroad-diagrams"] [[package]] name = "pytest" -version = "7.4.3" +version = "7.4.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.7" files = [ - {file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"}, - {file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"}, + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, ] [package.dependencies] @@ -832,13 +827,13 @@ test = ["asv", "gmpy2", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeo [[package]] name = "setuptools" -version = "69.0.2" +version = "69.0.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-69.0.2-py3-none-any.whl", hash = "sha256:1e8fdff6797d3865f37397be788a4e3cba233608e9b509382a2777d25ebde7f2"}, - {file = "setuptools-69.0.2.tar.gz", hash = "sha256:735896e78a4742605974de002ac60562d286fa8051a7e2299445e8e8fbb01aa6"}, + {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, + {file = "setuptools-69.0.3.tar.gz", hash = "sha256:be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78"}, ] [package.extras] @@ -997,17 +992,16 @@ test = ["flake8", "mypy", "pytest"] [[package]] name = "sphinxcontrib-matlabdomain" -version = "0.13.0" +version = "0.21.4" description = "Sphinx \"matlabdomain\" extension" optional = false python-versions = "*" files = [ - {file = "sphinxcontrib-matlabdomain-0.13.0.tar.gz", hash = "sha256:b5e2b3ae54e50876f34a20344bac2d1c0f8b7d882787da5cc6cf9ca6feaa4c14"}, - {file = "sphinxcontrib_matlabdomain-0.13.0-py3-none-any.whl", hash = "sha256:d7ed4496923849dfc43530693207f1cd159401dd1cef17d6cef10065b346621e"}, + {file = "sphinxcontrib-matlabdomain-0.21.4.tar.gz", hash = "sha256:f5b197b7b6d0de49d1978a71d3115e36e7b0fe331e216f37c8f9a505e73fa88f"}, + {file = "sphinxcontrib_matlabdomain-0.21.4-py3-none-any.whl", hash = "sha256:1174aa6bfa20ba2377256abbdc982e3bf7dcc010d2bf3d3fd7551cc480e09aea"}, ] [package.dependencies] -future = ">=0.16.0" Pygments = ">=2.0.1" Sphinx = ">=4.0.0" @@ -1041,16 +1035,6 @@ files = [ lint = ["docutils-stubs", "flake8", "mypy"] test = ["pytest"] -[[package]] -name = "termcolor" -version = "1.1.0" -description = "ANSII Color formatting for output in terminal." -optional = false -python-versions = "*" -files = [ - {file = "termcolor-1.1.0.tar.gz", hash = "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"}, -] - [[package]] name = "toml" version = "0.10.2" @@ -1122,5 +1106,5 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" -python-versions = ">=3.8,<=3.11" -content-hash = "b4fdb5b852b5d932b8899848b94dfbc118d12b11d53e1782e72aecf5f0c293fc" +python-versions = ">=3.8,<=3.11.6" +content-hash = "343f613d5205ee0c04bc8908f3d3d6736313f00c3d76752da6fa14eca8d1ebbd" diff --git a/pypet2bids/pypet2bids/dcm2niix4pet.py b/pypet2bids/pypet2bids/dcm2niix4pet.py index 0f6d0c3f..c41a10d8 100644 --- a/pypet2bids/pypet2bids/dcm2niix4pet.py +++ b/pypet2bids/pypet2bids/dcm2niix4pet.py @@ -28,7 +28,6 @@ from tempfile import TemporaryDirectory import shutil from dateutil import parser -from termcolor import colored import argparse import importlib import dotenv diff --git a/pypet2bids/pypet2bids/helper_functions.py b/pypet2bids/pypet2bids/helper_functions.py index 53bfd4a6..dea309a2 100644 --- a/pypet2bids/pypet2bids/helper_functions.py +++ b/pypet2bids/pypet2bids/helper_functions.py @@ -44,6 +44,8 @@ project_dir = parent_dir metadata_dir = os.path.join(project_dir, 'metadata') + +# check to see where the schema is at pet_metadata_json = os.path.join(metadata_dir, 'PET_metadata.json') permalink_pet_metadata_json = "https://github.com/openneuropet/PET2BIDS/blob/76d95cf65fa8a14f55a4405df3fdec705e2147cf/metadata/PET_metadata.json" pet_reconstruction_metadata_json = os.path.join(metadata_dir, 'PET_reconstruction_methods.json') @@ -309,7 +311,7 @@ def is_numeric(check_this_object: str) -> bool: class ParseKwargs(argparse.Action): """ - Class that is used to extract key pair arguments passed to an argparse.ArgumentParser objet via the command line. + Class that is used to extract key pair arguments passed to an argparse.ArgumentParser object via the command line. Accepts key value pairs in the form of 'key=value' and then passes these arguments onto the arg parser as kwargs. This class is used during the construction of the ArgumentParser class via the add_argument method. e.g.:\n `ArgumentParser.add_argument('--kwargs', '-k', nargs='*', action=helper_functions.ParseKwargs, default={})` diff --git a/pypet2bids/pypet2bids/sidecar.py b/pypet2bids/pypet2bids/sidecar.py index 9a9ed263..04f17667 100644 --- a/pypet2bids/pypet2bids/sidecar.py +++ b/pypet2bids/pypet2bids/sidecar.py @@ -2,10 +2,12 @@ This is a lazy way to avoid opening a json, simply import this file to collect your BIDS sidecar templates instead. This is not a function or a true module. This is just two python dictionaries with keys and empty value pairs. -:param sidecar_template_full: a dictionary containing every field specified in the BIDS standard for PET imaging data -:param sidecar_template_short: a dictionary containing only the required fields in the BIDS standard for PET - imaging data -:return: sidecar_template_full, sidecar_template_short +**Parameters** + +* sidecar_template_full: a dict containing every PET BIDS field +* sidecar_template_short: a dict containing only required PET BIDS fields + +**Returns** sidecar_template_full, sidecar_template_short *Anthony Galassi* *Copyright OpenNeuroPET team* diff --git a/pypet2bids/pyproject.toml b/pypet2bids/pyproject.toml index c5694979..66d30058 100644 --- a/pypet2bids/pyproject.toml +++ b/pypet2bids/pyproject.toml @@ -10,7 +10,7 @@ include = [ ] [tool.poetry.dependencies] -python = ">=3.8,<=3.11" +python = ">=3.8,<=3.11.6" nibabel = ">=3.2.1" numpy = "^1.21.3" pyparsing = "^3.0.4" @@ -21,7 +21,6 @@ six = "^1.16.0" pydicom = "^2.2.2" openpyxl = "^3.0.9" xlrd = "^2.0.1" -termcolor = "^1.1.0" json-maj = "^0.0.8" pandas = "^1.4.4" pyxlsb = "^1.0.9" @@ -33,7 +32,7 @@ toml = ">=0.10.2" pytest = ">=6.2.5, <8.0.0" sphinx = "<=4.5.0" sphinx-rtd-theme = "^1.0.0" -sphinxcontrib-matlabdomain = "^0.13.0" +sphinxcontrib-matlabdomain = "^0.21.4" [tool.poetry.scripts] ecatpet2bids = 'pypet2bids.ecat_cli:main'