Mapping dhcp volume fmri to surface

Hi, everyone,

I’m tryng to mapping volume fmri of dhcp_release3 to surface space using function ‘surface.sample_to_native’ in dhcp-neonatal-fmri-pipeline:

from dhcp.func import surface
surface.sample_to_native(
struct_white_surf_right=f’sub-{subid}_ses-{sesid}_right_white.surf.gii’,
struct_white_surf_left=f’sub-{subid}_ses-{sesid}_left_white.surf.gii’,
struct_pial_surf_right=f’sub-{subid}_ses-{sesid}_right_pial.surf.gii’,
struct_pial_surf_left=f’sub-{subid}_ses-{sesid}_left_pial.surf.gii’,
struct_mid_surf_right=f’sub-{subid}_ses-{sesid}_right_midthickness.surf.gii’,
struct_mid_surf_left=f’sub-{subid}_ses-{sesid}_left_midthickness.surf.gii’,
medialwall_shape_left=f’sub-{subid}_ses-{sesid}_left_roi.shape.gii’,
medialwall_shape_right=f’sub-{subid}_ses-{sesid}_right_roi.shape.gii’,
struct_to_func_affine=f’sub-{subid}/ses-{sesid}/reg/func-mcdc2struct_invaffine.mat’,
func=f’sub-{subid}/ses-{sesid}/fix/func_clean.nii.gz’,
func_brainmask=f’sub-{subid}/ses-{sesid}/mcdc/func_mcdc_brainmask.nii.gz’,
struct=f’sub-{subid}/ses-{sesid}/import/T2w.nii.gz’,
workdir=f’sub-{subid}/ses-{sesid}/surface’,
struct_subcortical_mask=f’sub-{subid}/ses-{sesid}/import/T2w_scmask.nii.gz’,
do_sigloss=True
)

But I noticed that some files (func_brainmaskstruct_subcortical_mask) do not exist in the rel3_dhcp_fmri_pipeline and rel3_dhcp_anat_pipeline data. (I can use fsl to get inverse affine matrix)

I can find func_brainmask in release2, but there is a little different in transformation matrix between func_brainmask in release2 and func image in release3.

I can’t find struct_subcortical_mask anywhere

How can I get these two files? Run corresponding part in GitHub - BioMedIA/dhcp-structural-pipeline: structural analysis of neonatal brain MRI scans ? (I really need the subcortical voxel).

Thank you very much!

xiangyu Kong

Hi Xiangyu

These files are created by running earlier stages of the dHCP fMRI pipeline.

The func_brainmask should be in the release torrent, but it seems several files are missing in the torrent. I will get someone to look into the missing files. In the interim you can recreate func_brainmask with:

from tempfile import TemporaryDirectory
from dhcp.util import fslpy as fsl
from dhcp.util.io import Path

mcdc = f'derivatives/dhcp_fmri_pipeline/sub-{subid}/ses-{sesid}/func/sub-{subid}_ses-{sesid}_task-rest_desc-mcdc_bold.nii.gz'
mcdc_brainmask = 'func_brainmask.nii.gz'

with TemporaryDirectory() as tmp:
    brain = f'{tmp}/brain.nii.gz')
    mean = f'{tmp}/mean.nii.gz')

    fsl.fslmaths(mcdc).Tmean().run(mean)
    fsl.bet(
        input=mean,
        output=brain,
        mask=False,
        fracintensity=0.4,
        robust=True
    )
    fsl.fslmaths(input=brain).bin().run(output=mcdc_brainmask)

The struct_subcortical_mask is not in the torrent because we have not released surface fMRI yet. It can be created with:

from dhcp.util import mask
from dhcp.util import enums

dseg = f'derivatives/dhcp_anat_pipeline/sub-{subid}/ses-{sesid}/anat/sub-{subid}_ses-{sesid}_desc-drawem9_dseg.nii.gz'

mask.create_mask(
    dseg=dseg,
    dseg_type=enums.SegType.drawem,
    labels=['sc', 'bs', 'cb'],
    outname='T2w_scmask.nii.gz'
)

However, keep in mind that the surface mapping code you are using is still under evaluation. I think we are unlikely to use partial volume correction in the final version. I hope to have finalised our surface mapping protocol in the next week or so.

Cheers, Sean

Hi seanfitz

Thank you very much! That was exactly what I was looking for.

And I hope it’s okay to throw in a little follow-up question…

After I used these scripts to creat func_brainmask and struct_subcortical_mask, I just run surface.sample_to_native.

When it running function wb_sample in step Sample to the surface:

############
# Sample to the surface
############

