我正在尝试从 R 中的直方图中提取一些指标。为此,我在 nifti 中有一个图像,并绘制了相应的直方图。之后我想提取平均值、中位数、峰高、峰值和峰宽。为此,我有以下代码:
img = readNIfTI("FA_skeleton_subj_0") #read nifti image
library(HistogramTools)
PlotRelativeFrequency(hist( x = img[ !img==0 ], xlim=c(0,0.8), breaks = seq(0,0.7,0.001)), xlab = "FA", main = "Histogram de FA") #plot relative frequency so I can compare between subjects
mean (img[ !img==0 ]) #!img==0 means that I don't want to count with zero voxels because they are background
median(img[ !img==0])
abline(v=median(img[ !img==0]),col="green")
abline(v=mean(img[ !img==0]),col="blue")
我会感谢一些帮助来计算峰值指标(高度、宽度和值)。谢谢!