[cf6a9e]: / metrics / __pycache__ / meanNSD.cpython-36.pyc

Download this file

28 lines (25 with data), 2.3 kB

3

mΏ€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<|jtjƒ}|jj	ƒj
ƒ}|jj	ƒj
ƒ}|dkr΄tdd„tt
|jƒƒDƒƒ}t||||ƒ}t||||ƒ}t
|ƒ}t
|ƒ}	tj||kƒ|}
tj||kƒ|	}tj||kƒ|}tj||kƒ|	}
|
||
|||
d	}|j|ƒ|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ϊ+/home/ws/yanghan/Newcode/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