部分容积校正(Partial Volume Correction)的目的是校正由于目标物体相对于分辨率大小的有限所造成的信号的损失,以及目标区域外的信号污染,即校正部分容积效应(Partial Volume Effect)。对于 PVE 与 PVC 的概念知识可以参考以下两篇知乎文章:Partial Volume Effect(部分容积效应) - 知乎 (zhihu.com), Partial Volume Correction(部分容积校正) - 知乎 (zhihu.com)

下面记录了我使用 FreeSurferPETPVC 的 PVC 功能进行部分容积校正的内容。

FreeSurfer

FreeSurfer 的安装与使用内容在另外两篇文档中已经记录,PVC 的内容主要包含在 PETSurfer 的内容中,之前根据官方文档的操作比较简单,下面是一些更为复杂的操作,操作时需要确保 Subject 已经经过了 recon-all 的操作。

FreeSurfer 的 PVC 使用的是 GTM 和 MG 方法,都是基于 VOI 的方法,所以需要确定一个标签图。在 FreeSurfer 中,可以使用 gtmseg 来创建一个自定义的标签图,或者使用默认的分割方式获得一个分割结果,下面就是终端运行 gtmseg --help 得到的一个结果。得到一个目标标签图之后就可以继续使用 mri_coregmri_gtmpvc 的命令去进行 PVC 的操作,操作参数与结果都在之前的文档中有写。

# gtmseg --help
You can use your own segmentation or a modified FS segmentation. It will be easiest if you modify apas+head.mgz to insert your segmentations. apas+head.mgz is created by gtmseg but you can create it with 

xcerebralseg --s $subject --o $SUBJECTS_DIR/$subject/mri/apas+head.mgz

To create a new segmentation by replacing voxels in apas+head.mgz with your segmentation: make sure that the index you give your new segmentation(s) is not already present in apas+head.mgz. Next create a color table text file that looks something like this:

# TissueTypeSchema 
#ctTType   0  unknown                           0   0   0    0
#ctTType   1  cortex                          205  62  78    0
#ctTType   2  subcort_gm                      230 148  34    0
#ctTType   3  wm                                0 255   0    0
#ctTType   4  csf                             120  18 134    0
#ctTType   5  head                            150 150 200    0
265 MySeg            219 100 176 0 2

In the above case, it is assumed that the index that you used was 265 and that your segmentation is for subcortical gray matter (thus making the last number=2 in the MySeg row). If you have more than one segmentation you are adding, then add rows into the color table. The first 5 entries codes for the different possible tissue types.

You can then run

gtmseg --s subject --head apas+head+myseg.mgz \
   --ctab myseg.colortable.txt --o gtmseg+myseg.mgz  

where apas+head+myseg.mgz is apas+head.mgz with your new segmentation, myseg.colortable.txt is the color table you created, and gtmseg+myseg.mgz will be your output volume. Note that an output color table gtmseg+myseg.ctab will be generated. You should check in this to make sure that your segmentation appears. You can also run

tkmeditfv subject orig.mgz -seg gtmseg+myseg.mgz  myseg.colortable.txt

PETPVC

PETPVC 是一个开源的工具箱,集成了众多的 PVC 方法,当前最新版本为 1.2.4, 以下为安装与使用方法。

# 下载
wget https://github.com/UCL/PETPVC/releases/download/v1.2.4/PETPVC-1.2.4-Linux.tar.gz
# 解压
tar -xzvf PETPVC-1.2.4-Linux.tar.gz
# 设置环境变量
# 文件夹其实不必要放在 /usr/local/ 下,但是需要保证 .bashrc 文件中指向正确的路径
sudo cp -r PETPVC-1.2.4 /usr/local/PETPVC
gedit ~/.bashrc # 拉到最后一行
PATH=$PATH:/usr/local/PETPVC/bin
source ~/.bashrc

所有基于 VOI 的 PVC 方法在使用时均需要一个标签图,假设使用 FreeSurfer 获得的 gtmseg.mgz 文件作为标签图,下面为处理流程。

  1. 预处理

如果使用基于 VOI 的方法,需要确保 PET 图像与标签图具有同一物理空间和图像尺寸,否则无法进行 PVC,然后对标签图进行处理。如果使用纯基于体素的方法,不需要下面的预处理。

# 转为 nii/nii.gz - PETPVC 使用的 ITK, 转换为 ITK 能够识别的格式即可
mri_convert gtmseg.mgz gtmseg.nii.gz
# 转换为 4D Mask,4D 文件中每个图像代表一个脑区
pvc_make4d -i gtmseg.nii.gz -o 4D_gtmseg.nii.gz
  1. PVC
# 官方示例
petpvc -i <PET> -m <MASK> -o <OUTPUT> --pvc IY -x 6.0 -y 6.0 -z 6.0 [--debug]

其中 xyz 为 PET 图像采集时机器决定的参数 FWHM,如果使用的是完全基于体素的算法,比如 RL,那么不需要输入 m 参数。

如果观察之前解压出来的 PETPVC 安装文件夹,可以发现 /bin 目录下还存在不少以 PVC 方法命名的可执行文件,比如 pvc_gtm pvc_iy pvc_mg pvc_mtc pvc_rbv pvc_relabel pvc_rl pvc_vc 等,也可以直接调用特定的方法来执行,而且如果直接执行这些文件的话,可以看到专属的帮助文档,比如 pvc_rl 的文档,可以看到使用 petpvc 看不到的迭代次数等参数。

# pvc_rl
Option petfile is required but not defined
Option outputfile is required but not defined
Option FWHMx is required but not defined
Option FWHMy is required but not defined
Option FWHMz is required but not defined
 Command tags: 
   -x < X > 
      = The full-width at half maximum in mm along x-axis
   -y < Y > 
      = The full-width at half maximum in mm along y-axis
   -z < Z > 
      = The full-width at half maximum in mm along z-axis
   [ -i --iter [ Val ] ]
      = Number of iterations
        With: Val (Default = 10)
   [ -d --debug ]
      = Prints debug information
 Command fields: 
   < petfile > 
      = PET filename
   < outputfile > 
      = output filename
  1. 并行处理

这一步是在处理大量 PET 数据时一个节省时间的做法,不影响 PVC 效果,GNU Parallel 的安装与使用见之前的 FreeSurfer 操作文档,PETPVC 在处理时会进行多核运算,所以没必要并行太多,以免服务器内存爆满导致 PVC 失败。

# subject_id.txt 存储了待处理的 Subjects ID
parallel -a subject_id.txt --jobs 4 petpvc -i ./PET/{}.nii.gz -o pvc_RL/{}.nii.gz --pvc RL -x 8 -y 8 -z 8