Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
 def ReadCIfile(self, fname):
     roi_idx = sf.FirstIntInStr(fname)
     exp_idx = sf.LastIntInStr(fname)
     cur_cI = np.loadtxt(os.path.join(self.outFolder, fname),
                         **self.loadtxt_kwargs)
     cur_times = cur_cI[:, 0]
     cur_cI = cur_cI[:, 1:]  # skip first row with image times
     if (cur_cI.shape != (self.NumTimes(), self.NumLagtimes())):
         logging.warning(
             'cI result file {0} potentially corrupted: shape {1} does not match expected {2}'
             .format(fname, cur_cI.shape,
                     (self.NumTimes(), self.NumLagtimes())))
     return cur_cI, cur_times, roi_idx, exp_idx