Hold on, you have gone past the point.

CIFTI files *DO NOT CONTAIN* coordinates for surface vertices.  Do not look
for them in the header, they are not there.  They are in gifti surface
files (.surf.gii) that we provide alongside the cifti files.

What Anand has done is use the fieldtrip matlab implementation of cifti,
which attempts to locate and load any nearby surface files that look
relevant to the cifti file you opened.  This gives the incorrect impression
that surface coordinates are contained in the file, when they are not.

Why doesn't cifti contain coordinates for surface vertices?  Well, which
coordinates would you want in the files?  The pial surface has different
coordinates from the white surface, but they are both relevant and useful
in processing (particularly for mapping from volume to surface or vice
versa).  We also have a compromise surface halfway between them, the
midthickness, which we use for most processing that doesn't need to take
thickness into account.  It is also possible to make an approximation of
layer 4.  However, these surfaces are all tightly folded, making it hard to
see data that isn't at the top of a gyrus.  So, for visualization, we have
inflated and very_inflated surfaces, which give up anatomical relevance of
coordinates in order to be able to see all the data at once.

So, which coordinates are you looking for?  That depends on what you are
trying to do.  This is why we don't put surface vertex coordinates in the
CIFTI file - there are too many choices, and none of them is always right.

Short version: If you want to do some analysis (people seem to like finding
center of gravity, despite its caveats), use the midthickness surfaces,
they are what we generally use for processing.  If you want to do
visualization of data without folds getting in the way, try the
very_inflated surfaces.

Tim


On Tue, Aug 1, 2017 at 2:08 PM, Demian Wassermann <
demian.wasserm...@inria.fr> wrote:

> Hi Anand,
>
> as one of the guys who helped with the *first* implementation of CIFTI in
> nibabel I can tell you that you need to navigate the header yourself. We
> went for a first implementation which can effectively parse the header and
> we are open for help in producing helper functions that will enable people
> to easily do what you want.
>
> I don’t know how it is done in matlab but in python you’ll need the
> accompanying surface.
>
> Assuming that you have it then, for the left cortex you can try:
>
> c = nibabel.load(cifti_filename)
>
> #this next line will fail if the required structure is not in the CIFTI
> file. Also I’m assuming that the grayordinates are along the column
> dimension
> brain_model_cortex_left = [brain_model for brain_model in
> c.header.get_index_map(1).brain_models if brain_model.brain_structure ==
> ‘CIFTI_STRUCTURE_CORTEX_LEFT’][0]
> vertex_indices = list(brain_model_cortex_left.vertex_indices)
>
> s = nibabel.load(gifti_left_surface_filename)
> grayordinates_surface = s.darrays[0].data
> grayordinates_cortex_left = [(brain_model_cortex_left.index_offset + i,
> grayordinates_surface[v]) for i, v in enumerate(vertex_indices)]
>
>
> Finally in grayordinates_cortex_left you’ll have a list of tuples where
> the first element is the column in the CIFTI matrix and the second is it’s
> grayordinate.
>
>
>
> Again, we just coded the bare bones to be able to implement the
> convenience functionality on top of it, collaborations to the codebase are
> more than welcomed.
>
> Best
> Demian
>
> --
> Demian Wassermann, PhD
> demian.wasserm...@inria.fr
> Associate Research Professor (CR1)
> Athena Project Team
> INRIA Sophia Antipolis - Méditerranée
> 2004 route des lucioles - FR-06902
>
>
>
>
> > On 1 Aug 2017, at 20:39, Glasser, Matthew <glass...@wustl.edu> wrote:
> >
> > I would ask the author of the nilearn/nibabbel tools as I don’t know
> > anything about the Python implementation of CIFTI.
> >
> > Peace,
> >
> > Matt.
> >
> > On 8/1/17, 1:25 PM, "Anand A Joshi" <ajo...@usc.edu> wrote:
> >
> >> Thanks Matt for the reply.
> >>
> >> I figured out how to get it in Matlab (see below), but not in Python. I
> >> can read cifti image in python.
> >>
> >> f=image.load_img(filename)
> >>
> >> But how do I get coordinates of the subcortical structures. I code
> >> snippet would be appreciated.
> >>
> >> Thank you,
> >> Best,
> >> Anand
> >>
> >> ________________________________________
> >> From: Glasser, Matthew <glass...@wustl.edu>
> >> Sent: Tuesday, August 1, 2017 11:07:53 AM
> >> To: Anand Joshi; hcp-users@humanconnectome.org
> >> Subject: Re: [HCP-Users] Reading Human Connectome Project (HCP)
> >> *.dtseries.* file in Python
> >>
> >> For the volume structures these are in the CIFTI header, however for the
> >> surfaces there are no veridical xyz coordinates, it all depends on the
> >> surface model you are using.  In general we recommend only using 3D
> >> coordinates of individual subject¹s midthickness surfaces (or in special
> >> circumstances white or pial surface.
> >>
> >> Peace,
> >>
> >> Matt.
> >>
> >> On 7/31/17, 9:07 PM, "hcp-users-boun...@humanconnectome.org on behalf
> of
> >> Anand Joshi" <hcp-users-boun...@humanconnectome.org on behalf of
> >> ajo...@ee.usc.edu> wrote:
> >>
> >>> I am trying to read .dtseries. grayordinate files from the human
> >>> connectome project. I am using nilearn.image which is based on
> >>> nibabel.
> >>>
> >>> f=image.load_img(filename)
> >>>
> >>> Now I want .pos filed from this file. I can get it in Matlab using:
> >>>
> >>> v=ft_cifti_read(filename) v.pos
> >>>
> >>> But nibabel does not create this field. How do I access it?
> >>>
> >>> Specifically, I want xyz coordinates of each of the grayordinates, How
> >>> do I get those in python?
> >>>
> >>> Thanks,
> >>> Anand
> >>> _______________________________________________
> >>> HCP-Users mailing list
> >>> HCP-Users@humanconnectome.org
> >>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.
> humanconnectome
> >>> .org_mailman_listinfo_hcp-2Dusers&d=DwIFAw&c=
> clK7kQUTWtAVEOVIgvi0NU5BOUHh
> >>> pN0H8p7CSfnc_gI&r=NnawZtcp5Dc-cUxKIrTjKclBU0ay65KOACBdeM_
> HeW8&m=MlW84e0R9
> >>> HVTEuuqVRxLJFr3bpV8Vw_w61iEFP1hyjU&s=OnOaVBPwuVkIqJcjm_5ZXzm-
> m5P80IJ1jonj
> >>> hayfqAs&e=
> >>
> >
> >
> > _______________________________________________
> > HCP-Users mailing list
> > HCP-Users@humanconnectome.org
> > http://lists.humanconnectome.org/mailman/listinfo/hcp-users
>
>
> _______________________________________________
> HCP-Users mailing list
> HCP-Users@humanconnectome.org
> http://lists.humanconnectome.org/mailman/listinfo/hcp-users
>

_______________________________________________
HCP-Users mailing list
HCP-Users@humanconnectome.org
http://lists.humanconnectome.org/mailman/listinfo/hcp-users

Reply via email to