dgobbi / vtk-dicom

A set of classes for using DICOM in VTK.
BSD 3-Clause "New" or "Revised" License
258 stars 94 forks source link

Get metadata from vtkNIFTIReader #205

Closed flaviu22 closed 3 years ago

flaviu22 commented 3 years ago

It is more a question, but because I didn't see any message menu, I write here: how can I get metadata from vtkNIFTIReader ?

I successfully did from vtkDICOMReader:

       vtkSmartPointer<vtkDICOMMetaData> pMeta = vtkSmartPointer< vtkDICOMMetaData>::New();
        pMeta = m_pDICOMReader->GetMetaData();
    const vtkDICOMValue& window = pMeta->GetAttributeValue(DC::WindowWidth);
    const vtkDICOMValue& level = pMeta->GetAttributeValue(DC::WindowCenter);
    const vtkDICOMValue& plan = pMeta->GetAttributeValue(DC::ImageOrientationPatient);

well, how can I do it for vtkNIFTIReader ?

I have tried:

vtkNIFTIHeader* pNIFTIHeader = m_pNIFTIReader->GetNIFTIHeader(); but I don't know how to proceed further ... and I didn't see anything appropiate here of on PDF help page. Can you lead me into solve this ? I really need this feature.

dgobbi commented 3 years ago

The vtkNIFTIHeader class is documented on this web page: http://dgobbi.github.io/vtk-dicom/doc/api/classvtk_n_i_f_t_i_header.html

The meanings of the fields are described in the nifti documentation: https://nifti.nimh.nih.gov/nifti-1/documentation/

For the window, use GetCalMin() and GetCalMax(). WindowCenter = (cal_min + cal_max)/2.0 WindowWidth = cal_max - cal_min However, please note that in many nifti files, the cal_max and cal_min will be zero!

The best way to get the orientation of a nifti file is via the quaternion parameters. The nifti documentation at the NIH website describes how to do this. There are also some notes in the vtkNIFTIReader source code: https://github.com/dgobbi/vtk-dicom/blob/master/Source/vtkNIFTIReader.cxx#L714

flaviu22 commented 3 years ago

David, thank you for your valuable information. However, I think is about more information than that, for instance, from vtkDICOMReader I could find a lot info:

    vtkDICOMMetaData* pMeta = pDICOMReader->GetMetaData();
    pMeta->GetAttributeValue(DC::InstitutionName).AsString().c_str());
    pMeta->GetAttributeValue(DC::PatientName).AsString().c_str());
    pMeta->GetAttributeValue(DC::PatientBirthName).AsString().c_str());
    pMeta->GetAttributeValue(DC::PatientID).AsString().c_str());
    pMeta->GetAttributeValue(DC::PatientSex).AsString().c_str());

Could I have the same things from vtkNIFTIReader ? If I can, how ?

dgobbi commented 3 years ago

NIFTI files do not have any of that information. You might be interested in BIDS.