2007年4月29日星期日

Crystal/Module的index

以Z方向为例,如果repeater里的数目是N,那么index就是0到N-1.

如果N是偶数,0点在N/2-1和N/2之间;如果N是奇数,0点在第(N-1)/2个crystal/module的中间。。。

An example of pinhole SPECT in [gate-users]

[gate-users] SPblurring

Christian Wietholt cwietholt at nhri.org.tw
Fri Jul 22 05:28:46 CEST 2005
Dear fellow GATE users, 

I am working on this problem already for a while. I am trying to
simulate a basic pinhole SPECT system, and at the moment I am mainly
interested in projection images using the Interfile output. So far I can
generate projection images of a point source, but for some reason, not
matter what SPblurring parameter I set (0mm, 5mm, 10mm) I don't get
any change in the resulting projection images. In the end I would like
to use digigate to simulate different detector responses.

I would greatly appreciate any help you can provide, since I already
exhausted all other sources.

Thanks,

chris

Here is a snapshot of my .mac file:

#############################################
# V I S U A L I S A T I O N
/control/execute visu.mac

/tracking/storeTrajectory 1
/gate/geometry/enableAutoUpdate

#############################################
# V E R B O S I T Y
/gate/output/verbose 2

#############################################
# W O R L D
# Define the world dimensions
/gate/world/geometry/setXLength 1000 mm
/gate/world/geometry/setYLength 1000 mm
/gate/world/geometry/setZLength 1000 mm

#############################################
# S C A N N E R H E A D
# Create a new box representing the main
# head-volume SPECThead is the name of the
# predefined SPECT system Create the SPECT
# system, which will yield an Interfile output
# of projection data
/gate/world/daughters/name SPECThead
/gate/world/daughters/insert box

# Define the dimensions of the main volume
/gate/SPECThead/geometry/setXLength 300. mm
/gate/SPECThead/geometry/setYLength 300. mm
/gate/SPECThead/geometry/setZLength 300. mm

# Define the position of the main volume
# Move the head 9 cm away from the Z axis,
# which is the rotation axis and the
# replication axis
/gate/SPECThead/placement/setTranslation 200. 0. 0. mm

# Set the material associated with the main volume
/gate/SPECThead/setMaterial Air
/gate/SPECThead/attachPhantomSD

# Define the rotation speed of the head
# Define the orbiting around the Z axis
/gate/SPECThead/moves/insert orbiting
/gate/SPECThead/orbiting/setSpeed 0.5625 deg/s
/gate/SPECThead/orbiting/setPoint1 0. 0. 0. mm
/gate/SPECThead/orbiting/setPoint2 0. 0. 1. mm

# Define some visualisation options
/gate/SPECThead/vis/forceWireframe

# Shielding
# Create the shielding volume
/gate/SPECThead/daughters/name shielding
/gate/SPECThead/daughters/insert box

# Define the dimensions of the shielding volume
/gate/shielding/geometry/setXLength 300. mm
/gate/shielding/geometry/setYLength 300. mm
/gate/shielding/geometry/setZLength 300. mm

# Define the position of the shielding volume
/gate/shielding/placement/setTranslation 0. 0. 0. mm

# Set the material corresponding to the
# shielding volume
/gate/shielding/setMaterial Lead

# Define some visualisation options
/gate/shielding/vis/setColor red
/gate/shielding/vis/forceWireframe

# Attach phantom SD to record Compton
# interactions in the shielding volume
# Needed to discriminate between scattered
# and unscattered photons
/gate/shielding/attachPhantomSD


#############################################
# C O L L I M A T O R
# Create a full volume defining the shape
# of the collimator
/gate/SPECThead/daughters/name collimator
/gate/SPECThead/daughters/insert box

/gate/collimator/geometry/setXLength 20. mm
/gate/collimator/geometry/setYLength 300. mm
/gate/collimator/geometry/setZLength 300. mm

/gate/collimator/setMaterial Lead
/gate/collimator/placement/setTranslation -140. 0. 0. mm

/gate/collimator/vis/forceWireframe
/gate/collimator/vis/setColor red

# Attach PhantomSD to record Compton
# interactions in the collimator volume
/gate/collimator/attachPhantomSD

#############################################
# P I N H O L E
# Insert the pinhole in the collimator
/gate/collimator/daughters/name hole
/gate/collimator/daughters/insert cylinder
/gate/hole/geometry/setHeight 20. mm
/gate/hole/geometry/setRmax 2.5 mm
/gate/hole/placement/alignToX
/gate/hole/setMaterial Air
/gate/hole/vis/forceSolid

/gate/collimator/daughters/name cone1
/gate/collimator/daughters/insert cone
#/gate/cone1/geometry/setHeight 7.5 mm
/gate/cone1/geometry/setHeight 9 mm
/gate/cone1/geometry/setRmax1 10. mm
/gate/cone1/geometry/setRmax2 2.5 mm
#/gate/cone1/placement/setTranslation -6.25 0 0 mm
/gate/cone1/placement/setTranslation - 5.5 0 0 mm
/gate/cone1/placement/alignToX
/gate/cone1/setMaterial Air
/gate/cone1/vis/forceSolid

