Skip to content
Permalink
a45ad1bad6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
94 lines (78 sloc) 1.92 KB
using Images, QuartzImageIO, FileIO, ProgressMeter
#using ImageView
function alignstack(img,dx,dy)
(xn, yn, zn) = size(img)
img_m = zeros(xn+zn*dx,yn+zn*dy,zn)
fill!(img_m, NaN)
for z = 1:zn
yaxi = 1:yn
yaxi = yaxi+(zn-z+1)*dy
xaxi = 1:xn
xaxi = xaxi+(zn-z+1)*dx
img_m[xaxi,yaxi,z]=img[:,:,z]
end
return img_m
end
function rm_na(img)
x=copy(img)
x[isnan.(x)]=0
img=x
return img
end
function rm_bad(img)
f(img)=img<0.29
mask = map(f,img[:,:,1])
sum(mask)
mask1 = Integer.(mask)
img = Array(img)
img_rm=img.*mask1
return img_rm
end
print("Date: ")
date=chomp(readline())
#date="10-28"
#filename="tim-a1T-0-0"
cd("/Volumes/")
files=readdir()
disk=filter(x->contains(x,"xitong_lab"),files)[1]
cd(@sprintf("/Volumes/%s/ocpi/%s/",disk,date))
files=readdir()
x=filter(x->contains(x,".imagine"),files)
k=1
filename=x[k][1:end-8]
exp = load(@sprintf("%s.imagine", filename))
# z = size(exp,3)÷2
# img1 = view(exp,:,:,z+1,1)
# img2 = view(exp,:,:,z,1)
# imgov = colorview(RGB, paddedviews(0, img1, img2, zeroarray)...)
# imshow(imgov)
t = 1
print("time: ")
t=chomp(readline())
t=parse(Int,t)
img1=exp[:,:,:,t]
img3=convert(Array{N0f16}, img1)
img3=colorview(Gray,img3)
QuartzImageIO.save(File{format"TIFF"}(@sprintf("%s-%s.tif", filename,t)), img3)
function drift(dx,dy,zrange=0)
tp=nimages(exp)
if zrange==0
zrange=1:size(exp)[3]
end
add = @sprintf("/Volumes/%s/images/%s/%s-%s",disk,date,filename,zrange)
if !isdir(add)
mkpath(add)
end
cd(add)
@showprogress for i in 1:tp
img1 = exp[:,:,zrange,i]
img1 = rm_bad(img1)
imgb = imfilter(img1, (KernelFactors.IIRGaussian(2.0),KernelFactors.IIRGaussian(2.0)));
img2 = alignstack(imgb,dx,dy)
img2 = rm_na(img2)
img3 = convert(Array{N0f16}, img2)
img3 = mapslices(maximum, img3, 3)
img3 = colorview(Gray,img3)
QuartzImageIO.save(File{format"TIFF"}(@sprintf("%s-%i.tif", filename,i)), img3)
end
end