def imgwriteincr(fn: Path, imgs, imgslice):
    """
    writes HDF5 huge image files in increments
    """
    if isinstance(imgslice, int):
        if imgslice and not (imgslice % 2000):
            print(f'appending images {imgslice} to {fn}')

    if isinstance(fn, Path):
        # avoid accidental overwriting of source file due to misspecified command line
        assert fn.suffix == '.h5', 'Expecting to write .h5 file'

        with h5py.File(fn, 'r+') as f:
            f['/rawimg'][imgslice, :, :] = imgs
    elif isinstance(fn, h5py.File):
        f['/rawimg'][imgslice, :, :] = imgs
    else:
        raise TypeError(
            f'{fn} must be Path or h5py.File instead of {type(fn)}')
def imgwriteincr ( fn : Path , imgs , imgslice ) : if isinstance ( imgslice , int ) : if imgslice and not ( imgslice % 2000 ) : print ( f'appending images {imgslice} to {fn}' ) if isinstance ( fn , Path ) : assert fn . suffix == '.h5' , 'Expecting to write .h5 file' with h5py . File ( fn , 'r+' ) as f : f [ '/rawimg' ] [ imgslice , : , : ] = imgs elif isinstance ( fn , h5py . File ) : f [ '/rawimg' ] [ imgslice , : , : ] = imgs else : raise TypeError ( f'{fn} must be Path or h5py.File instead of {type(fn)}' )
writes HDF5 huge image files in increments