GDCM python DICOM解压

2024-09-27 19:26:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我执行了这个python script。线路出错了

t = gdcm.Orientation.GetType(dircos)

错误信息是:

^{pr2}$

我查了classes reference。上面写着

Input is an array of 6 double

变量dircos正好是一个包含6个元素的列表

>>> dircos
Out[11]: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]

我不知道为什么会出错。在


Tags: ofaninputisscriptarray线路classes
1条回答
网友
1楼 · 发布于 2024-09-27 19:26:01

我检查了源代码,发现它实际上检查了tuple。这个信息是误导性的。在

// Grab a 6 element array as a Python 6-tuple
%typemap(in) const double dircos[6] (double temp[6]) {   // temp[6] becomes a local variable
  int i;
  if (PyTuple_Check($input) /*|| PyList_Check($input)*/) {
    if (!PyArg_ParseTuple($input,"dddddd",temp,temp+1,temp+2,temp+3,temp+4,temp+5)) {
      PyErr_SetString(PyExc_TypeError,"list must have 6 elements");
      return NULL;
    }
    $1 = &temp[0];
  } else {
    PyErr_SetString(PyExc_TypeError,"expected a list.");
    return NULL;
  }
}

您需要传递一个元组:

^{pr2}$

相关问题 更多 >

    热门问题