Skip to content

Commit

Permalink
Merge pull request #66 from KVSlab/update-vmtk
Browse files Browse the repository at this point in the history
Upgrade morphMan to v.1.2
  • Loading branch information
hkjeldsberg authored Jun 29, 2022
2 parents 981ab02 + 0ee0538 commit d081ec9
Show file tree
Hide file tree
Showing 26 changed files with 139 additions and 183 deletions.
11 changes: 3 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ workflows:
jobs:
install-and-test:
docker:
- image: cimg/python:3.6
- image: cimg/python:3.10
working_directory: ~/repo
steps:
- checkout
Expand All @@ -27,11 +27,11 @@ jobs:
# Set conda parameters
conda config --set restore_free_channel true
conda config --set always_yes yes --set changeps1 no
conda config --add channels vmtk
conda config --add channels conda-forge
conda config --add channels morphman
# Set up environment
conda create -n morphman morphman pytest llvm=3.3
conda create -n morphman morphman
# Activate environment
source activate morphman
Expand All @@ -42,11 +42,6 @@ jobs:
# Dependencies for code coverage
pip install pytest-cov codecov
# Edit VMTK files
sed -i -e 's/len(self.SourcePoints)\/3/len\(self.SourcePoints\)\/\/3/g' $HOME/miniconda/envs/morphman/lib/python3.6/site-packages/vmtk/vmtkcenterlines.py
sed -i -e 's/len(self.TargetPoints)\/3/len\(self.TargetPoints\)\/\/3/g' $HOME/miniconda/envs/morphman/lib/python3.6/site-packages/vmtk/vmtkcenterlines.py
sed -i -e 's/(len(values) - 1)\/2/\(len\(values\) - 1\)\/\/2/g' $HOME/miniconda/envs/morphman/lib/python3.6/site-packages/vmtk/vmtksurfacecurvature.py
# Run tests
cd test
pytest --cov=./
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Licence
morphMan is licensed under the GNU GPL, version 3 or (at your option) any
later version.

morphMan is Copyright (2016-2021) by the authors.
morphMan is Copyright (2016-2022) by the authors.

Documentation
-------------
Expand All @@ -56,7 +56,7 @@ Installation

For reference, morphMan requires the following dependencies: VTK > 8.1, Numpy <= 1.13, SciPy > 1.0.0, and VMTK 1.4.
If you are on Windows, macOS or Linux you can install all the general dependencies through anaconda.
First install Anaconda or Miniconda (preferably the Python 3.6 version).
First install Anaconda or Miniconda (preferably the Python 3.10 version).
Then execute the following command

conda create -n your_environment -c vmtk -c morphman morphman
Expand Down
33 changes: 7 additions & 26 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@ environment:
CONDA_INSTALL_LOCN: "C:\\Miniconda-x64"

matrix:
- PYTHON: "C:\\Python35_64"
PYTHON_VERSION: "3.5"
- PYTHON: "C:\\Python39_64"
PYTHON_VERSION: "3.9"
PYTHON_ARCH: "64"
CONDA_PY: "35"
CONDA_PY: "39"
CONDA_NPY: "18"
APP_CONDA_PY: "3.5.1"

- PYTHON: "C:\\Python36_64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
CONDA_PY: "36"
CONDA_NPY: "18"
APP_CONDA_PY: "3.6.1"
APP_CONDA_PY: "3.9.1"

platform:
- x64
Expand All @@ -43,33 +36,21 @@ install:
- cmd: conda config --set always_yes yes
- cmd: conda update --quiet conda
- cmd: conda install --quiet jinja2 conda-build=3.10.5 anaconda-client
- cmd: conda config --set restore_free_channel true

# Add custom channels
- cmd: conda config --add channels vmtk
- cmd: conda config --add channels conda-forge
- cmd: conda config --add channels morphman

# Install dependencies
- cmd: conda install pytest scipy vtk vmtk python=3.6

# Set up environment
- cmd: conda create -n morphman_env morphman
- cmd: conda create -n morphman morphman pytest

build: false

test_script:
# Activate environment
- cmd: conda init cmd.exe
- cmd: conda activate morphman_env