for hemi in [‘left’, ‘right’]:
defaults_hemi = defaults.update(hemi=hemi)

   _wb_sample(
       func=defaults.get('pvc_gm'),
      func_gii=defaults_hemi.get('func_gii', make_dir=True),
       mid_surf=defaults_hemi.get('mid_surf', make_dir=True),
      white_surf=defaults_hemi.get('white_surf', make_dir=True),
       pial_surf=defaults_hemi.get('pial_surf', make_dir=True),
       volume_roi=defaults.get('good_voxels'),
  )

I met a new problem:

wb_command -volume-to-surface-mapping
/…/pvc_gm.nii.gz
/…/midthickness_hemi-left_mesh-native_space-func.surf.gii
/…/func_hemi-left_mesh-native.func.gii
-ribbon-constrained
/…/white_hemi-left_mesh-native_space-func.surf.gii
/…/pial_hemi-left_mesh-native_space-func.surf.gii
-voxel-subdiv 10 -volume-roi
/…/good_voxels.nii.gz

ERROR: all surfaces must have vertex correspondence

Some subjects can run surface.sample_to_native successfully(e.g sub-CC00056XX07_ses-10700), but this error will occure in some subjects(e.g sub-CC00057XX08_ses-11002)

Is this an image quality issue? or something wrong with my operation? or something wrong in partial volume correction as you mentioned?

Thank you for any suggestions!

xiangyu kong

Hi

It sounds like white, pial, and midthickness native surfaces do not have the same number of vertices… These native surfaces are created by the structural pipeline and should have vertex correspondence.

Can you check this by running wb_command -surface-information on each of the surfaces and reporting the results? Can you also advise if this is release 02 or 03 data?

Cheers, Sean

Hi,

  • The data I used was Release 03.

  • Here are surface information for sub-CC00056XX07_ses-10700 ( run sample_to_native successfully)

    Name: sub-CC00056XX07_ses-10700_hemi-left_midthickness.surf.gii
    Type: Anatomical
    Number of Vertices: 93910
    Number of Triangles: 187816
    Bounds: (-43.2767, 0.555677, -35.7739, 77.2255, -18.4223, 60.1389)
    Spacing:
    Mean: 0.761947
    Std Dev: 0.164449
    Minimum: 0.079924
    Maximum: 1.629265

    Name: sub-CC00056XX07_ses-10700_hemi-left_pial.surf.gii
    Type: Anatomical
    Number of Vertices: 93910
    Number of Triangles: 187816
    Bounds: (-44.0236, 1.42818, -36.3437, 77.6846, -18.818, 60.8258)
    Spacing:
    Mean: 0.796758
    Std Dev: 0.273937
    Minimum: 0.006241
    Maximum: 2.075600

    Name: sub-CC00056XX07_ses-10700_hemi-left_wm.surf.gii
    Type: Anatomical
    Number of Vertices: 93910
    Number of Triangles: 187816
    Bounds: (-42.7848, 0.431395, -35.2475, 76.7664, -18.0326, 59.675)
    Spacing:
    Mean: 0.748349
    Std Dev: 0.115062
    Minimum: 0.079939
    Maximum: 1.629279

    Number of Vertices and Number of Triangles are consistent among the midthickness, pial and wm。

  • Here are surface information for CC00057XX08_ses-11002 ( run sample_to_native unsuccessfully)

    Name: sub-CC00057XX08_ses-11002_hemi-left_midthickness.surf.gii
    Type: Anatomical
    Number of Vertices: 93804
    Number of Triangles: 187604
    Bounds: (-49.2301, 4.28502, -40.9534, 67.6848, -18.0238, 52.6374)
    Spacing:
    Mean: 0.760819
    Std Dev: 0.170681
    Minimum: 0.000000
    Maximum: 2.113620

    Name: sub-CC00057XX08_ses-11002_hemi-left_pial.surf.gii
    Type: Anatomical
    Number of Vertices: 93804
    Number of Triangles: 187604
    Bounds: (-49.7727, 5.11741, -41.3548, 68.1142, -18.7199, 52.8151)
    Spacing:
    Mean: 0.793485
    Std Dev: 0.273903
    Minimum: 0.005009
    Maximum: 2.125155

    Name: sub-CC00057XX08_ses-11002_hemi-left_wm.surf.gii
    Type: Anatomical
    Number of Vertices: 93804
    Number of Triangles: 187604
    Bounds: (-48.7643, 3.53322, -40.552, 67.2555, -17.3276, 52.4597)
    Spacing:
    Mean: 0.747467
    Std Dev: 0.115179
    Minimum: 0.077172
    Maximum: 1.493315

    Number of Vertices and Number of Triangles are also consistent among the midthickness, pial and wm。

  • Then I check the function sample_to_native again, I found the pial, midthickness, and wm surface used in “wb_sample” step also have same vertex number:

    CC00057XX08_ses-11002 ( run sample_to_native unsuccessfully):

    Name: midthickness_hemi-left_mesh-native_space-func.surf.gii
    Type: Anatomical
    Number of Vertices: 93804
    Number of Triangles: 187604
    Bounds: (-49.1241, 3.80451, -40.3902, 69.6718, -17.9736, 50.463)
    Spacing:
    Mean: 0.760819
    Std Dev: 0.170681
    Minimum: 0.000000
    Maximum: 2.113619

    Name: pial_hemi-left_mesh-native_space-func.surf.gii
    Type: Anatomical
    Number of Vertices: 93804
    Number of Triangles: 187604
    Bounds: (-49.6853, 4.64433, -40.7854, 70.1031, -18.5606, 50.9066)
    Spacing:
    Mean: 0.793485
    Std Dev: 0.273903
    Minimum: 0.005008
    Maximum: 2.125154

    Name: white_hemi-left_mesh-native_space-func.surf.gii
    Type: Anatomical
    Number of Vertices: 93804
    Number of Triangles: 187604
    Bounds: (-48.5682, 3.05919, -39.995, 69.2404, -17.4403, 50.1174)
    Spacing:
    Mean: 0.747467
    Std Dev: 0.115179
    Minimum: 0.077172
    Maximum: 1.493315

