[f77492]: / metrics / __pycache__ / meanNSD.cpython-37.pyc

Download this file

28 lines (25 with data), 2.3 kB

B

`Éa{ã@s*ddlZddlZddlmZddd„ZdS)éN)Ú__surface_distancesécCsRtdd„t|j|jƒDƒƒs8tdt|jƒt|jƒfƒ‚d||dk<d||dk<d||dk<d||dk<| tj¡}|j 	¡ 
¡}|j 	¡ 
¡}|dkr´tdd„tt
|jƒƒDƒƒ}t||||ƒ}t||||ƒ}t
|ƒ}t
|ƒ}	t ||k¡|}
t ||k¡|	}t ||k¡|}t ||k¡|	}
|
||
|||
d	}| |¡|S)
aõ
    This implementation differs from the official surface dice implementation! These two are not comparable!!!!!

    The normalized surface dice is symmetric, so it should not matter whether a or b is the reference image

    This implementation natively supports 2D and 3D images. Whether other dimensions are supported depends on the
    __surface_distances implementation in medpy

    :param a: image 1, must have the same shape as b
    :param b: image 2, must have the same shape as a
    :param threshold: distances below this threshold will be counted as true positives. Threshold is in mm, not voxels!
    (if spacing = (1, 1(, 1)) then one voxel=1mm so the threshold is effectively in voxels)
    must be a tuple of len dimension(a)
    :param spacing: how many mm is one voxel in reality? Can be left at None, we then assume an isotropic spacing of 1mm
    :param connectivity: see scipy.ndimage.generate_binary_structure for more information. I suggest you leave that
    one alone
    :return:
    cSsg|]\}}||k‘qS©r)Ú.0ÚiÚjrrú8/home/wangqiuli/Code/Newcode1222_monk/metrics/meanNSD.pyú
<listcomp>szmeanNSD.<locals>.<listcomp>z:a and b must have the same shape. a.shape= %s, b.shape= %srgà?rNcSsg|]}d‘qS)rr)rÚ_rrrr	$sg:Œ0âŽyE>)ÚallÚzipÚshapeÚAssertionErrorÚstrÚtypeÚtorchÚ
LongTensorÚdataÚcpuÚnumpyÚtupleÚrangeÚlenrÚnpÚsumÚappend)ÚaÚbZnsdsÚ	thresholdÚspacingZconnectivityZa_to_bZb_to_aZnumel_aZnumel_bZtp_aZtp_bÚfpÚfnÚdcrrrÚmeanNSDs, 
r#)rNr)rrrZmedpy.metric.binaryrr#rrrrÚ<module>s