Here is the general process:
I'm 100% certain that your institute has the first right of refusal to
patent the invention. So you have to talk your PI and have he/she talk to
the office of technology transfer. If the school is going to take the
invention, the school will pay for all the cost and the maintenance fee (yes
, there is a maintenance fee per year). If the institution decide not to
take it, then you and your PI will have to pay for the cost. Your PI does
not have to include you as an inventor if he/she is an Ahole. Once you have
all the institutional details figured out, you send a package to a patent
lawyer. The attorney will do a search and tell you if your idea is
patentable or not. Even if the idea is not patentable, the attorney will
still go through the process if you insist on going through with it. You
patent will most likely not to be enforceable i.e. someone patented how to
toast a bread in 2010.
As for the cost, I think it is around 10-20k for the initial process. I
think the maintenance cost is like 1 to 5k/year. I never paid it myself so
the figure just what I heard.