JacobBumgarner / VesselVio

An open-source application for the analysis and visualization of segmented vasculature datasets
https://jacobbumgarner.github.io/VesselVio/
GNU General Public License v3.0
99 stars 21 forks source link

[Feature Request]: Throw a warning if the user loads non-binary images. #42

Closed JacobBumgarner closed 2 years ago

JacobBumgarner commented 2 years ago

Describe the feature you would like to be added.

Because it might be confusing for some what 'segmented' vs. 'binary' images are, a check should be implemented to determine whether the user is loading a non-binary image.

Pseudocode or Screenshots

def binary_check(volume: np.ndarray) -> bool:
    """Return a bool indicating if the loaded volume is binary or not.

    Takes a slice from the volume and checks to confirm that only two unique
    values are present.

    Parameters:
    volume : np.ndarray

    Returns:
    bool
        True if the spot check of the volume only return two unique values,
        False if more than two unique values were identified.
    """
    middle = int(volume.shape[0] / 2)
    unique = np.unique(volume[middle])

    return unique.shape[0] < 3

def segmentation_check(volume: np.ndarray) -> bool:
    """Return a bool indicating if volume has vessels after the segmentation.

    Some regions of interest may be present in the annotation, but there may
    be no corresponding vasculature in the datasets. This function checks to see
    if vessels are present.

    Parameters:
    volume : np.ndarray

    Returns:
    bool
        True if vessels are present, False if not.
    """
    if volume is None:
        return False
    elif not np.any(volume):
        return False
    return True
Screen Shot 2022-05-30 at 11 12 07 AM Screen Shot 2022-05-30 at 11 11 55 AM

Code of Conduct