I'm sort of foggy in general about how this works. If you are, say a a computer science graduate student, what kind of freedom do you have to pick a research topic that focuses more on something like cellular biology, swarms, or string theory? Do you need to change departments? Do you need to illustrate some connection back to CS techniques? Do you just have to pursuade your advisor to issue a blessing?
This will vary based on your adviser, your level of study (i.e. what degree you're going for), your committee and your department. In almost all cases for computer science, you will be required to demonstrate mastery of the subject. Incorporating outside knowledge from another subject area, say, cell biology, where you re-implemented or improved a gene matching algorithm, for example, would probably be allowed.
Simply doing an experiment from cell-biology with no tie-in to CS would almost certainly not be approved--but, this is where your adviser, et. al. come in. If you've got a smashing idea, a good adviser/committee will help you try and find a way to tie it into your degree and PhD students are typically given more leeway here than Masters students.
Though, be prepared, in some cases, an adviser will play a big role in determining what your thesis will be. Also, if you are being funded by a particular grant under a PI (principal investigator--typically a research professor), it is traditional (at least at my University) to pursue research related to what the PI is doing. Though it's definitely easy just to ask to be exempt from this tradition.
So, basically, the answer to your question is it depends. Almost certainly you will be required to do something Computer Science-y for a CS degree, but there can be a lot of leeway in determining what Computer Science-y means.
There are a lot of factors. Generally, your research topic is whatever you and your advisor agree on. In principle, you often have a dissertation committee that must also agree, but typically that is mostly a formality unless someone is totally off the rails.
So if you want to do something unusual, the hard part would be getting your advisor to agree. In deciding whether a topic is appropriate for a PhD dissertation, they should generally consider:
Is it significant? Is this a project that will be a genuine contribution to the field? Is it in an area that is generally recognized as important? Is it difficult enough to be worth a PhD? A project in a fringe area, or one that would advance the state of the art only infinitesimally even if successful, or one that is at too low a level, would likely not fly.
Is it original? The project should not primarily duplicate something that has already been done (unless you are trying to reproduce previous results, which in some situations would be considered valuable). Your advisor will have to be convinced that your literature search is thorough enough that you fully understand the context of your project and how it will extend previous work.
Is it feasible? Your advisor needs to be convinced that you have the necessary knowledge, expertise, resources, and funding, and that the project is of an appropriate difficulty and scale that you have a good chance of completing it within a reasonable period of time (some departments have firm limits on how long you can take to finish a PhD).
Are they qualified to advise you? Does the advisor have the necessary expertise to accurately evaluate the significance, originality and feasibility of the proposed project? Will they be able to help teach you some of the things you need to learn? Will they be able to judge your progress along the way? Will they be able to provide you with, or help you acquire, resources you may need?
So in most cases, if you have a particular area in mind, in order to pass the fourth test you will need to choose an advisor who is an expert in that area or something closely related. If nobody in the department qualifies, or none of them are willing to be your advisor, then you probably cannot work on that project in that department. Sometimes it is possible to take on a co-advisor from another department who does have the appropriate expertise. Otherwise, you either need to change departments (often tantamount to reapplying), change institutions (which means actually reapplying) or work on something else.
In many cases, the easiest way to meet all four criteria is to work on a project suggested by your advisor, even if it is something that you hadn't previously been interested in. This is particularly true in fields that are highly specialized, and where a beginning graduate student would not be expected to easily recognize interesting problems to study.
For students in the physical sciences and engineering, a major issue is getting funding to pay for required research equipment and supplies. This nearly always comes from a grant that has been awarded to the academic advisor. Thus students working in these disciplines are very constrained in their choice of projects- it has to be something that fits with the available funding.
Even if the student's research doesn't require expensive equipment and supplies, if the student is working on a research assistantship then the student will normally be expected to do a thesis or disseration that is part of the research project that funds the assistantship.
Some students work in areas where there isn't any need for expensive equipment or supplies and some students also have funding (a fellowship or a teaching assistantship) that isn't tied to a particular research grant. In such cases students can have a much greater say in what their thesis project will be. However, the project still must be acceptable to the advisor and the thesis or dissertation committee. It is not uncommon for advisors to simply say "no" to a student request to supervise a project that the advisor doesn't think is worthwhile. Even if the advisor says "yes", there are often other levels at which the project must be approved (e.g. by the thesis or dissertation committee, the department chair, or even a graduate dean.)