Created
August 21, 2014 19:35
-
-
Save janpipek/6ed17b21b15a8013eb19 to your computer and use it in GitHub Desktop.
Export pixel array from DICOM file to HDF5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dicom | |
import h5py | |
def export_pixel_array(in_file, out_file, dataset_name="data"): | |
pixel_array = dicom.read_file(in_file).pixel_array | |
h5 = h5py.File(out_file) | |
h5.create_dataset(dataset_name, data=pixel_array) | |
h5.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Thanks for sharing.
I want to convert files with *.h5 to *.dic format. Could you please assist me in this regard?