核磁共振仿真工具包
sycomore的Python项目详细描述
sycomore-一个mri模拟工具包
sycomore是一个mri仿真工具包,提供bloch仿真、扩展相位图(epg)(包括3d在内的规则和离散)和配置模型。SyCOORE是一个Python打包程序,其中所有计算密集型操作都由C++后端运行,提供了非常快速的运行时间,并通过OpenMP提供了进一步的加速。
安装
SyCORE需要一个C++ 11编译器,Python(3.5)和pybind11。为了充分利用您的CPU,强烈建议使用OpenMP。如果你想验证你的sycomore版本,你应该运行单元测试,这需要Boost.Test。sycomore使用CMake,因此构建它的最简单方法是在源目录中创建一个build目录,运行cmake,然后运行make:
mkdir build
cd build
cmake ..
make
其他详细信息在documentation中提供。
用法
下面的代码模拟了一个简单稀有序列的单一重复,并绘制了每个回波的横向磁化强度。
importmatplotlib.pyplotimportnumpyimportsycomorefromsycomore.unitsimport*species=sycomore.Species(1000*ms,100*ms,1*um**2/ms)TE=4*mstrain_length=40model=sycomore.epg.Regular(species)data=numpy.zeros(train_length,dtype=[("time",sycomore.Quantity),("signal",complex)])model.apply_pulse(90*deg)forechoinrange(train_length):model.apply_time_interval(TE/2)model.apply_pulse(180*deg)model.apply_time_interval(TE/2)data[echo]=(((1+echo)*TE),model.echo)times=[x.convert_to(ms)forxindata["time"]]magnitude=numpy.abs(data["signal"])matplotlib.pyplot.plot(times,magnitude,".",label="Simulated")matplotlib.pyplot.plot(times,[numpy.exp(-(x*species.R2).magnitude)forxindata["time"]],label="$T_2$ decay")matplotlib.pyplot.ylim(0,1)matplotlib.pyplot.xlabel("Time (ms)")matplotlib.pyplot.ylabel("Magnitude")matplotlib.pyplot.legend()matplotlib.pyplot.show()
文档中介绍了这些功能和数据结构: