torchreg

Lightweight image registration library using PyTorch

https://github.com/codingfisch/torchreg

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.3%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Lightweight image registration library using PyTorch

Basic Info
  • Host: GitHub
  • Owner: codingfisch
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 1.43 MB
Statistics
  • Stars: 26
  • Watchers: 2
  • Forks: 4
  • Open Issues: 0
  • Releases: 1
Created almost 3 years ago · Last pushed about 1 year ago
Metadata Files
Readme License Citation

README.md

torchreg

torchreg is a tiny (~300 lines) PyTorch-based library for 2D and 3D image registration.

Usage

Affine Registration of two image tensors is done via: ```python from torchreg import AffineRegistration

Load images as torch Tensors

bigalice = ... # Tensor with shape [1, 3 (color channel), 1024 (pixel), 1024 (pixel)] smallalice = ... # Tensor with shape [1, 3 (color channel), 1024 (pixel), 1024 (pixel)]

Intialize AffineRegistration

reg = AffineRegistration(is_3d=False)

Run it!

movedalice = reg(bigalice, small_alice) ```

Features

Multiresolution approach to save compute (per default 1/4 + 1/2 of original resolution for 500 + 100 iterations) python reg = AffineRegistration(scales=(4, 2), iterations=(500, 100)) Choosing which operations (translation, rotation, zoom, shear) to optimize python reg = AffineRegistration(with_zoom=False, with_shear=False) Custom initial parameters python reg = AffineRegistration(zoom=torch.Tensor([[1.5, 2.]])) Custom dissimilarity functions and optimizers ```python def dice_loss(x1, x2): dim = [2, 3, 4] if len(x2.shape) == 5 else [2, 3] inter = torch.sum(x1 * x2, dim=dim) union = torch.sum(x1 + x2, dim=dim) return 1 - (2. * inter / union).mean()

reg = AffineRegistration(dissimilarityfunction=diceloss, optimizer=torch.optim.Adam) CUDA support (NVIDIA GPU) python movedalice = reg(moving=bigalice.cuda(), static=small_alice.cuda()) ```

After the registration is run, you can apply it to new images (coregistration) python another_moved_alice = reg.transform(another_alice, shape=(256, 256)) with desired output shape.

You can access the affine python affine = reg.get_affine() and the four parameters (translation, rotation, zoom, shear) python translation = reg.parameters[0] rotation = reg.parameters[1] zoom = reg.parameters[2] shear = reg.parameters[3]

Installation

bash pip install torchreg

Examples/Tutorials

There are three example notebooks:

Background

If you want to know how the core of this package works, read the blog post!

TODO

  • [ ] Add 2D support to SyN, NCC and LinearElasticity
  • [ ] Add tests for SyN

Owner

  • Login: codingfisch
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Fisch"
  given-names: "Lukas"
title: "torchreg - Lightweight image registration library using PyTorch"
version: 0.0.1
#doi: 10.5281/zenodo.1234
date-released: 2023-08-23
url: "https://github.com/codingfisch/torchreg"

GitHub Events

Total
  • Watch event: 7
  • Push event: 2
  • Create event: 1
Last Year
  • Watch event: 7
  • Push event: 2
  • Create event: 1

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: 13 days
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Nilser3 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 132 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 5
  • Total maintainers: 1
pypi.org: torchreg

Lightweight image registration library using PyTorch

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 132 Last month
Rankings
Dependent packages count: 7.6%
Average: 38.5%
Dependent repos count: 69.5%
Maintainers (1)
Last synced: 11 months ago