-
Notifications
You must be signed in to change notification settings - Fork 262
BF FreeSurfer nifti surfaces can have >3 dimensions #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Seems reasonable. I'm afraid we do need some tests :) |
Okay. Looking at https://code.google.com/p/fieldtrip/source/browse/trunk/external/freesurfer/save_nifti.m?r=8776#52 again, it looks like this MATLAB code at least only ever works with 4D volumes, but does allow the 4th dimension to vary. The tests I uploaded permit up to 7 dimensions, which is the max of |
Looks reasonable to me as well. I would, however, add some comments to the |
How about adding the following to
Or should I describe the hacks? I think the code in |
@effigies that's just what I was looking for. I would put that on I found the code to be very readable, I doubt inline comments could help. |
Added a variation on that comment. One possible quibble is that surface files that have <65536 nodes will not trigger constraints on dimensions 2 and 3, since they won't hit either of the large surface hacks. I'm not sure this is a problem, but I'd be open to suggestions of rewording. |
@effigies I appreciate the note, and I'll follow up on this (to see if it is an issue) as I get closer to working on CIFTI/GIFTI stuff. |
@@ -723,6 +723,11 @@ def set_data_shape(self, shape): | |||
If ``ndims == len(shape)`` then we set zooms for dimensions higher than | |||
``ndims`` to 1.0 | |||
|
|||
Nifti1 images can have up to seven dimensions. For Nifti surface files, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say "Nifti surface files" - do you mean that this is part of the NIfTI standard somewhere? Or you just mean NIfTI as creatively reinterpreted by Freesurfer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's my understanding that CIFTI, which contains both surface and volume data, follows the NIFTI2 spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add something to that effect here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, there are Nifti1 surface files (http://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h):
#define NIFTI_INTENT_VECTOR 1007 /* for any other type of vector */
/*! To signify that the vector value at each voxel is really a
spatial coordinate (e.g., the vertices or nodes of a surface mesh):
- dataset must have a 5th dimension
- intent_code must be NIFTI_INTENT_POINTSET
- dim[0] = 5
- dim[1] = number of points
- dim[2] = dim[3] = dim[4] = 1
- dim[5] must be the dimensionality of space (e.g., 3 => 3D space).
- intent_name may describe the object these points come from
(e.g., "pial", "gray/white" , "EEG", "MEG"). */
Annoyingly, this isn't how FreeSurfer actually implements its surfaces, presumably because of the need for large vector hacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent precision of the thing - could these go in the docstring, for posterity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about the following documentation output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - but - can you clean up the appearance of the links in the output by using ReST links, defined at the bottom of the docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Learning Sphinx, today. Have another look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ! Does it look OK in the source code as well?
Looks good apart from my line comments. |
Pushed new commit. If source needs cleanup, let me know. |
Thanks for that - looks good now. Any more comments? Otherwise I will merge tomorrow. |
@matthew-brett @effigies this seems ready to go? |
MRG: FreeSurfer nifti surfaces can have >3 dimensions Quick workaround for https://mail.python.org/pipermail/neuroimaging/2015-July/000132.html. This uses the FreeSurfer hacks on any shapes beginning with (-1, 1, 1) or (27307, 1, 6), which seems fairly safe, but we can restrict down to 4-dimensional, or possibly only allow (-1, 1, 1, 1) or (27307, 1, 6, 1) in the 4D case.
Thanks for reminding me. |
MRG: FreeSurfer nifti surfaces can have >3 dimensions Quick workaround for https://mail.python.org/pipermail/neuroimaging/2015-July/000132.html. This uses the FreeSurfer hacks on any shapes beginning with (-1, 1, 1) or (27307, 1, 6), which seems fairly safe, but we can restrict down to 4-dimensional, or possibly only allow (-1, 1, 1, 1) or (27307, 1, 6, 1) in the 4D case.
Quick workaround for https://mail.python.org/pipermail/neuroimaging/2015-July/000132.html.
This uses the FreeSurfer hacks on any shapes beginning with (-1, 1, 1) or (27307, 1, 6), which seems fairly safe, but we can restrict down to 4-dimensional, or possibly only allow (-1, 1, 1, 1) or (27307, 1, 6, 1) in the 4D case.
I guess we should also add tests for these cases.