TuragaLab / DECODE

This is the official implementation of our publication "Deep learning enables fast and dense single-molecule localization with high accuracy" (Nature Methods)
GNU General Public License v3.0
95 stars 26 forks source link

Spline breaks with certain image size #187

Closed Haydnspass closed 1 year ago

Haydnspass commented 2 years ago

decode.io.psf.load_spline(p, xextent=(-0.5, 511.5), yextent=(-0.5, 511.5), img_shape=(512, 512), device="cuda:0")

results in


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [26], in <cell line: 1>()
----> 1 f = psf_0.forward(xyz=em_rand.xyz_px, weight=em_rand.phot, frame_ix=em_rand.frame_ix)

File ~/deploy/mac-ries26/decode/decode/simulation/psf_kernel.py:953, in CubicSplinePSF.forward(self, xyz, weight, frame_ix, ix_low, ix_high)
    949 xyz_r = self.coord2impl(xyz_r)
    951 n_frames = ix_high - ix_low
--> 953 frames = self._spline_impl.forward_frames(
    954     *self.img_shape,
    955     frame_ix,
    956     n_frames,
    957     xyz_r[:, 0],
    958     xyz_r[:, 1],
    959     xyz_r[:, 2],
    960     ix[:, 0],
    961     ix[:, 1],
    962     weight,
    963 )
    965 frames = torch.from_numpy(frames).reshape(n_frames, *self.img_shape)
    966 return frames

ValueError: negative dimensions are not allowed
Haydnspass commented 1 year ago

It seems to be a too large array. Currently we only capture too many emitters, but not too large frame. Implement similarly to roi_chunk, frame_chunk. But here instead of adding up frames per iteration, cat frames.