Re: A question about resampling dscalar files

269 views
Skip to first unread message

Coalson, Timothy Scott (S&T-Student)

unread,
May 12, 2021, 4:08:06 PM5/12/21
to hanhan, hcp-...@humanconnectome.org
1) exact zeros in the original map next to nonzero values will not remain 0 in the resampled version - however, due to the extent of colors in the resampled versions, I think the first image was masked by something to remove regions that aren't clearly responding to visual input.
2) -surface-largest is not intended for continuous data, and can result in a more "speckled" look, though polar angle maps can have an extreme jump which other methods would "smooth"
3) is the third image the original 32k version?  I'm guessing it has "display zeros" turned off, resulting in those scattered gray spots, but since you say you used -surface-largest, that should have carried over to the resampled version, which doesn't have these spots, suggesting you had display zeros on for that one?

When we resampled retinotopy maps, one method we used was to convert the polar angle and eccentricity into an x-y coordinate system, to get rid of the discontinuity at 360 degrees (and because simple interpolation in polar coordinates gives wrong answers because of eccentricity, consider the average of 5 degrees left and 5 degrees right - the correct answer is 0 degrees center, but averaging the polar coordinates will say something else, such as 5 degrees down).  Once that is done, you can resample the x and y maps with interpolation, and then convert back to polar representation.  I don't remember if there are real hard edged changes in the biology, but if there are, those will get a small interpolation fringe, but it should still make more sense this way than the same fringe from interpolating polar coordinates.

Tim


From: hanhan <31201...@bit.edu.cn>
Sent: Wednesday, May 12, 2021 11:44 AM
To: Coalson, Timothy Scott (S&T-Student) <tsc...@mst.edu>; coal...@wustl.edu <coal...@wustl.edu>; hcp-...@humanconnectome.org <hcp-...@humanconnectome.org>
Subject: A question about resampling dscalar files
 

Hi Dr. Tim,

 

I have a brief question about resampling dscalar.nii files from 32k fs_LR to 59k fs_LR surface. Because I can compare the  cerebral cortex parcellation results of my 7T rs-fMRI data which were processed on the 59k mesh with the results of HCP's retinotopy analysis (Benson et al.2018) on the same 59k fs_LR surface after resampling.  I also have tried to downsample the parcellation results of mine(func.gii) to 32k mesh, but this will result in lower accuracy and adjacent parcels will become closer and more crowded.
 

I used two methods to perform resampling. One is wb_command -cifti-resample, and the other one is wb_command -cifti-separate and -metric-resample. As the following figures show, the polar angle maps obtained by these two methods are almost the same(Fig. 2&Fig. 3), but they are quite different from the original 32k polar angle maps(Fig. 1). Many gray areas in the original result are colored in the resampled result. 

 

wb_command orders:

1.

wb_command -cifti-resample S1200_7T_Retinotopy181.Fit1_PolarangleMirror_MSMAll.32k_fs_LR.dscalar.nii COLUMN 170494_Greyordinates.dscalar.nii COLUMN ADAP_BARY_AREA CUBIC <cifti-out >  -surface-largest -left-spheres L.sphere.32k_fs_LR.surf.gii L.sphere.59k_fs_LR.surf.gii -left-area-surfs Conte69.L.midthickness.32k_fs_LR.surf.gii Conte69.L.midthickness.59k_fs_LR.surf.gii -right-spheres R.sphere.32k_fs_LR.surf.gii R.sphere.59k_fs_LR.surf.gii -right-area-surfs Conte69.R.midthickness.32k_fs_LR.surf.gii Conte69.R.midthickness.59k_fs_LR.surf.gii

2. 

wb_command -cifti-separate S1200_7T_Retinotopy181.Fit1_PolarangleMirror_MSMAll.32k_fs_LR.dscalar.nii COLUMN -metric CORTEX_LEFT <metric-out>

wb_command -metric-resample

