2007年4月23日星期一

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的错误。


0 条评论:

发表评论

订阅 博文评论 [Atom]

<< 主页