Added optional ndim argument to set explicit slicer size