lama/img_processing/organ_vol_calculation.py
def _get_label_sizes(paths: List[Path]) ->pd.DataFrame:
    """
    Get the organ volumes for a bunch of of specimens and output a csv

    Parameters
    ----------
    paths: list
        paths to labelmap volumes

    Returns
    -------
    pandas dataframe:
        columns: label (organ)
        rows: specimen ids
    """

    label_volumes = addict.Dict()
    n = 1

    for label_path in paths:

        n += 1
        # Get the name of the volume
        volname = os.path.split(split(label_path)[0])[1]
        labelmap = sitk.ReadImage(str(label_path))
        arr = sitk.GetArrayFromImage(labelmap)
        max_label = int(arr.max())

        lsf = sitk.LabelStatisticsImageFilter()
        labelmap = sitk.Cast(labelmap, sitk.sitkUInt16)
        lsf.Execute(labelmap, labelmap)
        # max_label = lsf.GetMaximum()
        for i in range(1, max_label + 1):
            voxel_count = lsf.GetCount(i)
            label_volumes[volname][i] = voxel_count
    return pd.DataFrame(label_volumes.to_dict()).T

    Get the organ volumes for a bunch of of specimens and output a csv

    Parameters
    ----------
    paths: list
        paths to labelmap volumes

    Returns
    -------
    pandas dataframe:
        columns: label (organ)
        rows: specimen ids
    
Get the organ volumes for a bunch of of specimens and output a csv
Parameters

list
paths to labelmap volumes

Returns

pandas dataframe:
columns: label (organ)
rows: specimen ids
Get the organ volumes for a bunch of of specimens and output a csv Parameters list paths to labelmap volumes Returns pandas dataframe : columns : label ( organ ) rows : specimen ids
def _get_label_sizes(paths: List[Path]) ->pd.DataFrame:
    label_volumes = addict.Dict()
    n = 1
    for label_path in paths:
        n += 1
        volname = os.path.split(split(label_path)[0])[1]
        labelmap = sitk.ReadImage(str(label_path))
        arr = sitk.GetArrayFromImage(labelmap)
        max_label = int(arr.max())
        lsf = sitk.LabelStatisticsImageFilter()
        labelmap = sitk.Cast(labelmap, sitk.sitkUInt16)
        lsf.Execute(labelmap, labelmap)
        for i in range(1, max_label + 1):
            voxel_count = lsf.GetCount(i)
            label_volumes[volname][i] = voxel_count
    return pd.DataFrame(label_volumes.to_dict()).T
def _get_label_sizes ( paths : List [ Path ] ) -> pd . DataFrame : label_volumes = addict . Dict ( ) n = 1 for label_path in paths : n += 1 volname = os . path . split ( split ( label_path ) [ 0 ] ) [ 1 ] labelmap = sitk . ReadImage ( str ( label_path ) ) arr = sitk . GetArrayFromImage ( labelmap ) max_label = int ( arr . max ( ) ) lsf = sitk . LabelStatisticsImageFilter ( ) labelmap = sitk . Cast ( labelmap , sitk . sitkUInt16 ) lsf . Execute ( labelmap , labelmap ) for i in range ( 1 , max_label + 1 ) : voxel_count = lsf . GetCount ( i ) label_volumes [ volname ] [ i ] = voxel_count return pd . DataFrame ( label_volumes . to_dict ( ) ) . T
Get the organ volumes for a bunch of of specimens and output a csv
Parameters
Get the organ volumes for a bunch of of specimens and output a csv Parameters
"""
    Get the organ volumes for a bunch of of specimens and output a csv

    Parameters
    ----------
    paths: list
        paths to labelmap volumes

    Returns
    -------
    pandas dataframe:
        columns: label (organ)
        rows: specimen ids
    """ # Get the name of the volume # max_label = lsf.GetMaximum()
paths
List[Path]