示例#1
0
"""
bias field correction to epi
"""
for i in range(len(path_epi)):
    n4 = N4BiasFieldCorrection()
    n4.inputs.dimension = 3
    n4.inputs.input_image = os.path.join(path_epi[i], "epi.nii")
    n4.inputs.bias_image = os.path.join(path_epi[i], 'n4bias.nii')
    n4.inputs.output_image = os.path.join(path_epi[i], "bepi.nii")
    n4.run()
"""
clean ana
"""
for i in range(len(path_t1)):
    clean_ana(os.path.join(path_t1[i], "T1.nii"),
              1000.0,
              4095.0,
              overwrite=True)
"""
mask t1 and epi
"""
for i in range(len(path_t1)):
    mask_ana(os.path.join(path_t1[i], "T1.nii"),
             os.path.join(path_t1[i], "mask.nii"),
             background_bright=False)

for i in range(len(path_epi)):
    mask_epi(os.path.join(path_epi[i], "bepi.nii"),
             os.path.join(path_t1[i], "pT1.nii"),
             os.path.join(path_t1[i], "mask.nii"), niter_mask, sigma_mask,
             file_cmap)
"""
示例#2
0
        os.makedirs(path_temp)

    # copy input files into temporary folder
    sh.copyfile(input_t1[i], os.path.join(path_temp,"T1"+ext_t1))
    sh.copyfile(input_mask[i], os.path.join(path_temp,"mask"+ext_mask))

    # get mean time series
    get_mean(input_epi[i], path_temp, "epi", type="mean")

    # new filenames
    file_epi_mean = os.path.join(path_temp, "mean_epi"+ext_epi)
    file_t1 = os.path.join(path_temp,"T1"+ext_t1)
    file_mask = os.path.join(path_temp,"mask"+ext_mask)

    # get mask
    clean_ana(file_t1, 1000.0, 4095.0, overwrite=True) # clean ana
    mask_ana(file_t1, file_mask, background_bright=False) # mask t1
    mask_epi(file_epi_mean, os.path.join(path_temp,"pT1"+ext_t1), file_mask, niter_mask, sigma_mask)
    
    # get outlier count within mask
    os.system("3dToutcount " + \
          "-mask " + os.path.join(path_temp,"mask_def-img3.nii.gz") + " " + \
          "-fraction " + \
          "-qthr " +str(qthr) + " " + input_epi[i] + " " + \
          " > " + os.path.join(path_output,"outlier_afni.txt"))
    
    # make plot
    log_data = np.loadtxt(os.path.join(path_output,"outlier_afni.txt"))

    # plots
    fig, ax = plt.subplots()