Pydicom tutorial


In [1]:
import scipy
import scipy.misc
# import skimage
# import skimage.io
import numpy as np
# import urllib
# import cStringIO

import matplotlib.pyplot as plt

In [2]:
# conda install -c conda-forge -c mjirik scikit-image

In [3]:
import pydicom
import os.path
import glob

if 5 < 10:
    print("ahoj " + str(18))
    print(10)
else:
    print("je to mensi")


pth = os.path.expanduser("~/data/medical/orig/jatra_5mm/*.dcm")


ahoj18
10

In [4]:
pth


Out[4]:
'C:\\Users\\miros/data/medical/orig/jatra_5mm/*.dcm'

In [5]:
pths = glob.glob(pth)
pths


Out[5]:
['C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0001.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0002.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0003.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0004.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0005.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0006.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0007.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0008.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0009.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0010.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0011.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0012.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0013.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0014.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0015.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0016.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0017.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0018.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0019.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0020.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0021.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0022.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0023.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0024.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0025.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0026.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0027.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0028.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0029.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0030.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0031.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0032.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0033.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0034.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0035.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0036.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0037.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0038.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0039.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0040.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0041.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0042.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0043.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0044.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0045.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0046.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0047.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0048.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0049.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0050.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0051.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0052.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0053.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0054.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0055.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0056.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0057.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0058.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0059.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0060.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0061.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0062.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0063.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0064.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0065.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0066.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0067.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0068.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0069.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0070.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0071.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0072.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0073.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0074.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0075.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0076.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0077.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0078.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0079.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0080.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0081.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0082.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0083.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0084.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0085.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0086.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0087.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0088.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0089.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0090.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0091.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0092.dcm',
 'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0093.dcm']

In [6]:
pths[0]


Out[6]:
'C:\\Users\\miros/data/medical/orig/jatra_5mm\\IM-0001-0001.dcm'

In [7]:
dcmobj = pydicom.read_file(pths[0])
# dcmobj

Dicom tags


In [8]:
dir(dcmobj)


Out[8]:
['AccessionNumber',
 'AcquisitionDate',
 'AcquisitionNumber',
 'AcquisitionTime',
 'BitsAllocated',
 'BitsStored',
 'BodyPartExamined',
 'CTDIvol',
 'Columns',
 'ContentDate',
 'ContentTime',
 'ContrastBolusAgent',
 'ContrastBolusIngredientConcentration',
 'ContrastBolusVolume',
 'ContrastFlowDuration',
 'ContrastFlowRate',
 'ConvolutionKernel',
 'DataCollectionDiameter',
 'DateOfLastCalibration',
 'DerivationDescription',
 'DeviceSerialNumber',
 'DistanceSourceToDetector',
 'DistanceSourceToPatient',
 'EstimatedDoseSaving',
 'ExposureModulationType',
 'FrameOfReferenceUID',
 'GantryDetectorTilt',
 'HighBit',
 'ImageComments',
 'ImageFrameOrigin',
 'ImageOrientationPatient',
 'ImagePositionPatient',
 'ImageType',
 'InstanceNumber',
 'KVP',
 'LargestImagePixelValue',
 'Manufacturer',
 'ManufacturerModelName',
 'Modality',
 'NumberOfFramesInOverlay',
 'OverlayBitPosition',
 'OverlayBitsAllocated',
 'OverlayColumns',
 'OverlayData',
 'OverlayDescription',
 'OverlayOrigin',
 'OverlayRows',
 'OverlayType',
 'PatientAddress',
 'PatientAge',
 'PatientBirthDate',
 'PatientID',
 'PatientName',
 'PatientPosition',
 'PatientSex',
 'PerformedStationAETitle',
 'PerformingPhysicianName',
 'PhotometricInterpretation',
 'PixelData',
 'PixelRepresentation',
 'PixelSpacing',
 'PositionReferenceIndicator',
 'ProcedureCodeSequence',
 'ProtocolName',
 'ReconstructionDiameter',
 'ReferencedImageSequence',
 'ReferringPhysicianName',
 'RequestAttributesSequence',
 'RequestedProcedureCodeSequence',
 'RequestedProcedureDescription',
 'RescaleIntercept',
 'RescaleSlope',
 'RotationDirection',
 'Rows',
 'SOPClassUID',
 'SOPInstanceUID',
 'SamplesPerPixel',
 'SeriesDate',
 'SeriesDescription',
 'SeriesInstanceUID',
 'SeriesNumber',
 'SeriesTime',
 'SingleCollimationWidth',
 'SliceLocation',
 'SliceThickness',
 'SmallestImagePixelValue',
 'SoftwareVersions',
 'SourceImageSequence',
 'SpecificCharacterSet',
 'SpiralPitchFactor',
 'StationName',
 'StorageMediaFileSetUID',
 'StudyDate',
 'StudyDescription',
 'StudyID',
 'StudyInstanceUID',
 'StudyTime',
 'TableFeedPerRotation',
 'TableHeight',
 'TableSpeed',
 'TimeOfLastCalibration',
 'TotalCollimationWidth',
 'WindowCenter',
 'WindowCenterWidthExplanation',
 'WindowWidth',
 '__contains__',
 '__delattr__',
 '__delitem__',
 '__dir__',
 '__enter__',
 '__eq__',
 '__exit__',
 '__format__',
 '__ge__',
 '__getattr__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__init__',
 '__init_subclass__',
 '__iter__',
 '__le__',
 '__len__',
 '__lt__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_character_set',
 '_convert_YBR_to_RGB',
 '_get_pixel_array',
 '_is_uncompressed_transfer_syntax',
 '_pretty_str',
 '_reshape_pixel_array',
 '_slice_dataset',
 'add',
 'add_new',
 'clear',
 'convert_pixel_data',
 'copy',
 'data_element',
 'decode',
 'decompress',
 'dir',
 'formatted_lines',
 'fromkeys',
 'get',
 'get_item',
 'group_dataset',
 'items',
 'iterall',
 'keys',
 'pixel_array',
 'pop',
 'popitem',
 'remove_private_tags',
 'save_as',
 'setdefault',
 'top',
 'trait_names',
 'update',
 'values',
 'walk']

