You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm generating a movie of synthetic calcium data (either as uint8 or float), in Windows 10 (note: subsequently confirmed on Ubuntu so this doesn't seem to be an OS-specific thing), and things are looking weird. Note code examples to reproduce are all below.
I roughly expect it to look like this (created using opencv, saved from uint8):
opencv_save.mp4
When a component is activated, it is bright, and then activity slowly decays. And each component is a 2d Gaussian, so has a bright center that gradually falls off as you move off from its center.
Using fastplotlib, the way it looks when I view with slider as original float data:
recreate_float.mp4
The way it looks as uint8 from fastplotlib:
recreate_uint8.mp4
This is better in the sense of no strange balloon artifacts, but still binarized (note it's qualitatively the same when cmap is gray, but I used viridis here it doesn't matter for the effect).
I've confirmed this on another Windows machine, and same behavior on Ubuntu 20.04.
Code
Create movie array
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal
# set up gaussians centered at component_centers
num_frames = 1000
image_size = 200
frame_shape = np.array([image_size, image_size])
component_centers = np.array([[40, 40],
[110, 90],
[180, 55],
[60, 135],
[140, 140]]);
num_components = component_centers.shape[0]
# create component images: stack of images one for ech component
sigma = 20
x, y = np.meshgrid(np.arange(0, image_size),
np.arange(0, image_size))
pos = np.dstack((x, y))
component_sigma = np.array([[sigma, 0],[0, sigma]])
component_images = []
for component_num in np.arange(num_components):
component_mean = component_centers[component_num]
gauss_rep = multivariate_normal(component_mean, component_sigma)
gauss_img = gauss_rep.pdf(pos)
component_images.append(gauss_img)
component_images = np.array(component_images)
# generate traces
tau = 10
max_amp = 255 # just to make saving as uint8 in opencv simple
amps_all = []
for component_num in np.arange(num_components):
amps = []
amp = 0
for time_step in np.arange(num_frames):
if np.random.uniform(0,1) > 0.98:
amp = max_amp
else:
amp = np.max(np.array([amp - amp/tau, 0]));
amps.append(amp)
amps = np.array(amps)
amps_all.append(amps)
amps_all = np.array(amps_all)
# create movie
movie = np.zeros((num_frames, image_size, image_size))
for frame_num in np.arange(num_frames):
component0 = amps_all[0][frame_num]*component_images[0]
component1 = amps_all[1][frame_num]*component_images[1]
component2 = amps_all[2][frame_num]*component_images[2]
component3 = amps_all[3][frame_num]*component_images[3]
component4 = amps_all[4][frame_num]*component_images[4]
movie[frame_num] = component0 + component1 + component2 + component3 + component4
I'm generating a movie of synthetic calcium data (either as
uint8
orfloat
), in Windows 10 (note: subsequently confirmed on Ubuntu so this doesn't seem to be an OS-specific thing), and things are looking weird. Note code examples to reproduce are all below.I roughly expect it to look like this (created using opencv, saved from
uint8
):opencv_save.mp4
When a component is activated, it is bright, and then activity slowly decays. And each component is a 2d Gaussian, so has a bright center that gradually falls off as you move off from its center.
Using fastplotlib, the way it looks when I view with slider as original float data:
recreate_float.mp4
The way it looks as uint8 from fastplotlib:
recreate_uint8.mp4
This is better in the sense of no strange balloon artifacts, but still binarized (note it's qualitatively the same when cmap is
gray
, but I usedviridis
here it doesn't matter for the effect).I've confirmed this on another Windows machine, and same behavior on Ubuntu 20.04.
Code
Create movie array
Show in fastplotlib (as float)
Save using opencv
Show uint8 version in fastplotlib
The text was updated successfully, but these errors were encountered: