def convert_ptt_units(ptt_list, tip_factor, tilt_factor, starting_units, ending_units):
    """
    Convert the PTT list to or from Poppy units and the segmented DM units.

    Note that this has been created for the IrisAO segmented DMs, therefore
    the tip and tilt values are swapped with what Poppy desginates.

    Poppy to segmented DM:
    - tip_factor = -1
    - tilt_facotr = 1
    - starting_units = (u.m, u.rad, u.rad)
    - ending_units = dm_ptt_units from the config.ini file

    Segmented DM to Poppy
    - tip_factor = 1
    - tilt_factor = -1
    - starting_units = dm_ptt_units from the config.ini file
    - ending_units = (u.m, u.rad, u.rad)

    :param ppt_list: list, of tuples existing of piston, tip, tilt, values for each
                     segment in a pupil, in the respective starting_units
    :param tip_factor: int, either -1 or 1 based on the information above
    :param tilt_factor: int, either -1 or 1 based on the information above
    :param starting_units: tuple or list of the units associated with the piston, tip,
                           tilt values respectively of the input ptt_list
    :param ending_units: tuple_or_list of the units associated with the piston, tip,
                           tilt values respectively of the expected output
    :return: list of tuples of the piston, tip, tilt values for each segment listed,
             in the respective ending_units
    """
    converted = [(ptt[0]*(starting_units[0]).to(ending_units[0]),
                  tip_factor*ptt[2]*(starting_units[2]).to(ending_units[2]),
                  tilt_factor*ptt[1]*(starting_units[1]).to(ending_units[1])) for ptt in ptt_list]
    return converted