Skip to content

Commit

Permalink
Merge pull request #17 from rhoitink/cupy-integration
Browse files Browse the repository at this point in the history
Cupy integration (experimental)
  • Loading branch information
rhoitink authored Mar 20, 2024
2 parents 5b6d875 + a863b84 commit 233f704
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 9 additions & 5 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Simulated Microscopy
message: >-
If you use this software, please cite it using the
metadata from this file.
title: >-
Simulated Microscopy: A Python Package for Simulation of
Confocal Microscopy Data based on Particle Coordinates
message: 'If you use this software, please cite using the Zenodo DOI.'
type: software
authors:
- given-names: Leroy Daniël
Expand All @@ -15,6 +15,10 @@ authors:
Soft Condensed Matter & Biophysics, Debye Institute
for Nanomaterials Science, Utrecht University
orcid: 'https://orcid.org/0000-0002-3470-0078'
identifiers:
- type: doi
value: 10.5281/zenodo.10678180
description: Zenodo
repository-code: 'https://github.com/rhoitink/simulatedmicroscopy'
url: 'https://rhoitink.github.io/simulatedmicroscopy/'
abstract: >-
Expand All @@ -28,5 +32,5 @@ keywords:
- point spread function
- image generation
license: MIT
version: "v1.6.1"
version: v1.6.1
date-released: '2024-02-19'
19 changes: 15 additions & 4 deletions src/simulatedmicroscopy/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import h5py
import numpy as np
import scipy.signal
import skimage.measure

from .input import Coordinates
Expand Down Expand Up @@ -419,9 +418,21 @@ def convolve(self, other: type[Image]) -> type[Image]:
"Cannot convolve images with different pixel sizes"
)

self.image = scipy.signal.convolve(
self.image, other.image, mode="same"
)
try:
import cupy as cp
from cupyx.scipy import signal as cusignal

self.image = cusignal.fftconvolve(
cp.asarray(self.image), cp.asarray(other.image), mode="same"
).get()
except ImportError:
# resort to scipy if cupy is not available

import scipy.signal

self.image = scipy.signal.convolve(
self.image, other.image, mode="same"
)

self.is_convolved = True
self.metadata["is_convolved"] = True
Expand Down

0 comments on commit 233f704

Please sign in to comment.