/gate/collimator/daughters/name cone2
/gate/collimator/daughters/insert cone
#/gate/cone2/geometry/setHeight 7.5 mm
/gate/cone2/geometry/setHeight 9 mm
/gate/cone2/geometry/setRmax1 2.5 mm
/gate/cone2/geometry/setRmax2 10. mm
#/gate/cone2/placement/setTranslation 6.25 0 0 mm
/gate/cone2/placement/setTranslation 5.5 0 0 mm
/gate/cone2/placement/alignToX
/gate/cone2/setMaterial Air
/gate/cone2/vis/forceSolid

############################################
# C A M H E A D A I R
# insert air behind the collimator
/gate/SPECThead/daughters/name aircomp
/gate/SPECThead/daughters/insert box
/gate/aircomp/geometry/setXLength 170 mm
/gate/aircomp/geometry/setYLength 260 mm
/gate/aircomp/geometry/setZLength 260 mm
/gate/aircomp/placement/setTranslation -45 0 0 mm
/gate/aircomp/vis/forceWireframe

############################################
# C R Y S T A L
# Create the crystal volume
/gate/SPECThead/daughters/name crystal
/gate/SPECThead/daughters/insert box

# Define the dimensions of the crystal volume
/gate/crystal/geometry/setXLength 6. mm
/gate/crystal/geometry/setYLength 260. mm
/gate/crystal/geometry/setZLength 260. mm

# Define the position of the crystal volume
/gate/crystal/placement/setTranslation 43. 0. 0. mm

# Set the material associated with the crystal
# volume
/gate/crystal/setMaterial NaI

# Define some visualisation options
/gate/crystal/vis/setColor yellow

###########################################
# B A C K - C O M P A R T M E N T
# Create the back-compartment volume
/gate/SPECThead/daughters/name compartment
/gate/SPECThead/daughters/insert box

# Define the dimensions of the back-compartment volume
/gate/compartment/geometry/setXLength 30. mm
/gate/compartment/geometry/setYLength 260. mm
/gate/compartment/geometry/setZLength 260. mm

# Define the position of the back-compartment volume
/gate/compartment/placement/setTranslation 61. 0. 0. mm

# Set the material of the back-compartment volume
/gate/compartment/setMaterial Glass

# Define some visualisation options
/gate/compartment/vis/setColor grey

# Attach PhantomSD to record Compton
# interactions in the back-compartment volume
/gate/compartment/attachPhantomSD


#############################################
# P H A N T O M
# Create the phantom volume
/gate/world/daughters/name Phantom
/gate/world/daughters/insert cylinder

# Define the dimensions of the phantom
# volume
/gate/Phantom/geometry/setRmax 0.5 mm
/gate/Phantom/geometry/setRmin 0. mm
/gate/Phantom/geometry/setHeight 0.5 mm
/gate/Phantom/placement/setTranslation 0 0 0 mm

# Set the material corresponding to the
# phantom volume
/gate/Phantom/setMaterial Water

# Define some visualisation options
/gate/Phantom/vis/setColor blue
/gate/Phantom/vis/forceWireframe

# Attach PhantomSD to record Compton
# interactions in the phantom volume
/gate/Phantom/attachPhantomSD


#############################################
# M O V I N G S O U R C E
# Add an extra object for source confinement
/gate/Phantom/daughters/name movsource
/gate/Phantom/daughters/insert cylinder

# Define the dimensions of the source volume
/gate/movsource/geometry/setRmax 0.5 mm
/gate/movsource/geometry/setRmin 0. mm
/gate/movsource/geometry/setHeight 0.5 mm

# Set the material corresponding to the
# phantom volume
/gate/movsource/setMaterial Water

# Define some visualisation options
/gate/movsource/vis/setColor magenta
/gate/movsource/attachPhantomSD

/control/execute timing.mac

#################################
# SENSITIVE DETECTORS
# GATE provides two sensitive detectors,
# which have two different functions
# Using them properly is very important
# for getting accurate results

###########################################
# Crystal SD
# The crystal SD makes it possible to
# record hits in a sensitive volume
# (e.g.,. in a scintillation crystal)
# It must be attached to any volume for
# which hit-data must be obtained
# For recording hits in the NaI volume
# only, the name of which is crystal,
# this volume is attached to the crystal SD
/gate/crystal/attachCrystalSD

#############################################
# Phantom SD
# The phantom SD makes it possible to record
# Compton events in the volumes within the
# field of view. This can provide information
# for result analysis to discriminate between
# scattered and unscattered photons. It must
# be attached to each and every volume for
# whom Compton interactions have to be recorded
/gate/Phantom/attachPhantomSD

#############################################
# D I G I T I Z E R
# The digitizer tracks what happens in the
# detection system and in the electronics
# Build a digitizer that first computes the
# centroid of interactions

/gate/digitizer/Singles/insert adder

/gate/digitizer/Singles/insert blurring
/gate/digitizer/Singles/blurring/setResolution 0.15
/gate/digitizer/Singles/blurring/setEnergyOfReference 140. keV

/gate/digitizer/Singles/insert spblurring
/gate/digitizer/Singles/spblurring/setSpresolution 10.0 mm
/gate/digitizer/Singles/spblurring/verbose 1

/gate/digitizer/Singles/insert thresholder
/gate/digitizer/Singles/thresholder/setThreshold 20. keV