(I'm sure the usage of -cifti-separate and -metric-resample is correct)

 

Question 

1. What's wrong with my wb_command orders? How could I resample the dscalar.nii files from 32k to 59k correctly? Actually, I only wanna resample the surface data of the CIFTI files.

 

Any help would be appreciated:)

Thank you for your time and best wishes!

 

Han


hanhan

unread,
May 12, 2021, 5:17:11 PM5/12/21
to Coalson, Timothy Scott (S, coal...@wustl.edu, hcp-...@humanconnectome.org

Coalson, Timothy Scott (S&T-Student)

unread,
May 14, 2021, 12:02:36 AM5/14/21
to hanhan, hcp-...@humanconnectome.org

You will need both the angle and eccentricity maps to do the x-y resampling trick.  Most software uses radians for trig functions (including wb_command -cifti-math or -metric-math, which can do the needed conversion), so assuming the angle map is in degrees:

for x, "eccentricity * cos(angle * PI / 180)"
for y, "eccentricity * sin(angle * PI / 180)"

resample x and y maps

then back to polar:
for angle, "atan2(y, x) * 180 / PI"
for eccentricity, "sqrt(x^2 + y^2)"

Tim


From: hanhan <31201...@bit.edu.cn>
Sent: Thursday, May 13, 2021 10:06 PM
To: Coalson, Timothy Scott (S&T-Student) <tsc...@mst.edu>; hcp-...@humanconnectome.org <hcp-...@humanconnectome.org>
Subject: Re:Re: A question about resampling dscalar files
 
Hi, Dr. Tim,
Thanks for your professional solutions.

1) What I was confused about before was many of the gray areas in the original 32k polar angle map (Fig. 1, the first image) are colored in the resampled version( Fig. 2&Fig. 3).  I double-checked it after receiving your email and found that the original one does have a mask. The original version is thresholded at 9.8% variance explained.

2)
  The second image(Fig. 2) is the "-cifti-resample" version (from 32k to 59k).  If I don't use -surface-largest,  the result will have distinct boundaries(Fig. 4).

3)The third image is the "-cifti-separate" one(Fig. 3) and I did turn "display zeros" off. Because if I turn it on, the medial wall areas will be colored even though the scattered gray spots will disappear.

I'm excited to learn that you have a better method to resample retinotopy maps. But I'm sorry that I'm not following. I have no idea about converting polar angle files which are in CIFTI(dscalar.nii) format into an X-Y coordinate system CIFTI files. Should I use Connectome Workbench or MATLAB? Do you mind providing more details?

Thanks for your time and best wishes.
Han

      
----------------
 


---------- Origin message ----------
>From:"Coalson, Timothy Scott (S&T-Student)" <tsc...@mst.edu>
>To:"hanhan" <31201...@bit.edu.cn>, "hcp-...@humanconnectome.org" <hcp-...@humanconnectome.org>
>Subject:Re: A question about resampling dscalar files
>Date:2021-05-13 04:08:00
1) exact zeros in the original map next to nonzero values will not remain 0 in the resampled version - however, due to the extent of colors in the resampled versions, I think the first image was masked by something to remove regions that aren't clearly responding to visual input.
2) -surface-largest is not intended for continuous data, and can result in a more "speckled" look, though polar angle maps can have an extreme jump which other methods would "smooth"
3) is the third image the original 32k version? I'm guessing it has "display zeros" turned off, resulting in those scattered gray spots, but since you say you used -surface-largest, that should have carried over to the resampled version, which doesn't have these spots, suggesting you had display zeros on for that one?

When we resampled retinotopy maps, one method we used was to convert the polar angle and eccentricity into an x-y coordinate system, to get rid of the discontinuity at 360 degrees (and because simple interpolation in polar coordinates gives wrong answers because of eccentricity, consider the average of 5 degrees left and 5 degrees right - the correct answer is 0 degrees center, but averaging the polar coordinates will say something else, such as 5 degrees down). Once that is done, you can resample the x and y maps with interpolation, and then convert back to polar representation. I don't remember if there are real hard edged changes in the biology, but if there are, those will get a small interpolation fringe, but it should still make more sense this way than the same fringe from interpolating polar coordinates.

