jrkerns / pylinac

An image analysis library for medical physics
https://pylinac.readthedocs.io/en/latest/
MIT License
157 stars 99 forks source link

Mistake with units in "bb_shift_instructions()" in winston lutz code #522

Open llorens99 opened 1 month ago

llorens99 commented 1 month ago

I was looking to the bb_shift_instructions() function. The function currently provides numerical values that are correct, but the units indicated are inconsistent. The couch positions (couch_vrt, couch_lat, couch_lng) are defined in centimeters, but the output for the new couch coordinates is labeled as "mm" (millimeters).

Sorry for the inconveniences, I show the function I'm refering to just below, and the change I suggest to make.

    ----------
    couch_vrt : float
        The current couch vertical position in cm.
    couch_lng : float
        The current couch longitudinal position in cm.
    couch_lat : float
        The current couch lateral position in cm.
    """
    sv = self.bb_shift_vector
    x_dir = "LEFT" if sv.x < 0 else "RIGHT"
    y_dir = "IN" if sv.y > 0 else "OUT"
    z_dir = "UP" if sv.z > 0 else "DOWN"
    move = f"{x_dir} {abs(sv.x):2.2f}mm; {y_dir} {abs(sv.y):2.2f}mm; {z_dir} {abs(sv.z):2.2f}mm"
    if all(val is not None for val in [couch_vrt, couch_lat, couch_lng]):
        new_lat = round(couch_lat + sv.x / 10, 2)
        new_vrt = round(couch_vrt + sv.z / 10, 2)
        new_lng = round(couch_lng + sv.y / 10, 2)
        move += f"\nNew couch coordinates (mm): VRT: {new_vrt:3.2f}; LNG: {new_lng:3.2f}; LAT: {new_lat:3.2f}"
    return move

I would say that move should be:

   move += f"\nNew couch coordinates (cm): VRT: {new_vrt:3.2f}; LNG: {new_lng:3.2f}; LAT: {new_lat:3.2f}"
jrkerns commented 1 week ago

Thanks. Will get it fixed.