Skip to content

Instantly share code, notes, and snippets.

@janpipek
Created August 21, 2014 19:35
Show Gist options
  • Save janpipek/6ed17b21b15a8013eb19 to your computer and use it in GitHub Desktop.
Save janpipek/6ed17b21b15a8013eb19 to your computer and use it in GitHub Desktop.
Export pixel array from DICOM file to HDF5
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()
@miladhasany
Copy link

Hello,

Thanks for sharing.

I want to convert files with *.h5 to *.dic format. Could you please assist me in this regard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment