Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buswinka/lsd_pure_torch
Local Shape Descriptors For Neuron Segmentation, but only pytorch.
https://github.com/buswinka/lsd_pure_torch
Last synced: 21 days ago
JSON representation
Local Shape Descriptors For Neuron Segmentation, but only pytorch.
- Host: GitHub
- URL: https://github.com/buswinka/lsd_pure_torch
- Owner: buswinka
- License: mit
- Created: 2023-03-16T15:54:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T17:10:24.000Z (11 months ago)
- Last Synced: 2024-11-06T17:57:23.235Z (2 months ago)
- Language: Python
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lsd_pure_torch
## Local Shape Descriptors For Neuron Segmentation, but only pytorch.This is more or less a rewrite of the work of Arlo Sheridan published here: https://www.nature.com/articles/s41592-022-01711-z
However removing numpy as a dependency. All functions should work with pytorch arrays, be differentiable, and cuda
compatible.Additionally, there should be a minimally functional training setup in scr/train/engine.py
This was originally written to be used in the Biomedical Image Segmentation Models (BISM) library: https://github.com/buswinka/bismTo calculate LSD of a 3D instance mask
```python
from lsd_pure_torch import lsd
import torch
import numpy as np
import skimage.io as io
from typing import Tupleinstance_mask: np.ndarray = io.imread('path/to/your/image.tif') ## shape: [X, Y, Z], dtype: np.uint32
instance_mask: torch.Tensor = torch.from_numpy(instance_mask)
instance_mask = instance_mask.to('cuda').unsqueeze(0) ## shape: [C=1, X, Y, Z], dtype: np.uint32, device='cuda'sigma: tuple[float, float, float] = (8., 8., 8.) # Standard deviation affecting shape descriptors.
voxel_size: tuple[int, int, int] = (1, 1, 5) ## Relative voxel anisotropy. In this case, Z is 5 time spatially larger than X and Y# LSD will return a 4D Tensor with shape [C=10, X, Y, Z], dtype=torch.float, device=instance_mask.device
local_shape_descriptors: torch.Tensor = lsd(segmentation=instance_mask, sigma=sigma, voxel_size=voxel_size)
```