Page MenuHomec4science

div_thresh_overlay.py
No OneTemporary

File Metadata

Created
Sun, Nov 10, 23:20

div_thresh_overlay.py

from skimage import io
import numpy as np
import cv2
#path = 'div_2_170608_fly1_007/div_l1000g0'
#path = 'div_4_170609_fly1_000/div_l1000g0'
path = 'div_1_170426_fly1_013/div_l1000g0'
paths = ['/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l100g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l200g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l300g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l400g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l500g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l600g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l700g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l800g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l900g10',
'/mnt/internal_hdd/aymanns/Chen2018/divergence/div_2_170608_fly1_007/div_l1000g10']
for path in paths:
div = io.imread(path+'/div_out.tif')
#wapred1 = io.imread(path+'/warped1.tif')
mask = np.where(div<-1.2)
z = np.zeros(div.shape,dtype=np.uint8)
z[mask] = 255
io.imsave(path+'/thresh_div.tif',z.astype(np.float32))
artefact = False
for i in range(len(z)):
#print(z[i])
output = cv2.connectedComponentsWithStats(z[i],8,cv2.CV_32S)
#print(output[2])
stats = output[2]
if np.any(stats[1:,cv2.CC_STAT_AREA]>20):
print(i,stats)
artefact = True
break
print(path,artefact)

Event Timeline