Skip to content

Error in parcellated volumes prior to ca7ab2f #123

@cookpa

Description

@cookpa

Hi @BenBillot

Thanks for this amazing tool! I was looking into some discrepancies between the parcellated cortical volumes between the latest SynthSeg and some earlier versions.

EDIT: To be clear, I'm talking about the volumes output with --vol, not the labels themselves.

I think I found a bug that was fixed in commit ca7ab2f but I'm not sure it has been documented.

I believe the error was in this block

# compute volumes
volumes = np.sum(posteriors[..., 1:], axis=tuple(range(0, len(posteriors.shape) - 1)))
if not v1:
volumes = np.concatenate([np.array([np.sum(volumes)]), volumes])
if post_patch_parc is not None:
volumes_parc = np.sum(post_patch_parc[..., 1:], axis=tuple(range(0, len(posteriors.shape) - 1)))
total_volume_cortex = np.sum(volumes[np.where((labels_segmentation == 3) | (labels_segmentation == 42))[0] - 1])
volumes_parc = volumes_parc / np.sum(volumes_parc) * total_volume_cortex
volumes = np.concatenate([volumes, volumes_parc])
volumes = np.around(volumes * np.prod(im_res), 3)

Specifically, we have

    if not v1:
        volumes = np.concatenate([np.array([np.sum(volumes)]), volumes])

which inserts a new element into volumes. But then

        total_volume_cortex = np.sum(volumes[np.where((labels_segmentation == 3) | (labels_segmentation == 42))[0] - 1])

Only now labels 3 and 42 are not total cerebral cortex, they are total cerebral white matter.

In the change to per-hemisphere normalization, this problem is circumvented by computing the per-hemisphere totals before doing

    if not v1:
        volumes = np.concatenate([np.array([np.sum(volumes)]), volumes])

And so the parcellated volumes for [hemi] sum to the "[hemi] cerebral cortex" number in the CSV.

Prior to this, the total sum of all parcellated volumes (left and right) sum up to ("left cerebral white matter" + "right cerebral white matter").

I just wanted to make a note in case anyone else is confused by the changes, or has older output they may want to correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions