I beginner in DICOM file, how to find pixel dimension or dim in these files? As we find these elements in the nifti files!
Asked
Active
Viewed 988 times
-1
-
It generally depends on the modality. For many modalities (like MR and CT) you will find the x/y dimension in the tag `PixelSpacing`. For the the z dimension, see for example [this question](https://stackoverflow.com/questions/65389506/how-to-calculate-a-voxel-size), but it also depends on the modality. – MrBean Bremen May 28 '22 at 10:54
1 Answers
3
With the pydicom
library you can get the pixel spacing and pixel data dimensions in the following way:
import pydicom
ds = pydicom.dcmread("/path/to/dcm_file.dcm")
# The size of each pixel
pixel_spacing = ds.PixelSpacing
# The number of pixels in each frame
rows = ds.Rows
columns = ds.Columns
# The number of frames, if there's more than 1
nr_frames = getattr(ds, "NumberOfFrames", 1)

scaramallion
- 1,251
- 1
- 6
- 14

blunova
- 2,122
- 3
- 9
- 21