/gate/digitizer/Singles/insert upholder
/gate/digitizer/Singles/upholder/setUphold 190. keV

#############################################
# S Y S T E M
# The system acts as an interpretor between
# the GATE geometry and data outputs for
# reconstruction in our case, the Interfile
# writer. A system must know which components
# of the geometry are parts of the scanner,
# and what their role are. For the moment,
# there is only a system SPECThead, which
# was built when the SPECThead volume was
# inserted.

# The SPECThead system is made of three
# levels: base (for the head), crystal (for
# the crystal and crystal matrix) and pixel
# (for individual crystals for pixellated
# gamma camera) For now, only the base of
# the system is attached to a volume: the
# volume SPECThead. For the system to get
# information about your crystal, the level
# crystal must be attached to the volume that
# has been defined for the scintillating
# crystal (crystal)
/gate/systems/SPECThead/crystal/attach crystal
# Look at the system
/gate/systems/SPECThead/describe

#############################################
# P H Y S I C S
# Select the processes to consider
/gate/physics/gamma/selectRayleigh lowenergy
/gate/physics/gamma/selectPhotoelectric lowenergy
/gate/physics/gamma/selectCompton lowenergy
/gate/physics/gamma/selectGammaConversion inactive
/gate/physics/gamma/listProcesses

# Set some cuts to speed up the simulation
# X-rays are tracked until their energy fell
# under 20 keV
/gate/physics/setXRayCut 20. keV
# Cut in order not to follow the secondary
# electrons
/gate/physics/setElectronCut 1. km
/gate/physics/setDeltaRayCut 1. GeV


# Physics initialization
/run/initialize

#############################################
# S O U R C E
# Setting up the source
/gate/source/addSource SourceConfinement

# Define the shape of the source
/gate/source/SourceConfinement/gps/type Volume
/gate/source/SourceConfinement/gps/shape Cylinder

# Define the dimensions of the source
/gate/source/SourceConfinement/gps/radius 0.5 mm
/gate/source/SourceConfinement/gps/halfz 0.25 mm

# Define the placement of the source
/gate/source/SourceConfinement/gps/centre 0. 0. 0. mm

# Define the source as a gamma source
/gate/source/SourceConfinement/gps/particle gamma

# Define the gamma energy
#/gate/source/SourceConfinement/gps/energytype Mono
/gate/source/SourceConfinement/gps/energy 140. keV

# Set the activity of the source
/gate/source/SourceConfinement/setActivity 500000. Bq

# Define a confinement
# the activity cannot move with time so the attenuating
# medium is moved and the activity is forced to be in the
# attenuating medium
/gate/source/SourceConfinement/gps/confine movsource_P

# Define the emission direction (4 str)
/gate/source/SourceConfinement/gps/angtype iso
/gate/source/SourceConfinement/gps/mintheta 0. deg
/gate/source/SourceConfinement/gps/maxtheta 180. deg
/gate/source/SourceConfinement/gps/minphi 0. deg
/gate/source/SourceConfinement/gps/maxphi 360. deg



#############################################
# R A N D O M
# Change the root of the random module to run different simulations
/gate/output/root/setSaveRndmFlag 1

#############################################
# O U T P U T
# Select the options of the data output
# As there are several modules, settings have
# to be defined for each module, especially in
# SPECT, where there are a lots of hits for
# only a few counts, so it's better to limit
# the amount of data produced Here the
# SingleDigi output can be used if you have
# your own program to process the data

/gate/output/root/setFileName pinholeSPECT
/gate/output/root/setRootSinglesAdderFlag 1
/gate/output/root/setRootSinglesBlurringFlag 1
/gate/output/root/setRootSinglesSpblurringFlag 1
/gate/output/root/setRootSinglesThresholderFlag 1
/gate/output/root/setRootSinglesUpholderFlag 1

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

#/gate/output/ascii/disable
/gate/output/ascii/setOutFileSinglesAdderFlag 0
/gate/output/ascii/setOutFileSinglesSpblurringFlag 0
/gate/output/ascii/setOutFileSinglesBlurringFlag 0
/gate/output/ascii/setOutFileSinglesThresholderFlag 0
/gate/output/ascii/setOutFileSinglesUpholderFlag 0

#############################################
# P R O J E C T I O N
# Makes a set of projections from the crystal
# hits Define the binning the projection module
# to be used
/gate/output/projection/pixelSizeX 2.03125 mm
/gate/output/projection/pixelSizeY 2.03125 mm
/gate/output/projection/pixelNumberX 128
/gate/output/projection/pixelNumberY 128

# Specify the projection plane (XY, YZ or ZX)
/gate/output/projection/projectionPlane YZ

#############################################
# E X P E R I M E N T
# Define the parameters of the experiment
# (start time, stop time and time slice)
# The number of projections depends on the
# number of time slice, the rotation speed of
# the system and the number of heads
/gate/application/setTimeSlice 10. s
/gate/application/setTimeStart 0. s
/gate/application/setTimeStop 10. s

#############################################
# V E R B O S I T Y
/control/verbose 0
/grdm/verbose 0
/run/verbose 0
/event/verbose 0
/tracking/verbose 0
/gate/application/verbose 0
/gate/generator/verbose 0
/gate/stacking/verbose 0
/gate/event/verbose 0
/gate/source/verbose 0
/gate/output/projection/verbose 0
/gate/output/verbose 0

