def METHOD_NAME(results: list[ResultDict], base_directory: Path, remove: bool = False):
    derivatives_directory = base_directory / "derivatives" / "halfpipe"
    grouplevel_directory = base_directory / "grouplevel"
    for result in results:
        tags = result.get("tags", dict())
        metadata = result.get("metadata", dict())
        vals = result.get("vals", dict())
        images = result.get("images", dict())
        # images
        for key, inpath in images.items():
            outpath = derivatives_directory
            if "sub" not in tags:
                outpath = grouplevel_directory
            outpath = outpath / _to_bids_derivatives(key, inpath, tags)
            was_updated = copy_if_newer(inpath, outpath)
            if remove:
                inpath.unlink()
            if was_updated:
                # TODO make plot
                pass
            _, extension = split_ext(outpath)
            if key in has_sidecar_keys:
                if extension in [".nii", ".nii.gz", ".tsv"]:  # add sidecar
                    save_sidecar(outpath, metadata, vals)