# Search and replace in vmtkcenterlines.py for / to //
- cmd: sed -i "s/len(self.SourcePoints)\/3/len\(self.SourcePoints\)\/\/3/g" %CONDA_INSTALL_LOCN%\\Lib\\site-packages\\vmtk\\vmtkcenterlines.py
- cmd: sed -i "s/len(self.TargetPoints)\/3/len\(self.TargetPoints\)\/\/3/g" %CONDA_INSTALL_LOCN%\\Lib\\site-packages\\vmtk\\vmtkcenterlines.py
- cmd: sed -i -e "s/(len(values) - 1)\/2/\(len\(values\) - 1\)\/\/2/g" %CONDA_INSTALL_LOCN%\\Lib\\site-packages\\vmtk\\vmtksurfacecurvature.py
- cmd: conda activate morphman

# Start testing
- cd .\\test
- ps: Start-FileDownload 'http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0001/C0001_models.tar.gz'
- tar --force-local -zxvf C0001_models.tar.gz
- del /f C0001_models.tar.gz
- pytest .
9 changes: 5 additions & 4 deletions conda-build/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
numpy:
- 1.13.*
- 1.23.*

python:
- 3.5.1
- 3.6.1
- 3.8.*
- 3.9.*
- 3.10.*

vtk:
- 8.1.0
- 9.1.*
2 changes: 1 addition & 1 deletion conda-build/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: "morphman"
version: "1.1"
version: "1.2"

source:
path: ../
Expand Down
2 changes: 1 addition & 1 deletion demo/demo_manipulate_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
default_values["poly_ball_size"] = [250, 250, 250]

# Run manipulation - smooth the entire geometry except aneurysm dome
#manipulate_surface(**default_values)
manipulate_surface(**default_values)

### Add noise to the surface
# Output file path
Expand Down
22 changes: 9 additions & 13 deletions demo/get_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,26 @@
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notices for more information.

from os import system, path
from os import system, path, makedirs
from sys import platform


def download_case(case):
abs_path = path.dirname(path.abspath(__file__))
output_file = path.join(abs_path, "{}_models.tar.gz".format(case))
url = "http://ecm2.mathcs.emory.edu/aneuriskdata/download/{}/{}_models.tar.gz".format(case, case)
output_file = path.join(abs_path, case, "surface", "model.vtp")
url = "https://github.com/hkjeldsberg/AneuriskDatabase/raw/master/models/{}/surface/model.vtp".format(case)

# Create test data folders
if not path.exists(path.join(abs_path, case, "surface")):
makedirs(path.join(abs_path, case, "surface"))

try:
if platform == "darwin":
system("curl {} --output {}".format(url, output_file))
system("tar -zxvf {}".format(output_file))
system("rm {}".format(output_file))

system("curl -L {} --output {}".format(url, output_file))
elif platform == "linux" or platform == "linux2":
system("wget {}".format(url))
system("tar -zxvf {}".format(output_file))
system("rm {}".format(output_file))

system("wget -O {} {}".format(output_file, url))
elif platform == "win32":
system("bitsadmin /transfer download_model /download /priority high {} {}".format(url, output_file))
system("tar -zxvf {}".format(output_file))
system("del /f {}".format(output_file))

