Problem with deskulling 7T scan

We recently started using the 7T scanner and are having problems with deskulling. The mprage in the directory looks fine but the background noise have values above zero and are different than the 3T data we have been processing. The deskulling is failing and the final image is clearly distorted/warped because of this. The original images in the briks directory are not warped. We are using afni_proc.py to generate the proc for the analysis. How can we modify the deskulling in the generated proc to fix this deskulling problem? Thanks for any help.

Hi-

Can you please post your exact command?

Also, have you tried using @SSwarper, which performs both skullstripping and nonlinear alignment to a standard template?

–pt

Well I looked thru the proc generated from afni_proc.py and this looks like the one that does it:

================================= align ==================================

for e2a: compute anat alignment transformation to EPI registration base

(new anat will be intermediate, stripped, mprage_ns+orig)

align_epi_anat.py -anat2epi -anat mprage+orig
-save_skullstrip -suffix _al_junk
-epi vr_base_min_outlier+orig -epi_base 0
-epi_strip 3dAutomask
-cost lpc+ZZ
-volreg off -tshift off

There is no separate deskulling command. This is the first one (that I see) in the proc that does something about deskulling.

MIke

Hi, Mike-

OK, I see. I guess I was wondering what your afni_proc.py command was, so I could see what options you were putting in there.

But, using @SSwarper would really be the best way to go; that will do a much better/more reliable skullstripping, as well as nonlinear warp estimation to standard space, if desired, and its results are passed directly into afni_proc.py as options. Are you warping your data to a template space? If so, which one?

–pt

OK here is the actual afni_proc.py cmd file command below. I guess I need more explanation of how I would run the @SSwarper command and then pass those results to the proc command.

Thanks for your help.

=================================================================================================

run afni_proc.py to create a single subject processing script

afni_proc.py -subj_id $subj
-script proc.$subj -scr_overwrite
-blocks tshift align tlrc volreg blur mask scale regress
-copy_anat $anat_dir/mprage+orig
-tcat_remove_first_trs 0
-dsets
$epi_dir/MID+orig.HEAD
-align_opts_aea -cost lpc+ZZ
-tlrc_base MNI152_T1_2009c+tlrc
-tlrc_NL_warp
-volreg_align_to MIN_OUTLIER
-volreg_align_e2a
-volreg_tlrc_warp
-blur_size 4.0
-regress_stim_times
$stim_dir/CII1085_ATNtd.txt
$stim_dir/CII1085_ATRHtd.txt
$stim_dir/CII1085_ATRLtd.txt
$stim_dir/CII1085_ATLHtd.txt
$stim_dir/CII1085_ATLLtd.txt
$stim_dir/CII1085_FRHHtd.txt
$stim_dir/CII1085_FRHMtd.txt
$stim_dir/CII1085_FRLHtd.txt
$stim_dir/CII1085_FRLMtd.txt
$stim_dir/CII1085_FLLHtd.txt
$stim_dir/CII1085_FLLMtd.txt
$stim_dir/CII1085_FLHHtd.txt
$stim_dir/CII1085_FLHMtd.txt
$stim_dir/CII1085_FNHtd.txt
$stim_dir/CII1085_FNMtd.txt
-regress_opts_3dD
-num_glt 12
-gltsym ‘SYM:ATRHtd -ATNtd’
-glt_label 1 AntTarg_RewHi-Neu
-gltsym ‘SYM:ATRLtd -ATNtd’
-glt_label 2 AntTarg_RewLow-Neu
-gltsym ‘SYM:ATLHtd -ATNtd’
-glt_label 3 AntTarg_LossHi-Neu
-gltsym ‘SYM:ATLLtd -ATNtd’
-glt_label 4 AntTarg_LossLow-Neu
-gltsym ‘SYM:FRHHtd -FNHtd’
-glt_label 5 FbHit_RewHi-Neu
-gltsym ‘SYM:FRHMtd -FNMtd’
-glt_label 6 FbMiss_RewHi-Neu
-gltsym ‘SYM:FRLHtd -FNHtd’
-glt_label 7 FbHit_RewLo-Neu
-gltsym ‘SYM:FRLMtd -FNMtd’
-glt_label 8 FbMiss_RewLo-Neu
-gltsym ‘SYM:FLHHtd -FNHtd’
-glt_label 9 FbHit_LossHi-Neu
-gltsym ‘SYM:FLHMtd -FNMtd’
-glt_label 10 FbMiss_LossHi-Neu
-gltsym ‘SYM:FLLHtd -FNHtd’
-glt_label 11 FbHit_LossLow-Neu
-regress_stim_labels
ATNtd ATRHtd ATRLtd ATLHtd ATLLtd FRHHtd FRHMtd FRLHtd FRLMtd FLLHtd FLLMtd FLHHtd FLHMtd FNHtd FNMtd
-regress_basis ‘dmBLOCK(1)’
-regress_stim_types AM2
-regress_censor_motion 0.3
-regress_apply_mot_types demean deriv
-regress_reml_exec
-regress_compute_fitts
-regress_make_ideal_sum sum_ideal.1D
-regress_est_blur_epits
-regress_est_blur_errts
-regress_make_cbucket yes

                                                                                95,0-1

