SciKit-Surgery / scikit-surgerytutorial02

SciKit-Surgery Tutorial02 provides a tutorial on how to implement a simple algorithm using the SciKit-Surgery project's Python Template
http://scikit-surgerytutorial02.readthedocs.io/en/latest/?badge=latest
Other
1 stars 1 forks source link

MacOS High Sierra - AttributeError in Tutorial 2 at UI implementation stage #14

Closed thompson318 closed 4 years ago

thompson318 commented 4 years ago

In GitLab by @NinaMontanaBrown on Nov 13, 2019, 17:30

Hi Stephen,

I'm currently running through the SNAPPY tutorials and finding them helpful - thanks for putting them together.

However, I am running into an error at the UI implementation stage. Having followed the tutorial up to and including whitelisting vtk, running tox produces the following test failure:

in tests/test_sksurgeryspherefitting_demo.py:

def test_fit_sphere_least_squares_demo():

    model_name = 'data/CT_Level_1.vtp'
    output_name = 'out_temp.vtp'
  run_demo(model_name, output_name)

tests/test_sksurgeryspherefitting_demo.py:12:


sksurgeryspherefitting/ui/sksurgeryspherefitting_demo.py:12: in run_demo x_values = model.get_points_as_numpy()[:, 0]


self = <sksurgeryvtk.models.vtk_surface_model.VTKSurfaceModel object at 0x125f292e8>

def get_points_as_numpy(self):
    """
    Returns the vtkPolyData points as a numpy array.
    :return: nx3 numpy ndarray
    """
    self.transform_filter.Update()
    vtk_points = self.transform_filter.GetOutput().GetPoints()
  as_numpy = numpy_support.vtk_to_numpy(vtk_points.GetData())

E AttributeError: 'NoneType' object has no attribute 'GetData'

Using MacOS High Sierra. Cloned the repo today - can't find a version of the tutorial.

Any pointers?

@MattClarkson

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 14, 2019, 09:13

Hello Nina, thanks for the feedback. I can't work it out from the output you've posted. Are you able to post the whole of the terminal output you get from running tox? My first thought was that the file 'data/CT_Level_1.vtp' was missing but that should be detected when you try to load it.

One other thing you could try is to get the sphere fitting library that the tutorial is based on, and compare with your version, try;

git clone https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting.git

thompson318 commented 4 years ago

In GitLab by @NinaMontanaBrown on Nov 18, 2019, 14:15

Find attached the error returned by tox, hope this helps?:

ToxTutorial2Error.rtf

Running tox on the sphere fitting library passes all the tests, still unsure where the error is coming from.

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 18, 2019, 21:03

This looks like something is wrong with the data file to me. The first error is "vtkXMLDataParser (0x7fcd6856b500): Error parsing XML in stream at line 57, column 2, byte index 6079: mismatched tag\" Can you check your model data, i.e. model_name = 'data/CT_Level_1.vtp' is CT_Level_1.vtp complete? Do you have any other applications that you can load vtk data with to check it? If not you can post it here and I'll have a look at it.

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 19, 2019, 16:44

The issue is caused by wget command returning a load of HTML instead of the actual file:

(snappytutorial02) MattClarksonsMBP13:tmp mattclarkson$ wget https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/blob/master/data/CT_Level_1.vtp
--2019-11-19 16:43:35--  https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/blob/master/data/CT_Level_1.vtp
Resolving weisslab.cs.ucl.ac.uk (weisslab.cs.ucl.ac.uk)... 128.16.4.22
Connecting to weisslab.cs.ucl.ac.uk (weisslab.cs.ucl.ac.uk)|128.16.4.22|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘CT_Level_1.vtp’

CT_Level_1.vtp                                       [ <=>                                                                                                       ]  33.71K   178KB/s    in 0.2s    

2019-11-19 16:43:37 (178 KB/s) - ‘CT_Level_1.vtp’ saved [34522]

(snappytutorial02) MattClarksonsMBP13:tmp mattclarkson$ head CT_Level_1.vtp 
<!DOCTYPE html>
<html class="" lang="en">
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="object" property="og:type">
<meta content="GitLab" property="og:site_name">
<meta content="data/CT_Level_1.vtp · master · Stephen Thompson / scikit-surgery-sphere-fitting" property="og:title">
<meta content="scikit-surgery-sphere-fitting implements a least squares sphere fitting algorithm, to read a vtk poly data file, a config file, and outputs the fitted sphere" property="og:description">
<meta content="https://weisslab.cs.ucl.ac.uk/assets/gitlab_logo-7ae504fe4f68fdebb3c2034e36621930cd36ea87924c11ff65dbcb8ed50dca58.png" property="og:image">
thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 19, 2019, 16:58

As its not immediately obvious how to download a single file from git, you either have to clone the repo, and extract one file, and copy it to data/CT_Level_1.vtp

OR

follow the instructions, which provide a link to here, click the download icon on the web page, and then save the resulting file to data/CT_Level_1.vtp.

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 19, 2019, 17:02

wget works for me if you run this:

wget https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/raw/master/data/CT_Level_1.vtp

Note that the address is slightly different .../raw/master/... instead of ../blob/master/...

Can you please test it, and then I'll fix the tutorial.

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 19, 2019, 17:05

Thats working.

thompson318 commented 4 years ago

In GitLab by @NinaMontanaBrown on Nov 19, 2019, 17:52

2 things:

  1. Downloading the file from the link creates a .txt file which leads to an error even I rename the file as .vtp. There must be an easy workaround to this (that I'm not aware of)...?

  2. I pip installed wget and tried the above command to get an error -wget: command not found. Pip list returns wget v 3.2, so not entirely sure what's happening here either. This reminds me that I had some issues with wget when I first ran this tutorial as another internet source suggested I should build it from the source code (which I tired but didn't work in the end). I think I used curl to download the data at that moment? In any case, curl https://weisslab.cs.ucl.ac.uk/StephenThompson/scikit-surgery-sphere-fitting/raw/master/data/CT_Level_1.vtp still doesn't download the file.

thompson318 commented 4 years ago

In GitLab by @MattClarkson on Nov 19, 2019, 17:56

Im not using a python version of wget. I never even knew such a thing existed!!! My wget is a binary program installed by homebrew (on Mac).

pip uninstall wget
brew install wget
thompson318 commented 4 years ago

In GitLab by @NinaMontanaBrown on Nov 19, 2019, 18:04

Ah, that was it. All okay now!

thompson318 commented 4 years ago

In GitLab by @NinaMontanaBrown on Nov 19, 2019, 18:04

closed

thompson318 commented 4 years ago

In GitLab by @StephenThompson on Nov 19, 2019, 19:51

mentioned in commit ad8406d90f95ad7aa9b5c1128fefb469a95fc837