class_docstr: Class to wrap MINC1 format opened netcdf object
  
  Although it has some of the same methods as a ``Header``, we use
  this only when reading a MINC file, to pull out useful header
  information, and for the method of reading the data out
docstr: Apply scaling to image data `data` already sliced with `sliceobj`
  
  https://en.wikibooks.org/wiki/MINC/Reference/MINC1-programmers-guide#Pixel_values_and_real_values
  
  MINC normalization uses "image-min" and "image-max" variables to
  map the data from the valid range of the image to the range
  specified by "image-min" and "image-max".
  
  The "image-max" and "image-min" are variables that describe the
  "max" and "min" of image over some dimensions of "image".
  
  The usual case is that "image" has dimensions ["zspace", "yspace",
  "xspace"] and "image-max" has dimensions ["zspace"], but there can be
  up to two dimensions for over which scaling is specified.
  
  Parameters
  ----------
  data : ndarray
      data after applying `sliceobj` slicing to full image
  sliceobj : tuple, optional
      slice definition. If not specified, assume no slicing has been
      applied to `data`
docstr_tok: ["Apply","scaling","to","image","data","`","data","`","already","sliced","with","`","sliceobj","`","https",":","\/\/en.wikibooks.org\/wiki\/MINC\/Reference\/MINC1-programmers-guide","#","Pixel_values_and_real_values","MINC","normalization","uses","``","image-min","''","and","``","image-max","''","variables","to","map","the","data","from","the","valid","range","of","the","image","to","the","range","specified","by","``","image-min","''","and","``","image-max","''",".","The","``","image-max","''","and","``","image-min","''","are","variables","that","describe","the","''","max","''","and","``","min","''","of","image","over","some","dimensions","of","``","image","''",".","The","usual","case","is","that","``","image","''","has","dimensions","[","``","zspace","''",",","``","yspace","''",",","''","xspace","''","]","and","``","image-max","''","has","dimensions","[","``","zspace","''","]",",","but","there","can","be","up","to","two","dimensions","for","over","which","scaling","is","specified",".","Parameters","--","--","--","--","--","data",":","ndarray","data","after","applying","`","sliceobj","`","slicing","to","full","image","sliceobj",":","tuple",",","optional","slice","definition",".","If","not","specified",",","assume","no","slicing","has","been","applied","to","`","data","`"]
code: def _normalize(self, data, sliceobj=()):
      """Apply scaling to image data `data` already sliced with `sliceobj`
  
      https://en.wikibooks.org/wiki/MINC/Reference/MINC1-programmers-guide#Pixel_values_and_real_values
  
      MINC normalization uses "image-min" and "image-max" variables to
      map the data from the valid range of the image to the range
      specified by "image-min" and "image-max".
  
      The "image-max" and "image-min" are variables that describe the
      "max" and "min" of image over some dimensions of "image".
  
      The usual case is that "image" has dimensions ["zspace", "yspace",
      "xspace"] and "image-max" has dimensions ["zspace"], but there can be
      up to two dimensions for over which scaling is specified.
  
      Parameters
      ----------
      data : ndarray
          data after applying `sliceobj` slicing to full image
      sliceobj : tuple, optional
          slice definition. If not specified, assume no slicing has been
          applied to `data`
      """
      ddt = self.get_data_dtype()
      if np.issubdtype(ddt.type, np.floating):
          return data
      image_max = self._image_max
      image_min = self._image_min
      mx_dims = self._get_dimensions(image_max)
      mn_dims = self._get_dimensions(image_min)
      if mx_dims != mn_dims:
          raise MincError(
              '"image-max" and "image-min" do not have the same dimensions'
          )
      nscales = len(mx_dims)
      if nscales > 2:
          raise MincError("More than two scaling dimensions")
      if mx_dims != self._dim_names[:nscales]:
          raise MincError("image-max and image dimensions do not match")
      dmin, dmax = self._get_valid_range()
      out_data = np.clip(data, dmin, dmax)
      if nscales == 0:  # scalar values
          imax = self._get_scalar(image_max)
          imin = self._get_scalar(image_min)
      else:  # 1D or 2D array of scaling values
          # We need to get the correct values from image-max and image-min to
          # do the scaling.
          shape = self.get_data_shape()
          sliceobj = canonical_slicers(sliceobj, shape)
          # Indices into sliceobj referring to image axes
          ax_inds = [
              i for i, obj in enumerate(sliceobj) if obj is not None
          ]
          assert len(ax_inds) == len(shape)
          # Slice imax, imin using same slicer as for data
          nscales_ax = ax_inds[nscales]
          i_slicer = sliceobj[:nscales_ax]
          # Fill slicer to broadcast against sliced data; add length 1 axis
          # for each axis except int axes (which are dropped by slicing)
          broad_part = tuple(
              None
              for s in sliceobj[ax_inds[nscales] :]
              if not isinstance(s, Integral)
          )
          i_slicer += broad_part
          imax = self._get_array(image_max)[i_slicer]
          imin = self._get_array(image_min)[i_slicer]
      slope = (imax - imin) / (dmax - dmin)
      inter = imin - dmin * slope
      out_data *= slope
      out_data += inter
      return out_data
  
imports: from __future__ import annotations
  from numbers import Integral
  import numpy
  from .externals.netcdf import netcdf_file
  from .fileslice import canonical_slicers
  from .spatialimages import SpatialHeader, SpatialImage
label_desc: Use image node_id 10 for calling the Minc1File obj's underlying member method code with example usage: obj._normalize(data, sliceobj) and returns: out_data, data