Questions tagged [pydicom]
pydicom is a pure Python package for working with DICOM files such as medical images, reports, and radiotherapy objects.
251
questions
-1
votes
0
answers
17
views
Cornerstone3d Server and multi-frame image
We are working from several days to run cornerstone 3d example with our local dicom images. We have used dicomweb-client (https://dicomweb-client.readthedocs.io/en/latest/introduction.html) to post ...
-1
votes
0
answers
39
views
How to convert DICOM header tag for slice timing to number?
I would like to extract fmri slice timing from a DICOM header, but the corresponding tag (dicom_0x0019:el_0x1029) is encoded in a way I don't know how to convert back to numbers. Could you please help?...
-3
votes
0
answers
31
views
Why am I unable to view pixel_array in the DICOM file? [closed]
I'm utilizing the Pydicom library in python to open Dicom and view it but it throws me a boolean value of "False" when I check the PixelData in mydicomfile. I have attached the snippet of my ...
0
votes
0
answers
55
views
Why does saving a DICOM file as a JPG image set using Python Imaging Library result in grayscale images? [duplicate]
I use dcmread to read a DICOM file as many slices of images.
For example, a single DICOM file can convert to 60 JPG images.
Then, I use a for-loop to save every slice as JPG image sequentially.
from ...
-2
votes
0
answers
46
views
Pydicom file_meta throwing error on AWS Lambda
I have a file that I read into a lambda function from s3 using this code:
object_for_meta = s3.get_object(Bucket = bucket, Key = file_meta)
meta_dicom = object_for_meta['Body'].read()
metadata = ...
-1
votes
1
answer
58
views
Using Pseudo Color Softcopy Presentation State with Weasis dicom viewer
I plan to use Pseudo Color Softcopy presentation state(PCSPS) to map pixel values from grayscale space to rgb space. I don't want set the photometric interpretation in the original dicom file to '...
0
votes
1
answer
68
views
How to retrieve .dcm image files from the ADLS gen2 using Azure Synapse and pySpark notebook?
I want to access the files of type .dcm (dicom) stored in a container on ADLS gen2 in a pyspark notebook on azure synapse analytics. I'm using pydicom to access the files but getting and error that ...
-1
votes
1
answer
61
views
Python DICOM--pixel dimension
I beginner in DICOM file, how to find pixel dimension or dim in these files? As we find these elements in the nifti files!
3
votes
2
answers
77
views
Extracting specific data from multiple DICOM files
I have multiple DICOM files with similar data, for example:
(0008, 0023) Content Date DA: '20200209'
(0008, 0033) Content Time TM: '192356.853736'
(0010, ...
1
vote
1
answer
90
views
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, ...
1
vote
1
answer
91
views
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
vote
1
answer
42
views
Is it possible to retrieve beam real world position from RT PLAN
I am currently working on some radiotherapy plan generation and I am trying to retrieve the beam source position from a DICOM RTPLAN file and point it on a related CT-Scan 3D image.
With the RTPLAN, I ...
0
votes
0
answers
19
views
Reorient/Reshape nifti image generatet from dicom stack
Im loading a dicom-series of 2D-Slice images and trying to convert them to single 3D-Nifti images:
import dcmstack
import torch
import torchio as tio
import nibabel as nib
from nibabel import ...
1
vote
1
answer
245
views
Get all images of a multi-frame DICOM file
I'm trying get all images in a multi-frame DICOM file. Right now I was successfully able to see and save a single image in a single-frame DICOM file, by using the pydicom and matplotlib libraries, ...
0
votes
1
answer
44
views
Resize the Depth of CT data in Python
I have multiple CT datasets in Dicom format all with varying number of slices or 2D CT images.
Example:
Dataset 1 Shape: (512 x 512) x 100
Dataset 2 Shape: (512 x 512) x 130
Dataset 3 Shape: (512 x ...
1
vote
0
answers
57
views
Pydicom private tag written as "UN"
I am adding some private tags with VR "LO" to an already existing DICOM file. With something like:
dcm.add_new("70d12000", "LO", "Private tag content")
Getting ...
0
votes
2
answers
65
views
trying to show image of a mammograms with pydicom
plt.imshow(datasetP2.pixel_array, cmap=plt.cm.bone)
tried this code on a file provided to me and ended up with this error
---------------------------------------------------------------------------
...
1
vote
0
answers
51
views
Stacking multiple Dicom series for a same patient
I have a a sereies of Dicom images for each patient and I would like to stack them and save them as one Volumetric Dicom image, Any idea of how to do that?
from glob import glob
import dcmstack
import ...
1
vote
1
answer
97
views
finding the size of an item in a Siemens DICOM tag
I am tryying to read a multi-slice (Mosaic) DICOM image from a Siemens scanner in C++, using DCMTK to read the tag and information on the nibabel pages.
As I understand, Mosaic images have a CSA ...
1
vote
1
answer
207
views
Extracting Data from a DICOMDIR file using Pydicom
I'm unable to read in a DICOM file as I usually would, citing the error:
AttributeError: 'DicomDir' object has no attribute 'DirectoryRecordSequence'
I've tried:
pydicom.fileset.FileSet
using ...
0
votes
1
answer
356
views
Conversion not working properly using dicom2nifti
I have a series of dicom files (.dcm) for each patient that I want to convert to nii.gz files, but nothing happens (even error info) with the following conversion...
import dicom2nifti
dicom2nifti....
0
votes
0
answers
102
views
How do I convert a 4D image to a DICOM image in pydicom?
I have a 4D dicom image which I read with dcmread. Consequently, I change a few pixels to black in order to remove the imprinted patient information. However, if I want so save these changes I get ...
1
vote
2
answers
323
views
Error when converting DICOM image to pixel_array using tensorflow_io
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 ...
0
votes
1
answer
211
views
How to access all tags from a DICOM group number?
I would like to extract from a DICOM all the dicom tags with the same group number. For example, I would like to extract all tags belonging to the group 0010. I tried this, and of course it made an ...
0
votes
1
answer
127
views
dummy mask for sample DICOM Image
I am trying to create a dummy mask on a sample DICOM Image using pydicom, Opencv and numpy
Getting error -
Traceback (most recent call last):
File "mymask.py", line 22, in <module>
...
0
votes
1
answer
65
views
Converting dicom file raising an OSError: cannot write mode I;16 as JPEG
I am trying to convert a Computed Radiography dicom file to jpeg using the code below but its raising an OSError: cannot write mode I;16 as JPEG. Here is the code I am using to convert:
ds = ...
0
votes
0
answers
191
views
Is there a way to save a 3D volume to a single DICOM file in python
I'm processing a 3D numpy array and would like to know if it is possible to write/read the entire 3D volume as 1 single 3D .dcm rather than a series of 2D .dcm files. Can this be accomplished using ...
0
votes
2
answers
402
views
Translate Image Orientation into axial, sagittal, or coronal plane
I've read through this question (Understanding DICOM image attributes to get axial/coronal/sagittal cuts) and responses a bunch, but I still can't seem to figure out the translation to connect the ...
0
votes
1
answer
212
views
DICOM image is not read correctly
I have a dicom file from which I read images. The images I read, however, has incorrect colormap. Ideally, the image should look like:
However, the following code only gives me
If I only take the red ...
0
votes
1
answer
73
views
Problem with assigning 2d array as a one slice of 3d array
I try to load series of DICOM files into 3d array. I do this on bad way because I got an error something like this (not fluent in Python):
ValueError: could not broadcast input array from shape (512,...
-1
votes
1
answer
584
views
Access DICOM files via DICOMDIR using pydicom
I am new to this file type. I want to access files in the folder S65279_1148582599_LIVER__QIU__SHIFU__M_53 by accessing the DICOMDIR located besides that folder. Inside the folder, I want to access ...
0
votes
1
answer
195
views
loading dicoms with pydicom and sitk results different outputs
My problem is a bit wired. I am working on Prostate MRI dataset which contains dicom images. When I load dicom files using Simple ITK the output numpy array's dtype will be float64 . But when I load ...
1
vote
1
answer
154
views
Trying to input a RGB fMRI DICOM image, modify it, and save it as a grayscale dicom image in Python using pydicom
I am trying to take in an RGB fMRI scan as input and output the same scan but in grayscale with the color parts "burned" white essentially.
Whenever I try and modify any of the Data Elements,...
0
votes
0
answers
67
views
Can't create dataloader although dataset is created correctly
I have write a custom Dataset for DICOM files. The getitem() function works well and I get the data with its label. Here is the custom dataset code:
class MyDataset(Dataset):
def __init__(...
0
votes
0
answers
38
views
Problems with replacing PixelData of Dicom file using Pydicom
I am trying to replace the PixelData of a CT dicom slice with another array translated by a CNN model from the original. The new array has the same dimension as the original, while I want to keep all ...
0
votes
1
answer
228
views
How to edit nested/child DICOM tags for sequences using pyDicom?
I'm trying to set all the TIME (VR = TM) tags contained within the DICOM dataset to a placeholder value, using pyDicom.
I can remove the value of all the TIME (VR = TM) tags that are within the root ...
0
votes
0
answers
12
views
Got a pydicom fail with dcmread [duplicate]
i got a problem with pydicom. I copied code from an example page and it gives me an error.
My Code
import pydicom
from pydicom.data import get_testdata_file
from pydicom import dcmread
fpath = ...
0
votes
1
answer
361
views
How to volume render 3D numpy array using VTK (MarchingCubes) in Python?
I have a 3D numpy array and I am trying to volume render it using VTK. However, I get a completely different volume rendering when I visualise it. I suspect it has something to do with my conversion ...
0
votes
1
answer
121
views
How to use VTK_array in VTK pipeline (Python)?
I am new to vtk and am trying to do volume rendering with a DICOM file.
When I try to read the DICOM file using VTK with the following code:
import vtk
reader = vtk.vtkDICOMImageReader()
reader....
3
votes
1
answer
84
views
Rescaling Dicom pixel values to be in the range [0,1]
I haven't been able to find the range of values that is returned from .pixel_array so I'm not sure how to scale the values to a custom range like [0,1]. Is there a pydicom inbuilt function that does ...
2
votes
1
answer
422
views
How to display Series data from DICOM C-FIND results? [duplicate]
I'm new to DICOM and was wondering how I would be able to return results of a C-FIND similar to how applications like Osirix display them after a query.
I'm doing this strictly in Python with ...
0
votes
0
answers
88
views
Animation of multiple stacked numpy array
Here is the problem.
I have two 3D numpy arrays, one extracted from DICOM images using pydicom library (that I shall call "phantom") and the other that binary I constructed (which I will ...
2
votes
1
answer
461
views
How to replace pixel data in dicom image with pydicom?
I'm trying to replace pixel data in given example image. My code:
import matplotlib.pyplot as plt
from pydicom import dcmread
from pydicom.data import get_testdata_file
fpath = get_testdata_file('...
2
votes
2
answers
431
views
Reading CT Scan dicom file
i am trying to read CT scan Dicom file using pydicom python library but i just can't get rid of this below error even when i install gdcm and pylibjpeg
RuntimeError: The following handlers are ...
1
vote
1
answer
266
views
Generating spatially correlated statistical noise using autocorrelation and python
I’m trying to emulate the methodology described in this paper:
http://www.ajnr.org/content/34/8/1506
under the heading “Noise Addition to Simulate Dose Reduction”
As far as I understand the authors ...
2
votes
1
answer
431
views
Create a Dicom from multiple jpg images
I've successfully built dicoms with one images but I cannot find a way to add more...
I think the problem may be in my pixel array, can anyone help me correct it ?
# Populate required values for file ...
0
votes
1
answer
668
views
How to save DICOM in same series using pydicom [duplicate]
I have saved the Preprocessed DICOM in a folder total of 300 .dcm files, but when I open this DICOM folder path in RadiANT DICOM Viewer only One slice is displayed, here is my code is attached, Can ...
1
vote
2
answers
979
views
Dicom to PNG Conversion - output image is completely black
While conversion of dicom to png using Python, without getting any error.
Output file is complete Black, although image array have variable values.
Code:
import pydicom
import cv2
import os
dicom = ...
1
vote
1
answer
392
views
Sorting DICOM images without SliceLocation attribute
Does anyone know if it is possible to sort dicom files if there is no SliceLocation attribute?
By "sort" I mean arrange the images longitudinally (in a craniocaudal orientation) with the ...
1
vote
2
answers
133
views
how to open dicom image using fastai?
I am working on Dicom images using pydicom.
But my project is in fasai and I want to open that Dicom image using the fastai library.
In fastai, we normally do open_image(path) its work fine for png or ...