Questions tagged [pydicom]

pydicom is a pure Python package for working with DICOM files such as medical images, reports, and radiotherapy objects.

pydicom is a pure Python package for working with DICOM files. pydicom makes it easy to read these complex files into natural pythonic structures for easy manipulation. Modified datasets can be written again to DICOM format files.

Resources

276 questions
3
votes
1 answer

From numpy array to DICOM

My code reads a DICOM file, takes the pixel information to a numpy array then it modifies the numpy array. It uses lists because im trying to operate with multiple DICOM files at the same time. I havent found any information on how to take my…
3
votes
1 answer

How to convert 2D DICOM slices to 3D image in Python

I am currently sitting on an task in which I need to plot DICOM slices into one 3D model using NumPy, Matplotlib, (Marchingcubes, Triangulation or Volumemodel) I have tried the method from this website :…
3
votes
1 answer

How to store the header data of a DICOM file in a pandas dataframe?

I am trying to read DICOM files using pydicom in Python and want to store the header data into a pandas dataframe. How do I extract the data element value for this purpose? So far I have created a dataframe with columns as the tag names in the DICOM…
Ashutosh Kumar
  • 109
  • 1
  • 9
3
votes
4 answers

Using dicom Images with OpenCV in Python

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.…
Mushfiq Alam
  • 49
  • 1
  • 1
  • 5
3
votes
1 answer

Unable to access PACS using pynetdicom3

I'm trying to connect to a PACS server using Python (specifically pynetdicom3), however I'm unable to do so using the method specified in the documentation. I am able to access this server using dcm4che. E.g. running findscu -c AETitle@serverIP:port…
3
votes
1 answer

How to extract/view all frames of a multi-frame DICOM file?

I know I can view a dicom file using following code: import dicom from dicom.contrib.pydicom_PIL import show_PIL f = "CT-MONO2-8-abdo.dcm" ds = dicom.read_file(f, force=True) show_PIL(ds) However, how can I extract and view all frames from a…
rnso
  • 23,686
  • 25
  • 112
  • 234
3
votes
3 answers

How to convert 12 bit DICOM image to 8 bit jpeg?

I am trying to load DICOM files into python using the DICOM library. I have done the following ds=dicom.read_file(r"C:\Users\Z003SPFR.AD005\ML\GLCM AND SVM\data\NECT\1.IMA") # # store the raw image data DicomImage = ds.pixel_array This gives me…
Reshma
  • 51
  • 1
  • 4
3
votes
2 answers

Anaconda and package installation (pydicom)

I have the following problem. I have tried to install the pydicom package in python 2.7 using the following command (windows, anaconda setup): conda install -c conda-forge pydicom everything seems to work fine, the package seems to be…
Eli
  • 81
  • 1
  • 6
3
votes
1 answer

Calculating value tag DICOM

I have a set of 20 DICOM images, and I need to show the average of Window and Center of these 20 images. Using pydicom I get the value of these tags, where the value of the 20 images are equal, WindowWidth = ['56', '3200'] and WindowCenter = ['29',…
Pedro Monteiro
  • 347
  • 1
  • 4
  • 12
3
votes
4 answers

pydicom module not found by python

The error message: In [1]: import pydicom as dicomio --------------------------------------------------------------------------- ImportError Traceback (most recent call last) in…
Linda Marsh
  • 105
  • 1
  • 1
  • 9
2
votes
2 answers

DICOM slice thickness in Python

I'm working on a project that requires slicing a 3D .stl file into a stack of DICOM slices, and I need to get the distance between the slices. I have figured out how to include the real .stl dimensions (in mm) in each DICOM file, using Autodesk…
Nico
  • 75
  • 5
2
votes
1 answer

How to mask a DICOM image?

I would like to analyze only "Bone" regions extracted from Head CT. For that, I read the DICOM files and masked regions where pixel values were less than 200 by filling in "0". However, because "0" means "water" in the DICOM image, I don't know…
kodhoi
  • 23
  • 5
2
votes
1 answer

PyDICOM Returns KeyError Even Though Field Exists

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…
nikebol906
  • 152
  • 1
  • 7
2
votes
1 answer

How to overlay a heatmap numpy array in red on a gray image?

I have tried first converting the grayscale image and the 2D-heatmap to RGB images. The heatmap is converted by making all except the red dimension zeros. Then the image is masked with a threshold, where the heatmap is above 0.01, and a new image is…
2
votes
1 answer

How to color a grayscale image based on a mask?

I have two images: A grayscale image, and a binary mask with the same dimensions. How do I color the image on the mask, while the rest of the image remains grayscale? Here's and example:
1 2
3
18 19