How to use the pymedphys._imports.numpy.any function in pymedphys

To help you get started, we’ve selected a few pymedphys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pymedphys / pymedphys / pymedphys / labs / managelogfiles / bygantry.py View on Github external
def assert_array_agreement(
    unique_logfile_gantry_angles, mosaiq_gantry_angles, allowed_deviation
):
    difference_matrix = np.abs(
        unique_logfile_gantry_angles[:, None] - mosaiq_gantry_angles[None, :]
    )
    agreement_matrix = difference_matrix <= allowed_deviation
    row_agreement = np.any(agreement_matrix, axis=1)
    at_least_one_agreement = np.all(row_agreement)

    assert at_least_one_agreement, (
        "There is a logfile gantry angle that deviates by more than {} degrees"
        " from the Mosaiq control points. Unsure how to handle this.\n\n"
        "Logfile: {}\nMosaiq: {}\nDifference Matrix:\n{}\n"
        "Agreement Matrix:\n{}".format(
            allowed_deviation,
            unique_logfile_gantry_angles,
            mosaiq_gantry_angles,
            difference_matrix,
            agreement_matrix,
        )
github pymedphys / pymedphys / pymedphys / _trf / table.py View on Github external
def apply_negative(column):
    result = np.ones_like(column).astype(np.float64) * np.nan
    negative_values = column.values > 2 ** 15

    result[negative_values] = column[negative_values] - 2 ** 16
    result[np.invert(negative_values)] = column[np.invert(negative_values)]

    if np.any(np.isnan(result)):
        raise Exception("Not all column values were converted")

    return result
github pymedphys / pymedphys / pymedphys / _gamma / implementation / shell.py View on Github external
)
            )

        min_relative_dose_difference = calculate_min_dose_difference(
            options, distance, to_be_checked, distance_step_size
        )

        current_gamma, still_searching_for_gamma_all = multi_thresholds_gamma_calc(
            options,
            current_gamma,
            min_relative_dose_difference,
            distance,
            to_be_checked,
        )

        still_searching_for_gamma = np.any(
            np.any(still_searching_for_gamma_all, axis=-1), axis=-1
        )

        to_be_checked = options.reference_points_to_calc & still_searching_for_gamma

        if np.sum(to_be_checked) == 0:
            break

        relevant_distances = options.distance_mm_threshold[
            np.any(
                np.any(
                    options.reference_points_to_calc[:, None, None]
                    & still_searching_for_gamma_all,
                    axis=0,
                ),
                axis=0,
github pymedphys / pymedphys / pymedphys / _trf / table.py View on Github external
def convert_numbers_to_string(name, lookup, column):
    dtype = np.array([item for _, item in lookup.items()]).dtype
    result = np.empty_like(column).astype(dtype)
    result[:] = ""

    for i, item in lookup.items():
        result[column.values == int(i)] = item

    if np.any(result == ""):
        print(lookup)
        print(np.where(result == ""))
        print(column[result == ""].values)
        unconverted_entries = np.unique(column[result == ""])
        raise Exception(
            "The conversion lookup list for converting {} is incomplete. "
            "The following data numbers were not converted:\n"
            "{}\n"
            "Please update the trf2csv conversion script to include these "
            "in its definitions.".format(name, unconverted_entries)
        )

    return result
github pymedphys / pymedphys / pymedphys / _gamma / implementation / shell.py View on Github external
)

        min_relative_dose_difference = calculate_min_dose_difference(
            options, distance, to_be_checked, distance_step_size
        )

        current_gamma, still_searching_for_gamma_all = multi_thresholds_gamma_calc(
            options,
            current_gamma,
            min_relative_dose_difference,
            distance,
            to_be_checked,
        )

        still_searching_for_gamma = np.any(
            np.any(still_searching_for_gamma_all, axis=-1), axis=-1
        )

        to_be_checked = options.reference_points_to_calc & still_searching_for_gamma

        if np.sum(to_be_checked) == 0:
            break

        relevant_distances = options.distance_mm_threshold[
            np.any(
                np.any(
                    options.reference_points_to_calc[:, None, None]
                    & still_searching_for_gamma_all,
                    axis=0,
                ),
                axis=0,
            )
github pymedphys / pymedphys / pymedphys / _wlutz / findfield.py View on Github external
penumbra,
            predicted_centre,
            predicted_rotation,
            find_bb=False,
        )
    except ValueError as e:
        raise ValueError(
            "After finding the field centre during comparison to Pylinac the pylinac "
            f"code raised the following error:\n    {e}"
        )

    pylinac_2_2_6_out_of_tol = np.any(
        np.abs(np.array(pylinac["v2.2.6"]["field_centre"]) - predicted_centre)
        > pylinac_tol
    )
    pylinac_2_2_7_out_of_tol = np.any(
        np.abs(np.array(pylinac["v2.2.7"]["field_centre"]) - predicted_centre)
        > pylinac_tol
    )
    if pylinac_2_2_6_out_of_tol or pylinac_2_2_7_out_of_tol:
        raise PylinacComparisonDeviation(
            "The determined field centre deviates from pylinac more "
            "than the defined tolerance"
        )

    centre = predicted_centre.tolist()
    return centre, predicted_rotation
github pymedphys / pymedphys / pymedphys / _wlutz / findfield.py View on Github external
penumbra,
            predicted_centre,
            predicted_rotation,
            find_bb=False,
        )
    except ValueError as e:
        raise ValueError(
            "After finding the field centre during comparison to Pylinac the pylinac "
            f"code raised the following error:\n    {e}"
        )

    pylinac_2_2_6_out_of_tol = np.any(
        np.abs(np.array(pylinac["v2.2.6"]["field_centre"]) - predicted_centre)
        > pylinac_tol
    )
    pylinac_2_2_7_out_of_tol = np.any(
        np.abs(np.array(pylinac["v2.2.7"]["field_centre"]) - predicted_centre)
        > pylinac_tol
    )
    if pylinac_2_2_6_out_of_tol or pylinac_2_2_7_out_of_tol:
        raise PylinacComparisonDeviation(
            "The determined field centre deviates from pylinac more "
            "than the defined tolerance"
        )

    centre = predicted_centre.tolist()
    return centre, predicted_rotation
github pymedphys / pymedphys / pymedphys / _gamma / implementation / shell.py View on Github external
distance,
            to_be_checked,
        )

        still_searching_for_gamma = np.any(
            np.any(still_searching_for_gamma_all, axis=-1), axis=-1
        )

        to_be_checked = options.reference_points_to_calc & still_searching_for_gamma

        if np.sum(to_be_checked) == 0:
            break

        relevant_distances = options.distance_mm_threshold[
            np.any(
                np.any(
                    options.reference_points_to_calc[:, None, None]
                    & still_searching_for_gamma_all,
                    axis=0,
                ),
                axis=0,
            )
        ]

        distance_step_size = np.min(relevant_distances) / options.interp_fraction

        distance_step_size = np.max(
            [distance / options.interp_fraction / options.max_gamma, distance_step_size]
        )

        distance += distance_step_size
        if len(force_search_distances) != 0: