def evaluate_surface_overlaps(labels, index, table1, table2,
                              output_file='', save_output=True):
    """
    Measure surface overlap per label by comparing Mindboggle vertices tables.

    Parameters
    ----------
    labels : list
        cortical label indices to measure surface overlap
    index : integer
        index (starting from zero) to column of table containing label indices
    table1 : string
        table with index labels for scalar values
    table2 : string
        table with index labels for scalar values
    output_file : string
        (optional) output file name

    Returns
    -------
    dice_overlaps : numpy array
        Dice overlap values
    jacc_overlaps : numpy array
        Jaccard overlap values
    output_file : string
        (optional) output file name
    save_output : Boolean
        save output file?

    Examples
    --------
    >>> import os
    >>> from mindboggle.evaluate.evaluate_labels import evaluate_surface_overlaps
    >>> from mindboggle.mio.labels import DKTprotocol
    >>> dkt = DKTprotocol()
    >>> labels = dkt.cerebrum_cortex_DKT31_numbers
    >>> index = 1
    >>> path = '/homedir/mindboggled'
    >>> table1 = os.path.join(path, 'Twins-2-1', 'tables', 'left_cortical_surface', 'vertices.csv')
    >>> table2 = os.path.join(path, 'Twins-2-1', 'tables', 'left_cortical_surface', 'vertices.csv')
    >>> output_file = ''
    >>> save_output = True
    >>> evaluate_surface_overlaps(labels, index, table1, table2, output_file=output_file, save_output=save_output)

    """
    import pandas as pd

    from mindboggle.guts.compute import compute_overlaps

    # Load surface label tables:
    df1 = pd.read_csv(table1)
    df2 = pd.read_csv(table2)
    list1 = df1.iloc[:, index]
    list2 = df2.iloc[:, index]
    print(list1)
    dice_overlaps, jacc_overlaps, output_file = compute_overlaps(labels,
        list1, list2, output_file=output_file, save_output=save_output)

    return dice_overlaps, jacc_overlaps, output_file
Beispiel #2
0
def evaluate_volume_overlaps(labels, file1, file2, 
                             output_file='', save_output=True):
    """
    Compute overlap between individual label regions
    in source and target nifti (nii.gz) images.

    Parameters
    ----------
    labels : list
        label indices
    file1 : string
        source image, consisting of index-labeled pixels/voxels
    file2 : string
        target image, consisting of index-labeled pixels/voxels
    output_file : string
        (optional) output file name
    save_output : bool
        save output file?

    Returns
    -------
    dice_overlaps : numpy array
        Dice overlap values
    jacc_overlaps : numpy array
        Jaccard overlap values
    output_file : string
        output text file name with overlap values

    Examples
    --------
    >>> # Compare FreeSurfer and ants labels for the same brain:
    >>> import os
    >>> from mindboggle.evaluate.evaluate_labels import evaluate_volume_overlaps
    >>> from mindboggle.mio.labels import DKTprotocol
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> file1 = fetch_data(urls['freesurfer_labels'], '', '.nii.gz')
    >>> file2 = fetch_data(urls['ants_labels'], '', '.nii.gz')
    >>> dkt = DKTprotocol()
    >>> labels = dkt.cerebrum_cortex_DKT31_numbers
    >>> output_file = ''
    >>> save_output = True
    >>> evaluate_volume_overlaps(labels, file1, file2,
    ...     output_file=output_file, save_output=save_output) # doctest: +SKIP

    """
    import nibabel as nb

    from mindboggle.guts.compute import compute_overlaps

    # Load labeled image volumes:
    list1 = nb.load(file1).get_data().ravel()
    list2 = nb.load(file2).get_data().ravel()

    dice_overlaps, jacc_overlaps, output_file = compute_overlaps(labels,
        list1, list2, output_file=output_file, save_output=save_output)

    return dice_overlaps, jacc_overlaps, output_file
def evaluate_volume_overlaps(labels, file1, file2, 
                             output_file='', save_output=True):
    """
    Compute overlap between individual label regions
    in source and target nifti (nii.gz) images.

    Parameters
    ----------
    labels : list
        label indices
    file1 : string
        source image, consisting of index-labeled pixels/voxels
    file2 : string
        target image, consisting of index-labeled pixels/voxels
    output_file : string
        (optional) output file name
    save_output : bool
        save output file?

    Returns
    -------
    dice_overlaps : numpy array
        Dice overlap values
    jacc_overlaps : numpy array
        Jaccard overlap values
    output_file : string
        output text file name with overlap values

    Examples
    --------
    >>> # Compare FreeSurfer and ants labels for the same brain:
    >>> import os
    >>> from mindboggle.evaluate.evaluate_labels import evaluate_volume_overlaps
    >>> from mindboggle.mio.labels import DKTprotocol
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> file1 = fetch_data(urls['freesurfer_labels'], '', '.nii.gz')
    >>> file2 = fetch_data(urls['ants_labels'], '', '.nii.gz')
    >>> dkt = DKTprotocol()
    >>> labels = dkt.cerebrum_cortex_DKT31_numbers
    >>> output_file = ''
    >>> save_output = True
    >>> evaluate_volume_overlaps(labels, file1, file2,
    ...     output_file=output_file, save_output=save_output) # doctest: +SKIP

    """
    import nibabel as nb

    from mindboggle.guts.compute import compute_overlaps

    # Load labeled image volumes:
    list1 = nb.load(file1).get_data().ravel()
    list2 = nb.load(file2).get_data().ravel()

    dice_overlaps, jacc_overlaps, output_file = compute_overlaps(labels,
        list1, list2, output_file=output_file, save_output=save_output)

    return dice_overlaps, jacc_overlaps, output_file
