Dear Kai Cheng,
The Rank Indicator decision is based on the number of transmitted data bits for a rank value, where it is chosen the RI for which the number of bits is maximized.
If you are interested on the actual calulation method, I suggest you have a look at the code where this is calculated: +feedback_calculation\CQI_and_rank.m, lines 130-143.
Best regards,
Fjolla