'Trackinghandle_ID183_a20_40nM_Pm2Cy3B_20uW_1_MMStack_Pos0.ome_locs_render_picked.hdf5' ]) file_names.extend([ 'Trackinghandle_ID183_a20_40nM_Pm2Cy3B_20uW_1_MMStack_Pos0.ome_locs_render_picked_tprops.hdf5' ]) ############################################ Set parameters CycleTime = 0.2 #Aquisition cycle time [s] #%% ############################################ Load _picked and _tprops paths = [ os.path.join(dir_names[i], file_name) for i, file_name in enumerate(file_names) ] locs_init, info = addon_io.load_locs(paths[0]) # Load _picked props, info = addon_io.load_locs(paths[1]) # Load _tprops #%% ############################################ Query _picked for groups in _tprops groups = props.group.values locs = locs_init.query('group in @groups') #%% ############################################ Select one group g = 102 picked = locs[locs.group == g] ### Trace trace = improps.get_trace(picked, info[0]['Frames'])
NewFirstFrame_list = [i * 1500 for i in range(1, 2)] NewNoFrames_list = [4500] * 1 #%% failed_path = [] for i in range(len(file_names)): ### Create full path path = os.path.join(dir_names[i], file_names[i]) for j in range(len(NewFirstFrame_list)): NewFirstFrame = NewFirstFrame_list[j] NewNoFrames = NewNoFrames_list[j] try: ### Load locs, info = io.load_locs(path) ### Modify istrue = locs.frame >= NewFirstFrame istrue = istrue & (locs.frame < (NewFirstFrame + NewNoFrames)) locs_filter = locs[istrue] locs_filter.frame = locs_filter.frame - NewFirstFrame # Set first frame to zero ### Save info_filter = info.copy() info_filter[0]['Frames'] = NewNoFrames extension = '_f%i-%i' % (NewFirstFrame, NewFirstFrame + NewNoFrames) io.save_locs(path.replace('.hdf5', extension + '.hdf5'), locs_filter, info_filter + [{
# file_names.extend(['slb_id169_R1-54#_R1s1-8_40nM_exp200_p250uW_T21_1_MMStack_Pos0.ome_locs_picked0503.hdf5']) ############################################ Set maximum length of sub-trajectories subN = 50 #%% ############################################ Main loop 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: ### Load locs, info = addon_io.load_locs(path) ### Split locs_split = special.split_trajectories(locs, subN) ### Save path = os.path.splitext(path)[0] info_split = info.copy() + [{'subN': subN}] addon_io.save_locs(path + '_split%i.hdf5' % subN, locs_split, info_split, mode='picasso_compatible') except Exception: traceback.print_exc() failed_path.extend([path])
file_names.extend([ 'slb_id169_R1-54#_R1s1-8_40nM_exp200_p114uW_T21_1_MMStack_Pos0.ome_locs_picked0503_split50.hdf5' ]) file_names.extend([ 'slb_id169_R1-54#_R1s1-8_40nM_exp200_p114uW_T21_1_MMStack_Pos0.ome_locs_picked0503_tmobprops.hdf5' ]) file_names.extend([ 'slb_id169_R1-54#_R1s1-8_40nM_exp200_p114uW_T21_1_MMStack_Pos0.ome_locs_picked0503_split50_tmobprops.hdf5' ]) ### Load datasets path = [ os.path.join(dir_names[i], file_names[i]) for i in range(len(file_names)) ] locs, inf = addon_io.load_locs(path[0]) # Full_picked locs_sub, info_sub = addon_io.load_locs(path[1]) # Sub _picked props, info_props = addon_io.load_locs(path[2]) # Full _props props_sub, info_props_sub = addon_io.load_locs(path[3]) # Sub _props #%% ############################################################## Prepare X = locs.copy() Xsub = locs_sub.copy() Y = props.copy() Ysub = props_sub.copy() ### Unit conversion Y.a_iter = Y.a_iter * a_iter_convert Ysub.a_iter = Ysub.a_iter * a_iter_convert
[r'C:\Users\flori\Documents\data\SPT\mobile\th\L21_exp200_p038uW']) file_names = [] file_names.extend([ r'slb_id169_R1-54#_R1s1-8_40nM_exp200_p038uW_T21_1_MMStack_Pos0.ome_locs_picked0503_tmobprops.hdf5' ]) ############################################################## Read in data #### Create list of paths path = [ os.path.join(dir_names[i], file_names[i]) for i in range(0, len(file_names)) ] labels = [i for i in range(0, len(path))] #### Read in locs locs_props = pd.concat([io.load_locs(p)[0] for p in path], keys=labels, names=['rep']) infos = [io.load_locs(p)[1] for p in path] # CycleTime=float(savename.split('_')[3][3:])*1e-3 CycleTime = 0.2 px = 0.13 # px size in microns ############################################################## Inspect dataset rep = 0 ### No. of tracks per frame and fit n_tracks = analyze.tracks_per_frame(locs_props.loc[(rep, slice(None)), :], infos[rep]) popt, frames, n_tracks_fit = analyze.fit_tracks_per_frame(n_tracks)
dir_names.extend([ r'C:\Data\p06.SP-tracking\20-01-17_fix_slb_L_T21\id140_L_exp200_p114uW_T21_1' ] * 2) file_names = [] file_names.extend([ 'id140_L_exp200_p114uW_T21_1_MMStack_Pos2.ome_locs_render_picked_tprops.hdf5' ]) file_names.extend( ['id140_L_exp200_p114uW_T21_1_MMStack_Pos2.ome_locs_render_picked.hdf5']) ############################################ Load data path = [os.path.join(dir_names[i], f) for i, f in enumerate(file_names)] # Path props, info_props = addon_io.load_locs(path[0]) # Load _props locs, info = addon_io.load_locs(path[1]) # Load _picked #%% X = locs.copy() Y = props.copy() ############################################################################## ''' Define criteria for ensemble selection based on _props. Rewrite this section as needed ... ''' ### Only get center FOV istrue = np.sqrt((Y.x - 350)**2 + (Y.y - 350)**2) <= 200 ### Number of localizations threshold istrue = istrue & (Y.n_locs >= 100) & (Y.n_locs <= 200)
savedir='~' savename='dye_sample_buffer_exp200_p114uW' ############################################################## Define data dir_names=[] dir_names.extend([r'/fs/pool/pool-schwille-paint/Data/p06.SP-tracking/20-03-05_pseries_th_B21/id169_B_exp200_p114uW_T21_1/20-03-05_JS']) file_names=[] file_names.extend([r'id169_B_exp200_p114uW_T21_1_MMStack_Pos0.ome_locs_render_picked_tprops.hdf5']) ############################################################## Read in data #### Create list of paths path=[os.path.join(dir_names[i],file_names[i]) for i in range(0,len(file_names))] labels=[i for i in range(0,len(path))] #### Read in locs locs_props=pd.concat([io.load_locs(p)[0] for p in path],keys=labels,names=['rep']) X=locs_props.copy() ############################################################## Result prep Y=analyze.get_result(X,savename) #### Save if save_results: Y.to_hdf(os.path.join(savedir,savename+'_stats.h5'),key='result') CycleTime=float(savename.split('_')[3][3:])*1e-3 #%% ############################################################## Plotting ############################################################## ''' 1st event length distribution