Repository: AMYPAD/AmyPET (language: python)

Issue:
rename to amypet
- AMYPAD = org
- amypet = package


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 3eacabe1..19d59b27 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,12 @@
-*.py[co]
+*.py[cod]
 __pycache__/
 
 # build
-/amypad/_dist_ver.py
+/amypet/_dist_ver.py
 /build/
 /dist/
 /*.egg*/
 
 /.coverage*
 /coverage.xml
+/.pytest_cache/
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 62ffebe4..b5f649e4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -31,9 +31,11 @@ repos:
   - id: flake8
     args: [-j8]
     additional_dependencies:
+    - flake8-broken-line
     - flake8-bugbear
     - flake8-comprehensions
     - flake8-debugger
+    - flake8-isort
     - flake8-string-format
 - repo: https://github.com/google/yapf
   rev: v0.31.0
@@ -41,10 +43,10 @@ repos:
   - id: yapf
     args: [-i]
 - repo: https://github.com/PyCQA/isort
-  rev: 5.9.3
+  rev: 5.10.1
   hooks:
   - id: isort
 - hooks:
   - id: mbeautify
   repo: https://github.com/AMYPAD/miutil
-  rev: v0.9.0
+  rev: v0.9.1
diff --git a/README.rst b/README.rst
index 29fdb60a..5cbfab0e 100644
--- a/README.rst
+++ b/README.rst
@@ -1,6 +1,6 @@
 |Logo|
 
-AMYPAD
+AMYPET
 ======
 
 Amyloid imaging to prevent Alzheimer's Disease.
@@ -13,8 +13,8 @@ Choose one of the following:
 
 .. code:: sh
 
-    pip install amypad  # command line interface (CLI) version
-    pip install amypad[gui]  # CLI and graphical user interface (GUI) version
+    pip install amypet  # command line interface (CLI) version
+    pip install amypet[gui]  # CLI and graphical user interface (GUI) version
 
 
 Usage
@@ -22,8 +22,8 @@ Usage
 
 .. code:: sh
 
-    amypad --help  # CLI version
-    amypad.gui     # GUI version
+    amypet --help  # CLI version
+    amypet.gui     # GUI version
 
 
 .. |Logo| image:: https://amypad.eu/wp-content/themes/AMYPAD/images/AMYPAD_Logo.jpg
diff --git a/amypad/__init__.py b/amypet/__init__.py
similarity index 90%
rename from amypad/__init__.py
rename to amypet/__init__.py
index 7b1b7acb..f7b99085 100644
--- a/amypad/__init__.py
+++ b/amypet/__init__.py
@@ -14,7 +14,7 @@
         __version__ = "UNKNOWN"
 
 try:
-    __licence__ = get_distribution("amypad").get_metadata("LICENCE.md")
+    __licence__ = get_distribution("amypet").get_metadata("LICENCE.md")
 except (DistributionNotFound, FileNotFoundError):
     try:
         __licence__ = (Path(__file__).parent.parent / "LICENCE.md").read_text()
