Dear member of the list,
I've compared the output of mri_compute_seg_overlap (FS 5.1.0 and 5.3.0) against an home-made script to calculate the DICE coefficients between two asg.mgz files.
The results ranges from being perfectly equal (e.g. label 58) up to an error at the second decimal place (e.g. label 42), which is not acceptable.
Where do you think is the origin of these inconsistencies?
Here's the complete result of the test:
freesurfer VS python script label 2 = 0.975814 label 2 = 0.975759 label 41 = 0.980171 label 41 = 0.980135 label 3 = 0.980298 label 3 = 0.961283 label 42 = 0.983296 label 42 = 0.965541 label 4 = 0.979572 label 4 = 0.979572 label 43 = 0.975789 label 43 = 0.975789 label 17 = 0.950502 label 17 = 0.942725 label 53 = 0.953055 label 53 = 0.945481 label 10 = 0.983729 label 10 = 0.983117 label 49 = 0.988228 label 49 = 0.987909 label 11 = 0.97027 label 11 = 0.970270 label 50 = 0.952635 label 50 = 0.952635 label 12 = 0.974187 label 12 = 0.974187 label 51 = 0.976775 label 51 = 0.976775 label 13 = 0.972107 label 13 = 0.972107 label 52 = 0.981569 label 52 = 0.981568 label 18 = 0.921979 label 18 = 0.920228 label 54 = 0.95705 label 54 = 0.950452 label 26 = 0.887918 label 26 = 0.887918 label 58 = 0.9501 label 58 = 0.950100 label 14 = 0.973062 label 14 = 0.971466 label 15 = 0.963786 label 15 = 0.960308 label 5 = 0.897959 label 5 = 0.897959 label 44 = 0.926717 label 44 = 0.924583
The core of the home-made python script is:
import numpy as np import nibabel as nib # usage: DICE('pathToAseg1.mgz','pathToAseg1.mgz',label) def DICE(dataPathX,dataPathY,label=1): # X and Y must be binary images # or specify label to be used (e.g LeftHippocampus=17) imageX = nib.load(dataPathX) imageY = nib.load(dataPathY) X = (imageX.get_data()==label).astype(float) Y = (imageY.get_data()==label).astype(float) VolX = X.sum() VolY = Y.sum() XY = (X*Y).sum() # X*Y prod element by elements. XY=volume of intersection diceXY = 2.0 * XY / (VolX + VolY) return diceXY
Best regards, Luigi Antelmi