def load_fnames(md_path): md = Metadata(md_path) md.image_table = md.image_table[[ True if (('hybe' in i) or ('nucstain' in i)) else False for i in md.image_table.acq ]] posnames = md.posnames print('posnames loaded') hybe_list = sorted([ i.split('_')[0] for i in md.acqnames if ('hybe' in i) or ('nucstain' in i) ]) if zindexes == -1: Input = [{ 'fname_dicts': md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list), 'posnames': pos } for pos in posnames] else: Input = [{ 'fname_dicts': md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list, Zindex=zindexes), 'posnames': pos } for pos in posnames] print('fnames loaded') return Input
if not os.path.exists(deconvolved_path): print('analysis path doesnt have your metadata') print('add path to metadata after analysis path') else: deconvolved_path = md_path bead_path = os.path.join(analysis_path, 'beads') if not os.path.exists(bead_path): os.makedirs(bead_path) results_path = os.path.join(analysis_path, 'results') if not os.path.exists(results_path): os.makedirs(results_path) #Retreiving file names and position names md = Metadata(deconvolved_path) md.image_table = md.image_table[[ True if 'hybe' in i else False for i in md.image_table.acq ]] posnames = md.posnames print('posnames loaded') hybe_list = sorted([i.split('_')[0] for i in md.acqnames if 'hybe' in i]) if zindexes == -1: fnames_dicts = [ md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list) for pos in posnames ] else: fnames_dicts = [ md.stkread(Channel='DeepBlue',
deconvolved_path = os.path.join(analysis_path,'deconvolved') if not os.path.exists(deconvolved_path): print('analysis path doesnt have your metadata') print('add path to metadata after analysis path') else: deconvolved_path = md_path # bead_path = os.path.join(analysis_path,'beads') # if not os.path.exists(bead_path): # os.makedirs(bead_path) results_path = os.path.join(analysis_path,'results') if not os.path.exists(results_path): os.makedirs(results_path) #Retreiving file names and position names md = Metadata(deconvolved_path) md.image_table = md.image_table[[True if (('hybe' in i) or ('nucstain' in i)) else False for i in md.image_table.acq]] posnames = md.posnames print('posnames loaded') hybe_list = sorted([i.split('_')[0] for i in md.acqnames if ('hybe' in i) or ('nucstain' in i)]) if zindexes == -1: Input = [ {'fname_dicts': md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list), 'posnames': pos} for pos in posnames] else: Input = [{'fname_dicts': md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list, Zindex=zindexes), 'posnames': pos} for pos in posnames] # print(Input[0]['fname_dicts']) print('fnames loaded') # Ave_Bead = pickle.load(open(ave_bead_path, 'rb'))
def load_fnames(md_path, zindexes): md = Metadata(md_path) md.image_table = md.image_table[[ True if (('hybe' in i) or ('nucstain' in i)) else False for i in md.image_table.acq ]] posnames = md.posnames # Speed up checking if a position is already fully done not_finished = [] finished_pos = [] for pos in posnames: try: processing = pickle.load( open( os.path.join(md_path, 'codestacks', pos, 'processing.pkl'), 'rb')) if len(processing ) == 18: # Check to make sure position is finished finished_pos.append(pos) else: not_finished.append(pos) except: not_finished.append(pos) random_posnames = np.random.choice(not_finished, size=len(not_finished), replace=False) hybe_list = sorted([ i.split('_')[0] for i in md.acqnames if ('hybe' in i) or ('nucstain' in i) ]) if zindexes == -1: Input = [{ 'fname_dicts': md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list), 'posnames': pos } for pos in random_posnames] else: Input = [{ 'fname_dicts': md.stkread(Channel='DeepBlue', Position=pos, fnames_only=True, groupby='acq', hybe=hybe_list, Zindex=list(range(8, 25))), 'posnames': pos } for pos in random_posnames] # Input = [] # for pos in random_posnames: # pos_df = {} # for hybe in hybe_list: # pos_df[hybe] = [] # for z in range(1,zindexes): # fnames = md.stkread(Channel='DeepBlue', Position=pos, # fnames_only=True, groupby='acq', # hybe=hybe_list,Zindex=z) # for h,f in fnames.items(): # pos_df[h.split('_')[0]].append(f) # Input.append({'fname_dicts':pos_df,'posnames': pos}) return Input