Metadata Update from @blackfile: - Issue assigned to blackfile
Metadata Update from @ankursinha: - Issue untagged with: F: Neuroimaging - Issue assigned to ankursinha (was: blackfile) - Issue tagged with: F: Data Analysis
Deps required from https://github.com/MouseLand/suite2p/blob/main/setup.py
Numba and Pytorch are the hard ones here.
Metadata Update from @ankursinha: - Assignee reset - Issue marked as depending on: #371
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:
setup.py
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.
suite2p/registration/rigid.py
It’s used (unconditionally) as an FFT accelerator in suite2p/registration/utils.py:
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
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.
torch
Login to comment on this ticket.