code: def ndimage_to_list(image):
      
      inpixeltype = image.pixeltype
      dimension = image.dimension
      components = 1
      imageShape = image.shape
      nSections = imageShape[ dimension - 1 ]
      subdimension = dimension - 1
      suborigin = iio.get_origin( image )[0:subdimension]
      subspacing = iio.get_spacing( image )[0:subdimension]
      subdirection = np.eye( subdimension )
      for i in range( subdimension ):
          subdirection[i,:] = iio.get_direction( image )[i,0:subdimension]
      subdim = image.shape[ 0:subdimension ]
      imagelist = []
      for i in range( nSections ):
          img = utils.slice_image( image, axis = subdimension, idx = i )
          iio.set_spacing( img, subspacing )
          iio.set_origin( img, suborigin )
          iio.set_direction( img, subdirection )
          imagelist.append( img )
  
      return imagelist
docs: Split a n dimensional ANTsImage into a list
      of n-1 dimensional ANTsImages
  
      Arguments
      ---------
      image : ANTsImage
          n-dimensional image to split
  
      Returns
      -------
      list of ANTsImage types
  
      Example
      -------
      >>> import ants
      >>> image = ants.image_read(ants.get_ants_data('r16'))
      >>> image2 = ants.image_read(ants.get_ants_data('r16'))
      >>> imageTar = ants.make_image( ( *image2.shape, 2 ) )
      >>> image3 = ants.list_to_ndimage( imageTar, [image,image2])
      >>> image3.dimension == 3
      >>> images_unmerged = ants.ndimage_to_list( image3 )
      >>> len(images_unmerged) == 2
      >>> images_unmerged[0].dimension == 2