Tim

________________________________
From: hanhan <31201...@bit.edu.cn>
Sent: Wednesday, May 12, 2021 11:44 AM
To: Coalson, Timothy Scott (S&T-Student) <tsc...@mst.edu>; coal...@wustl.edu <coal...@wustl.edu>; hcp-...@humanconnectome.org <hcp-...@humanconnectome.org>
Subject: A question about resampling dscalar files


[cid:8d430ba91ad7d7eaaede98e87da129d8][cid:445d1fb73055c227aac09d21c65c5e56][cid:4523ddac6a55e28830acca79d859999a]
 

hanhan

unread,
May 14, 2021, 12:18:45 PM5/14/21
to Coalson, Timothy Scott (S&T-Student), hcp-...@humanconnectome.org
Thank you very very much, Dr. Tim. It's so kind of you to help me out.

Han



----------------
 


---------- Origin message ----------
>From:"Coalson, Timothy Scott (S&T-Student)" <tsc...@mst.edu>
>To:"hanhan" <31201...@bit.edu.cn>, "hcp-...@humanconnectome.org" <hcp-...@humanconnectome.org>
>Subject:Re: Re:Re: A question about resampling dscalar files
>Date:2021-05-14 12:02:30
https://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordinates

You will need both the angle and eccentricity maps to do the x-y resampling trick. Most software uses radians for trig functions (including wb_command -cifti-math or -metric-math, which can do the needed conversion), so assuming the angle map is in degrees:

for x, "eccentricity * cos(angle * PI / 180)"
for y, "eccentricity * sin(angle * PI / 180)"

resample x and y maps

then back to polar:
for angle, "atan2(y, x) * 180 / PI"
for eccentricity, "sqrt(x^2 + y^2)"

Tim

________________________________
From: hanhan <31201...@bit.edu.cn>
Sent: Thursday, May 13, 2021 10:06 PM
To: Coalson, Timothy Scott (S&T-Student) <tsc...@mst.edu>; hcp-...@humanconnectome.org <hcp-...@humanconnectome.org>
Subject: Re:Re: A question about resampling dscalar files

Hi, Dr. Tim,
Thanks for your professional solutions.

1) What I was confused about before was many of the gray areas in the original 32k polar angle map (Fig. 1, the first image) are colored in the resampled version( Fig. 2&Fig. 3). I double-checked it after receiving your email and found that the original one does have a mask. The original version is thresholded at 9.8% variance explained.

2) The second image(Fig. 2) is the "-cifti-resample" version (from 32k to 59k). If I don't use -surface-largest, the result will have distinct boundaries(Fig. 4).

3)The third image is the "-cifti-separate" one(Fig. 3) and I did turn "display zeros" off. Because if I turn it on, the medial wall areas will be colored even though the scattered gray spots will disappear.

I'm excited to learn that you have a better method to resample retinotopy maps. But I'm sorry that I'm not following. I have no idea about converting polar angle files which are in CIFTI(dscalar.nii) format into an X-Y coordinate system CIFTI files. Should I use Connectome Workbench or MATLAB? Do you mind providing more details?

Thanks for your time and best wishes.
Han

[cid:9613827c8c845d58e085c526f02117d1][cid:6cb5dce6161f09d9d5c8331437580225][cid:694134ff56eca346356d9cff5df75424] [cid:8afca29708a9cd3f7302d317ba5724c4]

hanhan

unread,
May 14, 2021, 12:18:45 PM5/14/21
to Coalson, Timothy Scott (S&T-Student), hcp-...@humanconnectome.org
Hi, Dr. Tim,
Thanks for your professional solutions.

1) What I was confused about before was many of the gray areas in the original 32k polar angle map (Fig. 1, the first image) are colored in the resampled version( Fig. 2&Fig. 3).  I double-checked it after receiving your email and found that the original one does have a mask. The original version is thresholded at 9.8% variance explained.

