tf.config.set_visible_devices([], 'GPU') start = time.time() refX = tf.cast(tf.linspace(-2., 2., 5), tf.float32) refY = tf.cast(tf.linspace(-2., 2., 5), tf.float32) refXX, refYY = tf.meshgrid(refX, refY, indexing='ij') refShifts = tf.stack([tf.reshape(refXX, [-1]), tf.reshape(refYY, [-1])], 1) #refShifts = tf.cast(tf.constant([[0., 0.]]), tf.float32) #%% generate USAF parametersUSAF = MuScatParameters( 0.650, # wavelength in vacuum [1, 90, 90], # gridSize [z, x ,y] 0.3, # dx 0.3, # dy 0.25, # dz 1.4881, # refractive index in medium 0.5, # NAc 0.5) # NAo USAFObject = MuScatObject(parametersUSAF) usaf = np.loadtxt('USAF.csv', delimiter=',') usafPart = usaf[-100:-10, -91:-1] USAFObject.RIDistrib = tf.cast( tf.reshape(tf.constant(usafPart[::1, ::1] * (1 - USAFObject.refrIndexM)), USAFObject.gridSize), tf.float32) #%% generate random thick layer parametersRandLay = MuScatParameters( 0.650, # wavelength in vacuum [1, 90, 90], # gridSize [z, x ,y]
#%% Load data start = time.time() zStackMeasured = np.array(scipy.io.loadmat(r'twoBeads1.mat')['croppedBeads']) zStackMeasured *= 1 / 6000 zStackMeasured = np.transpose(zStackMeasured, [2, 0, 1]) zStackMeasured = zStackMeasured[:, ::3, ::3] zStckShape = zStackMeasured.shape zStackMeasured = tf.reshape(tf.constant(zStackMeasured), [1, zStckShape[0], zStckShape[1], zStckShape[2]]) #%% parameters = MuScatParameters( 0.650, # wavelength in vacuum [305, zStckShape[1], zStckShape[2]], # gridSize [z, x ,y] 0.47, # dx 0.47, # dy 0.3, # dz 1.5, # refractive index in medium 0.5, # NAc 0.95) # NAo regLambdaL1 = 0.001 regLambdaL2 = 0.0000 #1 learnRate = 0.01 refShifts = tf.cast(tf.constant([[0., 0.]]), tf.float32) imagingSim = MuScatMicroscopeSim(parameters) imagingSim.Illumination() imagingSim.Detection() print(time.time() - start)
from MuScatObject import MuScatObject from MuScatParameters import MuScatParameters from MuScatMicroscopeSim import MuScatMicroscopeSim import tensorflow as tf import time import numpy as np import matplotlib.pyplot as plt tf.config.set_visible_devices([], 'GPU') # remove in Google Colab start = time.time() parameters = MuScatParameters( 0.650, # wavelength in vacuum [50, 32, 32], # gridSize [z, x ,y] 0.3, # dx 0.3, # dy 0.3, # dz 1.5, # refractive index in medium 0.9, # NAc 0.95) # NAo regLambdaL1 = 0.0001 regLambdaL2 = 0.001 learnRate = 0.01 imagedObject = MuScatObject(parameters) imagedObject.GenerateTwoBeads(2., 6., 1.52) imagingSim = MuScatMicroscopeSim(parameters) imagingSim.Illumination() imagingSim.Detection() zPositions = imagedObject.realzzz[:, 0, 0] - imagedObject.realzzz[0, 0, 0]
from MuScatObject import MuScatObject from MuScatField import MuScatField from MuScatParameters import MuScatParameters from MuScatMicroscopeSim import MuScatMicroscopeSim import matplotlib.pyplot as plt import tensorflow as tf import tensorflow_addons as tfa import time import numpy as np tf.config.set_visible_devices([], 'GPU') # %% start = time.time() parameters = MuScatParameters(lambda0=0.650, # wavelength in vacuum gridSize=[50, 32, 32], # gridSize [z, x ,y] dx=0.45, # dx dy=0.45, # dy dz=0.3, # dz refrIndexM=1.5, # refr index in medium NAc=0.5, # NAc NAo=0.5) # NAo centerInd = np.int32(parameters.gridSize[1] / 2) regLambdaL1 = 0.0001 regLambdaL2 = 0.000 learnRate = 0.01 refShifts = tf.cast(tf.constant([[0., 0.]]), tf.float32) imagedObject = MuScatObject(parameters) # imagedObject.GenerateBox(4., 4., 4., 1.52) imagedObject.GenerateBead(3., 1.52) # imagedObject.GenerateSheppLogan(1.55) imagingSim = MuScatMicroscopeSim(parameters)