Gate使用手册(四)数据输出

原文通道http://wiki.opengatecollaboration.org/index.php/Users_Guide:Data_output

Gate中,你必须给定一个名字,不然默认数据输出是关闭的

所有的命令行必须写在initialization之后

/gate/output/...

一ASCII和二进制输出

GateToASCII/GateToBinary类允许ASCII/binary文件输出,你可以用自己的工具生成原始数据。另一方面,数据没有被压缩,所以会非常大,这个过程也非常耗时,.bin文件输出hits,singles(??),coincidience

/gate/output/ascii(binary)/enable
/gate/output/ascii/setFileName   test
下面的指令分别输出hits,singles(??),coincidience
# enable ascii(binary) output for hits
/gate/output/ascii(binary)/setOutFileHitsFlag   1

# enable ascii(binary) output for Singles (end of digitizer chain)
/gate/output/ascii(binary)/setOutFileSinglesFlag   1

# enable ascii(binary) output for coincidences
/gate/output/ascii(binary)/setOutFileCoincidencesFlag   1

# enable ascii(binary) output for singles (after a digitizer module)
/gate/output/ascii(binary)/setOutFileSingles< name of the digitizer module >Flag   1

数字模型的名字有:Adder(加法器), Readout(读取器), Spblurring, Blurring, Thresholder, Upholder

不输出这些庞大的文件可以

/gate/output/ascii(binary)/setOutFileHitsFlag            0
/gate/output/ascii(binary)/setOutFileSinglesFlag         0
/gate/output/ascii(binary)/setOutFileCoincidencesFlag    0

 

Root输出

/gate/output/root/enable
/gate/output/root/setFileName FILE_NAME

上面的命令给产生.root文件,默认情况下,root文件会包含:含有一些变量的两个SPECT系统的树(hits或者Singles),或者PET系统的tress(coincidence,hits,singles)。

如果需要,并且考虑到文件大小,您可以选择不生成所有树。

/gate/output/root/setRootHitFlag            0
/gate/output/root/setRootSinglesFlag        0
/gate/output/root/setRootCoincidencesFlag   0
/gate/output/root/setRootNtupleFlag         0

在调试模式下,将数字化器链中某个特定模块的操作后的信息存储到树中是很有用的。以下标志用于打开或关闭这些中间树。

/gate/output/root/setOutFileSinglesAdderFlag         0
/gate/output/root/setOutFileSinglesReadoutFlag       0
/gate/output/root/setOutFileSinglesSpblurringFlag    0
/gate/output/root/setOutFileSinglesBlurringFlag      0
/gate/output/root/setOutFileSinglesThresholderFlag   0
/gate/output/root/setOutFileSinglesUpholderFlag      0

如果不想用整个root输出,用下面命令

/gate/output/root/disable

使用tbrowser浏览root对象

root图形接口,Tbrowser可以交互地检查和可视化仿真数据。

在终端输入下面命令,可以看到root文件内容

root FILE_NAME.root
root [1] TBrowser t

 

选择目标输出文件,树(hits,single,etc)会根据.mac文件设置的flag填充

Hits树显示了很多分支。选择一个分支。要么在每一个分支上面双击来看histogram/potted数据,或者使用下面的root命令。

Hits->Draw( “posX:posY:posZ”) 

这个命令画了hits的3D位置。

增加条件来声明你的histogram

Hits->Draw(“posX:posY:posZ”,”PDGEncoding==0”)

这个命令绘画了光学光子的hit的地址

Hits->Draw(“posX:posY:posZ”,”PDGEncoding==0 && time<=1 ”)

可以添加多种条件,例如:模拟的第一秒光学光子的3D位置。

  • PDGEncoding(particle data group):可以获得典型的粒子(比如:“0”光学光子,"22"伽马粒子)
  • trackLocalTime:一个粒子走完一个轨迹的时间

根据下面公式计算trackLocalTime

时间:敏感检测器中一个hits的绝对时间

stepLength:一个粒子的两个互动的距离(比如,伽马粒子进入一个敏感volume和被分散的距离)

trackLength:一个粒子中的总距离,通常包含多个步骤

momDirX,Y,Z:一个检测器中的一个检测/吸收粒子的动量方向,包含形成3D向量的三个部分

Hits->Draw(“momDirX: momDirY: momDirZ”) 

