I think the line is:
dicom_file = os.path.join("/",dirName,filename)
maybe a problem? He will join all three to form a path rooted in '/'. For example:
os.path.join("/","directory","file")
will give you "/ directory / file" (absolute path), and:
os.path.join("directory","file")
will provide you with a "directory / file" (relative path)
, , , "*.dcm",
glob:
import glob
files_with_dcm = glob.glob("*.dcm")
:
import glob
files_with_dcm = glob.glob("/full/path/to/files/*.dcm")
os.listdir(dirName) , , whatnot
exists = os.path.isfile(dicom_file) , "if exists:".
glob, , :
if exists:
try:
ds = dicom.read_file(dicom_file)
except InvalidDicomError as exc:
print "something wrong with", dicom_file
/, : , ...