an.org 8.0 KB

poetry run emacs an.org

import tifffile as tff
import numpy as np
import aicsimageio
import matplotlib.pyplot as plt
import seaborn as sb
import impy
from pathlib import Path
import skimage
import scipy
import imageio
import pandas as pd

initial thumb folder clean up

cd "/home/dati/dt-evolv/data/2022-11-16/13401/TimePoint_1"
cd "/home/dati/dt-evolv/data/2022-11-16/13401/TimePoint_1"
mkdir -p thumbs
fd _thumb -0 | xargs -0 mv -t ./thumbs
pwd

single image test

cd "/home/dati/dt-evolv/data/2022-11-16/13401/TimePoint_1"
fp2 = "/home/dati/dt-evolv/data/2022-11-16/13401/TimePoint_1/6w-20Xph1-SpikeTest6-DA_A01_s1_w2B3DEDFEB-FB52-4D83-8176-CC090AD62AC4.tif"
fp1 = "/home/dati/dt-evolv/data/2022-11-16/13401/TimePoint_1/6w-20Xph1-SpikeTest6-DA_A01_s1_w19A3DA0A6-B9DD-475E-ABED-27415F9DE6EB.tif"
i1 = impy.imread(fp1)
i2 = impy.imread(fp2)
skimage.io.imshow(i2)

export same as for 2022-06-22

p = Path(".")
out1 = Path("./1024")
out2 = Path("./512")
out1.mkdir()
out2.mkdir()
import utils
p = Path(".")
s_in = ["A01", "B01", "A02", "A03"]
s_out = ["A01", "B01", "A02", "A03"]

for ins, outs in zip(s_in, s_out):
    for i in range(20, 40):
        print(ins, outs, i)
        fp1 = sorted(p.glob(f"**/*{ins}*s{i}_w1*"))[0]
        fp2 = sorted(p.glob(f"**/*{ins}*s{i}_w2*"))[0]
        c1 = tff.imread(fp1)
        c2 = tff.imread(fp2)
        # clip1 = int(utils.bg(c1)[0])
        clip2 = int(utils.bg(c2)[0])
        # c1r = skimage.util.img_as_ubyte(skimage.exposure.rescale_intensity(c1.clip(clip1, c1.max() * 0.95)))
        # c2r = skimage.util.img_as_ubyte(skimage.exposure.rescale_intensity(c2.clip(clip2, c2.max() * 0.95)))
        c1r = skimage.util.img_as_ubyte((c1))
        c2r = skimage.util.img_as_ubyte(skimage.exposure.rescale_intensity(c2.clip(clip2,65000)))
        cc = np.dstack((c2r, c1r, np.zeros_like(c1r)))
        cc = skimage.transform.downscale_local_mean(cc, (4, 4, 1))
        imageio.imwrite(out2 / f"{outs}_s{i}.png", cc)
A01 A01 20
Lossy conversion from float64 to uint8. Range [0.0, 211.5]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 21
Lossy conversion from float64 to uint8. Range [0.0, 189.0625]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 22
Lossy conversion from float64 to uint8. Range [0.0, 212.4375]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 23
Lossy conversion from float64 to uint8. Range [0.0, 173.25]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 24
Lossy conversion from float64 to uint8. Range [0.0, 227.0]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 25
Lossy conversion from float64 to uint8. Range [0.0, 237.25]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 26
Lossy conversion from float64 to uint8. Range [0.0, 190.0]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 27
Lossy conversion from float64 to uint8. Range [0.0, 204.9375]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 28
Lossy conversion from float64 to uint8. Range [0.0, 202.8125]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 29
Lossy conversion from float64 to uint8. Range [0.0, 221.3125]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 30
Lossy conversion from float64 to uint8. Range [0.0, 232.0625]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 31
Lossy conversion from float64 to uint8. Range [0.0, 245.875]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 32
Lossy conversion from float64 to uint8. Range [0.0, 233.75]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 33
Lossy conversion from float64 to uint8. Range [0.0, 183.6875]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 34
Lossy conversion from float64 to uint8. Range [0.0, 220.0]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 35
Lossy conversion from float64 to uint8. Range [0.0, 240.25]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 36
Lossy conversion from float64 to uint8. Range [0.0, 230.875]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 37
Lossy conversion from float64 to uint8. Range [0.0, 228.5]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 38
Lossy conversion from float64 to uint8. Range [0.0, 229.125]. Convert image to uint8 prior to saving to suppress this warning.
A01 A01 39
Lossy conversion from float64 to uint8. Range [0.0, 235.375]. Convert image to uint8 prior to saving to suppress this warning.
B01 B01 20
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [8], in <cell line: 6>()
      7 for i in range(20, 40):
      8     print(ins, outs, i)
----> 9     fp1 = sorted(p.glob(f"**/*{ins}*s{i}_w1*"))[0]
     10     fp2 = sorted(p.glob(f"**/*{ins}*s{i}_w2*"))[0]
     11     c1 = tff.imread(fp1)

IndexError: list index out of range

New export

cd "/home/dati/dt-evolv/data/2022-11-16/13401/TimePoint_1"
p = Path(".")
out2 = Path("./512n")
out2.mkdir()
import utils
p = Path(".")
s_in = ["A01", "B01", "A02", "B02", "A03", "B03"]
s_out = ["A01", "B01", "A02", "B02", "A03", "B03"]

for ins, outs in zip(s_in, s_out):
    print(ins)
    for i in range(1, 901):
        fp1 = sorted(p.glob(f"**/*{ins}*s{i}_w1*"))[0]
        fp2 = sorted(p.glob(f"**/*{ins}*s{i}_w2*"))[0]
        c1 = tff.imread(fp1)
        c2 = tff.imread(fp2)
        c1 = skimage.transform.downscale_local_mean(c1, 4)
        c2 = skimage.transform.downscale_local_mean(c2, 4)
        clip1 = int(np.sum(utils.bg(c1)))
        clip2 = int(np.sum(utils.bg(c2)))
        c1r = skimage.util.img_as_ubyte(skimage.exposure.rescale_intensity(c1.clip(clip1, c1.max() * 0.95)))
        c2r = skimage.util.img_as_ubyte(skimage.exposure.rescale_intensity(c2.clip(clip2, c2.max() * 0.95)))
        cc = np.dstack((c2r, c1r, np.zeros_like(c1r)))
        imageio.imwrite(out2 / f"{outs}_s{i}.png", cc)
A01
B01
/home/dan/Sync/tmp/datacode/.venv/lib/python3.10/site-packages/scipy/optimize/_minpack_py.py:476: RuntimeWarning: Number of calls to function has reached maxfev = 1000.
  warnings.warn(errors[info][0], RuntimeWarning)
A02
B02
A03
B03