# LET'S RUN THE SIMULATION!
/gate/application/startDAQ


More information about the Gate-users mailing list

2007年4月27日星期五

几何位置

用Gate的root格式输出,读出下面几个值:rsectorID,moduleID,globalPosX,globalPosY,globalPosZ

想搞清楚它们的关系。

detector的半径为fDetRad= 98.547;

发现 sqrt(globalProjX*globalProjX+globalProjY*globalProjY) 并不等于 fDetRad,所以应该不是photon在detector表面的位置,而是它最后消失在detector里面的位置。但是奇怪的是有些 sqrt(globalProjX*globalProjX+globalProjY*globalProjY) 值居然小于 fDetRad,难道还没有到达detector就消失了???


crystal的方向问题

Gate在用repeater构建detector的时候,crystal的index是以什么样的顺序?对Mosaic来说,axial方向最后面的crystal为0,最前面的为51;transaxial方向最右边的为0,顺时针方向增大至277.




Note that the default ring repetition goes counter clockwise.
These three commands are enough to repeat a volume along a ring over 360

. However, the repeat action
can be further customized using one or more of the following commands. To set the rotation angle for
the first copy, use:
/gate/Name_Volume/ring/setFirstAngle x deg
The default angle is 0 deg.
To set the rotation angle difference between the first and the last copy, use:
/gate/Name_Volume/ring/setAngularSpan x deg
The default angle is 360 deg.


我的mosaic系统模拟里面改成了这样:

/gate/box1/repeaters/insert ring
/gate/box1/ring/setFirstAngle 0 deg
/gate/box1/ring/setAngularSpan -360 deg
/gate/box1/ring/setRepeatNumber 278

2007年4月25日星期三

mosaic w/ mouse brain phantom

1. 用我的c程序生成analyze格式的mouse brain phantom
2. 用xmedcon转换成interfile格式
3. 修改brain.h33里面
!number format := unsigned integer
!extent of rotation := 1
4. 运行我的mosaic.mac


mosaic.zip
brain.zip

Activity

 If the number in the ASCII file, for a given voxel, is for instance between 221 and 230, then the activity for that voxel is set to 5. Bq.

利用linear或range把voxelized phantom的灰度值转换成activity的时候,比如linearTranslator/setScale 1. Bq ,指的是每个voxel的activity.

2007年4月23日星期一

source的range问题

一个range translation table for numbers to activities (activityRange.dat ) 的例子:
# set the number of subdivisions
6
# define the intervals ex. [200,210] and attach
# a correlated activity: 1. Bq in this example
200 210 1.
211 220 3.
221 230 5.
231 240 10.
241 250 20.
251 255 40.

问题: [200,210]对应的1. Bq是指每个voxel的activity么?还是整个volume的?

Gate里使用Voxelized phantom的问题

在gate_v3.1.0/src/GateGeometryVoxelInterfileReader.cc里有这样一个函数:

void GateGeometryVoxelInterfileReader::ReadKey(FILE* fp)

if ( key ==  "matrix size [1]" ) {
    sscanf(value,"%u",m_dim);
  } else if ( key ==  "matrix size [2]" ) {
    sscanf(value,"%u",m_dim+1);
  } else if ( ( key ==  "number of slices" ) || (key ==  "number of images" ) ) {
    sscanf(value,"%u",&m_numPlanes);
  } else if ( key ==  "scaling factor (mm/pixel) [1]" ) {
    sscanf(value,"%f",m_pixelSize);
  } else if ( key ==  "scaling factor (mm/pixel) [2]" ) {
    sscanf(value,"%f",m_pixelSize+1);
  } else if ( key ==  "slice thickness (pixels)" ) {
    sscanf(value,"%f",&m_planeThickness);
  } else if ( key ==  "name of data file" ) {
    m_dataFileName = std::string(value);
  } else if ( key ==  "number format" ) {
    if ( (strcmp(value,"float")==0) || (strcmp(value,"FLOAT")==0) )
      m_dataTypeName = "FLOAT";
    else if ( (strcmp(value,"unsigned integer")==0) || (strcmp(value,"UNSIGNED INTEGER")==0) )
      m_dataTypeName = "UNSIGNED INTEGER";
    else
      G4cout << "Unrecognised type name '" << value << "'" << G4endl;
  } else {
    // G4cout << "Key not processed: '" << key << "'" << G4endl;
  }

在我用xmedcon转换的interfile文件的header里,
% cat MouseBrain.h33 | grep images
!total number of images := 128
!number of images/energy window := 128

并没有number of slices 或 number of images
!total number of images 改成number of images 后,

Unrecognised type name 'signed integer'
 Header read from       'MouseBrain.h33'
 Data file name         'MouseBrain.i33'
 Nb of planes:           128
 Nb of pixels per plane: 128 128
 Pixel size:             0.4 0.4
 Slice thickness:        0
 Matrix size:            51.2 51.2
 Data type:             

nx ny nz: 128 128 128
dx dy dz: 0.4 0.4 0
ERROR - G4Box()::G4Box(): vxphantom_S
        Dimensions too small ! - 25.6, 25.6, 0