Hi-

Thanks; I see you are warping to MNI space, so an example @SSwarper command with some of your variable name(s) would be:


set subj = sub-000   # or, whatever your subject ID would be
set template = MNI152_2009_template_SSW.nii.gz 

@SSwarper             \
        -input  ${anat_dir}/mprage+orig           \
        -base   ${template}           \
        -subid  ${subj}           \
       -odir   ${anat_dir}/SSW          \

and then, as noted in the @SSwarper help file:


afni_proc.py                                                  \
      [...other stuff here: processing blocks, options...]        \
      -copy_anat ${anat_dir}/SSW/anatSS.${subj}.nii                               \
      -anat_has_skull no                                          \
      -volreg_align_to MIN_OUTLIER                                \
      -volreg_align_e2a                                           \
      -volreg_tlrc_warp \
      -tlrc_base ${template}              \
      -tlrc_NL_warp                                               \
      -tlrc_NL_warped_dsets                                       \
         ${anat_dir}/SSW/anatQQ.${subj}.nii                                       \
         ${anat_dir}/SSW/anatQQ.${subj}.aff12.1D                                  \
         ${anat_dir}/SSW/anatQQ.${subj}_WARP.nii

OK thank you for your help. I will give this a try and see how it goes. I hope you are keeping healthy and safe!

I had a similar problem with very noisy data acquired on a 3T scanner. I ended up having to clip as much of the non-head regions of the T1 images so that the noise would not pull the mask outside the head. I used @clip_volume to zero this out. In the AFNI viewer, load in your T1 and make a note of the six x, y, z planes that get you as close to the head as possible and then create, possibly multiple, @clip_volume commands to implement the clipping. You’d do this clipping before running @SSwarper. It’s a somewhat tedious process but it worked wonders for noisy T1s in this particular dataset.

Hi, Colm-

Thanks for that suggestion/advice. I would be curious to look at your dataset-- would you be able to upload it? I’d be curious to see if there might be a way to automate this process more.

Note that 3dZeropad can take negative values (-> negative zeropadding is removing slices), so that might be a useful way to go: counting the number of slices to delete from the left boundary, from the right boundary, from the anterior boundary, etc.

But again, I would hope we could try to help navigate some of this programmatically (which may just be naive optimism on my part, of course!).

–pt

Hi, Mike-

Okeydoke, sounds like a plan.

And based on Colm’s comment here about skullstripping 7T data:
https://afni.nimh.nih.gov/afni/community/board/read.php?1,163472,163481#msg-163481
please let me know how it goes; I am happy to take a look at the data as well, and see if some additional option(s) would be useful for @SSwarper, if the background is much higher, for example.

And thanks, adjusting to The New Normal at the moment, but staying healthy so far. Hope things are fine for you, as well.

–pt

Is the ${template} value the same in the afni_proc.py script piece as it was in the SSwarper script?

Mike

Yes, the same template file name is provided to the @SSwarper and afni_proc.py commands. I defined it as a variable to be used in both commands (though, you might run each command in a separate script, I suppose).

–pt

Ok I usually do. Thanks.

I no longer have the dataset. By now it would be 10-15 years old. You could probably simulate it quite well by adding salt and pepper noise to an existing dataset. A median filter cleaned it up very effectively.

Hmmm, OK.

–pt

