pydicom

PyDICOM Returns KeyError Even Though Field Exists

PyDICOM Returns KeyError Even Though Field Exists Question: I’m reading in a DICOM with pydicom.read_file() like this: x = pydicom.read_file(/path/to/dicom/) This returns an instance of FileDataset but I get an error when trying to access a value like this: x[0x20,0x32] OUTPUT: *** KeyError: (0020, 0032) I also tried accessing the value like this: x.ImagePositionPatient OUTPUT: …

Total answers: 1

Converting hand radiograph DICOM to PNG returns white/bright image

Converting hand radiograph DICOM to PNG returns white/bright image Question: I am converting hand X-rays in DICOM format to PNG format. The code below does this: import os import cv2 import pydicom import numpy as np from PIL import Image inputdir = "P:/BoneDataset/DICOM-File/0-RefinedDICOM/" outdir = ‘P:/BoneDataset/DICOM-File/1-ConvertedPics/’ test_list = [f for f in os.listdir(inputdir)] for f …

Total answers: 1

Error when converting DICOM image to pixel_array using tensorflow_io

Error when converting DICOM image to pixel_array using tensorflow_io Question: I am trying to create a TensorFlow Dataset from DICOM images using the tf.data API and tensorflow_io, and I want to perform some pre-processing using Hounsfield units from the images. The DICOM images have a shape of (512,512). I have extracted the PixelData from the …

Total answers: 2

DICOM slicing orders in python

DICOM slicing orders in python Question: I have a question about slices ordering: I have about 80 pictures of hip joint but there are not arranged from feet to head or head to feet. Is there any way to arrange them in an intended order? # pixel aspects, assuming all slices are the same ps …

Total answers: 1

Using dicom Images with OpenCV in Python

Using dicom Images with OpenCV in Python Question: I am trying to use a dicom image and manipulate it using OpenCV in a Python environment. So far I have used the pydicom library to read the dicom(.dcm) image data and using the pixel array attribute to display the picture using OpenCV imshow method. But the …

Total answers: 4

Reading .dcm files from a nested directory

Reading .dcm files from a nested directory Question: This is the form of my nested directory: /data/patient_level/study_level/series_level/ For each patient_level folder, I need to read the “.dcm” files from the corresponding “series_level” folder. How can I access the “.dcm” file in the “series_level” folders? I need 3 features from a DICOM object. This is my …

Total answers: 1