*** G4Exception : InvalidSetup
      issued by : G4Box::G4Box()
Invalid dimensions. Too small.
*** Fatal Exception *** core dump ***

*** G4Exception: Aborting execution ***
Abort

重新用xmedcon转换一次,再运行gate:

'nrecognised type name 'signed integer
 Header read from       'MouseBrain.h33'
'Data file name         'MouseBrain.i33
 Nb of planes:           128
 Nb of pixels per plane: 128 128
 Pixel size:             0.4 0.4
 Slice thickness:        1
 Matrix size:            51.2 51.2
 Data type:             


'!ror: Could not open header file ' MouseBrain.i33
ERROR - G4Box()::G4Box(): vxphantom_S
        Dimensions too small ! - 0, 0, 0

*** G4Exception : InvalidSetup
      issued by : G4Box::G4Box()
Invalid dimensions. Too small.
*** Fatal Exception *** core dump ***

*** G4Exception: Aborting execution ***
Abort

对于 Could not open header file 'MouseBrain.i33 的错误提示,找到GateGeometryVoxelInterfileReader.cc 文件里下面的函数:

  FILE* fpp=fopen(m_dataFileName.c_str(),"r");
  if (!fpp) {
    G4cerr << G4endl << "Error: Could not open header file '" << m_dataFileName << "'!" << G4endl;
    return;
  }

其中Error: Could not open header file这句话应该是Error: Could not open data file

把下面几句改了一下:

!extent of rotation := 1
!time per projection (sec) := 1
study duration (sec) := 1


Unrecognised type name 'signed integer'
 Header read from       'MouseBrain.h33'
 Data file name         'MouseBrain.i33'
 Nb of planes:           128
 Nb of pixels per plane: 128 128
 Pixel size:             0.4 0.4
 Slice thickness:        1
 Matrix size:            51.2 51.2
 Data type:             

nx ny nz: 128 128 128
dx dy dz: 0.4 0.4 1
world_L is registered to the default region.
  Volume of the same name and copy number ("world_P", copy 0) still exists and is being used.
  Be warned that this does not necessarily guarantee it's the same
  volume you originally specified in /vis/scene/add/.
/vis/scene/notifyHandlers scene-0

/vis/scene/notifyHandlers scene-0
Gate(1063) malloc: *** vm_allocate(size=8421376) failed (error code=3)
Gate(1063) malloc: *** error: can't allocate region
Gate(1063) malloc: *** set a breakpoint in szone_error to debug

从程序看:
  G4short  *buffer = (G4short*) malloc ( pixelNumber*sizeof(G4short) );
  if (!buffer) {
    G4cerr << G4endl << "Error: Could not allocate the buffer!" << G4endl;
    return;
  }
应该是Gate只能处理short的数据。

重新用short格式生成phantom,用xmedcon转换成interfile,然后
在!extent of rotation := 后面添上1,再运行gate,仍然有malloc的错误。想也许是phantom的matrix太大了,就把它从128x128x128改成了64x64x64,果然不再有mollac的错误。


从analyze用xmedcon转换成interfile之后读入gate的时候出错

/gate/vxphantom/interfileReader/readFile MouseBrain.h33
'nrecognised type name 'signed integer
 Header read from       'MouseBrain.h33'
'Data file name         'MouseBrain.i33
 Nb of planes:           128
 Nb of pixels per plane: 128 128
 Pixel size:             0.4 0.4
 Slice thickness:        1
 Matrix size:            51.2 51.2
 Data type:              


'!ror: Could not open header file ' MouseBrain.i33
ERROR - G4Box()::G4Box(): vxphantom_S
        Dimensions too small ! - 0, 0, 0

*** G4Exception : InvalidSetup
      issued by : G4Box::G4Box()
Invalid dimensions. Too small.
*** Fatal Exception *** core dump ***

*** G4Exception: Aborting execution ***
Abort



!INTERFILE :=
!imaging modality := nucmed
!originating system := (X)MedCon
!version of keys := 3.3
date of keys := 1996:09:24
conversion program := (X)MedCon
program author := Erik Nolf
program version := 0.9.9.3
program date := 2006:09:01
;
!GENERAL DATA :=
original institution := UZGENT
!data offset in bytes := 0
!name of data file := MouseBrain.i33
patient name := Unknown
!patient ID :=
patient dob := 0000:00:00
patient sex := Unknown
!study ID :=
exam type := Unknown
data compression := none
data encode := none
organ := Unknown
isotope := Unknown
dose := 0
NUD/Patient Weight [kg] := 0.00
NUD/imaging modality := NM
NUD/activity := 0
NUD/activity start time := 00:00:00
NUD/isotope half life [hours] := 0.000000
;
!GENERAL IMAGE DATA :=
!type of data := Tomographic
!total number of images := 128
study date := 0000:00:00
study time := 00:00:00
imagedata byte order := BIGENDIAN
process label :=
;
number of energy windows := 1
;
energy window [1] :=
energy window lower level [1] :=
energy window upper level [1] :=
flood corrected := N
decay corrected := N
;
!SPECT STUDY (general) :=
number of detector heads := 1
;
!number of images/energy window := 128
!process status := Reconstructed
!matrix size [1] := 128
!matrix size [2] := 128
!number format := signed integer
!number of bytes per pixel := 4
scaling factor (mm/pixel) [1] := +4.000000e-01
scaling factor (mm/pixel) [2] := +4.000000e-01
!number of projections := 128
!extent of rotation :=
!time per projection (sec) := 0
study duration (sec) := 0
!maximum pixel count := +1.000000e+01
patient orientation := head_in
patient rotation := supine
;
!SPECT STUDY (reconstructed data) :=
method of reconstruction := Unknown
!number of slices := 128
number of reference frame := 0
slice orientation := Transverse
slice thickness (pixels) := +1.000000e+00
centre-centre slice separation (pixels) := +1.000000e+00
filter name := Unknown
filter parameters := Cutoff
method of attenuation correction := measured
scatter corrected := N
oblique reconstruction := N
!END OF INTERFILE :=

