Slope and intercept when reading Nifti images

Dear all,

I have a very basic question: I am reading in nifti images using:

ImageType::Pointer readImage(string imageName) {
typename ReaderType::Pointer reader = ReaderType::New();
try {
catch (itk::ExceptionObject &excp) {
std::cerr << excp << std::endl;
ImageType::Pointer image = reader->GetOutput();
return reader->GetOutput();

Am I correct that the ITK image reader is applying the slope and intercept automatically? Or do I have to manually multiply by the slope and add the intercept to get the correct values?

I am asking because I have some images where the results are reasonable, but I have one image where the image values are not making sense after reading it. When I apply then slope and intercept, the values are making sense… (this file can be downloaded here:

Thanks a lot for your answer.


Hi Elli,

Yes, rescale / slope and intercept is applied with NIFTI files per:


1 Like

Dear Matt,

thanks for your answer…

But why is it not working for this specific image ? (you can find it here:


All other softwares I used for comparison (Matlab, nibabel in python, etc) can read the image correctly. But when I read it with ITK, i get as maximum intensity 32767 as if the image would not have been scaled. When I scale it then manually by mutliplying with slope, I get the correct values. How can that be?

Thanks a lot for your help,


When I try to download the offending image, I get “Transfer deleted”. Has the the link expired? Can you refresh it?

Sure, sorry. Here is a new link:

thanks in advance for looking into this!

The slope in this image is ignored because both SForm and QForm codes are zero:

1 Like

Hey Dzenan,

thanks! But officially that is not correct, right? Because I read that the scaling with slope and intercept should always be applied also when sform and qform are 0…

Anyhow, I can make a workaround in my code. So thanks a lot for the information!



Where is the official answer to this question? Also, you could dig a little through git history of that file to see when changes were made, and maybe also why.

Thanks, thats a good idea.

Well, officially is a bit difficult to define. We just had a big discussion in our group whats the right way to handle nifti images… And what we found online in the header descriptions was that scaling should always be applied. Anyhow, I will check the history! Thank you!

1 Like