<jupyter_start><jupyter_text>Load Data<jupyter_code>from skimage import io
mov = io.imread(filename).transpose([1,2,0])[:60,:60,:]
mov = np.asarray(mov,order='C',dtype=np.float64)
print(mov.shape)

fov_height, fov_width, num_frames = mov.shape<jupyter_output>(60, 60, 2000)<jupyter_text>Load Denoised Data<jupyter_code>data = np.load(os.path.join(ext, "demo_results.npz"))
U = data['arr_0']
V = data['arr_1']
mov_denoised = data['arr_2']
block_ranks = data['arr_3'][()]
block_height = data['arr_4']
block_width = data['arr_5']<jupyter_output><empty_output><jupyter_text>Compress overcomplete movie<jupyter_code>dim1, dim2, ncomp = U.shape
Ur = U.reshape((dim1*dim2, ncomp))
nblocks = [fov_height//block_height, fov_width//block_width]
Ur, V, num_rejected = overlap_reduction.compression_rdx(nblocks, Ur, V, block_ranks)<jupyter_output>Tile 0 from 9
Rejected 94 from 124<jupyter_text>Calculate total rejected components<jupyter_code>trim_idx = np.where(np.all(V==0,1))[0]
print('Total rejected %d out of %d'%(len(trim_idx),V.shape[0]))
Ur = np.delete(Ur, trim_idx, axis=1)
V = np.delete(V, trim_idx, axis=0)
PU = np.linalg.pinv(Ur)
VPU = PU.dot(mov_denoised.reshape(fov_height*fov_width,num_frames))
mov_reduced = np.dot(Ur, VPU).reshape((fov_height,fov_width,num_frames))<jupyter_output><empty_output><jupyter_text>Produce Diagnostics  Correlation Images<jupyter_code>util_plot.comparison_plot([mov, mov_denoised + np.random.randn(np.prod(mov.shape)).reshape(mov.shape)*.01],
                plot_orientation="vertical")
util_plot.comparison_plot([mov, mov_reduced + np.random.randn(np.prod(mov.shape)).reshape(mov.shape)*.01],
                plot_orientation="vertical")<jupyter_output>Local correlation:  range [2.1e-01 9.3e-01]
Local correlation:  range [5.9e-01 1.0e+00]
Local correlation:  range [-2.2e-01 2.6e-01]<jupyter_text>Render Videos & Residual<jupyter_code>play_cv2(np.vstack([mov, mov_reduced, mov-mov_reduced]), magnification=2)<jupyter_output><empty_output><jupyter_text>Save Results<jupyter_code>np.savez(os.path.join(ext, "demo2_results.npz"), U, V, mov_denoised, block_ranks, block_height, block_width)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15606130980027869, 'fraction_numerical': 0.03297724105898746, 'mean_word_length': 7.937759336099585, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '173167', 'license': 'MIT', 'n_tokens_mistral': 922, 'n_tokens_neox': 868, 'n_words': 119, 'path': 'demos/Demo Reduction.ipynb', 'repo_name': 'apasarkar/funimag', 'size': '2153'}