You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用NiftyPET重建PET图像时mmr_lmproc导入错误求助

NiftyPET导入mmr_lmproc模块失败的解决方法

我尝试使用NiftyPET进行PET图像重建时,出现ImportError,提示无法从niftypet.nipet.lm导入mmr_lmproc。已完整下载NiftyPET包,但仍找不到该模块,相关代码及报错信息如下:

运行代码

# create histogram

mMRpars['Cnt']['BTP'] = 0
m = nipet.mmrhist(datain, mMRpars, outpath=opth, store=True, use_stored=True)
if totCnt:
    mMRpars['Cnt']['BTP'] = 2  # enable parametric bootstrap
    mMRpars['Cnt']['BTPRT'] = totCnt / m['psino'].sum()  # ratio count level relative to the original
    m = nipet.mmrhist(datain, mMRpars, outpath=path.join(opth, 'BTP', '%.3g' % totCnt), store=True)

报错回溯

Traceback (most recent call last):

Cell In[3], line 3
  m = nipet.mmrhist(datain, mMRpars, outpath=opth, store=True, use_stored=True)

File ~\\NIPET\\niftypet\\nipet\\lm\\mmrhist.py:36 in mmrhist
  return hist(datain, txLUT, axLUT, Cnt, frms=frms, use_stored=use_stored, store=store,

File ~\\NIPET\\niftypet\\nipet\\lm\\mmrhist.py:58 in hist
  from . import mmr_lmproc

ImportError: cannot import name 'mmr_lmproc' from 'niftypet.nipet.lm' (C:\\Users\\Dell\\NIPET\\niftypet\\nipet\\lm\\__init__.py)

解决方法

  • 检查本地C:\\Users\\Dell\\NIPET\\niftypet\\nipet\\lm目录下是否存在mmr_lmproc.py文件。如果缺失,说明下载的包不完整,重新获取完整的NiftyPET源码包。
  • 打开C:\\Users\\Dell\\NIPET\\niftypet\\nipet\\lm\\__init__.py文件,确认其中是否包含mmr_lmproc的导入声明。如果没有,手动添加一行代码:from . import mmr_lmproc。
  • 确认Python环境是否识别NiftyPET的路径:可以在代码开头添加import sys; sys.path.append("C:\\Users\\Dell\\NIPET"),确保Python能找到该模块。
  • 尝试重新安装NiftyPET:如果是通过pip安装的,执行pip install --upgrade niftypet;如果是源码安装,重新运行python setup.py install完成安装。

内容的提问来源于stack exchange,提问作者Shruti Ray

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 05:22:12