Trying to visualize CT/MR data stored in HDF5 format

Hello,

I have CT/MR data stored in HDF5 format. My intention is to read the dataset that is stored in the .hdf5 file and display it in my own VTK viewer. Apparently not allowed to upload attachments, so I will send the vtk and hdf5 directly if required.

For now, I used h5tovtk to convert my dataset to a supported .VTK file format. I then thought after reading online that I should use either vtkImageViewer2 or vtkStructuredGrid to display the dataset.

This didn’t work well, so I have tried a few readers with no better result (vtkDICOMReader, etc.) … Can anyone point me in the right direction here?

Here is a snippet of the code which follows the online examples.

//reader 
    auto reader = vtkSmartPointer<vtkGenericDataObjectReader>::New();
    reader->SetFileName("convertedHd5.vtk");
    reader->Update();


// sest up renderer 
    auto renderer = vtkSmartPointer<vtkRenderer>::New();
// renderWindow 
    auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
//viewer 
    auto viewer = vtkSmartPointer<vtkImageViewer2>::New();
    viewer->SetInputConnection(reader->GetOutputPort());
    viewer->SetRenderWindow(renderWindow);

    viewer->SetColorWindow(1500);
    viewer->SetColorLevel(150);
// renderWindowInteractor
    auto renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
// style 
    auto style = vtkSmartPointer<vtkInteractorStyleImage>::New();

    renderWindowInteractor->SetInteractorStyle(style);

    renderWindowInteractor->SetRenderWindow(renderWindow);

    renderWindow->Render();

    renderWindowInteractor->Initialize();
    renderWindowInteractor->Start();

Any help is greatly appreciated…

Thanks,
Ryan

Could you change your data flow to keep the DICOM or convert to a standard research image file format instead of using HDF5 at all? You can read/write volumetric images in nrrd format in most environments, programming languages, and imaging analysis and visualization software. If you do neuroimaging then you can use nifti instead.

You can load the volume from common image file formats using VTK readers and visualize the resulting vtkImageData and visualize it in 2D or 3D.

My usual advice: Don’t develop yet another medical image viewer from scratch. Instead, there are good VTK-based platforms that you can customize and extend (3D Slicer, MITK, etc.).

Hi Ryan,

Use h5ls and h5dump to examine your hdf5 files to see how the image is stored:
https://support.hdfgroup.org/HDF5/Tutor/cmdtoolview.html

The thing with hdf5 is that it is a generic format, like xml or json. If you received a CT image in xml format, how would you read it? Well, you probably couldn’t unless you also had the schema to go along with it. It’s the same for hdf5. When you received the files, you hopefully should have also received a document that describes what hdf5 attributes and variables were used to store the image. If you don’t have such a document, then your best bet is to examine the file and figure things out by reverse engineering.