Beispiel #1
0
        # grab all realigned files
        allrealigned = crg_out.outputs.coregistered_files + \
                       rlgnout.outputs.realigned_files
        # make new mean files(s) based on fully realigned files
        # 1. first 20 mins for coreg (frames 1-23)
        # 2. 40-60 mins for possible SUVR (frames 28-31)
        mean_20min = pp.make_mean_20min(allrealigned)
        mean_40_60min = pp.make_mean_40_60(allrealigned)

        # clean up
        # remove copied unrealigned frames
        bg.remove_files(newnifti)

        # QA
        # make 4d for QA
        qadir, exists = qa.make_qa_dir(realigndir, name='data_QA')
        data4d = qa.make_4d_nibabel(allrealigned, outdir=qadir)
        #snrimg = qa.gen_sig2noise_img(data4d,qadir)
        #artout = qa.run_artdetect(data4d,tmpparameterfile)
        #qa.screen_data_dirnme(data4d, qadir)
        qa.plot_movement(tmpparameterfile, subid)
        qa.calc_robust_median_diff(data4d)
        qa.screen_pet(data4d)

        # Coregister cerebellum, brainmask and aparc_aseg to pet space
        #
        logging.info('Coreg %s' % (subid))
        coregdir, exists = bg.make_dir(pth, 'coreg')
        if exists:
            logging.warning('%s exists, remove to rerun' % (coregdir))
            continue
 timingf = glob(globstr)
 if len(timingf) < 1:
     globstr = os.path.join(sub, 'RawData', tracer, 'frametimes-*.csv')
     timingf = glob(globstr)
 if len(timingf) < 1:
     logging.error('%s missing, skipping' % (globstr))
     raise IOError('%s missing, skipping' % (globstr))
 timingf = timingf[0]
 ft = ft.read_frametimes(timingf)
 ft_sec = ft.copy() / 60.
 start = singlechoice(['%d' % x for x in ft_sec[:, 1]], text='Start Time')
 end = singlechoice(['%d' % x for x in ft_sec[:, -1]], text='End Time')
 k2ref = 0.15
 range = (int(start), int(end))
 logging.info('Running Logan')
 dvrdir, exists = qa.make_qa_dir(pth, name='dvr')
 if exists:
     logging.warning('%s exists, remove to re-run' % (pth + '/dvr'))
     raise IOError('%s exists, remove to re-run' % (pth + '/dvr'))
 midtimes, durs = pyl.midframes_from_file(timingf)
 data4d = pyl.get_data_nibabel(nifti)
 ref = pyl.get_ref(rcere, data4d)
 ref_fig = pyl.save_inputplot(ref, (midtimes + durs / 2.), dvrdir)
 masked_data, mask_roi = pyl.mask_data(rbrainmask, data4d)
 x, y = pyl.calc_xy(ref, masked_data, midtimes)
 allki, residuals = pyl.calc_ki(x, y, timingf, range=range)
 dvr = pyl.results_to_array(allki, mask_roi)
 resid = pyl.results_to_array(residuals, mask_roi)
 outf = pyl.save_data2nii(dvr,
                          rbrainmask,
                          filename='DVR-%s' % subid,
    # get timing file
    sub, _ = os.path.split(pth)
    timingf = bg.FileDialog(prompt="Select Timing File", indir=pth)
    if len(timingf) < 1:
        logging.error("%s missing, skipping" % (globstr))
        raise IOError("%s missing, skipping" % (globstr))
    timingf = timingf
    ft = ft.read_frametimes(timingf)
    ft_sec = ft.copy() / 60.0
    start = singlechoice(["%d" % x for x in ft_sec[:, 1]], text="Start Time")
    end = singlechoice(["%d" % x for x in ft_sec[:, -1]], text="End Time")
    k2ref = 0.15
    range = (int(start), int(end))
    logging.info("Running Logan")
    dvrdir, exists = qa.make_qa_dir(pth, name="dvr")
    if exists:
        logging.warning("%s exists, remove to re-run" % (pth + "/dvr"))
        raise IOError("%s exists, remove to re-run" % (pth + "/dvr"))
    midtimes, durs = pyl.midframes_from_file(timingf)
    data4d = pyl.get_data_nibabel(nifti)
    ref = pyl.get_ref(rcere, data4d)
    ref_fig = pyl.save_inputplot(ref, (midtimes + durs / 2.0), dvrdir)
    masked_data, mask_roi = pyl.mask_data(rbrainmask, data4d)
    x, y = pyl.calc_xy(ref, masked_data, midtimes)
    allki, residuals = pyl.calc_ki(x, y, timingf, range=range)
    dvr = pyl.results_to_array(allki, mask_roi)
    resid = pyl.results_to_array(residuals, mask_roi)
    outf = pyl.save_data2nii(dvr, rbrainmask, filename="DVR-%s" % subid, outdir=dvrdir)
    _ = pyl.save_data2nii(resid, rbrainmask, filename="RESID-%s" % subid, outdir=dvrdir)
    logging.info("%s Finished Logan: %s" % (subid, outf))
        allrealigned = crg_out.outputs.coregistered_files + \
                       rlgnout.outputs.realigned_files
        # make new mean files(s) based on fully realigned files
        # 1. first 20 mins for coreg (frames 1-23)
        # 2. 40-60 mins for possible SUVR (frames 28-31)
        mean_20min = pp.make_mean_20min(allrealigned)
        mean_40_60min = pp.make_mean_40_60(allrealigned)

        # clean up
        # remove copied unrealigned frames
        bg.remove_files(newnifti)
        

        # QA
        # make 4d for QA
        qadir, exists = qa.make_qa_dir(realigndir, name='data_QA')
        data4d = qa.make_4d_nibabel(allrealigned, outdir=qadir)
        #snrimg = qa.gen_sig2noise_img(data4d,qadir)
        #artout = qa.run_artdetect(data4d,tmpparameterfile)
        #qa.screen_data_dirnme(data4d, qadir)
        qa.plot_movement(tmpparameterfile, subid)
        qa.calc_robust_median_diff(data4d)
        qa.screen_pet(data4d)

        # Coregister cerebellum, brainmask and aparc_aseg to pet space
        #
        logging.info('Coreg %s'%(subid))
        coregdir, exists = bg.make_dir(pth, 'coreg')
        if exists:
            logging.warning('%s exists, remove to rerun'%(coregdir))
            continue
Beispiel #5
0
 timingf = glob(globstr)
 if len(timingf) < 1:
     globstr = os.path.join(sub, 'RawData', tracer, 'frametimes-*.csv')
     timingf = glob(globstr)
 if len(timingf) < 1:       
     logging.error('%s missing, skipping'%(globstr))
     raise IOError('%s missing, skipping'%(globstr))
 timingf = timingf[0]
 ft = ft.read_frametimes(timingf)
 ft_sec = ft.copy() / 60.
 start = singlechoice(['%d'%x for x in ft_sec[:,1]], text='Start Time')
 end = singlechoice(['%d'%x for x in ft_sec[:,-1]], text='End Time')
 k2ref = 0.15
 range = (int(start),int(end))
 logging.info('Running Logan')
 dvrdir, exists = qa.make_qa_dir(pth, name='dvr')
 if exists:
     logging.warning('%s exists, remove to re-run'%(pth + '/dvr'))
     raise IOError('%s exists, remove to re-run'%(pth + '/dvr'))
 midtimes, durs = pyl.midframes_from_file(timingf)
 data4d = pyl.get_data_nibabel(nifti)
 ref = pyl.get_ref(rcere, data4d)
 ref_fig = pyl.save_inputplot(ref, (midtimes + durs/2.), dvrdir)
 masked_data, mask_roi = pyl.mask_data(rbrainmask, data4d)
 x,y  = pyl.calc_xy(ref, masked_data, midtimes)
 allki, residuals = pyl.calc_ki(x, y, timingf, range=range)
 dvr = pyl.results_to_array(allki, mask_roi)
 resid = pyl.results_to_array(residuals, mask_roi)
 outf = pyl.save_data2nii(dvr, rbrainmask,
                          filename='DVR-%s'%subid, outdir=dvrdir)
 _ = pyl.save_data2nii(resid, rbrainmask,