File size: 1,049 Bytes
8f6f117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Bake a synthetic noisy calcium movie + clean ground-truth sidecar.

The noisy movie (Poisson shot + Gaussian read noise) is the /process input; the
clean movie is saved as example_clean.npy so PSNR/SSIM can be computed. No
external data dependence — this doubles as the smoke/validator input.
"""
from __future__ import annotations

import sys

import numpy as np
import tifffile

from core.io import APP_TMP_DIR, register_protected
from core.synth import add_noise, clean_movie


def main() -> int:
    clean = clean_movie(T=120, H=96, W=96, n_neurons=10, fps=10.0, seed=7)
    noisy = add_noise(clean, gain=0.15, read_sigma=180.0, seed=7)

    out = APP_TMP_DIR / "example.tif"
    tifffile.imwrite(out, noisy.astype("float32"))
    np.save(APP_TMP_DIR / "example_clean.npy", clean.astype("float32"))  # GT sidecar
    register_protected(out)
    register_protected(APP_TMP_DIR / "example_clean.npy")
    print(f"wrote {out}  shape={noisy.shape}  (+ example_clean.npy sidecar)")
    return 0


if __name__ == "__main__":
    sys.exit(main())