How to quickly obtain the pixel type of a nifti file?

I am using ITK C++. My project requires me to load the header information named data_type in a nifti file. I know how to get the image such as

  using ImageReaderType = itk::ImageFileReader<ImageType>;
  ImageReaderType::Pointer ImageReader = ImageReaderType::New();

I can use ImageReader->GetOutput() to get the image data, but how to quickly get the field of data_type in the header of nifti, such as INT8, INT16, FLOAT32?


You can use the ReadImageInformation method of the NiftiImageIO class to read the header of the file without reading the pixel data. Then you can use the GetPixelType method to determine the pixel type.

1 Like