Skip to content

Commit

Permalink
Merge pull request #106 from SciKit-Surgery/101-skutils
Browse files Browse the repository at this point in the history
101 skutils
  • Loading branch information
thompson318 committed Feb 8, 2023
2 parents 115a9ca + 87cb7f7 commit 82d8baa
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 94 deletions.
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ coveralls
mock
pyfakefs
parameterized
pylint<2.14
pylint>2.13
sphinx
sphinx_rtd_theme
pyinstaller
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
numpy
glob2
PySide2<5.15.0
scikit-surgerycalibration<=0.1.11
scikit-surgerycalibration>=0.1.9
scikit-surgerycore>=0.6.8
scikit-surgeryutils<1.2
scikit-surgeryutils>=1.2.1
scikit-surgeryvtk
scikit-surgeryarucotracker>=0.2.5
opencv-contrib-python-headless
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
'PySide2<5.15.0',
'opencv-contrib-python-headless',
'scikit-surgerycore>=0.6.8',
'scikit-surgerycalibration<=0.1.11',
'scikit-surgeryutils<1.2',
'scikit-surgerycalibration>=0.1.9',
'scikit-surgeryutils>=1.2.1',
'scikit-surgeryvtk',
'scikit-surgeryarucotracker>=0.2.5',
],
Expand Down
8 changes: 6 additions & 2 deletions sksurgerybard/ui/sksurgerybard_command_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

""" Demo app, to show OpenCV video and PySide2 widgets together."""

import sys
from PySide2.QtWidgets import QApplication
from sksurgerycore.configuration.configuration_manager import \
ConfigurationManager
Expand All @@ -22,6 +21,11 @@ def run_demo(config_file, calib_dir):

viewer = BARDOverlayApp(configuration, calib_dir)

viewer.vtk_overlay_window.Initialize()
viewer.vtk_overlay_window.Start()
viewer.show()
viewer.start()

sys.exit(app.exec_())
app.exec_()

viewer.vtk_overlay_window.Finalize()
8 changes: 4 additions & 4 deletions sksurgerybard/widgets/bard_overlay_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import cv2

from sksurgeryvtk.utils.matrix_utils import create_vtk_matrix_from_numpy
from sksurgeryutils.common_overlay_apps import OverlayBaseApp
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget
from sksurgeryarucotracker.arucotracker import ArUcoTracker
from sksurgerybard.algorithms.bard_config_algorithms import \
configure_interaction, configure_camera, replace_calibration_dir
Expand All @@ -19,7 +19,7 @@
from sksurgerybard.algorithms.decimation import decimate_actor
from sksurgerybard.tracking.bard_tracking import setup_tracker

class BARDOverlayApp(OverlayBaseApp):
class BARDOverlayApp(OverlayBaseWidget):
"""
Inherits from OverlayBaseApp, and adds methods to
detect aruco tags and move the model to follow.
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(self, configuration = None, calib_dir = None):

# call the constructor for the base class
try:
super().__init__(video_source, dims)
super().__init__(video_source, dims, init_vtk_widget=False)
except RuntimeError:
raise RuntimeError("Failed to create overlay window, check you " +
"have access to video source: ", video_source) \
Expand Down Expand Up @@ -160,7 +160,7 @@ def position_model_actors(self, increment = None):
self._model_list['target anatomy']:
actor.SetUserMatrix(matrix)

def update(self):
def update_view(self):
"""
Update the background render with a new frame
"""
Expand Down
14 changes: 7 additions & 7 deletions tests/interaction/test_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StartTrackingEvent(Exception):#pylint: disable=missing-class-docstring


class _FakePointerWriter:
def write_pointer_tip(self): # pylint: disable=no-self-use
def write_pointer_tip(self):
"""Raises an exception so we know when it's run"""
raise WritePointerEvent

Expand Down Expand Up @@ -58,28 +58,28 @@ def GetSize(self):# pylint: disable=invalid-name


class _FakeVisualisationControl:
def cycle_visible_anatomy_vis(self): # pylint: disable=no-self-use
def cycle_visible_anatomy_vis(self):
"""Raises an error so we know when it's run"""
raise CycleAnatomyEvent

def next_target(self): # pylint: disable=no-self-use
def next_target(self):
"""Raises an error so we know when it's run"""
raise NextTargetEvent

