cmtk parcellation

53 views
Skip to first unread message

Chris

unread,
Nov 19, 2012, 10:53:28 AM11/19/12
to nipy...@googlegroups.com
Hi all,

I'm not sure whether to put this to NiPy users or cmtk-users, but I attempted to make a cmtk parcellation of some freesurfer output overnight.
As it happened, the sample code at http://nipy.sourceforge.net/nipype/interfaces/generated/nipype.interfaces.cmtk.parcellation.html looked like it would do pretty much exactly what I needed done as a test, so I ran it exactly as indicated in my freesurfer $SUBJECTS_DIR, with the exception of the subject_id, of course.

When I returned this morning, I saw that the script failed at some point, although it looks like it made it quite a ways through the process. The last message printed was: 

FileNotFoundError: File/Directory '/home/chris/resting/anat/aseg.nii.gz' not found for Parcellate output 'aseg_file'.
Interface Parcellate failed to run.

Where /home/chris/resting/anat is the $SUBJECTS_DIR. And it is true, aseg.nii.gz is not to be found in this directory, though tmp.nii.gz and ROI_scale500.nii.gz are there, as are a number of new subdirectories containing .label files. So I was wondering if anyone had insight into how this error came to be and what might be done to fix it. 

Possibly related are some error messages that look like it suddenly was unable to read the structural file:

INFO     : 2012-11-19 01:53:58,787 : main       : reading template info from volume ./sub00156/mri/orig/001.mgz...
INFO     : 2012-11-19 01:53:58,787 : main       : reading template info from volume ./sub00156/mri/orig/001.mgz...
121119-01:53:58,788 main INFO:
error reading from volume ./sub00156/mri/orig/001.mgz
INFO     : 2012-11-19 01:53:58,788 : main       : error reading from volume ./sub00156/mri/orig/001.mgz
INFO     : 2012-11-19 01:53:58,788 : main       : error reading from volume ./sub00156/mri/orig/001.mgz
INFO     : 2012-11-19 01:53:58,788 : main       : error reading from volume ./sub00156/mri/orig/001.mgz
INFO     : 2012-11-19 01:53:58,788 : main       : error reading from volume ./sub00156/mri/orig/001.mgz
121119-01:53:58,799 runCmd CRITICAL:
Return Value: 1
CRITICAL : 2012-11-19 01:53:58,799 : runCmd     : Return Value: 1
CRITICAL : 2012-11-19 01:53:58,799 : runCmd     : Return Value: 1
CRITICAL : 2012-11-19 01:53:58,799 : runCmd     : Return Value: 1
CRITICAL : 2012-11-19 01:53:58,799 : runCmd     : Return Value: 1

Thanks,
Chris

Chris

unread,
Nov 19, 2012, 9:33:30 PM11/19/12
to nipy...@googlegroups.com
Update: I reran the parcellation script after making symlinks in $SUBJECTS_DIR to $SUBJECTS_DIR/subject_id/mri/aseg.nii.gz, and similarly for ribbon.nii.gz and fsmask_1mm.nii.gz. So far parcellate.run() seems to be running, so I hope that was the solution. It is odd, however, that it assumes that those files would be in the $SUBJECTS_DIR directory, rather than with the subject's data, as this seems to require parcellating participants serially. Am I doing something wrong?
Message has been deleted

Chris

unread,
Nov 19, 2012, 9:56:52 PM11/19/12
to nipy...@googlegroups.com
Update #2: Those symlinks didn't suffice. It had been running for a few hours and eventually conked out at:
File/Directory '/home/chris/resting/anat/ROI_HR_th.nii.gz' not found for Parcellate output 'roi_file_in_structural_space'.

Satrajit Ghosh

unread,
Nov 19, 2012, 10:12:11 PM11/19/12
to nipy-user
hi chris,

it would be helpful to know which version you are running. (nipype.get_info()). can you try to provide absolute paths to each input.

also i'm hoping erik can pitch in here.

cheers,

satra

--
 
 
 

Erik Kastman

unread,
Nov 20, 2012, 12:46:14 PM11/20/12
to nipy...@googlegroups.com
Hmm, one of the first things that Parcellate does (in create_annot_label) is to convert aseg.mgz back into aseg.nii.gz, so if you see a $SUBJECTS_DIR/subject_id/mri/aseg.nii.gz  to symlink, it sounds like the paths are correct. [Unless you created those yourself?]. Nonetheless, I second Satra's recommendation to try using absolute paths. 

The error "error reading from volume ./sub00156/mri/orig/001.mgz " is looking for the subject directory relative to the current directory ('.'), which to work means you have to be in $SUBJECTS_DIR when you either launch the nipype script or manually type the nipype commands. From the FileNoutFoundError it looks like you're doing that already, but you should double-check. Also, the full path to 001.mgz should be valid; make sure that  /home/chris/resting/anat/sub00156/mri/orig/001.mgz actually exists. If it's not, you need to initialize the subject or import it into FS' structure (I'm definitely not a FS guru, so I apologize if I'm butchering their terminology). If I recall it may be as simple as `recon-all -i ./path/to/001.dcm`?

As for why the script is looking in $SUBJECTS_DIR for the aseg output file, my guess is that it has more to do with looking in current directory that happens to be $SUBJECTS_DIR than it does with looking in $SUBJECTS_DIR explicitly. Most nipype nodes do processing & create outputs in the current directory (when running as a node in a workflow, all the directory management is done by the pipeline engine automatically, but when run as a single interface like this you'll see paths that seem almost, but not quite right, like this). It means what you already figured out, that processing broke somewhere earlier in the script and the failure wasn't detected until the end of the node when it came time to gather up all the outputs. (You can see this in the abspath call to find the aseg here:  https://github.com/nipy/nipype/blob/master/nipype/interfaces/cmtk/parcellation.py#L419, I'm betting that's where your error is coming from in the backtrace).

Try running the interface with absolute paths, and if that doesn't work send the nipype.get_info() and a full stack trace of the processing? Sorry for the long-winded response,

Erik

--
 
 
 

Chris

unread,
Nov 20, 2012, 4:18:35 PM11/20/12
to nipy...@googlegroups.com
Erik was, in fact, able to help over in the cmtk-users group. The problem seems to have resolved itself when I specified the inputs.freesurfer_dir and inputs.subjects_dir by fully spelling out the path:

>>> import nipype.interfaces.cmtk as cmtk
>>> parcellate = cmtk.Parcellate()
>>> parcellate.inputs.freesurfer_dir = '/path/to/freesurfer/installation'
>>> parcellate.inputs.subjects_dir = '/path/to/subjects'
>>> parcellate.inputs.subject_id = 'subj1'
>>> parcellate.inputs.parcellation_name = 'scale500'
>>> parcellate.run()    

In my case, my subjects_dir is nowhere near my freesurfer_dir, and I executed this code in my subjects_dir. The resulting output files ended up in my $SUBJECTS_DIR, so I'll have to move the files to a separate folder for my attempt to parcellate the next participant. I haven't tried to figure out how to incorporate this step into a pipeline so that multiple participants can be parcellated serially, with each of their parcellation outputs getting dumped into a different directory, but I'm sure that'll be possible.

Thanks for your help

Erik Ziegler

unread,
Nov 20, 2012, 4:42:04 PM11/20/12
to nipy...@googlegroups.com
Good to hear!

That should be easy to do. Just write a short workflow where an infosource node passes the subject IDs to the parcellate node using an interable list.

See:


Cheers,

Erik

--
 
 
 

Reply all
Reply to author
Forward
0 new messages