import dicom
import os
import numpy
PathDicom = "C:\Python34\Baza"
lstFilesDCM = [] # create an empty list
for dirName, subdirList, fileList in os.walk(PathDicom):
for filename in fileList:
if ".dcm" in filename.lower(): # check whether the file's DICOM
lstFilesDCM.append(os.path.join(dirName,filename))
# Get ref file
RefDs = dicom.read_file(lstFilesDCM[0])
# Load dimensions based on the number of rows, columns, and slices (along the Z axis)
ConstPixelDims = (int(RefDs.Rows), int(RefDs.Columns), len(lstFilesDCM))
# Load spacing values (in mm)
ConstPixelSpacing = (float(RefDs.PixelSpacing[0]), float(RefDs.PixelSpacing[1]), float(RefDs.SliceThickness)) ERROR: C:\Python34\python.exe C:/Users/041213/PycharmProjects/untitled1/Dejana.py Traceback (most recent call last): File "C:/Users/041213/PycharmProjects/untitled1/Dejana.py", line 13, in <module> RefDs = dicom.read_file(lstFilesDCM[0]) IndexError: list index out of range If someone could help me with this, I would really appreciate.
Or if someone could help me how do I load DICOM files in general? Sorry for a long post, Greetings,
Dejana
--
You received this message because you are subscribed to the Google Groups "pydicom" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydicom+unsubscribe@googlegroups.com.
To post to this group, send email to pyd...@googlegroups.com.
Visit this group at https://groups.google.com/group/pydicom.
For more options, visit https://groups.google.com/d/optout.
Yes, I understand that, but the problem is that is not an empty file, it consists of 20 dcm files.
import dicomfilePath="C:\Python34\Lib\site-packages\dicom\testfiles"
ds=dicom.read_file(filePath[0])Error is:
C:\Python34\python.exe C:/Users/041213/PycharmProjects/D/Deki.py Traceback (most recent call last):
File "C:/Users/041213/PycharmProjects/D/Deki.py", line 4, in
ds=dicom.read_file(filePath[0])
File "C:\Python34\lib\site-packages\dicom\filereader.py", line 589, in read_file
fp = open(fp, 'rb') FileNotFoundError: [Errno 2]
No such file or directory: 'C'
filePath=r"C:\Python34\Lib\site-packages\dicom\testfiles"--