voxel.utils.pixel_data.apply_window

voxel.utils.pixel_data.apply_window(volume: ndarray, center: float, width: float, output_range: Optional[Tuple[float, float]] = None, mode: Optional[str] = None, inplace: bool = False) ndarray[source]

Apply a window to a volume.

The output range defaults to the boundaries of the window in contrast to the default behaviour of pydicom which is to use the pixel range. Explicitly setting the output range to the pixel range will result in the same behaviour. Set the output range to (0, 1) to normalize the volume.

NB: Whether the minimum output value is rendered as black or white may depend on the value of Photometric Interpretation (0028,0004).

Parameters:
  • volume (np.ndarray) – Volume to apply the window to.

  • center (float) – Window center.

  • width (float) – Window width.

  • output_range (Tuple[float, float]) – Output range.

  • mode (str, optional) – VOI LUT function. Defaults to None.

  • inplace (bool, optional) – Whether to apply the window in place. Defaults to False.

Returns:

Windowed volume.

Return type:

np.ndarray