Some Zero Standard Deviation Vertices when Metric Resampled to fsaverage4 on rsfMRI data

263 views
Skip to first unread message

Sovesh Mohapatra

unread,
Oct 13, 2023, 6:19:07 PM10/13/23
to HCP-Users
When I resampled and made the new dtseries. There are some vertices which has 0 standard deviation for which I want to create a filtered one which can be further used to find structural functional connectivity. 

Can you suggest how can I change the header file for the new filtered one?

Best 
Sovesh

Tim Coalson

unread,
Oct 13, 2023, 6:52:00 PM10/13/23
to hcp-...@humanconnectome.org
Did you resample the cortical gray matter masks in global/templates/91282_Greyordinates/ and specify them to -cifti-create-dense-timeries as -roi-left and -roi-right?  If not, you have included the medial wall, where there is no data in the original files (because it is a part of the surface that cuts through white matter fairly arbitrarily, and thus is not interesting when studying gray matter).

fsaverage does not have vertex correspondence between left and right hemisphere (click in the central sulcus on one hemisphere, and you might get something in the temporal lobe as your "contralateral" vertex in wb_view, because fsaverage doesn't match up the left/right vertex numbers).

Why do you need a ~3k mesh?  Have you considered using parcellation for your dimensionality reduction instead, such as our MMP 1.0?  It is fairly easy to make an additional fs_LR-family set of spheres at whatever resolution you want (there are a dozen choices in between fsaverage4 (2.5k) and fsaverage5 (10k)), if you are sure parcellation isn't what you want, with the additional advantage of gaining left/right vertex correspondence again.

Tim


--
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/07ae89b6-3f48-41a3-b5eb-77459c83e443n%40humanconnectome.org.
Message has been deleted

Sovesh Mohapatra

unread,
Oct 13, 2023, 7:16:21 PM10/13/23
to HCP-Users, tim.c...@gmail.com
Hi 

I followed the below steps:

1. wb_command -surface-sphere-project-unproject Data/{patient_id}/{patient_id}.{hemisphere}.sphere.MSMAll.native.surf.gii standard_mesh_atlases/fsaverage.{hemisphere}_LR.spherical_std.164k_fs_LR.surf.gii standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.{hemisphere}.sphere.164k_fs_LR.surf.gii {patient_id}.{hemisphere}.sphere.fsaverage.native.surf.gii

2.  wb_command -surface-resample Data/{patient_id}/{patient_id}.{hemisphere}.midthickness.native.surf.gii {patient_id}.{hemisphere}.sphere.fsaverage.native.surf.gii standard_mesh_atlases/resample_fsaverage/fsaverage4_std_sphere.{hemisphere}.3k_fsavg_{hemisphere}.surf.gii BARYCENTRIC {patient_id}.{hemisphere}.midthickness.3k_fsavg_{hemisphere}.surf.gii

3. wb_command -cifti-separate 

4. wb_command -metric-resample standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.{hemisphere}.sphere.32k_fs_LR.surf.gii standard_mesh_atlases/resample_fsaverage/fsaverage4_std_sphere.{hemisphere}.3k_fsavg_{hemisphere}.surf.gii ADAP_BARY_AREA {hemisphere}_hemisphere_fsaverage4_{patient_id}_{rest_key}.func.gii -area-surfs {patient_id}.{hemisphere}.midthickness_MSMAll.32k_fs_LR.surf.gii {patient_id}.{hemisphere}.midthickness.3k_fsavg_{hemisphere}.surf.gii

5. wb_command -cifti-create-dense-timeseries left_file -left-metric right_file right_metric_file


This is how I resampled the data into fsaverage4. Now when I checked for zero standard deviation vertices, there 323 and non-zero 4801. So I wanted filter non-zero and then calculate functional connectivity. 

Best 
Sovesh

Sovesh Mohapatra

unread,
Oct 13, 2023, 7:36:15 PM10/13/23
to HCP-Users, Sovesh Mohapatra, tim.c...@gmail.com
Shall I use these files to resample using BARYCENTRIC:

R.atlasroi.32k_fs_LR.shape.gii
L.atlasroi.32k_fs_LR.shape.gii

with the help of 

fsaverage4.L.midthickness_va_avg.3k_fsavg_L.shape.gii
fsaverage4.R.midthickness_va_avg.3k_fsavg_R.shape.gii

Tim Coalson

unread,
Oct 13, 2023, 7:41:08 PM10/13/23
to Sovesh Mohapatra, HCP-Users
If all you want is a dimensionality reduction of our data, we generally recommend -cifti-parcellate with our MMP 1.0 atlas, which will get you 180 areas per hemisphere (using distinct area boundaries to substantially reduce cross-area mixing when compared to a downsampling like you are doing) and the main subcortical gray matter structures in a single command, wb_command -cifti-parcellate, using this file:


If you don't need to reduce the dimensionality, we would suggest using fsaverage6 at 41k, as being a reasonably close match to our 32k fMRI-resolution surfaces.

To clarify, with the downsampling approach, it is expected that there will be zeros in the medial wall when the data is in metric (.func.gii) format.  cifti format allows excluding the medial wall (and therefore the zeros that would be inside it), but you need to provide masks to the -cifti-create-dense-timeseries command in order for it to do that (with -roi-left and -roi-right, in the proper places).  I would create these masks this by -metric-resampling the 32k masks from our pipelines:


And then using -metric-math to threshold those outputs at 0.5.

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 7:44:54 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra
Yes I want to create the masks. I don't want dimensionality reduction.
Shall I use these files to resample using BARYCENTRIC:

R.atlasroi.32k_fs_LR.shape.gii
L.atlasroi.32k_fs_LR.shape.gii

with the help of 

fsaverage4.L.midthickness_va_avg.3k_fsavg_L.shape.gii
fsaverage4.R.midthickness_va_avg.3k_fsavg_R.shape.gii. and then use -metric-math?

Tim Coalson

unread,
Oct 13, 2023, 7:54:09 PM10/13/23
to Sovesh Mohapatra, HCP-Users
fsaverage4 is a large dimensionality reduction of our data, about 10x.  If you don't want that, you should use fsaverage6, if you specifically need it in an fsaverage space.

Ideally, you would use -current-roi in the -metric-resample command to avoid interpolating the medial wall zeros into the edge of the valid data.  There is a -valid-roi-out option that will then tell you what vertices have values, but it will be slightly dilated compared to the original mask.  You could also resample those atlasroi metric files without -current-roi and threshold at 0.5 in order to get something closer to the original ROI.

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 7:58:18 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra

Hi again, 

I am so sorry first of all for asking so many rudimentary question. 

So, 

This would be my final command right? 

wb_command -metric-resampling L.atlasroi.32k_fs_LR.shape.gii fsaverage6.L.midthickness_va_avg.41k_fsavg_L.shape.gii BARYCENTRIC metric-out fs_trial.L.shape.gii

Tim Coalson

unread,
Oct 13, 2023, 9:12:56 PM10/13/23
to Sovesh Mohapatra, HCP-Users
If you want to use fsaverage6, you should go back to step 2 and use fsaverage6 instead of fsaverage4.  What do you plan to do with it once it is on an fsaverage mesh?

When you get to -metric-resample, add "-current-roi L.atlasroi.32k_fs_LR.shape.gii -valid-roi-out L.validout.fs_L6.shape.gii" to the command (with paths to those files as needed).  You can then use "-roi-left L.validout.fs_L6.shape.gii" in the -cifti-create-dense-timeseries command (and similar for the right hemisphere), it shouldn't have zeros in the result.  If you want to be more accurate about where the medial wall should end, you can additionally do -metric-resample with L.atlasroi.32k_fs_LR.shape.gii as the input, without -current-roi or -valid-roi-out, but otherwise the same inputs, and threshold the output at 0.5.

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 9:26:34 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra
Hi 

I am trying to do parcellation in another Deep Learning way. Also where can I locate this L/R.validout.fs_L6.shape.gii? Because I could not find

Tim Coalson

unread,
Oct 13, 2023, 9:49:12 PM10/13/23
to Sovesh Mohapatra, HCP-Users
Sorry, I didn't phrase that well - the L.validout.fs_L6.shape.gii file doesn't exist yet, it will be written by the command.  Add a path or change the name based on where you want it written to.

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 9:51:50 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra
Little bit off topic but how would you calculate voxel wise structural functional connectivity if I want to directly do it on 32k mesh. Any suggestion? Because it will be a 32kX32k for one hemisphere. 

Tim Coalson

unread,
Oct 13, 2023, 10:04:06 PM10/13/23
to Sovesh Mohapatra, HCP-Users
Look at wb_command -cifti-correlation and -cifti-correlation-gradient.  If you just want to click around, you can also load the dtseries and inflated surfaces into wb_view, turn on dynamic connectivity, and it will do the correlation on the fly when you click on a vertex/voxel.

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 10:09:32 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra
I meant like doing Calculating Pearson and Spearman correlations.

Tim Coalson

unread,
Oct 13, 2023, 10:15:53 PM10/13/23
to Sovesh Mohapatra, HCP-Users
All of those methods use Pearson correlation, with an optional fisher small-z transform for at least the wb_command options.  We don't have Spearman implemented.

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 10:18:11 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra
Is there way to store that data in array format like npy ?

Tim Coalson

unread,
Oct 13, 2023, 10:21:17 PM10/13/23
to Sovesh Mohapatra, HCP-Users
nibabel can read any cifti file into python (the original dtseries, or the 91k x 91k dconn from -cifti-correlation, or the dscalar from -cifti-correlation-gradient).

Tim

Sovesh Mohapatra

unread,
Oct 13, 2023, 10:25:20 PM10/13/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Sovesh Mohapatra
Yes. Thats a great idea. 

Thanks a lot. You have been really helping me a lot with these data structuring. Again, I am really sorry if I keep asking rudimentary questions. 

Best
Sovesh

Lin Chen

unread,
Nov 10, 2023, 10:21:46 AM11/10/23
to HCP-Users, tim.c...@gmail.com
Hi all

Hope it's ok to ask a follow-up question on this topic... If you do want resample (downsample) the 91k .dtseries (for computational reasons) would you recommend to use the steps described in this thread with creating a specific fsaverage.surf template, and then use that for the cifti down sampling? Or is possible to somehow downsample global/templates/91282_Greyordinates.dscalar.nii and use that as a resampling template (to be used in wb_command -cifti-resample)?

Best
Lin

Tim Coalson

unread,
Nov 10, 2023, 11:18:21 AM11/10/23
to Lin Chen, HCP-Users
If you need a dimensionality reduction from 91k, we recommend parcellating to the 360 HCP MMP 1.0 cortical areas (and the various subcortical structures), because it avoids creating further "some of this area plus some of that area" data samples.  If 32k per hemisphere is just barely intractable, you can make an additional fs_LR variant at a lower resolution, starting with wb_command -surface-create-sphere:


Tim

Lin Chen

unread,
Nov 10, 2023, 2:45:26 PM11/10/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Lin Chen
Hi,

Thank you! I don't really understand though how to proceed from these two spheres? Ie how do I use them to create the actual resampling template?

Lin

Tim Coalson

unread,
Nov 10, 2023, 6:51:32 PM11/10/23
to Lin Chen, HCP-Users
You treat the two new spheres as the right and left standard spheres of a new fs_LR resolution, inherently in register with the other fs_LR standard spheres.  You can feed them directly as the new-sphere arguments of -cifti-resample...except, first you need to make a new cifti file using this resolution to use as the template, for which you need the cortical ROIs that mask out the medial wall.  You can make those by resampling the existing atlasroi .shape.gii files in global/templates/standard_mesh_atlases to the new resolution with barycentric and threshold them at 0.5 with -metric-math.

If you need to go below 4k per hemisphere, I would suggest you try the parcellation method first, as it is easily tractable and yet doesn't add interpolation across areas.

Tim

Lin Chen

unread,
Nov 11, 2023, 5:02:06 AM11/11/23
to Tim Coalson, HCP-Users
Thanks.

I have to say I haven't really understood what is included in this medial wall - does that only include eg corpus callosum or also eg cuneus, precuneues etc?

Lin

Tim Coalson

unread,
Nov 11, 2023, 10:15:17 AM11/11/23
to Lin Chen, HCP-Users
The medial wall is the part of the surface file that does not represent cortex.  So, we mask out the data inside it as it is invalid for cortical analysis.  Cifti handles the noncortical gray matter structures with voxels, if you need them.

Tim

Lin Chen

unread,
Nov 11, 2023, 10:37:27 AM11/11/23
to HCP-Users, tim.c...@gmail.com, HCP-Users, Lin Chen
Ok I just wanted to make sure!

I have to say I don''t really understand how to do this medial wall masking/ creating the cifti template?

I can't just use standard_mesh_atlas/resample/fsaverage6_std_sphere.L.10k_fsaverage_L.surf.gii as a template and resample the .dtseries using this one?

Thanks
Lin

Tim Coalson

unread,
Nov 11, 2023, 11:33:26 AM11/11/23
to Lin Chen, HCP-Users
wb_command -cifti-create-dense-scalar has options for right and left ROIs, which is where you put the medial wall masks.  The data doesn't matter when creating the template file, so those can also be the masks.

Fsaverage variants don't have vertex correspondence between right and left hemispheres.  You could use them, but since we don't make cifti files with that, you'll still need to handle the medial wall yourself.  You don't technically need to mask it out, but if you don't, you get the original question's problem of having vertices that contain only zeros.

I'm curious what operation you are doing that is feasible on 10k surfaces (fsaverage5) but not the original 32k.

Tim
Reply all
Reply to author
Forward
0 new messages