def pre_process(self): in_pData = self.get_plugin_in_datasets()[0] data = self.get_in_datasets()[0] dict_entry = data.get_name() + '_preview_starts' shift = self.exp.meta_data.get(dict_entry) det_y = data.get_data_dimension_by_axis_label('detector_y') det_x = data.get_data_dimension_by_axis_label('detector_x') # If the data is cropped then the centre of distortion must be shifted # accordingly, e.g if preview is [:, a:b, c:d] then shift is (a, c) centre = np.array( [self.parameters['centre_x'], self.parameters['centre_y']]) centre[0] -= shift[det_y] centre[1] -= shift[det_x] # flipping the values centre = centre[::-1] # pass two empty arrays of frame chunk size unwarp.setcoeff(*self.parameters['polynomial_coeffs']) unwarp.setctr(*centre) plugin_data_shape = in_pData.get_shape() temp_array = np.empty(plugin_data_shape, dtype=np.float32) unwarp.setup(temp_array, temp_array) self.new_slice = [slice(None)] * 3 orig_shape = self.get_in_datasets()[0].get_shape() for ddir in self.core_dims: self.new_slice[ddir] = \ slice(self.crop, orig_shape[ddir]-self.crop)
def pre_process(self): in_pData = self.get_plugin_in_datasets()[0] data = self.get_in_datasets()[0] name = data.get_name() shift = self.exp.meta_data.get(name + '_preview_starts') step = self.exp.meta_data.get(name + '_preview_steps') det_y = data.get_data_dimension_by_axis_label('detector_y') det_x = data.get_data_dimension_by_axis_label('detector_x') # check stepping as should not be > 1 self.step_check = \ True if max([step[i] for i in [det_y, det_x]]) > 1 else False # If the data is cropped then the centre of distortion must be shifted # accordingly, e.g if preview is [:, a:b, c:d] then shift is (a, c) centre = np.array([self.parameters['centre_from_left'], self.parameters['centre_from_top']]) centre[0] -= shift[det_x] centre[1] -= shift[det_y] # pass two empty arrays of frame chunk size unwarp.setcoeff(*self.parameters['polynomial_coeffs']) unwarp.setctr(*centre) plugin_data_shape = in_pData.get_shape() temp_array = np.empty(plugin_data_shape, dtype=np.float32) unwarp.setup(temp_array, temp_array) self.new_slice = [slice(None)]*3 orig_shape = self.get_in_datasets()[0].get_shape() for ddir in self.core_dims: self.new_slice[ddir] = \ slice(self.crop, orig_shape[ddir]-self.crop)
def pre_process(self): centre = np.array(self.parameters['centre']) centre[0] -= self.parameters['shift'][0] centre[1] -= self.parameters['shift'][1] # flipping the values centre = centre[::-1] #pass two empty arrays of frame chunk size unwarp.setcoeff(*self.parameters['polynomial_coeffs']) unwarp.setctr(*centre) plugin_data_shape = self.get_plugin_in_datasets()[0].get_shape() temp_array = np.empty(plugin_data_shape, dtype=np.float32) unwarp.setup(temp_array, temp_array) self.new_slice = [slice(None)]*3 orig_shape = self.get_in_datasets()[0].get_shape() for ddir in self.core_dir: self.new_slice[ddir] = \ slice(self.crop, orig_shape[ddir]-self.crop)
def pre_process(self): centre = np.array(self.parameters['centre']) centre[0] -= self.parameters['shift'][0] centre[1] -= self.parameters['shift'][1] # flipping the values centre = centre[::-1] #pass two empty arrays of frame chunk size unwarp.setcoeff(*self.parameters['polynomial_coeffs']) unwarp.setctr(*centre) plugin_data_shape = self.get_plugin_in_datasets()[0].get_shape() temp_array = np.empty(plugin_data_shape, dtype=np.float32) unwarp.setup(temp_array, temp_array) self.slice_list = [slice(None)]*3 orig_shape = self.get_in_datasets()[0].get_shape() for ddir in self.core_dir: self.slice_list[ddir] = \ slice(self.crop, orig_shape[ddir]-self.crop)
def pre_process(self): in_pData = self.get_plugin_in_datasets()[0] data = self.get_in_datasets()[0] name = data.get_name() shift = self.exp.meta_data.get(name + '_preview_starts') step = self.exp.meta_data.get(name + '_preview_steps') det_y = data.get_data_dimension_by_axis_label('detector_y') det_x = data.get_data_dimension_by_axis_label('detector_x') # check stepping as should not be > 1 self.step_check = \ True if max([step[i] for i in [det_y, det_x]]) > 1 else False # If the data is cropped then the centre of distortion must be shifted # accordingly, e.g if preview is [:, a:b, c:d] then shift is (a, c) centre = np.array([self.parameters['centre_from_left'], self.parameters['centre_from_top']]) centre[0] -= shift[det_x] centre[1] -= shift[det_y] # pass two empty arrays of frame chunk size unwarp.setcoeff(*self.parameters['polynomial_coeffs']) unwarp.setctr(*centre) plugin_data_shape = in_pData.get_shape() temp_array = np.empty(plugin_data_shape, dtype=np.float32) unwarp.setup(temp_array, temp_array) self.new_slice = [slice(None)] * 3 orig_shape = self.get_in_datasets()[0].get_shape() for ddir in self.core_dims: self.new_slice[ddir] = \ slice(self.crop, orig_shape[ddir] - self.crop)
def get_image_array(): global nbatch #inim=np.expand_dims(tifffile.imread("index-1.tif"),0) #inim=np.expand_dims(tifffile.imread("p_00600.tif"),0) inim=np.expand_dims(tifffile.imread("i32.tif"),0) inimt=np.tile(inim,(nbatch,1,1)) inim3=np.ascontiguousarray(inimt.astype(np.float32)) print "shape: ",inim3.shape outim=np.empty_like(inim3) return(inim3,outim) #end of get_image_array (inarray,outarray)=get_image_array() #set the coefficients -- this coudl be rolled into setup with additional args? unwarp.setcoeff(1,-1e-3,-6e-7,5e-10,-4e-13) unwarp.setctr(1000,1000) #call setup routine unwarp.setup(inarray,outarray) unwarp.run(inarray,outarray) #multiple calls so long as centre and parameters are fixed #could be different data solong as it is same type/size/etc unwarp.run(inarray,outarray) unwarp.cleanup() print("Writing the files to /dls/i12/data/2015/cm12163-5/tmp/unwarptest/cython_out") try: