Thank you Demian and Matt for your fast responses.
I will try these suggestions.
Thank you again!
best,
Anand

________________________________________
From: Demian Wassermann <demian.wasserm...@inria.fr>
Sent: Tuesday, August 1, 2017 12:08:26 PM
To: Glasser, Matthew
Cc: Anand A Joshi; Anand Joshi; hcp-users@humanconnectome.org
Subject: Re: [HCP-Users] Reading Human Connectome Project (HCP) *.dtseries.* 
file in Python

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
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.humanconnectome.org_mailman_listinfo_hcp-2Dusers&d=DwIFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=AxNlWlS5mlAxVU9t_tvUnw&m=STk8Nhutdy9dWh6cWS7f_cvRfOCAr2sauRnLBOKOmp0&s=KAUtckT8GzBPSj3euMksGAckMp2YgJZ87VISIEO5ufU&e=


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

Reply via email to