def OpenG2M1s(froot, expt_idx=None, roi_idx=None): res = [] filter_str = '' if roi_idx is not None: filter_str += '_' + ROI_PREFIX + str(roi_idx).zfill(ROI_IDXLEN) if expt_idx is not None: filter_str += '_' + EXP_PREFIX + +str(expt_idx).zfill(EXP_IDXLEN) fnames_list = sf.FindFileNames(froot, Prefix=G2M1_PREFIX, Ext='.dat', FilterString=filter_str, Sort='ASC') ROI_list = [sf.FirstIntInStr(name) for name in fnames_list] exptime_list = [sf.LastIntInStr(name) for name in fnames_list] lagtimes = [] imgtimes = [] for i, fname in enumerate(fnames_list): res_g2m1, res_hdr = sf.LoadResFile(os.path.join(froot, fname), delimiter=TXT_DELIMITER, comments=TXT_COMMENT, readHeader=True, isolateFirst=0) res.append(res_g2m1[:, 1::2].T) lagtimes.append(res_g2m1[:, ::2].T) imgtimes.append( np.asarray([ sf.FirstFloatInStr(res_hdr[j]) for j in range(1, len(res_hdr), 2) ])) return res, lagtimes, imgtimes, ROI_list, exptime_list
def OpenCIs(froot): res = [] fnames_list = sf.FindFileNames(froot, Prefix=CI_PREFIX + '_', Ext='.dat', Sort='ASC') ROI_list = [sf.FirstIntInStr(name) for name in fnames_list] exptime_list = [sf.LastIntInStr(name) for name in fnames_list] lagtimes = [] imgtimes = [] for i, fname in enumerate(fnames_list): res_cI, res_hdr, col_times = sf.LoadResFile(os.path.join(froot, fname), delimiter=TXT_DELIMITER, comments=TXT_COMMENT, readHeader=True, isolateFirst=1) res.append(res_cI) lagtimes.append(np.asarray([sf.FirstIntInStr(hdr) for hdr in res_hdr])) imgtimes.append(col_times) return res, imgtimes, lagtimes, ROI_list, exptime_list
def OpenSLS(froot, open_raw=False): if open_raw: fname = os.path.join(froot, SLS_RAW_FNAME) else: fname = os.path.join(froot, SLS_FNAME) res_Ir, res_hdr, r_phi = sf.LoadResFile(fname, delimiter=TXT_DELIMITER, comments=TXT_COMMENT, readHeader=True, isolateFirst=2) times = np.asarray([sf.FirstFloatInStr(hdr) for hdr in res_hdr]) if open_raw: exptimes = np.asarray([sf.LastFloatInStr(hdr) for hdr in res_hdr]) return np.squeeze( res_Ir.reshape( (res_Ir.shape[0], -1, len(set(exptimes))))), r_phi[:, 0], r_phi[:, 1], times, exptimes else: return res_Ir, r_phi[:, 0], r_phi[:, 1], times