In [9]:
dcmobj.SeriesDescription


Out[9]:
'DE_Abdom_1F  5.0  B30f M_0.3'

In [10]:
hasattr(dcmobj, "SeriesDescription")


Out[10]:
True

Obrazová data


In [11]:
data3d = dcmobj.pixel_array
data3d


Out[11]:
array([[0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       ..., 
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0]], dtype=uint16)

In [12]:
plt.imshow(data3d[:, :])
plt.colorbar()


Out[12]:
<matplotlib.colorbar.Colorbar at 0x1ec4ba80240>

In [13]:
plt.imshow(data3d[:, :], cmap="gray")


Out[13]:
<matplotlib.image.AxesImage at 0x1ec4bd91588>

Processing files in directory

$a^2 + 3 = y$


In [14]:
for filename in pths:
    dcmobj = pydicom.read_file(filename)
    print(dcmobj.SliceLocation, filename)


-601.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0001.dcm
-606.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0002.dcm
-611.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0003.dcm
-616.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0004.dcm
-621.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0005.dcm
-626.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0006.dcm
-631.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0007.dcm
-636.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0008.dcm
-641.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0009.dcm
-646.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0010.dcm
-651.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0011.dcm
-656.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0012.dcm
-661.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0013.dcm
-666.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0014.dcm
-671.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0015.dcm
-676.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0016.dcm
-681.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0017.dcm
-686.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0018.dcm
-691.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0019.dcm
-696.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0020.dcm
-701.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0021.dcm
-706.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0022.dcm
-711.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0023.dcm
-716.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0024.dcm
-721.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0025.dcm
-726.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0026.dcm
-731.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0027.dcm
-736.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0028.dcm
-741.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0029.dcm
-746.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0030.dcm
-751.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0031.dcm
-756.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0032.dcm
-761.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0033.dcm
-766.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0034.dcm
-771.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0035.dcm
-776.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0036.dcm
-781.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0037.dcm
-786.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0038.dcm
-791.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0039.dcm
-796.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0040.dcm
-801.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0041.dcm
-806.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0042.dcm
-811.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0043.dcm
-816.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0044.dcm
-821.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0045.dcm
-826.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0046.dcm
-831.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0047.dcm
-836.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0048.dcm
-841.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0049.dcm
-846.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0050.dcm
-851.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0051.dcm
-856.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0052.dcm
-861.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0053.dcm
-866.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0054.dcm
-871.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0055.dcm
-876.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0056.dcm
-881.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0057.dcm
-886.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0058.dcm
-891.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0059.dcm
-896.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0060.dcm
-901.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0061.dcm
-906.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0062.dcm
-911.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0063.dcm
-916.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0064.dcm
-921.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0065.dcm
-926.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0066.dcm
-931.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0067.dcm
-936.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0068.dcm
-941.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0069.dcm
-946.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0070.dcm
-951.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0071.dcm
-956.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0072.dcm
-961.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0073.dcm
-966.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0074.dcm
-971.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0075.dcm
-976.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0076.dcm
-981.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0077.dcm
-986.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0078.dcm
-991.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0079.dcm
-996.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0080.dcm
-1001.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0081.dcm
-1006.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0082.dcm
-1011.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0083.dcm
-1016.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0084.dcm
-1021.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0085.dcm
-1026.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0086.dcm
-1031.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0087.dcm
-1036.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0088.dcm
-1041.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0089.dcm
-1046.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0090.dcm
-1051.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0091.dcm
-1056.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0092.dcm
-1061.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-0001-0093.dcm

