def loadmat(self, experiments): # Cast the parameter-mat file into a python class self.matpath = experiments.matlab_par_filename self.matname = experiments.matlab_par_name myParamter = data.import_parameters_mat(filename = self.matpath, matname = self.matname) # ASsign variables from Experiment self.lambda0 = np.squeeze(np.array(myParamter.get('lambda0'))) # free space wavelength (µm) self.NAo= np.squeeze(np.array(myParamter.get('NAo'))); # Numerical aperture objective self.NAc= np.squeeze(np.array(myParamter.get('NAc'))); # Numerical aperture condenser try: self.NAci = np.squeeze(np.array(myParamter.get('NAci')[0])); # Numerical aperture condenser except: print('No inner NA has been defined!') self.NAci = None if self.NAci == None: try: self.NAci = np.squeeze(np.array(experiments.NAci)); # Numerical aperture condenser except: print('No inner NA has been defined!') self.NAci = self.NAc # eventually decenter the illumination source - only integer! self.shiftIcX = 0#int(np.squeeze(np.array(myParamter.get('shiftIcX')))) self.shiftIcY = 0#int(np.squeeze(np.array(myParamter.get('shiftIcY')))) self.nEmbb = np.squeeze(np.array(myParamter.get('nEmbb'))) self.dn=.1; # self.nImm - self.nEmbb print('Assigned some value for dn which is not good!') # calculate pixelsize self.dx = np.double(np.squeeze(np.array(myParamter.get('dx')))) self.dy = np.double(np.array(myParamter.get('dy'))) self.dz = np.double(np.array(myParamter.get('dz'))) # Sampling coordinates self.Rsim= 0.5*np.double(np.array(myParamter.get('Nx')))*self.dx; # Radius over which simulation is performed. self.Nz=int(np.double(np.array(myParamter.get('Nz')))) self.Nx=np.int(np.floor((2*self.Rsim)/self.dx)); self.Ny=np.int(np.floor((2*self.Rsim)/self.dy)) self.mysize = (self.Nz,self.Nx,self.Ny) # ordering is (Nillu, Nz, Nx, Ny) self.shiftIcY=experiments.shiftIcY self.shiftIcX=experiments.shiftIcX self.dn = experiments.dn self.NAc = experiments.NAc self.zernikefactors = experiments.zernikefactors self.zernikemask = experiments.zernikemask self.Nzernikes = np.squeeze(self.zernikefactors.shape) self.is_mictype = experiments.is_mictype
def loadmat(self, mymatpath='./Data/DROPLETS/S19_multiple/Parameter.mat', mymatname='myParameter'): # Cast the parameter-mat file into a python class self.matpath = mymatpath self.matname = mymatname myParamter = data.import_parameters_mat(filename=self.matpath, matname=self.matname) # ASsign variables from Experiment self.lambda0 = np.squeeze(np.array( myParamter.get('lambda0'))) # free space wavelength (µm) self.NAo = np.squeeze(np.array(myParamter.get('NAo'))) # Numerical aperture objective self.NAc = np.squeeze(np.array(myParamter.get('NAc'))) # Numerical aperture condenser self.NAci = np.squeeze(np.array(myParamter.get('NAci'))) # Numerical aperture condenser # eventually decenter the illumination source - only integer! self.shiftIcX = 0 #int(np.squeeze(np.array(myParamter.get('shiftIcX')))) self.shiftIcY = 0 #int(np.squeeze(np.array(myParamter.get('shiftIcY')))) self.nEmbb = np.squeeze(np.array(myParamter.get('nEmbb'))) self.dn = .1 # self.nImm - self.nEmbb print('Assigned some value for dn which is not good!') # calculate pixelsize self.dx = np.double(np.squeeze(np.array(myParamter.get('dx')))) self.dy = np.double(np.array(myParamter.get('dy'))) self.dz = np.double(np.array(myParamter.get('dz'))) # Sampling coordinates self.Rsim = 0.5 * np.double(np.array(myParamter.get('Nx'))) * self.dx # Radius over which simulation is performed. self.Nz = int(np.double(np.array(myParamter.get('Nz')))) self.Nx = np.int(np.floor((2 * self.Rsim) / self.dx) + 1) self.Ny = np.int(np.floor((2 * self.Rsim) / self.dy) + 1)
is_padding = False # better don't do it, some normalization is probably incorrect is_display = True is_optimization = False is_optimization_psf = False is_flip = False is_measurement = False mysubsamplingIC=0 psf_modell ='corr'#'corr' # None # 'sep' tf.reset_default_graph() ''' File which stores the experimental parameters from the Q-PHASE setup 1.) Read in the parameters of the dataset ''' matlab_par_name = 'myParameter' #'./Data/DROPLETS/myParameterNew.mat';matname='myParameterNew' #'./Data/DROPLETS/myParameterNew.mat' matlab_par_file = './Data/DROPLETS/S19_multiple/Parameter.mat'; matname='myParameter' matlab_pars = data.import_parameters_mat(filename = matlab_par_file, matname=matlab_par_name) ''' Create the Model''' muscat = mus.MuScatModel(matlab_pars, is_optimization=is_optimization) muscat.Nx,muscat.Ny = int(np.squeeze(matlab_pars['Nx'].value)), int(np.squeeze(matlab_pars['Ny'].value)) zernikefactors = np.array((0,0,0,0,0,0,0,0,0.0,0.0,0.0)) # 7: ComaX, 8: ComaY, 11: Spherical Aberration zernikemask = np.array(np.abs(zernikefactors)>0)*1#!= np.array((0, 0, 0, 0, 0, 0, , 1, 1, 1, 1))# mask which factors should be updated muscat.shiftIcX = 0 # has influence on the XZ-Plot - negative values shifts the input wave (coming from 0..end) to the left muscat.shiftIcY = 0 # has influence on the YZ-Plot - negative values shifts the input wave (coming from 0..end) to the left muscat.NAc = .1 muscat.NAo = .95 dn = .105 #(1.437-1.3326)#/np.pi myfac = 1 #- 1e-6
my_learningrate = 1e-2 # learning rate lambda_tv = 1e-5 # lambda for Total variation lambda_gr = 0 # lambda for Goods Roughness lambda_pos = 10 lambda_neg = 10 Niter = 5000 Ndisplay = 10 '''START CODE''' tf.reset_default_graph() # just in case there was an open session ''' File which stores the experimental parameters from the Q-PHASE setup 1.) Read in the parameters of the dataset ''' matlab_pars = data.import_parameters_mat(filename = matlab_par_file, matname='myParameterNew') ''' 2.) Read in the parameters of the dataset ''' if(matlab_val_file.find('mat')==-1): matlab_val = np.load(matlab_val_file) else: matlab_val = data.import_realdata_h5(filename = matlab_val_file, matname='allAmp_red', is_complex=True) if(is_flip): np_meas = np.flip(matlab_val,0) print('Attention: We are flipping the data!') else: np_meas = matlab_val print('do we need to flip the data?! -> Observe FFT!!')
mpl.rc('figure', figsize=(12, 9)) mpl.rc('image', cmap='gray') #%% '''Define some stuff related to infrastructure''' mytimestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') basepath = './' #'/projectnb/cislidt/diederich/muScat/Multiple-Scattering_Tensorflow/' resultpath = 'Data/DROPLETS/RESULTS/' # optional - reset tensorflow graph tf.reset_default_graph() # Generate Test-Object ''' File which stores the experimental parameters from the Q-PHASE setup 1.) Read in the parameters of the dataset ''' matlab_pars = data.import_parameters_mat(filename=experiments.matlab_par_file, matname=experiments.matlab_par_name) ''' 2.) Read in the parameters of the dataset ''' if (experiments.matlab_val_file.find('mat') == -1): matlab_val = np.load(experiments.matlab_val_file) + 1j else: matlab_val = data.import_realdata_h5(filename=experiments.matlab_val_file, matname=experiments.matlab_val_name, is_complex=True) # Make sure it's even numberalong Z if (np.mod(matlab_val.shape[0], 2) == 1): matlab_val = matlab_val[0:matlab_val.shape[0] - 1, :, :] matlab_val = (matlab_val) # - .6j matlab_val = matlab_val[:, 0:50, 0:50] ''' Create the Model''' muscat = mus.MuScatModel(matlab_pars, is_optimization=True)