Commit 129c69e8 authored by Stephen Thompson's avatar Stephen Thompson

Merge branch '2-implement-ui'

parents eb306911 26e3bc0c
Pipeline #2188 passed with stages
in 30 minutes and 58 seconds
......@@ -80,42 +80,6 @@ test Windows:
tags:
- shared-win
# Template for deploy stages that depend on 'build docs'
# if the build stage is skipped, skip these also
.deploy-docs-skip-template: &deploy-docs-skip-template
stage: deploy
when: manual
except:
variables:
- $CI_COMMIT_MESSAGE =~ /\[skip[ _-]build?\]/i
dependencies:
- build docs
deploy docs to staging:
<<: *deploy-docs-skip-template
script:
# Note: the group/username directory must already exist on the server before calling this command
- rsync -avz -e'ssh -v' --numeric-ids --delete doc/build/html/* staging_docs_rsync:StephenThompson/sksurgeryspherefitting 2>&1
tags:
- docs-staging
environment:
name: staging
url: http://weisslab-lin.cs.ucl.ac.uk/staging/StephenThompson/sksurgeryspherefitting
only:
- master
deploy docs to production:
<<: *deploy-docs-skip-template
script:
# Note: the group/username directory must already exist on the server before calling this command
- rsync -avz -e'ssh -v' --numeric-ids --delete doc/build/html/* production_docs_rsync:StephenThompson/sksurgeryspherefitting 2>&1
tags:
- docs-production
environment:
name: production
only:
- public
deploy pip to PyPI:
stage: deploy
when: manual
......@@ -124,7 +88,7 @@ deploy pip to PyPI:
environment:
name: PyPI
url: https://pypi.python.org/pypi/sksurgeryspherefitting
url: https://pypi.python.org/pypi/scikit-surgery-sphere-fitting
tags:
- pip-production
......
scikit-surgery-sphere-fitting
===============================
.. image:: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/raw/master/project-icon.png
.. image:: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/raw/master/project-icon.png
:height: 128px
:width: 128px
:target: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting
:target: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting
:alt: Logo
.. image:: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/badges/master/build.svg
:target: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/pipelines
.. image:: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/badges/master/build.svg
:target: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/pipelines
:alt: GitLab-CI test status
.. image:: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/badges/master/coverage.svg
:target: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/commits/master
.. image:: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/badges/master/coverage.svg
:target: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/commits/master
:alt: Test coverage
.. image:: https://readthedocs.org/projects/sksurgeryspherefitting/badge/?version=latest
:target: http://sksurgeryspherefitting.readthedocs.io/en/latest/?badge=latest
.. image:: https://readthedocs.org/projects/scikit-surgery-sphere-fitting/badge/?version=latest
:target: http://scikit-surgery-sphere-fitting.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
......@@ -25,16 +25,19 @@ Author: Stephen Thompson
scikit-surgery-sphere-fitting is part of the `SNAPPY`_ software project, developed at the `Wellcome EPSRC Centre for Interventional and Surgical Sciences`_, part of `University College London (UCL)`_.
scikit-surgery-sphere-fitting supports Python 2.7 and Python 3.6.
scikit-surgery-sphere-fitting supports Python 3.6.
scikit-surgery-sphere-fitting is currently a demo project, which will add/multiply two numbers. Example usage:
scikit-surgery-sphere-fitting fits a sphere to a set of 3D points. It includes a user interface that
will read data from a vtk polydata file create an output polydata file showing the fitted sphere.
Example usage:
::
python sksurgeryspherefitting.py 5 8
python sksurgeryspherefitting.py 3 6 --multiply
python sksurgeryspherefitting.py polydata_in.vtp --output polydatata_in.vtp
Please explore the project structure, and implement your own functionality.
It was created in part to provide a simple demonstration of algorithm development as part of a
program of SNAPPY Tutorials, but also provides a useful service should you want to fit a sphere
to some data.
Developing
----------
......@@ -46,7 +49,7 @@ You can clone the repository using the following command:
::
git clone https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting
git clone https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting
Running tests
......@@ -76,8 +79,13 @@ You can pip install directly from the repository as follows:
::
pip install git+https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting
pip install git+https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting
or directly from pypi
::
pip install scikit-surgery-sphere-fitting
Contributing
......@@ -107,12 +115,12 @@ Supported by `Wellcome`_ and `EPSRC`_.
.. _`Wellcome EPSRC Centre for Interventional and Surgical Sciences`: http://www.ucl.ac.uk/weiss
.. _`source code repository`: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting
.. _`Documentation`: https://sksurgeryspherefitting.readthedocs.io
.. _`source code repository`: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting
.. _`Documentation`: https://scikit-surgery-sphere-fitting.readthedocs.io
.. _`SNAPPY`: https://weisslab.cs.ucl.ac.uk/WEISS/PlatformManagement/SNAPPY/wikis/home
.. _`University College London (UCL)`: http://www.ucl.ac.uk/
.. _`Wellcome`: https://wellcome.ac.uk/
.. _`EPSRC`: https://www.epsrc.ac.uk/
.. _`contributing guidelines`: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/blob/master/CONTRIBUTING.rst
.. _`license file`: https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting/blob/master/LICENSE
.. _`contributing guidelines`: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/blob/master/CONTRIBUTING.rst
.. _`license file`: https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/blob/master/LICENSE
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,3 +4,5 @@
# doc/requirements.rst
numpy
scipy
vtk
scikit-surgeryvtk
......@@ -19,7 +19,7 @@ setup(
long_description_content_type='text/x-rst',
url='https://weisslab.cs.ucl.ac.uk/StephenThompson/sksurgeryspherefitting',
author='Stephen Thompson',
author_email='YOUR-EMAIL@ucl.ac.uk',
author_email='s.thompson@ucl.ac.uk',
license='BSD-3 license',
classifiers=[
'Development Status :: 3 - Alpha',
......@@ -34,7 +34,6 @@ setup(
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Information Analysis',
......@@ -47,12 +46,15 @@ setup(
exclude=[
'doc',
'tests',
'data'
]
),
install_requires=[
'six>=1.10',
'numpy>=1.11',
'scipy',
'vtk',
'scikit-surgeryvtk'
],
entry_points={
......
......@@ -11,26 +11,20 @@ from sksurgeryspherefitting.ui.sksurgeryspherefitting_demo import run_demo
def main(args=None):
"""Entry point for scikit-surgery-sphere-fitting application"""
parser = argparse.ArgumentParser(description='scikit-surgery-sphere-fitting')
parser = argparse.ArgumentParser(
description='scikit-surgery-sphere-fitting')
## ADD POSITIONAL ARGUMENTS
parser.add_argument("x",
type=int,
help="1st number")
parser.add_argument("y",
type=int,
help="2nd number")
parser.add_argument("model",
type=str,
help="Filename for vtk surface model")
# ADD OPTINAL ARGUMENTS
parser.add_argument("-m", "--multiply",
action="store_true",
help="Enable multiplication of inputs."
)
parser.add_argument("-v", "--verbose",
action="store_true",
help="Enable verbose output",
parser.add_argument("-o", "--output",
required=False,
type=str,
default="",
help="Write the fitted sphere to file"
)
version_string = __version__
......@@ -38,8 +32,10 @@ def main(args=None):
parser.add_argument(
"--version",
action='version',
version='scikit-surgery-sphere-fitting version ' + friendly_version_string)
version='scikit-surgery-sphere-fitting version '
+ friendly_version_string
)
args = parser.parse_args(args)
run_demo(args.x, args.y, args.multiply, args.verbose)
run_demo(args.model, args.output)
# coding=utf-8
"""Hello world demo module"""
from sksurgeryspherefitting.algorithms import addition, multiplication
"""Uses sphere fitting to fit to vtk model"""
import vtk
from sksurgeryvtk.models.vtk_surface_model import VTKSurfaceModel
from sksurgeryspherefitting.algorithms import sphere_fitting
def run_demo(input_x, input_y, multiply, verbose):
def run_demo(model_file_name, output=""):
""" Run the application """
model = VTKSurfaceModel(model_file_name, [1., 0., 0.])
x_values = model.get_points_as_numpy()[:, 0]
y_values = model.get_points_as_numpy()[:, 1]
z_values = model.get_points_as_numpy()[:, 2]
if multiply:
result = multiplication.multiply_two_numbers(input_x, input_y)
initial_parameters = [0.0, 0.0, 0.0, 0.0]
result = sphere_fitting.fit_sphere_least_squares(x_values,
y_values,
z_values,
initial_parameters)
else:
result = addition.add_two_numbers(input_x, input_y)
if verbose:
if multiply:
print("Calculating {} * {}".format(input_x, input_y))
print("Result is {}".format(result))
else:
print("Calculating {} + {}".format(input_x, input_y))
if output != "":
print("Result is {}".format(result))
sphere = vtk.vtkSphereSource()
sphere.SetCenter(result[0][0], result[0][1], result[0][2])
sphere.SetRadius(result[0][3])
sphere.SetThetaResolution(60)
sphere.SetPhiResolution(60)
return result
writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName(output)
writer.SetInputData(sphere.GetOutput())
sphere.Update()
writer.Write()
......@@ -9,7 +9,7 @@
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS, ui
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
......@@ -32,7 +32,7 @@ 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
extension-pkg-whitelist=numpy, vtk
# Allow optimization of some AST trees. This will activate a peephole AST
# optimizer, which will apply various small optimizations. For instance, it can
......
# content of: tox.ini , put in same dir as setup.py
[tox]
envlist = py27,py36,lint
envlist = py36,lint
skipsdist = True
[travis]
python =
2.7: py27
3.6: py36, docs, lint
[testenv]
......@@ -31,13 +30,6 @@ commands = sphinx-build -M html . build
basepython=python3.6
commands=pyinstaller --onefile sksurgeryspherefitting.py --noconfirm --windowed
[testenv:pip2]
basepython=python2.7
changedir=pip_test
skip_install=True
commands = pip install {posargs}
sksurgeryspherefitting --help
[testenv:pip3]
basepython=python3.6
changedir=pip_test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment