Nilearn: Intersecting masks with union vs. intersection


I am using the Nilearn function nilearn.masking.intersect_masks to create the union or intersection of two binarized masks.

According to the Nilearn documentation, the threshold argument can be set to go from intersection of the masks (threshold = 1) to union of the masks (threshold = 0).

threshold: float, optional
Gives the level of the intersection, must be within [0, 1]. threshold=1 corresponds to keeping the intersection of all masks, whereas threshold=0 is the union of all masks.

In my understanding union means an additive combination of the masks, i.e., the union contains all voxels in mask A and mask B combined. In contrast, I understand intersection as selecting only those voxels that are in both mask A and mask B but not the voxels that are only in mask A or mask B.

Alright, I did combine the masks using both thresholds and the results are a bit puzzling for me:

Okay, so from the first two images you can see that the two masks are largely overlapping (the first mask is colored in yellow and the second mask is colored in blue):

Now, if use masking.intersect_maks with threshold = 0 to (supposedly) create the union of the masks.

Well, for me this does not seem like the union of the masks (intersected mask shown in white):

The intersection (threshold = 1) does not really look like the intersection either:

So, can someone tell me what’s actually happening or could be the issue?

System specification:

  • macOS Sierra version 10.12.6
  • nilearn==0.6.0
  • FSLeyes version 0.26.1+build0

Thanks in advance!