I hope this information will be helpful in solving this problem,Thank you again for your help!

xiangyu

Hello @xiangyu_kong and @seanfitz

I am experiencing the same error while trying to map to a ribbon constrained surface. I hope to help pinpoint the problem by saying I am using the exact same script that works fine for the second release, so it would seem to be related to the 3rd release surface giftis.

I also checked that the number of vertices is the same for all surfaces, maybe @lzjwilliams will know if there is any other possible difference between the pial, midthickness, and white matter surfaces that could be causing this problem? Thank you very much in advance!

Best,
Diego

Hi @xiangyu_kong and @diegoder

Sorry I have not responded on this matter earlier. I hope to be able to onto this tomorrow. I will get back to you soon thereafter.

Thanks, Sean

Hi @xiangyu_kong and @diegoder

Just a quick update. I have replicated the problem and I believe that it stems from the released native surfaces. I have slightly older (pre-release) versions of the same surfaces that run without problem. I have raised this internally with the dHCP team and I’ll let you know when we have a better understanding of the cause.

Sorry for the delay.

Cheers, Sean

Hi @xiangyu_kong and @diegoder

The cause of the problem with the native surfaces has been identified and a fix is being tested. We will update you when new surfaces are available for download.

Cheers, Sean

Hi @seanfitz,

Thank you very much for dealing with this issue. Do you know by any chnace if it affects every single session (in the 3rd rel)? I have not had opportunity to check that.

Thank you,
Diego

Hi @seanfitz
Thanks for your help solving this problem. I do appreciate it. I will wait for your notice.

xiangyu

Hi @seanfitz

Do you have any updates on this issue?

Thank you very much in advance!
Best,
Diego

Hi @diegoder

Unfortunately I don’t have a further update at this. AFAIK the fix was successful and we are still waiting for the data to be reprocessed. I will raise this with the project PIs to see if I can get an ETA on completion and release.

Sorry, Sean

Hi @seanfitz

I’m wondering, for the subjects in the 2nd release, whether their surfaces in folder ‘rel3_dhcp_anat_pipeline’ in the 3rd release are consistent with those in the 2nd release. If not, what’s the difference between them.
Many thanks!

Best,
Dingna

Hi Dinga

I am not sure exactly what you mean by “consistent”. However, release three introduced a wide range of pipeline improvements, as well as new versions of the initial reconstruction. We do not consider release 2 and release 3 to be compatible.

Cheers, Sean

Hi @seanfitz

Do you know if the June patch included this reprocessing? I don’t see any further update on the torrents.

Thank you,
Diego

Hi @diegoder,

Can I check that you no longer have this problem with vertex correspondence?

Best wishes,

Logan

Hi Logan,

Thanks for reaching out. I am not able to check since my dhcp account has been disabled. I will try to e-mail the administrators and will get back to you.

Best,
Diego

Hi @lzjwilliams and @seanfitz! I seem to be encountering the same issue as xiangyu_kong described above. Has a solution be found for the vertex correspondence problem?
Thanks!
Lena