In [ ]:

Tables with pandas for analysis (we don't want to use pandas in io3d)


In [40]:
import pandas as pd
df = pd.DataFrame()

for filename in pths:
#     print(filename)
    dcmobj = pydicom.read_file(filename)
    df = df.append({
        "filename": filename, 
        "SliceLocation": dcmobj.SliceLocation,
        "ContentTime": dcmobj.ContentTime
    }, ignore_index=True)
#     print(filename)
df


Out[40]:
ContentTime SliceLocation filename
0 103644.875000 -601.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
1 103645.015000 -606.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
2 103645.187000 -611.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
3 103645.312000 -616.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
4 103645.468000 -621.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
5 103645.625000 -626.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
6 103645.781000 -631.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
7 103645.921000 -636.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
8 103646.109000 -641.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
9 103646.250000 -646.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
10 103646.546000 -651.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
11 103646.671000 -656.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
12 103646.828000 -661.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
13 103646.984000 -666.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
14 103647.140000 -671.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
15 103647.281000 -676.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
16 103647.468000 -681.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
17 103647.625000 -686.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
18 103647.781000 -691.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
19 103647.937000 -696.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
20 103648.093000 -701.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
21 103648.265000 -706.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
22 103648.421000 -711.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
23 103648.562000 -716.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
24 103648.718000 -721.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
25 103648.875000 -726.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
26 103649.015000 -731.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
27 103649.171000 -736.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
28 103649.343000 -741.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
29 103649.515000 -746.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
... ... ... ...
63 103655.000000 -916.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
64 103655.171000 -921.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
65 103655.328000 -926.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
66 103655.515000 -931.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
67 103655.671000 -936.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
68 103655.843000 -941.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
69 103656.031000 -946.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
70 103656.218000 -951.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
71 103656.375000 -956.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
72 103656.578000 -961.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
73 103656.734000 -966.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
74 103656.906000 -971.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
75 103657.062000 -976.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
76 103657.234000 -981.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
77 103657.421000 -986.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
78 103657.578000 -991.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
79 103657.750000 -996.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
80 103657.937000 -1001.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
81 103658.093000 -1006.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
82 103658.250000 -1011.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
83 103658.406000 -1016.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
84 103658.578000 -1021.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
85 103658.750000 -1026.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
86 103658.937000 -1031.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
87 103659.093000 -1036.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
88 103659.265000 -1041.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
89 103659.437000 -1046.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
90 103659.609000 -1051.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
91 103659.765000 -1056.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...
92 103659.937000 -1061.6 C:\Users\miros/data/medical/orig/jatra_5mm\IM-...

93 rows × 3 columns


In [ ]: