Loading GIFTI to MATLAB with HCP command

247 views
Skip to first unread message

mason wells

unread,
Sep 22, 2022, 11:35:39 AM9/22/22
to HCP-Users
Hi Experts,

I am using the HCP command gifti=(filename) to load BOLD data projected to the fsaverage surface into MATLAB. However, the command is taking almost 17 minutes to run when using 2021b and close to an hour with 2018b. Has anyone else ran into this issue, or is there any suggestions for speeding this up?

Any tips would be great.
Best,
Mason

Glasser, Matt

unread,
Sep 22, 2022, 11:38:03 AM9/22/22
to hcp-...@humanconnectome.org

GIFTI is not the best format for fMRI timeseries data, particularly at high mesh resolution.  I would recommend using CIFTI, which should load a bit faster.


Matt.

--
You received this message because you are subscribed to the Google Groups "HCP-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hcp-users+...@humanconnectome.org.
To view this discussion on the web visit https://groups.google.com/a/humanconnectome.org/d/msgid/hcp-users/ac0fa0f4-6c2b-4a76-8621-19f2d2396146n%40humanconnectome.org.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

mason wells

unread,
Sep 22, 2022, 12:03:31 PM9/22/22
to HCP-Users, glas...@wustl.edu
Thanks, Matt. Unfortunately, I am working with an existing dataset and the space they are using is fsaverage in GIFTI format (the data was processed using fMRIPrep). I only need to load the data in MATLAB to perform some exploratory vertex-to-vertex correlations and so need the data in the standard vertex space. Are there any other GIFTI loading commands that HCP use that might load the data faster?

Glasser, Matt

unread,
Sep 22, 2022, 12:20:58 PM9/22/22
to hcp-...@humanconnectome.org

That’s too bad then.  My understanding is that fMRIPrep can also produce CIFTI files, but the folks who developed fMRIPrep may have been a bit more focused on volume-based analysis.  Although we produce some GIFTI native mesh timeseries, they are only an intermediate file and only are used in wb_command, which doesn’t have as much of a slowdown.  If you don’t like the speed of the GIFTI toolbox, you can complain to its developer or improve it yourself. 

Patterson, Dianne K - (dkp)

unread,
Sep 22, 2022, 12:41:12 PM9/22/22
to hcp-...@humanconnectome.org
fMRIprep can definitely produce CIFTI files and can do so in both standard and native spaces.
I am surprised that it is possible to get just the GIFTI files. Here's what I get from fMRIprep.  Note that the fMRI data is in standard space by default, unless you ask for native space to be provided as well (which I have here):

├── anat
│   ├── sub-219_ses-itbs_desc-aparcaseg_dseg.nii.gz
│   ├── sub-219_ses-itbs_desc-aseg_dseg.nii.gz
│   ├── sub-219_ses-itbs_desc-brain_mask.json
│   ├── sub-219_ses-itbs_desc-brain_mask.nii.gz
│   ├── sub-219_ses-itbs_desc-preproc_T1w.json
│   ├── sub-219_ses-itbs_desc-preproc_T1w.nii.gz
│   ├── sub-219_ses-itbs_dseg.nii.gz
│   ├── sub-219_ses-itbs_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5
│   ├── sub-219_ses-itbs_from-MNI152NLin6Asym_to-T1w_mode-image_xfm.h5
│   ├── sub-219_ses-itbs_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5
│   ├── sub-219_ses-itbs_from-T1w_to-MNI152NLin6Asym_mode-image_xfm.h5
│   ├── sub-219_ses-itbs_from-T1w_to-fsnative_mode-image_xfm.txt
│   ├── sub-219_ses-itbs_from-fsnative_to-T1w_mode-image_xfm.txt
│   ├── sub-219_ses-itbs_hemi-L_inflated.surf.gii
│   ├── sub-219_ses-itbs_hemi-L_midthickness.surf.gii
│   ├── sub-219_ses-itbs_hemi-L_pial.surf.gii
│   ├── sub-219_ses-itbs_hemi-L_smoothwm.surf.gii
│   ├── sub-219_ses-itbs_hemi-R_inflated.surf.gii
│   ├── sub-219_ses-itbs_hemi-R_midthickness.surf.gii
│   ├── sub-219_ses-itbs_hemi-R_pial.surf.gii
│   ├── sub-219_ses-itbs_hemi-R_smoothwm.surf.gii
│   ├── sub-219_ses-itbs_label-CSF_probseg.nii.gz
│   ├── sub-219_ses-itbs_label-GM_probseg.nii.gz
│   └── sub-219_ses-itbs_label-WM_probseg.nii.gz
└── func
    ├── sub-219_ses-itbs_task-rest_run-1_AROMAnoiseICs.csv
    ├── sub-219_ses-itbs_task-rest_run-1_desc-MELODIC_mixing.tsv
    ├── sub-219_ses-itbs_task-rest_run-1_desc-confounds_timeseries.json
    ├── sub-219_ses-itbs_task-rest_run-1_desc-confounds_timeseries.tsv
    ├── sub-219_ses-itbs_task-rest_run-1_from-T1w_to-scanner_mode-image_xfm.txt
    ├── sub-219_ses-itbs_task-rest_run-1_from-scanner_to-T1w_mode-image_xfm.txt
    ├── sub-219_ses-itbs_task-rest_run-1_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.json
    ├── sub-219_ses-itbs_task-rest_run-1_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii.gz
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsLR_den-91k_bold.dtseries.json
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsLR_den-91k_bold.dtseries.nii
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsLR_den-91k_bold.json
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsaverage_hemi-L_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsaverage_hemi-L_bold.json
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsaverage_hemi-R_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsaverage_hemi-R_bold.json
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsnative_hemi-L_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsnative_hemi-L_bold.json
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsnative_hemi-R_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-1_space-fsnative_hemi-R_bold.json
    ├── sub-219_ses-itbs_task-rest_run-2_AROMAnoiseICs.csv
    ├── sub-219_ses-itbs_task-rest_run-2_desc-MELODIC_mixing.tsv
    ├── sub-219_ses-itbs_task-rest_run-2_desc-confounds_timeseries.json
    ├── sub-219_ses-itbs_task-rest_run-2_desc-confounds_timeseries.tsv
    ├── sub-219_ses-itbs_task-rest_run-2_from-T1w_to-scanner_mode-image_xfm.txt
    ├── sub-219_ses-itbs_task-rest_run-2_from-scanner_to-T1w_mode-image_xfm.txt
    ├── sub-219_ses-itbs_task-rest_run-2_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.json
    ├── sub-219_ses-itbs_task-rest_run-2_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii.gz
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsLR_den-91k_bold.dtseries.json
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsLR_den-91k_bold.dtseries.nii
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsLR_den-91k_bold.json
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsaverage_hemi-L_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsaverage_hemi-L_bold.json
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsaverage_hemi-R_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsaverage_hemi-R_bold.json
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsnative_hemi-L_bold.func.gii
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsnative_hemi-L_bold.json
    ├── sub-219_ses-itbs_task-rest_run-2_space-fsnative_hemi-R_bold.func.gii
    └── sub-219_ses-itbs_task-rest_run-2_space-fsnative_hemi-R_bold.json

Dianne Patterson, Ph.D
RII Neuroimaging Staff Scientist
Program Coordinator: Neuroimaging Methods Certificate 
Cognitive Science GIDP affiliate faculty member
Office: Speech, Language and Hearing Sciences, Room 314

From: Glasser, Matt <glas...@wustl.edu>
Sent: Thursday, September 22, 2022 9:20 AM
To: hcp-...@humanconnectome.org <hcp-...@humanconnectome.org>
Subject: [EXT]Re: [hcp-users] Loading GIFTI to MATLAB with HCP command
 

External Email

mason wells

unread,
Sep 22, 2022, 12:52:40 PM9/22/22
to HCP-Users, Patterson, Dianne K - (dkp)
Hi Dianne,

Thanks for the reply. The issue isn't with fMRIPrep, I have other datasets that I have output in bunch of other spaces, including CIFTI. My issue is that with this one particularly dataset I only have the processed outputs and these do not included CIFTI, only fsaverage GIFTI. If I was processing the data myself, you're correct, I would certainly output in CIFTI space. 

Cheers,
Mason

Coalson, Timothy Scott (S&T-Student)

unread,
Sep 22, 2022, 3:30:58 PM9/22/22
to HCP-Users
Have you compiled the mex file for zstream in the gifti toolbox?  It should be faster than the java that it uses when the mex isn't compiled, though I don't know how much faster overall.

As an alternative, you could use one of the wb_command -cifti-create commands to make a cifti file from them, so that you don't have to read from gifti every time you want to use them.

Tim


From: mason wells <mason...@hotmail.co.uk>
Sent: Thursday, September 22, 2022 11:52 AM
To: HCP-Users <hcp-...@humanconnectome.org>
Cc: Patterson, Dianne K - (dkp) <d...@arizona.edu>

Subject: Re: [hcp-users] Loading GIFTI to MATLAB with HCP command
 
WARNING: This message has originated from an External Source. This may be a phishing expedition that can result in unauthorized access to our IT System. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

江亚

unread,
Jan 19, 2026, 9:02:01 PM (yesterday) Jan 19
to HCP-Users, mason wells
I encountered a similar issue as yours, and my solution was to use the built-in gifti toolkit in SPM, rather than other versions.

Glasser, Matthew

unread,
Jan 19, 2026, 9:17:51 PM (yesterday) Jan 19
to hcp-...@humanconnectome.org, mason wells

I wouldn’t recommend putting fMRI data on a 164k mesh.  That is massively oversampling the data.  I would use the CIFTI dense timeseries that we create, which sample the data at their acquisition resolution.


Matt.

--

You received this message because you are subscribed to the Google Groups "HCP-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hcp-users+...@humanconnectome.org.

Reply all
Reply to author
Forward
0 new messages