The SSwarper seemed to work perfectly (see attached picture). I modified the cmd file as you suggested (I think i did this correctly) but the final outputted images are as warped as before (see attached picture of anat_final). Maybe the deskulling was not the problem or maybe I did something else wrong. Can you advise me?

Here is my modifed cmd file:

afni_proc.py -subj_id $subj
-script proc.subj -scr_overwrite \ -blocks tshift align tlrc volreg blur mask scale regress \ -copy_anat {anat_dir}/SSW/anatSS.${subj}.nii
-tcat_remove_first_trs 0
-dsets
epi_dir/MID+orig.HEAD \ -anat_has_skull no \ -volreg_align_to MIN_OUTLIER \ -volreg_align_e2a \ -volreg_tlrc_warp \ -tlrc_base {template}
-tlrc_NL_warp
-tlrc_NL_warped_dsets
{anat_dir}/SSW/anatQQ.{subj}.nii
{anat_dir}/SSW/anatQQ.{subj}.aff12.1D
{anat_dir}/SSW/anatQQ.{subj}_WARP.nii
-dsets
$epi_dir/MID+orig.HEAD
-blur_size 4.0
-regress_stim_times
$stim_dir/CII1085_ATNtd.txt
$stim_dir/CII1085_ATRHtd.txt
$stim_dir/CII1085_ATRLtd.txt
$stim_dir/CII1085_ATLHtd.txt
$stim_dir/CII1085_ATLLtd.txt
$stim_dir/CII1085_FRHHtd.txt
$stim_dir/CII1085_FRHMtd.txt
$stim_dir/CII1085_FRLHtd.txt
$stim_dir/CII1085_FRLMtd.txt
$stim_dir/CII1085_FLLHtd.txt
$stim_dir/CII1085_FLLMtd.txt
$stim_dir/CII1085_FLHHtd.txt
$stim_dir/CII1085_FLHMtd.txt
$stim_dir/CII1085_FNHtd.txt
$stim_dir/CII1085_FNMtd.txt
-regress_opts_3dD
-num_glt 12
-gltsym ‘SYM:ATRHtd -ATNtd’
-glt_label 1 AntTarg_RewHi-Neu
-gltsym ‘SYM:ATRLtd -ATNtd’
-glt_label 2 AntTarg_RewLow-Neu
-gltsym ‘SYM:ATLHtd -ATNtd’
-glt_label 3 AntTarg_LossHi-Neu
-gltsym ‘SYM:ATLLtd -ATNtd’
-glt_label 4 AntTarg_LossLow-Neu
-gltsym ‘SYM:FRHHtd -FNHtd’
-glt_label 5 FbHit_RewHi-Neu
-gltsym ‘SYM:FRHMtd -FNMtd’
-glt_label 6 FbMiss_RewHi-Neu
-gltsym ‘SYM:FRLHtd -FNHtd’
-glt_label 7 FbHit_RewLo-Neu
-gltsym ‘SYM:FRLMtd -FNMtd’
-glt_label 8 FbMiss_RewLo-Neu
-gltsym ‘SYM:FLHHtd -FNHtd’
-glt_label 9 FbHit_LossHi-Neu
-gltsym ‘SYM:FLHMtd -FNMtd’
-glt_label 10 FbMiss_LossHi-Neu
-gltsym ‘SYM:FLLHtd -FNHtd’
-glt_label 11 FbHit_LossLow-Neu
-gltsym ‘SYM:FLLMtd -FNMtd’
-glt_label 12 FbMiss_LossLow-Neu
-regress_stim_labels
ATNtd ATRHtd ATRLtd ATLHtd ATLLtd FRHHtd FRHMtd FRLHtd FRLMtd FLLHtd FLLMtd FLHHtd FLHMtd FNHtd FNMtd
-regress_basis ‘dmBLOCK(1)’
-regress_stim_types AM2
-regress_censor_motion 0.3
-regress_apply_mot_types demean deriv
-regress_reml_exec
-regress_compute_fitts
-regress_make_ideal_sum sum_ideal.1D
-regress_est_blur_epits
-regress_est_blur_errts
-regress_make_cbucket yes

I just realized I ran the old proc instead of the new one so of course I got the same results. I am running the correct one now. Sorry for my mistake.

OK, no worries.

Re. @SSwarper results: there should be *.jpg images created automagically to show the results of alignment+skullstripping-- would you mind attaching those when you have a chance, just to verify that things went well?

–pt