Installation
SPARCSpy has been tested with Python 3.8, 3.9 and 3.10. We recommended installing the library within a separate conda environment.
We recommend installing the dependencies with mamba or conda before installing SPARCSpy.
Note
Using Mamba instead of Conda
We have encountered issues with resolving dependencies when trying to install prerequisites using conda. In our experience, using mamba instead of conda leads to reliable results. To install mamba check out the documentation here. After installation, you can use mamba instead of conda simply by replacing the command conda
with mamba
in the following instructions.
git clone https://github.com/MannLabs/SPARCSpy
cd SPARCSpy
conda create -n "SPARCSpy"
conda activate SPARCSpy
conda install python=3.9 scipy 'scikit-image>=0.19' scikit-fmm cellpose opencv numba -c conda-forge
In case you wish to utilize the ML capabilities of SPARCSpy (either for segmentation or classification) please follow the instructions here to install pytorch correctly for your operating system. After you can verify your installation by executing the following python code:
import torch
x = torch.rand(5, 3)
print(x)
You can access the Python console by typing python
and exit it when you are finished by entering exit()
.
The output should look similar to this:
tensor([[0.3380, 0.3845, 0.3217],
[0.8337, 0.9050, 0.2650],
[0.2979, 0.7141, 0.9069],
[0.1449, 0.1132, 0.1375],
[0.4675, 0.3947, 0.1426]])
Once you have installed pytorch according to the instructions you still need to install pytorch lightning. To do this run:
conda install -c pytorch pytorch-lightning
Note
pytorch and pytorch lightning installation from pytorch channel
We have encountered issues with installed pytorch dependencies when they are not installed from the pytorch
channel but from conda-forge
. We highly recommend only installing pytorch and its dependencies from the pytorch
channel. You can check your installation by importing import pytorch_lightning
in Python. If this import fails please double check what channel your packages are installed from and reinstall them from the pytorch
channel if necessary.
Currently SPARCSpy depends on a developer version of alphabase so please install the package from source by doing the following:
pip install git+https://github.com/MannLabs/alphabase
SPARCSpy also depends on the py-lmd library. Before proceeding please install the py-lmd libray into the same conda environment following the installation instructions here. Once these steps are completed you can proceed to install the SPARCSpy package.
Clone the Github repository and use pip to install the library in your current environment. Please make sure that the package is installed editable (with the -e flag). Otherwise pretrained models might not be available:
pip install -e .