Installation¶
Usage of AFMSlicer and the Napari plugin require installation and usage of a Python Virtual Environment. This page details how to setup a Python virtual environment using uv and how to install AFMSlicer and the Napari plugin within this virtual environment using either stable releases to PyPI or installing development versions from GitHub.
Virtual Environment¶
We recommend using uv to install and manage your virtual environments but you do not have to. Other options such virtualenvwrapper and MiniForge also allow you to create and manage virtual environments but are not covered here.
Install uv¶
uv has excellent instructions on how to install the software on different operating systems.
Create a project folder¶
You need somewhere to undertake the work of processing images with AFMSlicer. There are two strategies that could be employed here...
- Create a single directory for installing AFMSlicer virtual environment and have nested directories for each project/set of images.
- Create a virtual environment in each directory of images you wish to process.
The following instructions assume the former approach and that the directory is called AFMSlicer and is located under
the users home directory work/
Create a Virtual Environment¶
To create a virtual environment you should create a directory for undertaking your work, change directory into it and
then us uv venv --python 3.11.
NB Because of a performance regression in one of TopoStats dependencies, the package Topoly, TopoStats only supports Python 3.10 and 3.11. The TopoStats developers are aware and are hoping this will be resolved in the near future. In the mean time you have to explicitly create
Activate Virtual Environment¶
You can now activate the environment and check that your are using the python binary from that environment.
afm_slicing programme.
direnv
GNU/Linux and OSX users may want to consider using dirnev to automate activation of virtual
environments on navigation to the AFMSlicer directory. Add the following to .envrc to activate the environment
from within the AFMSlicer directory and grant direnv the ability to be activated in this directory.
Installing AFMSlicer/Napari plugin¶
You now have the choice of whether to install a stable released version from the Python Package Index or install a development version from GitHub.
PyPI¶
You can install both AFMSlicer and the Napari plugin from the Python Package Index (PyPI) within the virtual environment using the following command.
You can now proceed with using AFMSlicer.
Development¶
AFMSlicer is in continual development and as such can be installed from the GitHub repository along with the development versions of its dependency TopoStats. The steps involved in installing the development version are slightly more involved but are described below and require that you install and use uv to set things up (see above for a brief overview).
Cloning Repositories¶
The following repositories need cloning.
You can use the following commands to clone these.
mkdir -p ~/work/AFMSlicer
cd ~/work/AFMSlicer
git clone https://github.com/AFM-SPM/AFMSlicer.git
git clone https://github.com/AFM-SPM/napari-afmslicer.git
Create a virtual environment and install packages¶
If you haven't already create a virtual environment using uv and activate it (see above). Whether you are using just
AFMSlicer at the Command Line Interface or the Napari Graphical User
Interface you should create the virtual environment in the directory from which you ran the
above git clone commands, which in the above example is ~/work/AFMSlicer.
NB TopoStats is constrained to using Python >=3.10 and < 3.12 hence why Python 3.11 is explicitly installed.
Install AFMSlicer and napari-afmslicer from the cloned repositories using the following commands.
cd ~/work/AFMSlicer
uv venv --python 3.11
uv pip install -e AFMSlicer/. --group dev
uv pip install -e napari-afmslicer/. --group dev
Tip
Cloning and installing will take a few minutes because of the downloads that need to be made, please be patient.
You can now proceed to the usage section to learn how to use AFMSlicer.