def sparse_block_mask_for_labels(self, labels, clip=True):
        """
        Determine which bricks (each with our ``preferred_message_shape``)
        would need to be accessed download all data for the given labels,
        and return the result as a ``SparseBlockMask`` object.

        This function uses a dask to fetch the coarse sparsevols in parallel.
        The sparsevols are extracted directly from the labelindex.
        If the ``self.supervoxels`` is True, the labels are grouped
        by body before fetching the labelindexes,
        to avoid fetching the same labelindexes more than once.

        Args:
            labels:
                A list of body IDs (if ``self.supervoxels`` is False),
                or supervoxel IDs (if ``self.supervoxels`` is True).

            clip:
                If True, filter the results to exclude any coordinates
                that fall outside this service's bounding-box.
                Otherwise, all brick coordinates that encompass the given label groups
                will be returned, whether or not they fall within the bounding box.

        Returns:
            ``SparseBlockMask``
        """
        from neuclease.util import SparseBlockMask
        coords_df = self.sparse_brick_coords_for_labels(labels, clip)
        coords_df.drop_duplicates(['z', 'y', 'x'], inplace=True)

        brick_shape = self.preferred_message_shape
        coords_df[['z', 'y', 'x']] //= brick_shape

        coords = coords_df[['z', 'y', 'x']].values
        return SparseBlockMask.create_from_lowres_coords(coords, brick_shape)
    def init_brickwall(self, volume_service, subset_groups):
        try:
            brick_coords_df = volume_service.sparse_brick_coords_for_label_groups(
                subset_groups)
            np.save('brick-coords.npy',
                    brick_coords_df.to_records(index=False))

            brick_shape = volume_service.preferred_message_shape
            brick_indexes = brick_coords_df[['z', 'y', 'x'
                                             ]].values // brick_shape
            sbm = SparseBlockMask.create_from_lowres_coords(
                brick_indexes, brick_shape)
        except NotImplementedError:
            logger.warning(
                "The volume service does not support sparse fetching.  All bricks will be analyzed."
            )
            sbm = None

        with Timer("Initializing BrickWall", logger):
            # Aim for 2 GB RDD partitions when loading segmentation
            GB = 2**30
            target_partition_size_voxels = 2 * GB // np.uint64().nbytes

            # Apply halo WHILE downloading the data.
            # TODO: Allow the user to configure whether or not the halo should
            #       be fetched from the outset, or added after the blocks are loaded.
            halo = self.config["findadjacencies"]["halo"]
            brickwall = BrickWall.from_volume_service(
                volume_service,
                0,
                None,
                self.client,
                target_partition_size_voxels,
                halo,
                sbm,
                compression='lz4_2x')

        return brickwall