Installation#

Installing the Magnet Segmentation Toolkit#

First step is installing the Magnet Segmentation Toolkit. In order to do so, follow the next steps.

  1. Download the necessary installer from the latest available release. The file should be named Magnet-Segmentation-Toolkit-Installer.exe.

  2. Execute the installer.

  3. Search for the Magnet Segmentation Toolkit and run it.

The Magnet Segmentation Toolkit window should appear at this stage.

Prerequisites:

  1. OS supported for Ubuntu(24.04 and 22.04).

  2. Update apt-get repository and install the following packages with sudo privileges: wget, gnome, libffi-dev, libssl-dev, libsqlite3-dev, libxcb-xinerama0 and build-essential packages with sudo privileges

    sudo apt-get update -y
    sudo apt-get install wget gnome libffi-dev libssl-dev libsqlite3-dev libxcb-xinerama0 build-essential -y
    
  3. Install zlib package

    wget https://zlib.net/current/zlib.tar.gz
    tar xvzf zlib.tar.gz
    cd zlib-*
    make clean
    ./configure
    make
    sudo make install
    

To install the Magnet Segmentation Toolkit, follow below steps.

  1. Download the necessary installer from the latest available release. The file should be named Magnet-Segmentation-Toolkit-Installer-ubuntu_*.zip.

  2. Execute the below command on the terminal

    unzip Magnet-Segmentation-Toolkit-Installer-ubuntu_*.zip
    ./installer.sh
    
  3. Search for the Magnet Segmentation Toolkit and run it.

The Magnet Segmentation Toolkit window should appear at this stage.

To uninstall the Magnet Segmentation Toolkit, follow below steps.

  1. Go to File menu. Click Uninstall option.

  2. Click Uninstall button.

Python Installation#

The Magnet Segmentation Toolkit can be installed like any other open source package. From PyPI, you can either install both the backend and user interface (UI) methods or install only the backend methods.

You can either install both the backend and user interface (UI) methods or install only the backend methods.

To install both the backend and UI methods, run this command:

pip install ansys-magnet-segmentation-toolkit[all]

If you only need the common API, install only the backend methods with this command:

pip install ansys-magnet-segmentation-toolkit

For developers#

You can be up and running with four lines of code:

git clone https://github.com/ansys/magnet-segmentation-toolkit
cd magnet-segmentation-toolkit
pip install -e .

Now you can run it with:

run_toolkit

Details

Installing Pytools installer in developer mode allows you to modify the source and enhance it.

Before contributing to the project, please refer to the PyAnsys Developer’s guide. You need to follow these steps:

  1. Start by cloning this repository:

    git clone https://github.com/ansys/magnet-segmentation-toolkit
    
  2. Create a fresh-clean Python environment and activate it. Refer to the official venv documentation if you require further information:

    # Create a virtual environment
    python -m venv .venv
    # Activate it in a POSIX system
    source .venv/bin/activate
    # Activate it in Windows CMD environment
    .venv\Scripts\activate.bat
    # Activate it in Windows Powershell
    .venv\Scripts\Activate.ps1
    
  3. Install the project in editable mode:

    python -m pip install -e .[tests,doc]
    
  4. Finally, verify your development installation by running:

    pytest tests -v
    

Style and testing#

This project uses pre-commit. Install with:

pip install pre-commit
run pre-commit install

This now runs pre-commit for each commit to ensure you follow project style guidelines. For example:

git commit -am 'fix style'
isort....................................................................Passed
black....................................................................Passed
blacken-docs.............................................................Passed
flake8...................................................................Passed
codespell................................................................Passed
pydocstyle...............................................................Passed
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
check yaml...............................................................Passed
trim trailing whitespace.................................................Passed
Validate GitHub Workflows................................................Passed

If you need to run it again on all files and not just staged files, run:

run pre-commit run --all-files

Local build#

This app can be deployed as a ‘frozen’ app using pyinstaller with:

pip install -e .[freeze]
run pyinstaller frozen.spec

This generates app files at dist/magnet_segmentation_toolkit and you can run it locally by executing Magnet Segmentation Toolkit.exe. For more information on how to create a standalone executable, refer to this section: How to distribute.

Documentation#

For building documentation, you can either run the usual rules provided in the Sphinx Makefile:

pip install -e .[doc]
doc/make.bat html
# subsequently open the documentation with (under Linux):
<your_browser_name> doc/html/index.html