#17 Package suite2p
Opened 5 years ago by ankursinha. Modified 2 years ago


Metadata Update from @blackfile:
- Issue assigned to blackfile

4 years ago

Metadata Update from @ankursinha:
- Issue untagged with: F: Neuroimaging
- Issue assigned to ankursinha (was: blackfile)
- Issue tagged with: F: Data Analysis

2 years ago

Deps required from https://github.com/MouseLand/suite2p/blob/main/setup.py

  • python-rastermap
  • scanfile-tiff-reader
  • pytorch (can we include that without GPU support, though, and would that be enough?): not listed in the readme, though, but it doesn't say that you need a GPU anywhere.
  • numba
  • sbxreader
  • dvc

Numba and Pytorch are the hard ones here.

Metadata Update from @ankursinha:
- Assignee reset
- Issue marked as depending on: #371

2 years ago

Notes on Pytorch:

It’s removed from the dependencies in setup.py if there is an import error, or (weirdly) if the first digit of the minor version number is at least 6:

try:
    import torch
    a = torch.ones(2, 3)
    version = int(torch.__version__[2])
    if version >= 6:
        install_deps.remove('torch')
except:
    pass

It’s imported unconditionally in suite2p/registration/rigid.py but is not used there at all.

It’s used (unconditionally) as an FFT accelerator in suite2p/registration/utils.py:

import torch

# there are two formats of fft
try:
    # pytorch > 1.7
    from torch.fft import fft as torch_fft
    from torch.fft import ifft as torch_ifft
except:
    # pytorch <= 1.7
    from torch import fft as torch_fft
    from torch import ifft as torch_ifft

def fft2(data, size=None):
    """ compute fft2 over last two dimensions using pytorch
    size (padding) is not used
    """ 
    data_torch = torch.from_numpy(data)
    data2 = torch_fft(data_torch, dim=-1)
    data2 = torch_fft(data2, dim=-2)
    return data2.cpu().numpy()

def ifft2(data, size=None):
    """ compute ifft2 over last two dimensions using pytorch
    size (padding) is not used
    """
    data_torch = torch.from_numpy(data)
    data2 = torch_ifft(data_torch, dim=-1)
    data2 = torch_ifft(data2, dim=-2)
    return data2.cpu().numpy()

but there is commented-out code to use each of:

  • numpy.fft.fft2 / numpy.fft.ifft2
  • scipy.fft.fft2 / scipy.fft.ifft2
  • mkl_fft.fft2 / mkl_fft.ifft2 (obviously, also not happening in Fedora)

So I think it would be easy to enough to patch this to fall back to, say, scipy.fft.fft2 / scipy.fft.ifft2, when torch is not installed.

Login to comment on this ticket.

Metadata
Boards 1
Software packaging Status: Backlog