Skip to content

Artifacts in mosaic plots when intersection of masks and visualization planes is minimal #542

@oesteban

Description

@oesteban

This problem has been around for a long while. When the intersection of the mask with the visualization plane only contains a fraction of a voxel, nilearn plotting gets very confused:

With nipreps/fmriprep#2130 the problem is exacerbated (not so much for fully sampled datasets, but definitely for our test data).

I believe this problem would completely be fixed if we replaced the affine information of the input images to be aligned with the cardinal axes. To do so, I'd propose:

  1. nibabel.as_closest_canonical to all volumetric inputs of plots.
  2. Generate a new affine with: image_zooms x identity
  3. Perhaps re-center the volume for visualization purposes (so reported coordinates are w.r.t. the center of the volume).

This way, visualization will cut through full voxels always and the marching cubes algorithm will not go bananas.

In general, this approach would also make our reports more transparent because:

  1. We would be able to safely drop interpolations by nilearn
  2. The user will have access to the visualization of the naked data array, instead of a reoriented version.

Opinions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions