nipy / PySurfer

Cortical neuroimaging visualization in Python
https://pysurfer.github.io/
BSD 3-Clause "New" or "Revised" License
240 stars 97 forks source link

View NifTi files #128

Closed TheChymera closed 9 years ago

TheChymera commented 9 years ago

Hi guys, I converted a DICOM series to NifTi (with dcmstack - as seen here), and I would like to visualize it. Pysurfer asks me about a SUBJECTS_DIR. But I cannot find any information about what this should be in the docs. Here is my attempt to run pysurfer:

chymera@zenbookhost ~/src/RS $ pysurfer 60001-T2S_Anatomical_Feb15.nii.gz left pial
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/pysurfer", line 26, in <module>
    subjects_dir = os.environ['SUBJECTS_DIR']
  File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'SUBJECTS_DIR'

Can you guys help me out?

mwaskom commented 9 years ago

PySurfer requires you to have processed your anatomy in Freesurfer (recon-all), and then you can visualize data on the surface much as you would in tksurfer. Using Freesurfer involves setting up a directory with anatomical data for each subject, aka the SUBJECTS_DIR. Everything is in a well-organized hierarchy, so PySurfer knows where to find the files it needs. But it doesn't create those files itself, so until you preprocess the data with Freesurfer, it will not be too useful.

TheChymera commented 9 years ago

so there is no way to circumvent freesurfer in my data visualization? Is PySurfer only usagbe in conjunction with freesurfer?

mwaskom commented 9 years ago

For single subject data, yes. You need to have processed the anatomy to create a mesh model of the cortical surface with Freesurfer that PySurfer uses.

One caveat is that you can project volume data in MNI space onto the average cortical surface template that ships with Freesurfer (as in this example). The correspondence between the MNI volume and the average surface template is inexact, though, so that's really more useful for illustrative purposes than for making principle decisions about the localization of activation. And even there you'll have to have Freesurfer installed and set up properly, both so that you can use the template mesh and because that function makes an external system call to a Freesurfer binary.

TheChymera commented 9 years ago

Not to bash the freesurfer developers, but freesurfer is anything but free (which bothers me fairly little ideologically, but makes it difficult for me to properly ship it with my distro). It would be really great if it weren't needed...

mwaskom commented 9 years ago

I'm sorry; I'm unable to help with that problem.

TheChymera commented 9 years ago

In any case thanks for the clarification.

mwaskom commented 9 years ago

I am a little curious to hear what the issue is, though? Freesurfer is distributed as part of Neurodebian, so I wouldn't have expected there to be a problem with its license terms.

TheChymera commented 9 years ago

I am trying to distribute the most popular neuroscience packages as part of the Gentoo science repository. This is in part because Gentoo is my favourite distribution (and I am a neuroscientist), but also because Gentoo provides excellent support for live (not even just nightly!) builds. I guess you can agree that as a scientist it is really amazing to have access to the very latest code from your colleagues (who are developing package whatever) directly through your system's package manager. (here's an already older post about that, by me)

But we do not have access to the newest Freesurfer sources, so that benefit is voided for this package. Additionally, Freesurfer is distributed as a binary, so all the other benefits you get by compiling from source (modularity, portability, speed) also go out the window. Even if you distribute it as a binary, you still have to include their nonstandard license (which is not that horrible, but still a nuisance). Least but probably most annoyingly, we have to require our users to manually get a registration key, log in as root, and edit some otherwise obscure system directory manually... I am guessing Neurodebian also does this?

mwaskom commented 9 years ago

I don't use debian so I'm not sure, but I do know they package it. I think that you should be able to download the Freesurfer source from the cvs repository or nightly builds, not just the released binaries.