You can modify this logic to backup and restore individual file groups. But this sample will at least get you started and shows how to backup and restore a single database using SMO.
Note: You may need to adjust the output folder path and the server settings in order to get this sample to work for you.