except:
raise RuntimeError("Problem downloading the testdata, please do it manually from "
Expand Down
4 changes: 2 additions & 2 deletions docs/source/Miscellaneous.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ the geometric properties (curvature and torsion) of the centerline, set with
2. Discrete derivatives (``disc``)
3. VMTK (``vmtk``)

To perform landmarking, we will be using the model with `ID C0001 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0001/C0001_models.tar.gz>`_
To perform landmarking, we will be using the model with `ID C0001 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0001>`_
from the Aneurisk database. For the commands below we assume that there is a file `./C0001/surface/model.vtp`, relative to where you execute the command.
To landmark the surface model, run the following command::

Expand Down Expand Up @@ -71,7 +71,7 @@ manipulates only the centerline for a range of ``--alpha`` and
``--beta`` values. The resulting 2D data can be fitted to a surface through cubic spline interpolation, from
which one can easily collect appropriate values for ``--alpha`` and ``--beta``.

To estimate :math:`\alpha` and :math:`\beta`, we will be using the model with `ID C0005 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0005/C0005_models.tar.gz>`_
To estimate :math:`\alpha` and :math:`\beta`, we will be using the model with `ID C0005 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0005>`_
from the Aneurisk database. For the commands below we assume that there is a file `./C0005/surface/model.vtp`, relative to where you execute the command.

Imagine we are interested in changing the bend angle by :math:`\pm 10^{\circ}`.
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
# -- Project information -----------------------------------------------------

project = 'morphman'
copyright = '2021, Aslak W. Bergersen & Henrik A. Kjeldsberg'
copyright = '2022, Aslak W. Bergersen & Henrik A. Kjeldsberg'
author = 'Aslak W. Bergersen & Henrik A. Kjeldsberg'

# The short X.Y version.
version = '1.1'
version = '1.2'
# The full version, including alpha/beta/rc tags
release = '1.1'
release = '1.2'

# -- General configuration ---------------------------------------------------

Expand Down
60 changes: 22 additions & 38 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
============
Installation
============
.. highlight:: console

morphMan (morphological manipulation) is a collection of scripts to objectively manipulate
morphological features of patient-specific vascular geometries. The project is accessible through
`GitHub <https://github.com/KVSlab/morphMan/>`_ and `Anaconda <https://anaconda.org/morphman/morphman>`_.
Expand All @@ -12,21 +14,24 @@ Compatibility and Dependencies
==============================
The general dependencies of morphMan are

* VMTK 1.4.0
* VTK 8.1.0
* Numpy <= 1.13
* SciPy 1.1.0
* Python (2.7 or >=3.5)
* VMTK 1.5.0
* VTK 9.1.0
* Numpy 1.23
* SciPy 1.8.1
* Python >=3.8

Basic Installation
==================
We recommend that you can install morphMan through Anaconda.
First, install Anaconda or Miniconda (preferably the Python 3.6 version).
Then execute the following command in a terminal window::
First, install `Anaconda <https://www.anaconda.com/products/distribution>`_ or `Miniconda <https://docs.conda.io/en/latest/miniconda.html>`_.
Then execute the following command in a terminal window to create a Conda environment with morphMan installed::

$ conda create -n your_environment -c conda-forge -c morphman morphman

$ conda create -n your_environment -c vmtk -c morphman morphman
.. note::
Replace ``your_environment`` with the environment name.

You can then activate your environment by running ``source activate your_environment``.
You can then activate your environment by running ``conda activate your_environment`` or ``source activate your_environment``.
Now you are all set, and can start using morphMan. morphMan can be accessed by opening a Python console
and typing::

Expand All @@ -39,53 +44,32 @@ Alternatively you can use one of the six main methods of manipulation directly t

followed by the command line arguments for the selected method. A detailed explanation for usage of morphMan is described in :ref:`getting_started`.

.. WARNING:: The VMTK version 1.4, the one currently distributed with Anaconda, has a Python3 bug in `vmtkcenterlines` and `vmtksurfacecurvature`. As a workaround you have to change these files. To find out where it is located please execute::

$ which vmtkcenterlines
/Users/[Name]/anaconda3/envs/[your_environment]/bin/vmtkcenterlines
$ python -V
Python 3.6.2 :: Continuum Analytics, Inc.

Now copy the path up until ``[your_environment]`` and add ``lib/python3.6/site-packages/vmtk/vmtkcenterlines.py``. Please change the path separation symbol to match your operating system and change ``python3.6`` to the python version you are using. If you are using Miniconda, replace `anaconda3` with `miniconda3`. Using this path you can run the two following lines::

$ sed -i -e 's/len(self.SourcePoints)\/3/len\(self.SourcePoints\)\/\/3/g' /Users/[Name]/anaconda3/envs/[your_environment]/lib/python3.6/site-packages/vmtk/vmtkcenterlines.py
$ sed -i -e 's/len(self.TargetPoints)\/3/len\(self.TargetPoints\)\/\/3/g' /Users/[Name]/anaconda3/envs/[your_environment]/lib/python3.6/site-packages/vmtk/vmtkcenterlines.py

Similarly, for `vmtksurfacecurvature.py`, run the following command::

$ sed -i -e 's/(len(values) - 1)\/2/\(len\(values\) - 1\)\/\/2/g' /Users/[Name]/anaconda3/envs/[your_environment]/lib/python3.6/site-packages/vmtk/vmtksurfacecurvature.py


.. WARNING:: Some users may experience the following Python compatibility issue::

ModuleNotFoundError: No module named 'vtkRenderingOpenGL2Python'

To fix this issue, a temporary solution is the install the ``llvm`` library directly in the virtual environment, using the following commands::

$ conda config --set restore_free_channel true
$ conda install llvm=3.3

Development version
===================

Downloading
~~~~~~~~~~~
The latest development version of morphMan can be found on the official
`morphMan git repository <https://github.com/KVSlab/morphMan>`_ on GitHub.
Make sure Git (>=1.6) is installed, which is needed to clone the repository.
Make sure `Git <https://git-scm.com/>`_ is installed, which is needed to clone the repository.
To clone the morphMan repository, navigate to the directory where you wish
morphMan to be stored, type the following command, and press Enter::

$ git clone https://github.com/KVSlab/morphMan
$ git clone https://github.com/KVSlab/morphMan

If it not already present, this will install Python for you.
After the source distribution has been downloaded, all the files required will be located
in the newly created ``morphMan`` folder.

Building
~~~~~~~~
In order to build and install morphMan, navigate into the ``morphMan`` folder, where a ``setup.py``
file will be located. First, make sure that all dependencies are installed. Then, building and installation of morphMan
can be performed by simply running the following command from the terminal window::
can be performed with ``pip`` by running the following command::

$ python -m pip install .

Alternatively, morphMan can be installed using Python directly (deprecated)::

$ python setup.py install

2 changes: 1 addition & 1 deletion docs/source/manipulate_area.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ demo folder where we show how to run this tutorial from a Python script, please
run the demos.

In this tutorial, we are using the model with
`ID C0002 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0002/C0002_models.tar.gz>`_
`ID C0002 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0002>`_
from the Aneurisk database. For the commands below we assume that there is a file `./C0002/surface/model.vtp`, relative to where you execute the command.

For changing the area you first need to define which segment you want to alter. For ``morphman-area`` there are
Expand Down
2 changes: 1 addition & 1 deletion docs/source/manipulate_bend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ respectively. For a detailed description on how we have defined of the
vectors :math:`\alpha` and :math:`\beta`, see [1]_.

In this tutorial, we are using the model with
`ID C0005 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0005/C0005_models.tar.gz>`_
`ID C0005 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0005>`_
from the Aneurisk database. For the commands below we assume that there is a folder
a `./C0005/surface/model.vtp`, relative to where you execute the command.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/manipulate_bifurcation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The algorithm builds on previous work of Ford et al. [1]_
Figure 1: An illustration of the goal of ``morphman-bifurcation``.

In this tutorial, we are using the model with
`ID C0005 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0005/C0005_models.tar.gz>`_
`ID C0005 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0005>`_
from the Aneurisk database. For the commands below we assume that there
is a file `./C0005/surface/model.vtp`, relative to where you execute the command.
Performing the manipulation can be achieved by running ``morphman-bifurcation`` in the terminal, followed by the
Expand Down Expand Up @@ -62,7 +62,7 @@ The default is to rotate both branches, but if either ``--keep-fixed-1`` or
fixed, respectively. Furthermore, if both parameters are set to **True**
then the algorithm can be used to remove an aneurysm (a balloon-shaped bleb
on the artery), see Figure 4. To this specific tutorial, we have used the model
with `ID C0066 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0066/C0066_models.tar.gz>`_
with `ID C0066 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0066>`_
, which harbors an aneurysm located at the terminal bifurcation in the internal carotid artery.

.. figure:: remove_aneurysm.png
Expand Down
2 changes: 1 addition & 1 deletion docs/source/manipulate_branch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ run the demos.
Figure 1: An illustration of the desired output from the method.

In this tutorial, we are using the model with
`ID C0002 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0002/C0002_models.tar.gz>`_
`ID C0002 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0002>`_
from the Aneurisk database. For the commands below we assume that there is a
file `./C0002/surface/model.vtp`, relative to where you execute the command.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/manipulate_curvature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ run the demos.
Figure 1: An illustration of the desired output from the method.

In this tutorial, we are using the model with
`ID C0005 <http://ecm2.mathcs.emory.edu/aneuriskdata/download/C0005/C0005_models.tar.gz>`_
`ID C0005 <https://github.com/hkjeldsberg/AneuriskDatabase/tree/master/models/C0005>`_
from the Aneurisk database. For the commands below we assume that there is a
file `./C0005/surface/model.vtp`, relative to where you execute the command.

Expand Down
Loading

0 comments on commit d081ec9

Please sign in to comment.