diff --git a/amypad/__main__.py b/amypet/__main__.py
similarity index 100%
rename from amypad/__main__.py
rename to amypet/__main__.py
diff --git a/amypad/centiloid/__init__.py b/amypet/centiloid/__init__.py
similarity index 100%
rename from amypad/centiloid/__init__.py
rename to amypet/centiloid/__init__.py
diff --git a/amypad/centiloid/f_1CorregisterEstimate.m b/amypet/centiloid/f_1CorregisterEstimate.m
similarity index 100%
rename from amypad/centiloid/f_1CorregisterEstimate.m
rename to amypet/centiloid/f_1CorregisterEstimate.m
diff --git a/amypad/centiloid/f_2CorregisterEstimate.m b/amypet/centiloid/f_2CorregisterEstimate.m
similarity index 100%
rename from amypad/centiloid/f_2CorregisterEstimate.m
rename to amypet/centiloid/f_2CorregisterEstimate.m
diff --git a/amypad/centiloid/f_3Segment.m b/amypet/centiloid/f_3Segment.m
similarity index 100%
rename from amypad/centiloid/f_3Segment.m
rename to amypet/centiloid/f_3Segment.m
diff --git a/amypad/centiloid/f_4Normalise.m b/amypet/centiloid/f_4Normalise.m
similarity index 100%
rename from amypad/centiloid/f_4Normalise.m
rename to amypet/centiloid/f_4Normalise.m
diff --git a/amypad/centiloid/f_Quant_centiloid.m b/amypet/centiloid/f_Quant_centiloid.m
similarity index 100%
rename from amypad/centiloid/f_Quant_centiloid.m
rename to amypet/centiloid/f_Quant_centiloid.m
diff --git a/amypad/centiloid/f_acpcReorientation.m b/amypet/centiloid/f_acpcReorientation.m
similarity index 100%
rename from amypad/centiloid/f_acpcReorientation.m
rename to amypet/centiloid/f_acpcReorientation.m
diff --git a/amypad/centiloid/f_noNaN.m b/amypet/centiloid/f_noNaN.m
similarity index 100%
rename from amypad/centiloid/f_noNaN.m
rename to amypet/centiloid/f_noNaN.m
diff --git a/amypad/cli.py b/amypet/cli.py
similarity index 100%
rename from amypad/cli.py
rename to amypet/cli.py
diff --git a/amypad/config_icon.png b/amypet/config_icon.png
similarity index 100%
rename from amypad/config_icon.png
rename to amypet/config_icon.png
diff --git a/amypad/gui.py b/amypet/gui.py
similarity index 94%
rename from amypad/gui.py
rename to amypet/gui.py
index d2c89c64..bec07df3 100755
--- a/amypad/gui.py
+++ b/amypet/gui.py
@@ -232,15 +232,15 @@ def print_not_none(value, **kwargs):
 # progress_expr="float(percent or 0)",
 # hide_progress_msg=True,
 # richtext_controls=True,
