code: def shape_based_slice_insertation_object_wise(
      sl1, sl2, dim, nslices, order=3
  ):
      """
      Wrapper to apply `shape_based_slice_insertation()` for each binary object
      separately to ensure correct extrapolation behaviour.
      """
      out = None
      sandwich = numpy.concatenate(
          (sl1[numpy.newaxis], sl2[numpy.newaxis]), 0
      )
      label_image, n_labels = label(sandwich)
      for lid in range(1, n_labels + 1):
          _sl1, _sl2 = label_image == lid
          _out = shape_based_slice_insertation(
              _sl1, _sl2, dim, nslices, order=3
          )
          if out is None:
              out = _out
          else:
              out |= _out
      return out
  
file_path: medpy/bin/medpy_binary_resampling.py
imports: import os
  import logging
  import argparse
  import numpy
  from scipy.ndimage import zoom
  from scipy.ndimage import distance_transform_edt, binary_erosion
  from scipy.ndimage import label
  from medpy.core import Logger
  from medpy.filter import resample, bounding_box
  from medpy.utilities import argparseu
  from medpy.io import load, save, header
label_desc: Use image node_id 3 for calling a global function with example usage: shape_based_slice_insertation_object_wise(sl1, sl2, dim, nslices, order) and returns: out