
医学图像处理
xiav
Wei Xia
展开
-
cuda10.0配置pytorch1.7.0+monai0.9.0
CUDA10.2(10.0能用,但如果命令里面写cudatoolkit=10.0,pytorch是cpu版的,不好改过来)condainstallnumpy=1.21(monai依赖numpy>=1.17,pytorch>=1.7.0)没有对应cuda10.0的命令,重装10.2嫌麻烦,尝试直接用10.2的cudatoolkit,结果可行。1.pytorch安装。2.monai安装。...原创 2022-07-20 20:43:55 · 1824 阅读 · 0 评论 -
[Python][CV2]cv2.imwrite写jpg图像会引入噪声
cv2.imwrite写jpg图像会引入噪声,而写png图像就不会,差点被坑。猜测可能因为jpg是压缩格式?原创 2022-06-08 09:06:23 · 503 阅读 · 0 评论 -
【Pyradiomics】提取的影像组学特征值不正常(很多0和1)
用Pyradiomics提取的影像特征很多都是0和1(下图excel表),这样看起来不太正常,可能也会影响建模结果。原因是归一化的问题。需要修改参数文件*.yaml。如果设置了归一化 normalize: True(或者自己进行归一化),那么灰度值范围在0-1之间,此时如果设置了binWidth: 32(其他值也一样),那么就会产生以上情况。这是因为程序会将灰度值按每间隔32归为1个bin,也就是0-32归为1个灰度级,依次类推。所以有两种解决方法:1.binWidth: 32...原创 2021-07-29 23:19:30 · 2396 阅读 · 1 评论 -
【python】只保留字符串中的英文字母
>>> s = 'as32{ vd"s k!+'>>> ''.join(x for x in s if x.isalpha())'asvdsk' >>> filter(str.isalpha, s) # works in python-2.7'asvdsk'>>> ''.join(filter(str.isalpha, s)) # works in python3'asvdsk'转载 2021-07-07 20:11:10 · 5570 阅读 · 0 评论 -
【python】汉字转拼音
import pypinyin# 不带声调的(style=pypinyin.NORMAL)def pinyin(word):s = ''for i in pypinyin.pinyin(word, style=pypinyin.NORMAL):s += ''.join(i)return s# 带声调的(默认)def yinjie(word):s = ''# heteronym=True开启多音字for i in pypinyin.pi...转载 2021-07-07 10:42:10 · 216 阅读 · 0 评论 -
【python】将单通道图像转换为3通道图像
#single channel image# shape of img is [x, y]# repeat as three channels# shape of img_3channel is [x, y, 3]img_3channel = np.repeat(img[..., np.newaxis], 3, 3)原创 2021-07-01 16:06:15 · 1152 阅读 · 0 评论 -
【Python】【SimpleITK】医学影像重采样至指定的Spacing
import osimport SimpleITK as sitkdef resampleVolume(outspacing, vol): """ 将体数据重采样的指定的spacing大小\n paras: outpacing:指定的spacing,例如[1,1,1] vol:sitk读取的image信息,这里是体数据\n return:重采样后的数据 """ outsize = [0, 0, 0] # 读取文件的size和sp.原创 2021-07-01 16:02:25 · 4524 阅读 · 0 评论 -
【pyradiomics】bugFix:GLCM特征时:IndexError: arrays used as indices must be of integer (or boolean) type
GLCM特征时出现bug:IndexError:arrays used as indices must beof integer (or boolean) type解决方法:https://github.com/AIM-Harvard/pyradiomics/issues/634也就是:Downgrading numpy from1.19to1.18by running:pip install numpy==1.18It extracted everything fine....原创 2021-04-26 10:03:57 · 302 阅读 · 0 评论 -
DWI图像 从DICOM Tag识别 b value 的方法
DWI序列图像包含高低b值的DICOM图像,经常需要将高低b值DICOM图像分开以便后续计算。一般来讲DWI图像DICOM TAG里面的b值读取按以下规则:https://www.na-mic.org/wiki/NAMIC_Wiki:DTI:DICOM_for_DWI_and_DTI即按机器厂家区分:Philips: b_value (0018,9087) ----- 0 1000 (这也是DICOM标准推荐的tag)SIEMENS: b_value (0019,100C) -----...原创 2021-03-24 16:52:53 · 3542 阅读 · 1 评论