phantom材料的range.dat如何设置?

hoffman brain phantom 的例子是 :
5
0 0 Air false 0.0 0.0 0.0 0.2
0 33 Lung false 1.0 0.0 0.0 0.2
33 53 Breast flase 0.0 1.0 0.0 0.2
53 75 Plastic true 0.0 0.0 1.0 0.2
75 200 Air false 0.0 0.0 0.0 0.2

The first line must contain the number of materials (i.e. the number of subse-
quent lines). The following lines contain either a material number (or range) followed by a material name
(for the old format) or, for the new format, a material number (or range), a material name, a visibility
boolean (true or false) and color attribute values (red, green, blue, alpha). If the old format is used, the
phantom will be of a uniform dark red color.

An example for error "material translation not found"

Hi,

In fact, you need to define a material for each pixel range (from 0 to
200 in the case off hoffman brain phantom which is include in the
example folder)

ex :
5
0 0 Air false 0.0 0.0 0.0 0.2
0 33 Lung false 1.0 0.0 0.0 0.2
33 53 Breast flase 0.0 1.0 0.0 0.2
53 75 Plastic true 0.0 0.0 1.0 0.2
75 200 Air false 0.0 0.0 0.0 0.2

cheers
seb

Susana Silva a écrit:
> Hi, everyone!
>
> I have a problem when i'm trying to use the hoffman brain phantom in the new version.
> The problem is the following: when GATE is reading the interfile "hof3.h33" appears this message continuosly (i need to press ctrl+c to stop it):
>
>
> GateGeometryVoxelInterfileReader::ReadFile: WARNING: voxel not added (material translation not found); value: 200
> GateGeometryVoxelInterfileReader::ReadFile: WARNING: voxel not added (material translation not found); value: 200
> [...]
>
> Can anyone help me?
>
> Thanks in advance,
>
> Susana Silva
>

2007年4月20日星期五

手册里的一个错误

GATE Users Guide ,Version 3.0.0 (27 July 2006)

99页(PDF的107页)/gate/digitizer/Singles/blurring 应该是/gate/digitizer/Singles/insert blurring


InterFile文件格式之1

Interfile - A Nuclear Medicine File Format

Interfile is a nuclear medicine file format based on the AAPM Image file format first promulgated in the early '80's. It has been adopted by the COST-B2 project of the European community and, in 1994, was supported by the Society of Nuclear Medicine as the nuclear medicine image file format of choice.


Interfile官方说明下载:
interfile.zip

2007年4月19日星期四

parameterizedBoxMatrix

parameterizedBoxMatrix 比 replicaMatrix 更好地被 geant 支持


gate can only read integer values for phantoms- NCAT output is float 32. When I
used it, I had to use something to convert to integer values.

如何读取phantom和source文件?

读了半天manual也不得要领。readFile命令要求什么样的文件格式呢?Translator是怎么回事?

一个例子是:
/gate/world/daughters/name ncat
/gate/world/daughters/insert parameterizedBoxMatrix
/gate/ncat/geometry/insertReader image
/gate/ncat/imageReader/insertTranslator range
/gate/ncat/imageReader/rangeTranslator/readTable range.dat
/gate/ncat/imageReader/rangeTranslator/describe 1
/gate/ncat/imageReader/readFile myo_atn.dat
/gate/ncat/attachVoxelPhantomSD

需要搞清楚的是,range.dat和myo_atn.dat的格式

注意这里用的是insertReader image,而不是insertReader interfile

2007年4月16日星期一

定义object的先后顺序

发现如果先定义detector再定义collimator(包括holes),holes的生成就特别慢;如果先定义collimator再定义detector就变得飞快。不确定先后顺序有没有问题。

daughter会和mother一起移动

如果定义B是A的daughter,那么在setTranslation移动mother的时候,daughter也会一起动。

在定义collimator的时候,把hole定义成FOV的daughter还是collimator的daughter?对最后结果有没有区别?

setRotationAngle不能叠加!

如果想把物体分别绕三个轴各旋转多少度,不能用三次setRotationAngle,即下面的方法是错误的:
/gate/PinholeInsert/placement/setRotationAxis 0 0 1
/gate/PinholeInsert/placement/setRotationAngle -10 deg
/gate/PinholeInsert/placement/setRotationAxis 1 0 0
/gate/PinholeInsert/placement/setRotationAngle 20. deg
/gate/PinholeInsert/placement/setRotationAxis 0 1 0
/gate/PinholeInsert/placement/setRotationAngle -30. deg

