How does Slicer finds the optimal viewing window (min/max values) when importing nifti file?

Hi,

I want to find out how does Slicer determines the optimal viewing window (min/max values) when importing nifti file. I know that when importing dicoms the windowing info is in the metadata, however as far as I know nifti and nrrd files does not contain this info in the metadata. How is Slicer able to display the correct viewing window (for the brain tissue) after importing a nifti file?

It’s done in the code linked below - basically it is heuristic that looks at the histogram and expects a big hump of dark background, and then a hump of brighter foreground (a reasonable approximation of most CT and MR images). Then it ignores the background and picks a range around the foreground.

2 Likes