text_plain_output_1.png
import dicom # for reading dicom files

import os # for doing directory operations

import dicom
import os
import pandas as pd
data_dir = '../input/sample_images/'
patients = os.listdir(data_dir)
patients
file_list = os.listdir('../input/')
file_list

for patient in patients[:1]:
    path = data_dir + patient
    slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)]
    slices.sort(key=lambda x: int(x.ImagePositionPatient[2]))
    print(len(slices))
    print(slices[0])