Hi Sara
Re. your second question: one way to compare a pair of binary masks visually is to merge them into a single segmentation image. Using c3d, you could do it like this:
c3d mask-A.nii.gz -scale 2 mask-B.nii.gz -add -o sum.nii.gz
In sum.nii.gz, overlapping mask portions will have voxel values of 3, those that are foreground only in A will have values 2, and those that are foreground only in B will have values 1. To visualize it, open it as a segmentation and load a label description file with the following content:
0 0 0 0 0 0 0 "Clear Label"
1 255 0 0 1 1 1 "B \ A"
2 255 255 0 1 1 1 "A \ B"
3 0 255 0 1 1 1 "A ∩ B"
Now you can see overlap (intersection) in green, A-only as yellow, and B-only as red.
Re. your first question: to retrieve the coordinates of all discrepancies individually, the following approach works in principle (although there may be more elegant ways):
c3d sum.nii.gz -split -oo l%01d.nii.gz # Isolate the discrepancy types into separate files
c3d l1.nii.gz -comp l1-comp.nii.gz # Looking at B \ A, number the discrepancies as disconnected components
c3d l1-comp.nii.gz -split -oo l1-d%01d.nii.gz # Split the disconnected components into individual files
c3d l1-d1.nii.gz -centroid # Extract the coordinates of discrepancy #1
c3d l1-d2.nii.gz -centroid # Extract the coordinates of discrepancy #2 -- repeat this for l1-d*.nii.gz
# Repeat this procedure for l2.nii.gz
Hope this helps!
Rolf