code: def transform_to_2d(data, max_axis):
      
      import numpy as np
      # get the shape of the array we are projecting to
      new_shape = list(data.shape)
      del new_shape[max_axis]
  
      # generate a 3D indexing array that points to max abs value in the
      # current projection
      a1, a2 = np.indices(new_shape)
      inds = [a1, a2]
      inds.insert(max_axis, np.abs(data).argmax(axis=max_axis))
  
      # take the values where the absolute value of the projection
      # is the highest
      maximum_intensity_data = data[inds]
  
      return np.rot90(maximum_intensity_data)
docs: Projects 3d data cube along one axis using maximum intensity with
      preservation of the signs. Adapted from nilearn.