-@Gooey(default_size=(768, 768), program_name="amypad", sidebar_title="pipeline",
+@Gooey(default_size=(768, 768), program_name="amypet", sidebar_title="pipeline",
        image_dir=resource_filename(__name__, ""), show_restart_button=False,
        header_bg_color="#ffffff", sidebar_bg_color="#a3b5cd", body_bg_color="#a3b5cd",
        footer_bg_color="#2a569f", terminal_font_family="monospace", menu=[{
            "name": "Help", "items": [{
                "type": "Link", "menuTitle": "🌐 View source (online)",
-               "url": "https://github.com/AMYPAD/amypad"}, {
-                   "type": "AboutDialog", "menuTitle": "🔍 About", "name": "AMYPAD Pipeline",
-                   "description": "GUI to run AMYPAD tools", "version": __version__,
+               "url": "https://github.com/AMYPAD/amypet"}, {
+                   "type": "AboutDialog", "menuTitle": "🔍 About", "name": "AMYPET Pipeline",
+                   "description": "GUI to run AMYPET tools", "version": __version__,
                    "copyright": "2021", "website": "https://amypad.eu",
                    "developer": "https://github.com/AMYPAD", "license": __licence__}]}])
 def main(args=None, gui_mode=True):
@@ -249,9 +249,9 @@ def main(args=None, gui_mode=True):
     import niftypad.api
     import niftypad.models
 
-    from amypad import centiloid, imscroll, imtrimup
+    from amypet import centiloid, imscroll, imtrimup
 
-    parser = fix_subparser(MyParser(prog=None if gui_mode else "amypad"), gui_mode=gui_mode)
+    parser = fix_subparser(MyParser(prog=None if gui_mode else "amypet"), gui_mode=gui_mode)
     sub_kwargs = {}
     if sys.version_info[:2] >= (3, 7):
         sub_kwargs["required"] = True
@@ -290,11 +290,11 @@ def argparser(prog, description=None, epilog=None, formatter_class=None):
           <src>  : Input file/folder [default: FileChooser]
 
         Options:
-          -d PATH, --dst PATH      : Output file/folder (default: input folder)
-                                     [default: FileChooser]
-          -m MODEL, --model MODEL  : model [default: srtmb_basis]
-          -p FILE, --params FILE   : config file hint (relative to `--input`)
-                                     [default: FileChooser]
+          --dst PATH           : Output file/folder (default: input folder)
+            [default: FileChooser]
+          --model MODEL        : model [default: srtmb_basis]
+          --params FILE        : config file hint (relative to `src` input).
+            Default: search for {config,params}.{yaml,json}.
           --w W                : (default: None)
           --r1 R1              : [default: 0.905:float]
           --k2p K2P            : [default: 0.000250:float]
@@ -333,7 +333,7 @@ def argparser(prog, description=None, epilog=None, formatter_class=None):
     args = [i for i in args if i not in ("--dry-run",)] # strip args
 
     if gui_mode:
-        print(" ".join([Path(sys.executable).name, "-m amypad"] + args))
+        print(" ".join([Path(sys.executable).name, "-m amypet"] + args))
     if opts.dry_run:
         pass
     elif hasattr(opts, "main__"):                                                    # Cmd
diff --git a/amypad/imscroll.py b/amypet/imscroll.py
similarity index 100%
rename from amypad/imscroll.py
rename to amypet/imscroll.py
diff --git a/amypad/imtrimup.py b/amypet/imtrimup.py
similarity index 100%
rename from amypad/imtrimup.py
rename to amypet/imtrimup.py
diff --git a/amypad/program_icon.png b/amypet/program_icon.png
similarity index 100%
rename from amypad/program_icon.png
rename to amypet/program_icon.png
diff --git a/amypad/utils.py b/amypet/utils.py
similarity index 100%
rename from amypad/utils.py
rename to amypet/utils.py
diff --git a/pyproject.toml b/pyproject.toml
index a77e1bab..f49fc768 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,5 +2,5 @@
 requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
 
 [tool.setuptools_scm]
-write_to = "amypad/_dist_ver.py"
+write_to = "amypet/_dist_ver.py"
 write_to_template = "__version__ = '{version}'\n"
diff --git a/setup.cfg b/setup.cfg
index 27218c72..2a100733 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [metadata]
-name=amypad
+name=amypet
 description=Amyloid imaging to prevent Alzheimer's Disease
 long_description=file: README.rst
 long_description_content_type=text/x-rst
@@ -7,14 +7,14 @@ license=MPL 2.0
 license_file=LICENCE.md
 url=https://amypad.eu
 project_urls=
-    Repository=https://github.com/AMYPAD/amypad
-    Changelog=https://github.com/AMYPAD/amypad/releases
-    Documentation=https://github.com/AMYPAD/amypad/#amypad
+    Repository=https://github.com/AMYPAD/amypet
+    Changelog=https://github.com/AMYPAD/amypet/releases
+    Documentation=https://github.com/AMYPAD/amypet/#amypet
 maintainer=Casper da Costa-Luis
 maintainer_email=casper.dcl@physics.org
 keywords=pet, alzheimers
 platforms=any
-provides=amypad
+provides=amypet
 classifiers=
     Development Status :: 3 - Alpha
     Intended Audience :: Developers
@@ -61,8 +61,8 @@ gui=Gooey>=1.0.8
 niftypet=niftypet>=0.0.1
 [options.entry_points]
 console_scripts=
-    amypad=amypad.cli:main
-    amypad.gui=amypad.gui:main
+    amypet=amypet.cli:main
+    amypet.gui=amypet.gui:main
 [options.packages.find]
 exclude=tests
 [options.package_data]
@@ -87,12 +87,12 @@ split_before_closing_bracket=False
 [isort]
 profile=black
 line_length=99
-known_first_party=amypad,tests
+known_first_party=amypet,tests
 
 [tool:pytest]
 timeout=10
 log_level=INFO
 python_files=tests/test_*.py
-addopts=-v --tb=short -rxs -W=error -n=auto --durations=0 --durations-min=1 --cov=amypad --cov-report=term-missing --cov-report=xml
+addopts=-v --tb=short -rxs -W=error -n=auto --durations=0 --durations-min=1 --cov=amypet --cov-report=term-missing --cov-report=xml
 filterwarnings=
     ignore:numpy.ufunc size changed.*:RuntimeWarning


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 11190c98..d82d0268 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -94,7 +94,7 @@ jobs:
       env:
         GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
       with:
-        name: amypad ${{ steps.meta.outputs.tag }} alpha
+        name: amypet ${{ steps.meta.outputs.tag }} alpha
         body_path: _CHANGES.md
         draft: true
         files: |
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 00dcdbbe..26eec280 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,4 +1,4 @@
-from amypad.cli import main
+from amypet.cli import main
 
 
 def test_run():
diff --git a/tests/test_imtrimup.py b/tests/test_imtrimup.py
index eaefbdbb..374f1798 100644
--- a/tests/test_imtrimup.py
+++ b/tests/test_imtrimup.py
@@ -5,13 +5,11 @@
 
 @pytest.fixture
 def dyndir(datain, mMRpars):
-    # definition of dynamic frames for kinetic analysis
-    frmdef = ["def", [4, 15], [8, 30], [9, 60], [2, 180], [8, 300]]
     # output path
     opth = str(Path(datain["corepath"]).parent / "amypad" / "dyndir")
 
     res = Path(opth) / "PET" / "multiple-frames"
-    if res.is_dir():
+    if res.is_dir() and len(list(res.glob('*.nii*'))) > 1:
         return res
 
     nipet = pytest.importorskip("niftypet.nipet")
@@ -19,8 +17,10 @@ def dyndir(datain, mMRpars):
     # offset for the time from which meaningful events are detected
     toff = nipet.lm.get_time_offset(hst)
     # dynamic frame timings
+    # frmdef = ["def", [4, 15], [8, 30], [9, 60], [2, 180], [8, 300]]
+    frmdef = ["def", [4, (hst['t1'] - hst['t0'] - toff) / 4]]
     frm_timings = nipet.lm.dynamic_timings(frmdef, offset=toff)
-    nipet.lm.draw_frames(hst, frm_timings["timings"])
+    # nipet.lm.draw_frames(hst, frm_timings["timings"]) # plot frames
     # hardware mu-map
     muhdct = nipet.hdw_mumap(datain, [1, 2, 4], mMRpars, outpath=opth, use_stored=True)
 
@@ -30,6 +30,7 @@ def dyndir(datain, mMRpars):
         mMRpars,
         outpath=opth,
         store=True,
+        use_stored=True,
         hst=hst,
         itr=2,
         petopt="ac",
@@ -44,7 +45,7 @@ def dyndir(datain, mMRpars):
         mMRpars,
         frames=frm_timings["timings"],
         mu_h=muhdct,
-        mu_o=mupdct,                   # muodct,
+        mu_o=mupdct,
         itr=5,
         fwhm=0.0,
         outpath=opth,
@@ -55,7 +56,7 @@ def dyndir(datain, mMRpars):
     return Path(opth) / "PET" / "multiple-frames"
 
 
-@pytest.mark.timeout(2 * 60 * 60) # 2h
-def test_rectrim(dyndir):
-    rectrim = pytest.importorskip("amypad.rectrim")
-    rectrim.run(dyndir)
+@pytest.mark.timeout(30 * 60) # 30m
+def test_imtrimup(dyndir):
+    imtrimup = pytest.importorskip("amypet.imtrimup")
+    imtrimup.run(dyndir, glob='*_frm?_t*.nii*')