Commit f37acf43 authored by Edward Andò's avatar Edward Andò
Browse files

this morning's work

parent 13eff767
......@@ -62,7 +62,16 @@ Todo next in the Alps
- Don't forget the calibration sphere
- No need to do a noise-scan, but a sample rotation (in a cylindrical holder) would be good
- Attempt to measure L vs I/I0 directly on a tomopack reconstruction
-> Recognise 3D positions from tomopack-scan
- assemble ψ-scan
- run ψ-scan on the centred ψ-image to get fXseries and compute characteristic template for one particle
- chop this off on detector and in X-direction and save this as a convolution kernel
- run ψ-scan on real pack of spheres to get fXseries, and run kernel on it
- threshold centres, that's your 3D reconstruction!
-> compute P (in mm) and plot, for (every?) pixel on the detector P vs I/I0
-> Fit attenuation (hopefully a nice line) and look at fitting residuals on the detector
-> do optimisation in greylevels to avoid ln(I/I0)
-> party
Installing radioSphere
-----------------------
......
......@@ -29,31 +29,36 @@ files = sorted(glob.glob("./data/2021-05-07-EPFL/03-scan/*.tiff"))
psiXseries = numpy.zeros((len(files), I0_for_psi.shape[0], I0_for_psi.shape[1]), dtype=float)
CORxPositions = numpy.zeros(len(files))
for n in range(len(files)):
CORxPositions[n] = -float(files[n][-11:-5]) + 13.91 # could be going the wrong way?
#SOD = 34.5615 but the system is at -20.65 in the centre
# load data, normalise, and crop
tmp = (tifffile.imread(files[n]) / I0_for_psi)
### What should be done now: Take particle centre, do a radial reslice around there,
# average the angles (avoiding the base) and produce a smoothed radio
label = skimage.measure.label(tmp < 0.92)
props = sorted(skimage.measure.regionprops(label),
key=lambda r: r.area,
reverse=True,)
centreYXpx = props[0].centroid
#print(centreYXpx/numpy.array(tmp.shape))
### What we're doing to do: cut the image and half and flip it
assert numpy.allclose(numpy.array([0.5, 0.5]), centreYXpx/numpy.array(tmp.shape), atol=0.01)
# write top
psiXseries[n,0:tmp.shape[0]//2] = tmp[0:tmp.shape[0]//2]
# write bot
psiXseries[n,tmp.shape[0]//2:] = tmp[tmp.shape[0]//2:0:-1]
#psiXseries[n] = ???
if not os.path.isfile("./cache/psiXseries-exp.tif"):
for n in range(len(files)):
# Hacking the displacements hardcoded in filenames into our coordinate system in X
CORxPositions[n] = -float(files[n][-11:-5]) + 13.91 # could be going the wrong way?
#SOD = 34.5615 but the system is at -20.65 in the centre
# load data, normalise
tmp = (tifffile.imread(files[n]) / I0_for_psi)
### What should be done now: Take particle centre, do a radial reslice around there,
# average the angles (avoiding the base) and produce a smoothed radio
label = skimage.measure.label(tmp < 0.92)
props = sorted(skimage.measure.regionprops(label),
key=lambda r: r.area,
reverse=True,)
centreYXpx = props[0].centroid
#print(centreYXpx/numpy.array(tmp.shape))
### What we're doing to do: cut the image and half and flip it
assert numpy.allclose(numpy.array([0.5, 0.5]), centreYXpx/numpy.array(tmp.shape), atol=0.01)
# write top
psiXseries[n,0:tmp.shape[0]//2] = tmp[0:tmp.shape[0]//2]
# write bot
psiXseries[n,tmp.shape[0]//2:] = tmp[tmp.shape[0]//2:0:-1]
#psiXseries[n] = ???
tifffile.imsave(f"./cache/psiXseries-exp.tif", psiXseries.astype('float'))
else:
psiXseries = tifffile.imread(f"./cache/psiXseries-exp.tif")
# crop!
psiXseries = psiXseries[:, radioCrop:-radioCrop]
......@@ -77,7 +82,7 @@ output = radioSphere.detectSpheres.psiSeriesScanTo3DPositions(radio,
scanFixedNumber=nSphere,
sourceDetectorDistMM=384.343,
verbose=True,
pixelSizeMM=0.127*4 # could well be off, to be checked
pixelSizeMM=0.139*4
)
numpy.save("psi-Scan.npy", output)
print(output)
......@@ -356,7 +356,8 @@ def psiSeriesScanTo3DPositions(radio, # not (necessarily) MM
maxIterations=maxIterations,
l=l,
kTrustRatio=kTrustRatio)
tifffile.imsave(cacheFile, fXseries.astype('float'))
print(f"saved {cacheFile}")
#loadedCache = False
#if useCache:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment