docs: def lsm2bin(lsmfile, binfile=None, tile=None, verbose=True):
      """Convert [MP]TZCYX LSM file to series of BIN files.
  
      One BIN file containing 'ZCYX' data are created for each position, time,
      and tile. The position, time, and tile indices are encoded at the end
      of the filenames.
  
      """
      verbose = print_ if verbose else nullfunc
  
      if tile is None:
          tile = (256, 256)
  
      if binfile is None:
          binfile = lsmfile
      elif binfile.lower() == 'none':
          binfile = None
      if binfile:
          binfile += '_(z%ic%iy%ix%i)_m%%ip%%it%%03iy%%ix%%i.bin'
  
      verbose('\nOpening LSM file... ', end='', flush=True)
      start_time = time.time()
  
      with TiffFile(lsmfile) as lsm:
          if not lsm.is_lsm:
              verbose('\n', lsm, flush=True)
              raise ValueError('not a LSM file')
          series = lsm.series[0]  # first series contains the image data
          shape = series.shape
          axes = series.axes
          dtype = series.dtype
          size = product(shape) * dtype.itemsize
  
          verbose('%.3f s' % (time.time() - start_time))
          # verbose(lsm, flush=True)
          verbose('Image\n  axes:  %s\n  shape: %s\n  dtype: %s\n  size:  %s'
                  % (axes, shape, dtype, format_size(size)), flush=True)
          if not series.axes.endswith('TZCYX'):
              raise ValueError('not a *TZCYX LSM file')
  
          verbose('Copying image from LSM to BIN files', end='', flush=True)
          start_time = time.time()
          tiles = shape[-2] // tile[-2], shape[-1] // tile[-1]
          if binfile:
              binfile = binfile % (shape[-4], shape[-3], tile[0], tile[1])
          shape = (1,) * (7-len(shape)) + shape
          # cache for ZCYX stacks and output files
          data = numpy.empty(shape[3:], dtype=dtype)
          out = numpy.empty((shape[-4], shape[-3], tile[0], tile[1]),
                            dtype=dtype)
          # iterate over Tiff pages containing data
          pages = iter(series.pages)
          for m in range(shape[0]):  # mosaic axis
              for p in range(shape[1]):  # position axis
                  for t in range(shape[2]):  # time axis
                      for z in range(shape[3]):  # z slices
                          data[z] = next(pages).asarray()
                      for y in range(tiles[0]):  # tile y
                          for x in range(tiles[1]):  # tile x
                              out[:] = data[...,
                                            y*tile[0]:(y+1)*tile[0],
                                            x*tile[1]:(x+1)*tile[1]]
                              if binfile:
                                  out.tofile(binfile % (m, p, t, y, x))
                              verbose('.', end='', flush=True)
          verbose(' %.3f s' % (time.time() - start_time))