GDCM python DICOM解压
我执行了这个。线路中发生了一个错误GDCM python DICOM解压,python,swig,dicom,gdcm,Python,Swig,Dicom,Gdcm,我执行了这个。线路中发生了一个错误 t = gdcm.Orientation.GetType(dircos) 错误信息为: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2820, in run_code exec code_obj in self.user_global_ns, self.user_n
t = gdcm.Orientation.GetType(dircos)
错误信息为:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2820, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-8-fb43b0929780>", line 1, in <module>
gdcm.Orientation.GetType(dircos)
TypeError: expected a list.
我不知道它为什么出错。我检查了源代码,发现它实际上检查了
元组。这个信息具有误导性
//获取一个6元素数组作为Python 6元组
%typemap(in)const double dircos[6](double temp[6]){//temp[6]成为局部变量
int i;
if(PyTuple_Check($input)/*| PyList_Check($input)*/){
如果(!PyArg_ParseTuple($input,“ddddddd”,temp,temp+1,temp+2,temp+3,temp+4,temp+5)){
PyErr_SetString(PyExc_TypeError,“列表必须有6个元素”);
返回NULL;
}
$1=&temp[0];
}否则{
PyErr_SetString(PyExc_TypeError,“需要一个列表”);
返回NULL;
}
}
您需要传递一个元组:
>>> import gdcm
>>> dircos = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
>>> gdcm.Orientation.GetType(tuple(dircos))
1
这已被报告为上游的一个bug
>>> import gdcm
>>> dircos = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
>>> gdcm.Orientation.GetType(tuple(dircos))
1