2)
  The second image(Fig. 2) is the "-cifti-resample" version (from 32k to 59k).  If I don't use -surface-largest,  the result will have distinct boundaries(Fig. 4).

3)The third image is the "-cifti-separate" one(Fig. 3) and I did turn "display zeros" off. Because if I turn it on, the medial wall areas will be colored even though the scattered gray spots will disappear.

I'm excited to learn that you have a better method to resample retinotopy maps. But I'm sorry that I'm not following. I have no idea about converting polar angle files which are in CIFTI(dscalar.nii) format into an X-Y coordinate system CIFTI files. Should I use Connectome Workbench or MATLAB? Do you mind providing more details?

Thanks for your time and best wishes.
Han

      

Eun Young Choi

unread,
Apr 6, 2024, 8:01:05 PM4/6/24
to HCP-Users, Coalson, Timothy Scott (S&T-Student)
Hi Tim,

I'd like to resample the volumetric voxels, as well as the surface, of a .dscalar file from 32k to 59k. I followed the guidance below and was able to see a correct resampling of the surface vertices in the Surface tab of  Connectome Workbench, but nothing at all for the voxels in the Volume Tab. In fact, the 59k resampled file doesn't even show up in the drop down menu of volume files to select from (as opposed to in the Surface tab, where I can see the 59k resampled file in the drop down menu).

Here's the syntax I used, which specifies the surface templates, but no specifications for volume other than to use CUBIC resampling  method. Should I include a volume-related flag (I'm unclear which one to use)?

wb_command -cifti-resample input_32k.dscalar.nii COLUMN S1200_MSMAll7T175.MyelinMap_BC_1.6mm_MSMAll.59k_fs_LR.dscalar.nii COLUMN ADAP_BARY_AREA CUBIC output_59k.dscalar.nii -left-spheres /usr/local/HCPpipelines-4.3.0/global/templates/standard_mesh_atlases/L.sphere.32k_fs_LR.surf.gii /usr/local/HCPpipelines-4.3.0/global/templates/standard_mesh_atlases/L.sphere.59k_fs_LR.surf.gii -left-area-surfs S1200_MSMAll7T175.L.midthickness_MSMAll.32k_fs_LR.surf.gii S1200_MSMAll7T175.L.midthickness_1.6mm_MSMAll.59k_fs_LR.surf.gii -right-spheres /usr/local/HCPpipelines-4.3.0/global/templates/standard_mesh_atlases/R.sphere.32k_fs_LR.surf.gii /usr/local/HCPpipelines-4.3.0/global/templates/standard_mesh_atlases/R.sphere.59k_fs_LR.surf.gii -right-area-surfs S1200_MSMAll7T175.R.midthickness_MSMAll.32k_fs_LR.surf.gii S1200_MSMAll7T175.R.midthickness_1.6mm_MSMAll.59k_fs_LR.surf.gii

Thanks!
EY

Glasser, Matt

unread,
Apr 6, 2024, 8:11:40 PM4/6/24
to hcp-...@humanconnectome.org, Coalson, Timothy Scott (S&T-Student)

Hi EY,

 

You need to use a CIFTI template with subcortical data (the myelin maps don’t have it).   Any of the fMRI .dscalar.nii files in the 91282 grayordinates space will do (and there are some templates in the global folder of the pipelines as well).


Matt.


Image removed by sender.Image removed by sender.Image removed by sender.

--
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/74d9f2f4-bb3e-422f-a9f5-8314cbc9b1ben%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.

Tim Coalson

unread,
Apr 9, 2024, 6:08:19 PM4/9/24
to hcp-...@humanconnectome.org, Coalson, Timothy Scott (S&T-Student)
I suggest using the 170k standard grayordinates file as the template for upsampling to 59k/1.6mm, the dscalar file in here:


Tim


Reply all
Reply to author
Forward
0 new messages