Getting Started#

What is MagTrack?#

MagTrack is a free open-source Python library for tracking symmetric beads in single-molecule magnetic tweezers experiments.

System requirements#

  • Python >=3.9

  • Supports Windows, macOS, and Linux

    • macOS does not support CUDA GPU acceleration

Installation#

Method 1: CPU only (easier)#

This method supports macOS, Windows, or Linux. But MagTrack will only be able to use your CPU. You can always later use method 2 if you want to add GPU acceleration.

pip install magtrack[cpu]

Method 2: CPU + GPU (a little harder)#

This method supports Windows or Linux. This allows MagTrack to use either the CPU or a CUDA-capable GPU.

  1. Confirm that your system has an NVIDIA GPU.

  2. Install the free CUDA Toolkit.

    • Versions 11, 12, or 13 are supported.

    • You can check the installed version by running nvcc -V in a terminal such as Command Prompt.

  3. Install MagTrack using the pip command that matches your CUDA version:

    CUDA Toolkit Version

    Pip command

    11.x

    pip install magtrack[cu11]

    12.x

    pip install magtrack[cu12]

    13.x

    pip install magtrack[cu13]

Verify the installation#

After installing, import MagTrack in a Python session and print the version string. This confirms that Python can locate the package and that the compiled extensions were installed correctly:

import magtrack
print(magtrack.__version__)

You can also try a function like center-of-mass, which converts an image stack into x,y bead coordinates:

import magtrack
import numpy as np

stack = np.zeros((10, 10, 3))
x, y = magtrack.center_of_mass(stack)

print(f'x: {x}')
print(f'y: {y}')