而必须算出最后的setRotationAxis和setRotationAngle。

setTranslation与setRotation

setTranslation与setRotationAngle每次移动物体时,是在以前一个位置的基础上,还是每次都是从原点开始?

简单测试一下:

运行两遍 /gate/PinholeInsert/placement/setTranslation -20 0 0 mm,发现第二遍不再动,说明每次setTranslation都是以原点为基准的绝对位移。

 /gate/PinholeInsert/placement/setRotationAxis 0 1 0   
 /gate/PinholeInsert/placement/setRotationAngle 10 deg 也是如此。



2007年4月13日星期五

New Gate 支持 Cluster

下面是Gate-users邮件列表里面的一封:

Dear Gaters,
The last Gate version, gate v3.1.0, is now available on our official
web
site.

_/http://opengatecollaboration.healthgrid.org/GATEregisteredUsers/download_index.php/_

This version includes tools to run Gate on a cluster architecture.
Find all informations about new developments and installation
configurations in the README and ReleaseNotes.pdf files.
For details about developments (specially for cluster tools), you can
download the last User's Guide version : v3.1.0.

All the best
Sebastien JAN

2007年4月12日星期四

New Gate (3.1.0)

新的Gate3.1.0启动正常。

如果不是先cd到G4WORKDIR下面再运行Gate,就和3.0.0一样提示:

I/O warning : failed to load external entity "Materials.xml"
   GateMaterialDatabase: did not find the Materials.xml file: no properties read for material 'Air'
     This is only a problem when OPTICAL PHOTONS are transported in this material.'

在G4WORKDIR下面再运行没有问题。

*************************************************************
 Geant4 version Name: geant4-08-01-patch-01    (27-July-2006)
                      Copyright : Geant4 Collaboration
                      Reference : NIM A 506 (2003), 250-303
                            WWW : http://cern.ch/geant4
*************************************************************

Visualization Manager instantiating...
Visualization Manager initialising...
Registering graphics systems...

You have successfully registered the following graphics systems.
Current available graphics systems are:
  ASCIITree (ATree)
  DAWNFILE (DAWNFILE)
  GAGTree (GAGTree)
  G4HepRep (HepRepXML)
  G4HepRepFile (HepRepFile)
  RayTracer (RayTracer)
  VRML1FILE (VRML1FILE)
  VRML2FILE (VRML2FILE)
  OpenGLImmediateX (OGLIX)
  OpenGLStoredX (OGLSX)
  RayTracerX (RayTracerX)

Registering model factories...

You have successfully registered the following model factories.
Registered model factories:
  generic
  drawByCharge
  drawByParticleID
  drawByOriginVolume

Registered models:
  None

Registered filter factories:
  chargeFilter
  particleFilter
  originVolumeFilter

Registered filters:
  None

Time set to (s) 0
/control/saveHistory
/run/verbose 2
/event/verbose 1
/tracking/verbose 1
/gate/timing/setTime 0. s
Time set to (s) 0
/gate/application/setTimeSlice 1. s

exit退出正常。以前的3.0.0不能用exit退出。

Upgrade Gate to 3.1.0

我在Geant4 8.1上面装了Gate 3.0.0,据说不是很好。碰到一些问题,也不知道是不是版本造成的。今天去Gate主页发现正巧刚刚发布3.1.0,所以就来升级一下吧。

Gate3.1.0说支持Geant4 8.1p02,我安装的是Geant4 8.1p01,希望不会有问题。

1. Set the environment variable GATEHOME to /Application/gate3.1.0

2. Adapt the GATE configuration script env_gate.csh to your environment
2.1 $G4INSTALL /Applications/geant4.8.1.p01/
2.2 make sure that this directory contains a Geant4 configuration script env.csh;
2.3 $ G4VERSION 8.1

3. Launch the configuration script env_gate.csh by typing source env_gate.csh;

The current value of G4INSTALL is: /Applications/geant4.8.1.p01/
The current value of G4VERSION is: 8.1

Launching Geant4 configuration script /Applications/geant4.8.1.p01//env.csh

On this machine the G4SYSTEM=Darwin-g++
On this machine the G4INSTALL=/Applications/geant4.8.1.p01
On this machine the G4LIB=/Applications/geant4.8.1.p01/lib
On this machine the G4LEVELGAMMADATA=/Applications/geant4.8.1.p01/data/PhotonEvaporation2.0
On this machine the G4RADIOACTIVEDATA=/Applications/geant4.8.1.p01/data/RadiativeDecay3.0
On this machine the G4LEDATA=/Applications/geant4.8.1.p01/data/G4EMLOW4.0
On this machine the NeutronHPCrossSections=/Applications/geant4.8.1.p01/data/G4NDL3.9
On this machine the G4ELASTICDATA=/Applications/geant4.8.1.p01/data/G4ELASTIC1.1
On this machine the CLHEP_BASE_DIR=/sw
On this machine the CLHEP_INCLUDE_DIR=/sw/include
On this machine the CLHEP_LIB_DIR=/sw/lib
On this machine the CLHEP_LIB=CLHEP
On this machine the G4VIS_BUILD_OPENGLX_DRIVER=1
On this machine the G4VIS_BUILD_RAYTRACERX_DRIVER=1
On this machine the G4VIS_USE_OPENGLX=1
On this machine the G4VIS_USE_RAYTRACERX=1
On this machine the XMFLAGS=
On this machine the XMLIBS=
On this machine the XMFLAGS=
On this machine the XMLIBS=
On this machine the XAWFLAGS=
On this machine the XAWLIBS=
On this machine the G4LIB_BUILD_STATIC=1
On this machine the G4LIB_USE_GRANULAR=1
On this machine the G4UI_USE_TCSH=1
In your environment you have the G4WORKDIR=/Users/zixiongcao/G4work