def evaluate_volume_overlaps(labels, file1, file2, 
                             output_file='', save_output=True):
    """
    Compute overlap between individual label regions
    in source and target nifti (nii.gz) images.

    Parameters
    ----------
    labels : list
        label indices
    file1 : string
        source image, consisting of index-labeled pixels/voxels
    file2 : string
        target image, consisting of index-labeled pixels/voxels
    output_file : string
        (optional) output file name
    save_output : Boolean
        save output file?

    Returns
    -------
    dice_overlaps : numpy array
        Dice overlap values
    jacc_overlaps : numpy array
        Jaccard overlap values
    output_file : string
        output text file name with overlap values

    Examples
    --------
    >>> import os
    >>> from mindboggle.evaluate.evaluate_labels import evaluate_volume_overlaps
    >>> from mindboggle.mio.labels import DKTprotocol
    >>> path = '/homedir/mindboggled'
    >>> file1 = os.path.join(path, 'Twins-2-1', 'labels', 'freesurfer_wmparc_filled_labels.nii.gz')
    >>> file2 = os.path.join(path, 'Twins-2-1', 'labels', 'freesurfer_wmparc_filled_labels.nii.gz')
    >>> dkt = DKTprotocol()
    >>> labels = dkt.cerebrum_cortex_DKT31_numbers
    >>> output_file = ''
    >>> save_output = True
    >>> evaluate_volume_overlaps(labels, file1, file2, output_file=output_file, save_output=save_output)

    """
    import nibabel as nb

    from mindboggle.guts.compute import compute_overlaps

    # Load labeled image volumes:
    list1 = nb.load(file1).get_data().ravel()
    list2 = nb.load(file2).get_data().ravel()

    dice_overlaps, jacc_overlaps, output_file = compute_overlaps(labels,
        list1, list2, output_file=output_file, save_output=save_output)

    return dice_overlaps, jacc_overlaps, output_file
def evaluate_surface_overlaps(labels,
                              index,
                              table1,
                              table2,
                              output_file='',
                              save_output=True):
    """
    Measure surface overlap per label by comparing Mindboggle vertices tables.

    Parameters
    ----------
    labels : list
        cortical label indices to measure surface overlap
    index : integer
        index (starting from zero) to column of table containing label indices
    table1 : string
        table with index labels for scalar values
    table2 : string
        table with index labels for scalar values
    output_file : string
        (optional) output file name

    Returns
    -------
    dice_overlaps : numpy array
        Dice overlap values
    jacc_overlaps : numpy array
        Jaccard overlap values
    output_file : string
        (optional) output file name
    save_output : bool
        save output file?

    Examples
    --------
    >>> # Compare volume label overlaps in trivial case: brain with itself:
    >>> import os
    >>> from mindboggle.evaluate.evaluate_labels import evaluate_surface_overlaps
    >>> from mindboggle.mio.labels import DKTprotocol
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> table1 = fetch_data(urls['left_vertices_table'])
    >>> table2 = fetch_data(urls['left_vertices_table'])
    >>> dkt = DKTprotocol()
    >>> labels = dkt.cerebrum_cortex_DKT31_numbers
    >>> index = 1
    >>> output_file = ''
    >>> save_output = True
    >>> evaluate_surface_overlaps(labels, index, table1, table2,
    ...     output_file=output_file, save_output=save_output) # doctest: +SKIP

    """
    import pandas as pd

    from mindboggle.guts.compute import compute_overlaps

    # Load surface label tables:
    df1 = pd.read_csv(table1)
    df2 = pd.read_csv(table2)
    list1 = df1.iloc[:, index]
    list2 = df2.iloc[:, index]
    print(list1)
    dice_overlaps, jacc_overlaps, output_file = compute_overlaps(
        labels, list1, list2, output_file=output_file, save_output=save_output)

    return dice_overlaps, jacc_overlaps, output_file
Beispiel #6
0
def evaluate_surface_overlaps(labels, index, table1, table2,
                              output_file='', save_output=True):
    """
    Measure surface overlap per label by comparing Mindboggle vertices tables.

    Parameters
    ----------
    labels : list
        cortical label indices to measure surface overlap
    index : integer
        index (starting from zero) to column of table containing label indices
    table1 : string
        table with index labels for scalar values
    table2 : string
        table with index labels for scalar values
    output_file : string
        (optional) output file name

    Returns
    -------
    dice_overlaps : numpy array
        Dice overlap values
    jacc_overlaps : numpy array
        Jaccard overlap values
    output_file : string
        (optional) output file name
    save_output : bool
        save output file?

    Examples
    --------
    >>> # Compare volume label overlaps in trivial case: brain with itself:
    >>> import os
    >>> from mindboggle.evaluate.evaluate_labels import evaluate_surface_overlaps
    >>> from mindboggle.mio.labels import DKTprotocol
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> table1 = fetch_data(urls['left_vertices_table'], '', '.csv')
    >>> table2 = fetch_data(urls['left_vertices_table'], '', '.csv')
    >>> dkt = DKTprotocol()
    >>> labels = dkt.cerebrum_cortex_DKT31_numbers
    >>> index = 1
    >>> output_file = ''
    >>> save_output = True
    >>> evaluate_surface_overlaps(labels, index, table1, table2,
    ...     output_file=output_file, save_output=save_output) # doctest: +SKIP

    """
    import pandas as pd

    from mindboggle.guts.compute import compute_overlaps

    # Load surface label tables:
    df1 = pd.read_csv(table1)
    df2 = pd.read_csv(table2)
    list1 = df1.iloc[:, index]
    list2 = df2.iloc[:, index]
    print(list1)
    dice_overlaps, jacc_overlaps, output_file = compute_overlaps(labels,
        list1, list2, output_file=output_file, save_output=save_output)

    return dice_overlaps, jacc_overlaps, output_file