processname:粒子在灵敏探测器中终止其路径的过程(例如:传输(“T”)、光吸收(“O”)、康普顿散射(“C”)、光电(“P”)、罗利散射(“R”)。您可能有兴趣区分在检测器(“T”)检测到的粒子和被吸收的粒子(“O”)。经过康普顿散射(“C”)的粒子在分裂时被算作两次撞击。

怎样分析root输出

你可以直接从browser里面绘制变量,或者通过PET_Analyse.C的宏文件绘制。分析宏文件https://github.com/OpenGATE/GateContrib/tree/master/imaging/ROOT_Analyse

这样的话,打开root之后

root [0] .x PET_Analyse.C

你也可以用一个叫做MakeClass的root类,它产生一个框架类来对你的root文件循环遍历,在你的root文件目录下,运行root,敲下面的命令:

root [0] TChain chain(“Hits”);          <<<=== name of the tree of interest : Hits
root [1] chain.Add(“output1.root”);
root [1] chain.Add(“output2.root”);
root [2] chain.MakeClass(“MyAnalysis”); <<<==== name of your macro : MyAnalysis.C

MakeClass会产生连个文件,MyAnalysis.h和MyAnalysis.c你可以在root中运行下面的代码

Root >  .L MyAnalysis.C
Root >  MyAnalysis t
Root >  t.Loop();

 

 

~~(暂时省略,设计root源码部分)内容分别是

1.设计一个计数器

2.把一个root文件转换成text文件

root在线绘画器

root提供一个非常方便的在线绘画器,能够显示多个变量,即使你把root output disable之后也可以使用。在线绘画器可以通过下面的宏使用。

/gate/output/plotter/enable
/gate/output/plotter/showPlotter 
/gate/output/plotter/setNColumns                2                             <=== sets the number of display windows to be used  
/gate/output/plotter/setPlotHeight              250
/gate/output/plotter/setPlotWidth               300
/gate/output/plotter/addPlot hist               Ion_decay_time_s              <=== plots an histogram previously defined in GATE  
/gate/output/plotter/addPlot hist               Positron_Kinetic_Energy_MeV   <=== plots a variable from one of the GATE trees
/gate/output/plotter/addPlot tree Singles       comptonPhantom
/gate/output/plotter/addPlot tree Coincidences  energy1
/gate/output/plotter/listPlots

执行上面的宏文件可以得到

投影集的interfile输出

(不知所云,纯百度翻译)

文件间格式特别适用于使用多头旋转伽马照相机的采集协议。文件间v3.3格式的总说明可在文件间网站上找到:

http://www.medphys.ucl.ac.uk/interfile/index.htm.
当在多个窗口(如能量窗口、时间窗口、多个磁头)中采集图像时,将按照定义相应键的顺序记录图像。因此,如果使用多个能量窗口,则必须首先给出第一个窗口的所有图像数据,然后给出第二个窗口的图像数据等。使用“for”语句在文件间语法中定义了此循环结构。使用文件间/投影输出时会创建两个文件:your_file.hdrand your_file.sin。头文件包含有关采集的所有信息,而您的_file.sin文件包含二进制信息。这种头的一个例子是:

要使用文件间输出,必须将以下行添加到宏中:

# PROJECTION
/gate/output/projection/enable
/gate/output/projection/setFileName      your_file
/gate/output/projection/projectionPlane  YZ
/gate/output/projection/pixelSizeY       1. mm
/gate/output/projection/pixelSizeX       1. mm
/gate/output/projection/pixelNumberY     16
/gate/output/projection/pixelNumberX     16

用imageJ读取interfile图像

".sin" and ".hdr"格式的文件会写到相关的目录下面。

打开ImageJ之后,点击thumb文件,选择import->raw,便会出现一个.sin文件的窗口

用户必须小心编写,已经有用户报道说图像会堆叠出现。

第二种方法是使用这个插件来读取Interfile Plugin Decoder.

用IDL读取interfile图像

在平面投影中,用Gate产生的投影也可以用IDL中‘read binary’函数来读取。下面的例子中,投影文件.sin要在IDLmain文件下面,图像大小必须详细的告诉IDL,否则可能出错

  • IDL> file = 'name.sin'
  • IDL> SizeIMageX = 128
  • IDL> SizeImageZ = 128
  • IDL> data=READ_BINARY(file,DATA_DIMS=[SizeIMageX,SizeIMageY],DATA_TYPE=12,ENDIAN='Little')

Sinogram输出

对于ecat系统或者ecatAccel系统,可以用下面的命令打开sinogram

For the ecat system :

/gate/output/sinogram/enable
/gate/output/sinogram/setFileName MySinogramFileName

For the ecatAccel system :

/gate/output/sinoAccel/enable
/gate/output/sinoAccel/setFileName MySinogramFileName

每一对晶石环都有2Dsinogram,例如对于ECAT EXACT HR+ scanner (32 crystal-rings),有1024 2Dsinogram。可以用下面命令声明径向箱(??)的数量

For the ecat system :

/gate/output/sinogram/RadialBins 256

For the ecatAccel system :

/gate/output/sinoAccel/RadialBins 256

可以选择记录/不记录随机事件命令

For the ecat system :

/gate/output/sinogram/TruesOnly true

For the ecatAccel system :

/gate/output/sinoAccel/TruesOnly true

enable来进行raw  data输出

For the ecat system :

/gate/output/sinogram/RawOutputEnable

For the ecatAccel system :

/gate/output/sinoAccel/RawOutputEnable

sinogram文件

每个运行结束之后,一个新的3Dsinogram使用一个增加性框架写入。例如,通过下面的配置,会产生5帧(每一帧60s)

/gate/application/setTimeSlice   60 s
/gate/application/setTimeStart    0 s
/gate/appication/setTimeStop    300 s

扫描器模型的ECAT代码通过下面声明

/gate/output/ecat7/system 962

这个信息可能被基于重建策略的方法使用。

要注意的是,并非所有的主头文件和子头文件被填充了,尤其是无论/gate/output/sinogram/TruesOnly tag的值是多少,主头文件的coincidence_sampling_mode区域经常设置为Prompts and Delayed(1)。

对于子头文件,prompt场的值正确的被填充,delayed场的值是随机符合的真实数量而不是delayed符合。

子头文件中的radial bin大小是晶体横向取样的一半值,并不算入弧向和DOI(depth of interaction)效应。在弧向就整治后,径向箱应该逐微增加来说明DOI效应,注意这个纠正包含在ECAT扫描器提供的重建软件里面

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值