Configuring GATE options

G4WORKDIR set to .
G4TMP set to ./tmp
G4BIN set to ./bin
Data analysis and output features enabled
Ascii data output enabled
Transport and generation of optical photons is enabled
Checking your LD_LIBRARY_PATH variable...
==> OK: /Users/zixiongcao/Projects/Root/lib is already in your LD_LIBRARY_PATH
Use of ROOT enabled
ROOT real-time plotter disabled
LMF data output disabled
ECAT7 data output disabled
GATEHOME is set to /Applications/gate_v3.1.0
Checking your path variable...
==> OK: /Applications/gate_v3.1.0/bin/Darwin-g++ is already in your path variable
G4VERSION7 is not set: GATE is compatible with the geant4 version 7.1
G4VERSION8 is set: GATE is compatible with the geant4 version 8.0 and 8.1

Done
不知道为什么总是把G4WORKDIR设成了当前目录(.)。

4. make

Compiling GateVoxelReplicaMatrixInserterMessenger.cc ...
Compiling GateXMLDocument.cc ...
Creating/replacing object files in ./tmp/Darwin-g++/Gate/libGate.a ...
ar: creating archive ./tmp/Darwin-g++/Gate/libGate.a
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateHitConverter.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateRadioactiveDecay.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateRadioactiveDecayMessenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoAccelToEcat7.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoAccelToEcat7Messenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoToEcat7.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoToEcat7Messenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToLMF.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToLMFMessenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToRootPlotter.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToRootPlotterMessenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateHitConverter.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateRadioactiveDecay.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateRadioactiveDecayMessenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoAccelToEcat7.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoAccelToEcat7Messenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoToEcat7.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateSinoToEcat7Messenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToLMF.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToLMFMessenger.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToRootPlotter.o) has no symbols
ranlib: file: ./tmp/Darwin-g++/Gate/libGate.a(GateToRootPlotterMessenger.o) has no symbols
Compiling Gate.cc ...
warning: this program uses gets(), which is unsafe.
Using granular libraries ...
Linking Gate ...
powerpc-apple-darwin8-g++-4.0.1: unrecognized option '-rdynamic'
... Done!

如何使用attachPhantomSD

如果定义了FOV,里面有daughters比如phantom和collimator,那么每个都需要用一遍attachPhantomSD命令么?

/gate/FOV/attachPhantomSD
/gate/collimator/attachPhantomSD
/gate/pinhole/attachPhantomSD

还是用第一个就够了?

如何定义collimator?

Collimator需要attachPhantomSD么?

Manual里好像说对collimator既可以用attachPhantomSD也可以用attachCrystalSD,到底是什么时候用哪个呢?

Gate Intro

GATE, the Geant4 Application for Emission Tomography, incorporates the Geant4 libraries in a modular, versatile, and scripted simulation toolkit which is adapted to the field of nuclear medicine. In addition, GATE allows the accurate description of time-dependent phenomena such as source or detector movement and source decay kinetics. The ability to synchronize all time-dependent components allows a coherent description of the acquisition process and is one of the most innovative features of GATE. It makes it possible to perform realistic simulations of data acquisitions in time. The example below shows the simulation of the decay of O-15 (in green) and C-11 (in blue) sources throughout 3 time frames with the GATE: 0-2 min (left), 7-9 min (centre), and 14-16 min (right). On all frames, one detector has been hidden (gap in the detector ring) to illustrate the scanner rotation steps.
















In addition to the timing features, a dedicated scripting mechanism extends the native command interpreter of Geant4 and allows to perform and control the Monte Carlo simulation in an intuitive manner. Moreover, the Geant4 interaction histories or hits can be further processed to realistically mimic detector output pulses. This digitization of the hits allows for the modeling of the detector response by using a chain of processing modules designed by the user. In the example below, GATE has been used to study the effect of detector dead-time (DT) and coincidence time window duration (CW) on the Noise Equivalent Count (NEC) rate of a prospective small animal PET scanner design. Detector electronic response was modeled including detector cross-talk, transfer efficiency of the scintillation photons to the photodetector, quantum efficiency of the photodetector, detector energy resolution, and trigger efficiency.

欢迎加入Gate学习小组!

这里是Gate中文学习小组。如果你也在学习和使用Gate,欢迎你加入我们的小组,并且共同来写这个学习博客。下面是加入我们的方法:

1. 给shawn@tutorsky.net发一个邮件,说明你想加入"Gate学习小组"

2. 我收到邮件后会告诉你一个特殊的邮件地址,以后你往这个地址发邮件,邮件内容就自动转成文章发表在我们的博客上了

Shawn
shawn@tutorsky.net