def turn_on_all_targets(self): # pylint: disable=no-self-use
def turn_on_all_targets(self):
"""Raises an error so we know when it's run"""
raise TurnOnAllEvent

def visibility_toggle(self, _): # pylint: disable=no-self-use
def visibility_toggle(self, _):
"""Raises an error so we know when it's run"""
raise VisibilityToggleEvent

def change_opacity(self, _): # pylint: disable=no-self-use
def change_opacity(self, _):
"""Raises an error so we know when it's run"""
raise ChangeOpacityEvent

class _FakeBardWidget:
def position_model_actors(self, increment): # pylint: disable=no-self-use
def position_model_actors(self, increment):
"""Raises and error so we know it's run"""
raise PositionModelEvent(increment)
class transform_manager: #pylint: disable=invalid-name
Expand Down
10 changes: 5 additions & 5 deletions tests/interaction/test_speech_interation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ class ChangeOpacityEvent(Exception):#pylint: disable=missing-class-docstring
pass

class _FakeVisualisationControl:
def cycle_visible_anatomy_vis(self): # pylint: disable=no-self-use
def cycle_visible_anatomy_vis(self):
"""Raises an error so we know when it's run"""
raise CycleAnatomyEvent

def next_target(self): # pylint: disable=no-self-use
def next_target(self):
"""Raises an error so we know when it's run"""
raise NextTargetEvent

def turn_on_all_targets(self): # pylint: disable=no-self-use
def turn_on_all_targets(self):
"""Raises an error so we know when it's run"""
raise TurnOnAllEvent

def visibility_toggle(self, _): # pylint: disable=no-self-use
def visibility_toggle(self, _):
"""Raises an error so we know when it's run"""
raise VisibilityToggleEvent

def change_opacity(self, _): # pylint: disable=no-self-use
def change_opacity(self, _):
"""Raises an error so we know when it's run"""
raise ChangeOpacityEvent

Expand Down
64 changes: 0 additions & 64 deletions tests/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ unsafe-load-any-extension=no
# run arbitrary code
extension-pkg-whitelist=numpy,aruco

# 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


[MESSAGES CONTROL]

Expand All @@ -56,31 +47,13 @@ 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]

# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html. You can also give a reporter class, eg
# 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

Expand Down Expand Up @@ -118,64 +91,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
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Naming hint for constant names
const-name-hint=(([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_

Expand All @@ -202,12 +144,6 @@ ignore-long-lines=^\s*(# )?<?https?://\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

Expand Down
12 changes: 6 additions & 6 deletions tests/widgets/test_bard_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_valid_config():
bard_overlay.transform_manager.get("pointerref2camera"),
np.eye(4, dtype = np.float64))

bard_overlay.update()
bard_overlay.update_view()

cam2model_regression = np.array([
[-0.85007277, 0.51807849, -0.09471516, -8.06235428e+01],
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_valid_config():

#skip 5 frames
for _ in range(5):
bard_overlay.update()
bard_overlay.update_view()

cam2model_regression = np.array([
[-8.50551488e-01, 5.17049795e-01, -9.60295592e-02, -8.10664190e+01],
Expand Down Expand Up @@ -131,8 +131,8 @@ def test_valid_config():
dtype=np.float32)

assert matrices_equivalent(pointer2model_regression,
bard_overlay.transform_manager.get("pointerref2modelreference")
,tolerance = 13.0)
bard_overlay.transform_manager.get("pointerref2modelreference"),
tolerance = 13.0)


def test_with_no_pointer():
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_with_no_pointer():
with pytest.raises(ValueError):
bard_overlay.transform_manager.get("pointerref2camera")

bard_overlay.update()
bard_overlay.update_view()

cam2model_regression = np.array([
[-0.85007277, 0.51807849, -0.09471516, -8.06235428e+01],
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_with_camera_only():
with pytest.raises(ValueError):
bard_overlay.transform_manager.get("pointerref2camera")

bard_overlay.update()
bard_overlay.update_view()


def test_with_model_no_tracking():
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ python =
[testenv]
passenv = *
deps=-rrequirements-dev.txt
whitelist_externals=git
allowlist_externals=git
# See .coveragerc for list of omitted files
commands = versioneer install
git restore --staged sksurgerybard/_version.py
Expand Down

0 comments on commit 82d8baa

Please sign in to comment.