diff --git a/.coveragerc b/.coveragerc index 09d324b..fbc3618 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,4 @@ [run] omit = - ./snappytutorial01/_version.py - ./snappytutorial01/__init__.py + ./sksurgerytutorial01/_version.py + ./sksurgerytutorial01/__init__.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1b1c8c..935f1e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [windows-latest] python-ver: [3.7, 3.8] experimental: [false] exclude: @@ -59,13 +59,12 @@ jobs: run: | python -m pip install --upgrade pip pip install pip-tools - pip-compile requirements.txt pip install -r requirements-dev.txt - name: Run tests using xvfb (Ubuntu) if: startsWith(matrix.os, 'ubuntu') run: | - sudo apt-get install xvfb libxkbcommon-x11-0 + sudo apt-get install xvfb libxkbcommon-x11-0 libgl1 freeglut3-dev sudo Xvfb :1 -screen 0 1024x768x24 =1.17.4 - - vtk=8.1.2 - - tox>=3.26.0 - - pytest>=7.1.2 - - pylint>=2.14.5 - - pip>=22.2.2 - - pip: - - PySide2>=5.14.2.3 - - scikit-surgerycore>=0.1.7 - - scikit-surgeryutils>=1.2.0 - - scikit-surgeryarucotracker>=0.1.1 - - opencv-python-headless - -Step 2: -You should now be able to follow the tutorial, using the code snippets contained herein. + + conda update -n base -c defaults conda + conda create -n sst01VE python=3.8 pip -c conda-forge #try3.7 + conda activate sst01VE + pip install -r requirements.txt + .. _`python.org`: https://www.python.org/downloads/ .. _`SmartLiver`: https://link.springer.com/article/10.1007/s11548-018-1761-3 diff --git a/requirements.txt b/requirements.txt index 4fc3e80..103caac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,9 @@ # confused with the software requirements, which are listed in # doc/requirements.rst numpy>=1.17.4 -PySide2 +vtk>=9.2.6 +PySide6>=6.5.1.1 +opencv-contrib-python-headless>=4.2.0.32 scikit-surgerycore>=0.1.7 scikit-surgeryutils>=1.2.0 -scikit-surgeryarucotracker>= 0.2.7 \ No newline at end of file +scikit-surgeryarucotracker>= 0.2.7 diff --git a/sksurgerytutorial01/vtk_aruco_app.py b/sksurgerytutorial01/vtk_aruco_app.py index ddd3cbe..84e68b7 100644 --- a/sksurgerytutorial01/vtk_aruco_app.py +++ b/sksurgerytutorial01/vtk_aruco_app.py @@ -1,12 +1,15 @@ -# coding=utf-8 +""" +Script to create a viewer window with a movable surface +model overlaid in a live video feed -"""Script to create a viewer window with a movable surface -model overlaid in a live video feed""" +USAGE: +python vtk_aruco_app.py +""" import sys #add an import for numpy, to manipulate arrays import numpy -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication from sksurgeryutils.common_overlay_apps import OverlayBaseWidget from sksurgerycore.transforms.transform_manager import TransformManager from sksurgeryarucotracker.arucotracker import ArUcoTracker @@ -60,6 +63,9 @@ def update_view(self): #see what happens. self.vtk_overlay_window.set_camera_state({"ClippingRange": [10, 800]}) self.vtk_overlay_window.set_video_image(image) + # Allows the interactor to initialize itself. + self.vtk_overlay_window.Initialize() + self.vtk_overlay_window.Start() # Start the event loop. self.vtk_overlay_window.Render() def _aruco_detect_and_follow(self, image): @@ -95,13 +101,13 @@ def _move_camera(self, tag2camera): if __name__ == '__main__': app = QApplication([]) - video_source = 0 - viewer = OverlayApp(video_source) + VIDEO_SOURCE = 0 + viewer = OverlayApp(VIDEO_SOURCE) - model_dir = '../models' - viewer.add_vtk_models_from_dir(model_dir) + MODEL_DIR = '../models' + viewer.add_vtk_models_from_dir(MODEL_DIR) viewer.show() viewer.start() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/sksurgerytutorial01/vtkoverlay_app.py b/sksurgerytutorial01/vtkoverlay_app.py index 7deb70f..774f573 100644 --- a/sksurgerytutorial01/vtkoverlay_app.py +++ b/sksurgerytutorial01/vtkoverlay_app.py @@ -1,10 +1,13 @@ -# coding=utf-8 +""" +Script to create a viewer window with a static surface +model overlaid in a live video feed -"""Script to create a viewer window with a static surface -model overlaid in a live video feed""" +USAGE: +python vtkoverlay_app.py +""" import sys -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication from sksurgeryutils.common_overlay_apps import OverlayBaseWidget #create an OverlayApp class, that inherits from OverlayBaseApp @@ -16,6 +19,9 @@ def update_view(self): and render""" _, image = self.video_source.read() self.vtk_overlay_window.set_video_image(image) + # Allows the interactor to initialize itself. + self.vtk_overlay_window.Initialize() + self.vtk_overlay_window.Start() # Start the event loop. self.vtk_overlay_window.Render() #the following line prevents the code below from running unless @@ -29,18 +35,18 @@ def update_view(self): #is set when we create the instance. This is an index #starting at 0. If you have more than one webcam, you can #try using different numbered sources - video_source = 0 - viewer = OverlayApp(video_source) + VIDEO_SOURCE = 0 + viewer = OverlayApp(VIDEO_SOURCE) #Set a model directory containing the models you wish #to render and optionally a colours.txt defining the #colours to render in. - model_dir = '../models' - viewer.add_vtk_models_from_dir(model_dir) + MODEL_DIR = '../models' + viewer.add_vtk_models_from_dir(MODEL_DIR) #start the viewer viewer.show() viewer.start() #start the application - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/sksurgerytutorial01/vtkoverlay_with_movement_app.py b/sksurgerytutorial01/vtkoverlay_with_movement_app.py index 1e611fa..7b1c8ac 100644 --- a/sksurgerytutorial01/vtkoverlay_with_movement_app.py +++ b/sksurgerytutorial01/vtkoverlay_with_movement_app.py @@ -1,10 +1,13 @@ -# coding=utf-8 +""" +Script to create a viewer window with a moving surface +model overlaid in a live video feed -"""Script to create a viewer window with a moving surface -model overlaid in a live video feed""" +USAGE: +python vtkoverlay_with_movement_app.py +""" import sys -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication from sksurgeryutils.common_overlay_apps import OverlayBaseWidget class OverlayApp(OverlayBaseWidget): @@ -20,6 +23,9 @@ def update_view(self): self._move_model() self.vtk_overlay_window.set_video_image(image) + # Allows the interactor to initialize itself. + self.vtk_overlay_window.Initialize() + self.vtk_overlay_window.Start() # Start the event loop. self.vtk_overlay_window.Render() def _move_model(self): @@ -39,13 +45,13 @@ def _move_model(self): if __name__ == '__main__': app = QApplication([]) - video_source = 0 - viewer = OverlayApp(video_source) + VIDEO_SOURCE = 0 + viewer = OverlayApp(VIDEO_SOURCE) - model_dir = '../models' - viewer.add_vtk_models_from_dir(model_dir) + MODEL_DIR = '../models' + viewer.add_vtk_models_from_dir(MODEL_DIR) viewer.show() viewer.start() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/tests/conftest.py b/tests/conftest.py index e87f0d5..316a666 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import pytest -from PySide2.QtWidgets import QApplication +from PySide6.QtWidgets import QApplication @pytest.fixture(scope="session") def setup_qt(): """ Create the QT application. """ app = QApplication([]) - return app \ No newline at end of file + return app diff --git a/tests/pylintrc b/tests/pylintrc index 6d86379..a93fb5d 100644 --- a/tests/pylintrc +++ b/tests/pylintrc @@ -32,17 +32,8 @@ unsafe-load-any-extension=no # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code -extension-pkg-whitelist=numpy,PySide2,cv2,vtk - -# Allow optimization of some AST trees. This will activate a peephole AST -# optimizer, which will apply various small optimizations. For instance, it can -# be used to obtain the result of joining multiple strings with the addition -# operator. Joining a lot of strings can lead to a maximum recursion error in -# Pylint and this flag can prevent that. It has one side effect, the resulting -# AST will be different than the one from reality. This option is deprecated -# and it will be removed in Pylint 2.0. -optimize-ast=no - +extension-pkg-whitelist=numpy, PySide6 +extension-pkg-allow-list=PySide6 [MESSAGES CONTROL] @@ -56,17 +47,6 @@ confidence= # it should appear only once). See also the "--disable" option for examples. #enable= -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=long-suffix,standarderror-builtin,indexing-exception,delslice-method,unichr-builtin,dict-view-method,parameter-unpacking,unicode-builtin,cmp-builtin,intern-builtin,round-builtin,backtick,nonzero-method,xrange-builtin,coerce-method,raw_input-builtin,old-division,filter-builtin-not-iterating,old-octal-literal,input-builtin,map-builtin-not-iterating,buffer-builtin,basestring-builtin,zip-builtin-not-iterating,using-cmp-argument,unpacking-in-except,old-raise-syntax,coerce-builtin,dict-iter-method,hex-method,range-builtin-not-iterating,useless-suppression,cmp-method,print-statement,reduce-builtin,file-builtin,long-builtin,getslice-method,execfile-builtin,no-absolute-import,metaclass-assignment,oct-method,reload-builtin,import-star-module-level,suppressed-message,apply-builtin,raising-string,next-method-called,setslice-method,old-ne-operator,arguments-differ,wildcard-import,locally-disabled - [REPORTS] @@ -75,12 +55,6 @@ disable=long-suffix,standarderror-builtin,indexing-exception,delslice-method,uni # mypackage.mymodule.MyReporterClass. output-format=text -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". This option is deprecated -# and it will be removed in Pylint 2.0. -files-output=no - # Tells whether to display a full report or only the messages reports=yes @@ -118,64 +92,33 @@ property-classes=abc.abstractproperty # Regular expression matching correct variable names variable-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for variable names -variable-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct argument names argument-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for argument names -argument-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct constant names -# changed to lower case as we're writing little scripts. -const-rgx=(([a-z_][a-z0-9_]*)|(__.*__))$ - -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct method names method-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for method names -method-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct function names function-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for function names -function-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct attribute names attr-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for attribute names -attr-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct class names class-rgx=[A-Z_][a-zA-Z0-9]+$ -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - # Regular expression which should only match function or class names that do # not require a docstring. #no-docstring-rgx=^test_ @@ -203,12 +146,6 @@ ignore-long-lines=^\s*(# )??$ # else. single-line-if-stmt=y -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Maximum number of lines in a module max-module-lines=1000 @@ -278,7 +215,7 @@ ignore-mixin-members=yes # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules=PySide2,cv2,sksurgeryvtk,numpy +ignored-modules= # List of class names for which member attributes should not be checked (useful # for classes with dynamically set attributes). This supports the use of @@ -315,7 +252,7 @@ callbacks=cb_,_cb # List of qualified module names which can have objects that can redefine # builtins. -redefining-builtins-modules=six.moves,future.builtins +redefining-builtins-modules=future.builtins [CLASSES] @@ -405,4 +342,4 @@ analyse-fallback-blocks=no # Exceptions that will emit a warning when being caught. Defaults to # "Exception" -overgeneral-exceptions=Exception +overgeneral-exceptions=builtins.Exception diff --git a/tests/test_sksurgerytorial01.py b/tests/test_sksurgerytorial01.py index 0c841b5..78b8274 100644 --- a/tests/test_sksurgerytorial01.py +++ b/tests/test_sksurgerytorial01.py @@ -1,6 +1,9 @@ -# coding=utf-8 +""" +sksurgerytutorial01 vtkoverlay tests -"""sksurgerytutorial01 vtkoverlay tests""" +USAGE: +python -m pytest -v -s tests +""" import pytest