def pcmatrixrow(matrix, form, trans):
    """
    Returns the row for the specified form and transposition level.
    
    Parameters
    ----------
    matrix : tuple
        A pitch class matrix created by pcmatrix().
    form : 'p' | 'r' | 'i' | 'ri'
        The row form to return: 'p' is prime, 'r' is retrogade, 'i' is inversion, and 'ri' is retrograde-inversion.
    trans : pc
        The pitch class transposition level of the row to return.

    Returns
    -------
    A tuple containing the pitch classes for the given form and transposition.
    """
    size = len(matrix)
    assert 0 <= trans < size, "Not a valid transposition level: {}.".format(trans)
    row = col = 0
    if form in ['p', 'r']:
        while row < size:
            if matrix[row][col] == trans:
                break
            row += 1
        assert row < size, "Not a valid row transposition: {}.".format(row)
        return matrix[row] if form == 'p' else matrix[row][::-1]
    elif form in ['i', 'ri']:
        while col < size:
            if matrix[row][col] == trans:
                break
            col += 1
        assert col < size, "Not a valid row transposition: {}.".format(col)
        rng = range(0, size) if form == 'i' else reversed(range(0, size))
        return tuple(matrix[r][col] for r in rng)
    else:
        raise Exception("Not a valid row form: {}".format(form))