def locs_glob_map(func, pattern, args=[], kwargs={}, extension=''): ''' Maps a function to localization files, specified by a unix style path pattern. The function must take two arguments: locs and info. It may take additional args and kwargs which are supplied to this map function. A new locs file will be saved if an extension is provided. In that case the mapped function must return new locs and a new info dict. ''' paths = _glob.glob(pattern) for path in paths: locs, info = _io.load_locs(path) result = func(locs, info, path, *args, **kwargs) if extension: base, ext = _ospath.splitext(path) out_path = base + '_' + extension + '.hdf5' locs, info = result _io.save_locs(out_path, locs, info)
def load_locs(path): """ Returns localization .hdf5 from picasso as pandas.DataFrame and corresponding .yaml as list of dictionaries. Args: path (str): Path to .hdf5 file as generated by `picasso.localize`_ container (str): Name of dataset within .hdf5 container. Must be set to: * ``'locs'`` for _locs, _render and _picked .hdf5 files as generated by `picasso.render`_. * ``'groups'`` for _pickprops.hdf5 files as generated by `picasso.render`_. * Defaults to ``'locs'``. Returns: tuple: - [0] (pandas.DataFrame): Localizations stored under ``'locs'`` in .hdf5 file - [1] (list): List of dictionaries contained in .yaml corresponding to .hdf5 file """ locs, info = io.load_locs(path) locs = pd.DataFrame(locs) return locs, info
############################################ Set parameters params = {} # params ={'mng':250} #%% ############################################ Main loop paths=[os.path.join(dir_names[i],file_name) for i, file_name in enumerate(file_names)] failed_path=[] for path in paths: ### Try loading movie or localizations try: try: file,info=io.load_movie(path) # Load movie except: file,info=io.load_locs(path) # Load _locs out=localize.main(file,info,path,**params) except Exception: traceback.print_exc() failed_path.extend([path]) print() print('Failed attempts: %i'%(len(failed_path))) #%%
file_names = [] file_names.extend( ['id200_5000pM_p40uW_exp400_1_MMStack_Pos0.ome_locs_render.hdf5']) ############################################ Set parameters params = {'pick_diameter': 10, 'min_n_locs': 5000} #%% failed_path = [] for i in range(0, len(file_names)): ### Create path path = os.path.join(dir_names[i], file_names[i]) ### Run main function try: locs, info = io.load_locs(path) out = autopick.main(locs, info, path, **params) except Exception: traceback.print_exc() failed_path.extend([path]) print() print('Failed attempts: %i' % (len(failed_path))) #%% ############################################ Checkout single files # i=0 # params={'oversampling':5, # 'pick_box':11, # Usually 2*oversampling+1 # 'min_n_locs':225,
file_names = [] file_names.extend([ '04_FOV1_Cy3B_p038uW_R1s1-8-100pM_POC_1_MMStack_Pos0.ome_locs_render.hdf5' ]) file_names.extend([ '09_FOV1_Cy3B_p038uW_R1s1-8-050pM_POC_1_MMStack_Pos0.ome_locs_render.hdf5' ]) ### Create paths path = [ os.path.join(dir_names[i], file_names[i]) for i in range(len(file_names)) ] ### Load data locs_ref, info_ref = io.load_locs(path[0]) locs, info = io.load_locs(path[1]) #%% ############################################# Shift ### Define shift dx = 21 dy = -4 oversampling = 1 c_min = 0 c_max = 500 x_center = 300 x_width = 100 y_center = 300 y_width = 100
import picasso.io as io import picasso.render as render import picasso_addon.autopick as autopick ############################################# Load raw data dir_names = [] dir_names.extend([ r'C:\Data\p17.lbFCS2\21-04-21_EGFR_2xCTC\09_w5-250pM_Cy3B-CTween-c2500_561-p50uW-s75_Pos0-4_1\pick_test' ]) file_names = [] file_names.extend(['render_picked_render.hdf5']) path = os.path.join(dir_names[0], file_names[0]) locs_in, info = io.load_locs(path) ############################################# Render oversampling = 5 image = render.render( locs_in, info, oversampling=oversampling, )[1] ############################################# Identify pick centers pick_box = 11 min_n_locs = 120 centers_image, fit = autopick.spotcenters_in_image(image, pick_box, min_n_locs,
r'C:\Users\flori\Documents\mpi\repos\lbFCS\styles\paper.mplstyle') ############################################# Define data dir_names = [] dir_names.extend([ r'C:\Data\p06.SP-tracking\20-01-16_immob-th_pseries_livecell\id169_R1-54#_R1s1-8_40nM_exp200_p114uW_T21_1' ]) file_names = [] file_names.extend([ 'id169_R1-54#_R1s1-8_40nM_exp200_p114uW_T21_1_MMStack_Pos0.ome_locs_render_picked_query_avg3_render.hdf5' ]) ############################################ Load data path = [os.path.join(dir_names[i], f) for i, f in enumerate(file_names)] # Path locs, info = io.load_locs(path[0]) # Load _locs #%% ################ Get rendered image xy_lim = [349.7, 350.3] oversampling = 40 image = render.render( locs, info=None, oversampling=oversampling, viewport=[(xy_lim[0], xy_lim[0]), (xy_lim[1], xy_lim[1])], blur_method=None, min_blur_width=0, )[1] ################ Lineplot histogram through center and fitting ### Get line