FCP-INDI / C-PAC

Configurable Pipeline for the Analysis of Connectomes
https://fcp-indi.github.io/
GNU Lesser General Public License v3.0
63 stars 41 forks source link

Template-space bold mask clipping in child data #1909

Open sgiavasis opened 1 year ago

sgiavasis commented 1 year ago
tergeorge commented 1 year ago
  1. Looked at the various skull stripping strategies used to see if its causing the issue. BET skull stripping is broken and we need to add the robustfov before the BET step. This is not the main reason for the clipping of the mask because even though 3dskull stripping works we even see this issue when 3dskullstrip is used.
  2. Looked at single step resampling. The antsApplyTransforms for the brain mask did not use the motion and the blip transform which is used for the functional timeseries. Checked if adding the two transforms to the brain mask would make a difference but the output did not change.

Image

The gray regions in the image show the overlapping regions on the brain mask with and without the addition of the 2 transforms (motion correction and identity). As you can see from the image, the outputs do not change.

sgiavasis commented 1 year ago

@tergeorge currently also running fmriprep on this data:

tergeorge commented 1 year ago

Current status: Ran fmriprep-LTS and fmriprep 20.0.7 on lisa. Run command: /data3/cnl/mindboggle/opt/singularity/bin/singularity run -B /data3/cnl/tgeorge/Leonas_issue:/data3/cnl/tgeorge/Leonas_issue -B /data3/aki/Leona/cpac_output/sample_data_and_fmriprepoutput/BIDs-raw:/data3/aki/Leona/cpac_output/sample_data_and_fmriprepoutput/BIDs-raw -B /home/agutierrez/Documents/C-PAC/dev/docker_data --cleanenv /data3/cnl/tgeorge/Leonas_issue/images/fmriprep-20.2.7.sif /data3/aki/Leona/cpac_output/sample_data_and_fmriprepoutput/BIDs-raw /data3/cnl/tgeorge/Leonas_issue/output/fmriprep_LTS_sub-PA009 participant --participant-label sub-PA009 -t ovalfamily --skip-bids-validation --fd-spike-threshold 0.9 --dvars-spike-threshold 2.0 --bold2t1w-dof 12 --output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym:res-2 --stop-on-first-crash --notrack -w /data3/cnl/tgeorge/Leonas_issue/work/fmriprep_LTS_sub-PA009 --skip_bids_validation --fs-license-file /home/agutierrez/Documents/C-PAC/dev/docker_data/license.txt --fs-no-reconall --nthreads 8 --omp-nthreads 8 --mem-mb 12000

Singularity image error: Error message: /data3/cnl/mindboggle/opt/singularity/bin/singularity run -B /data3/cnl/tgeorge/Leonas_issue:/data3/cnl/tgeorge/Leonas_issue -B /data3/aki/Leona/cpac_output/sample_data_and_fmriprepoutput/BIDs-raw:/data3/aki/Leona/cpac_output/sample_data_and_fmriprepoutput/BIDs-raw -B /home/agutierrez/Documents/C-PAC/dev/docker_data --cleanenv /data3/cnl/tgeorge/Leonas_issue/images/fmriprep-20.2.7.sif /data3/aki/Leona/cpac_output/sample_data_and_fmriprepoutput/BIDs-raw /data3/cnl/tgeorge/Leonas_issue/output/fmriprep_LTS_sub-PA009 participant --participant-label sub-PA009 -t ovalfamily --skip-bids-validation --fd-spike-threshold 0.9 --dvars-spike-threshold 2.0 --bold2t1w-dof 12 --output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym:res-2 --stop-on-first-crash --notrack -w /data3/cnl/tgeorge/Leonas_issue/work/fmriprep_LTS_sub-PA009 --skip_bids_validation --fs-license-file /home/agutierrez/Documents/C-PAC/dev/docker_data/license.txt --fs-no-reconall --nthreads 8 --omp-nthreads 8 --mem-mb 12000

Next steps: Build the image on ACCESS and run fmriprep again with the new singularity images.

tergeorge commented 1 year ago

ACCESS run command: LTS run: singularity run --cleanenv /ocean/projects/med220004p/tgeorge/Leonas_issue/images/fmriprep_20.2.7.sif /ocean/projects/med220004p/tgeorge/Leonas_issue/input/BIDs-raw /ocean/projects/med220004p/tgeorge/Leonas_issue/output/fmriprep_LTS_sub-PA009 participant --participant-label sub-PA009 -t ovalfamily --skip-bids-validation --fd-spike-threshold 0.9 --dvars-spike-threshold 2.0 --bold2t1w-dof 12 --output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym:res-2 --stop-on-first-crash --notrack -w /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_LTS_sub-PA009 --skip_bids_validation --fs-license-file /ocean/projects/med220004p/tgeorge/Leonas_issue/images/fs_license.txt --fs-no-reconall --nthreads 8 --omp-nthreads 8 --mem-mb 12000

fmrprep: 20.0.7

singularity run --cleanenv /ocean/projects/med220004p/tgeorge/Leonas_issue/images/fmriprep_20.0.7.sif /ocean/projects/med220004p/tgeorge/Leonas_issue/input/BIDs-raw /ocean/projects/med220004p/tgeorge/Leonas_issue/output/fmriprep_LTS_sub-PA009 participant --participant-label sub-PA009 -t ovalfamily --skip-bids-validation --fd-spike-threshold 0.9 --dvars-spike-threshold 2.0 --bold2t1w-dof 12 --output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym:res-2 --stop-on-first-crash --notrack -w /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009 --skip_bids_validation --fs-license-file /ocean/projects/med220004p/tgeorge/Leonas_issue/images/fs_license.txt --fs-no-reconall --nthreads 8 --omp-nthreads 8 --mem-mb 12000

Output dir of runs: /ocean/projects/med220004p/tgeorge/Leonas_issue/output Working dir of runs: /ocean/projects/med220004p/tgeorge/Leonas_issue/work/

tergeorge commented 1 year ago

Fmriprep work directory outputs: https://docs.google.com/document/d/1k0O-IH-5ZmXM2EHhKg4v_BFatw4kKRduUQc5dPClGms/edit

tergeorge commented 1 year ago

Template space bold mask generation in fmriprep:

antsApplyTransforms --default-value 0 --float 1 --input /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/sdc_estimate_wf/pepolar_unwarp_wf/enhance_and_skullstrip_bold_wf/combine_masks/ref_bold_corrected_trans_corrected_brain_mask_maths.nii.gz --interpolation MultiLabel --output ref_bold_corrected_trans_corrected_brain_mask_maths_trans.nii.gz --reference-image /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_t1_trans_wf/gen_ref/sub-PA048_ses-V3W3_acq-MPR_rec-vNavNorm_T1w_corrected_masked_xform_reference.nii.gz --transform /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_reg_wf/fsl_bbr_wf/fsl2itk_fwd/affine.txt

Template space bold mask generation in CPAC:

antsApplyTransforms --default-value 0 --float 0 --input /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/_scan_ovalfamily/combine_masks_112/ref_bold_corrected_brain_mask_maths.nii.gz --interpolation MultiLabel --output ref_bold_corrected_brain_mask_maths_trans.nii.gz --reference-image /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/resampled_T1w-brain-template-funcreg/T1w-brain-template-funcreg/tpl-MNI152NLin2009cAsym_res-02_T1w_reference_resample.nii.gz --transform /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/ANTS_T1_to_template_58/write_composite_xfm/from-T1w_to-template_mode-image_xfm.nii.gz --transform /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/_scan_ovalfamily/convert_bbr2itk_200/affine.txt

sgiavasis commented 1 year ago

Splitting these up:

fmriprep:

antsApplyTransforms

--default-value 0

--float 1

--input /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/sdc_estimate_wf/pepolar_unwarp_wf/enhance_and_skullstrip_bold_wf/combine_masks/ref_bold_corrected_trans_corrected_brain_mask_maths.nii.gz

--interpolation MultiLabel

--output ref_bold_corrected_trans_corrected_brain_mask_maths_trans.nii.gz

--reference-image /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_t1_trans_wf/gen_ref/sub-PA048_ses-V3W3_acq-MPR_rec-vNavNorm_T1w_corrected_masked_xform_reference.nii.gz

--transform /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_reg_wf/fsl_bbr_wf/fsl2itk_fwd/affine.txt

CPAC:

antsApplyTransforms

--default-value 0

--float 0

--input /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/_scan_ovalfamily/combine_masks_112/ref_bold_corrected_brain_mask_maths.nii.gz

--interpolation MultiLabel

--output ref_bold_corrected_brain_mask_maths_trans.nii.gz

--reference-image /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/resampled_T1w-brain-template-funcreg/T1w-brain-template-funcreg/tpl-MNI152NLin2009cAsym_res-02_T1w_reference_resample.nii.gz

--transform /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/ANTS_T1_to_template_58/write_composite_xfm/from-T1w_to-template_mode-image_xfm.nii.gz

--transform /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/_scan_ovalfamily/convert_bbr2itk_200/affine.txt

In the meantime-

Can we see an overlay of the two input files, plus a correlation of the two? /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/sdc_estimate_wf/pepolar_unwarp_wf/enhance_and_skullstrip_bold_wf/combine_masks/ref_bold_corrected_trans_corrected_brain_mask_maths.nii.gz vs. /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/_scan_ovalfamily/combine_masks_112/ref_bold_corrected_brain_mask_maths.nii.gz

And same with the two references? /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA048/fmriprep_wf/single_subject_PA048_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_t1_trans_wf/gen_ref/sub-PA048_ses-V3W3_acq-MPR_rec-vNavNorm_T1w_corrected_masked_xform_reference.nii.gz vs. /outputs/working/pipeline_default-fmriprep_fs-off_be-bet_seg-ants_despike-off_nightly/cpac_sub-PA048_ses-V3W3/resampled_T1w-brain-template-funcreg/T1w-brain-template-funcreg/tpl-MNI152NLin2009cAsym_res-02_T1w_reference_resample.nii.gz

tergeorge commented 1 year ago

This is what the two inputs look like:

image

The one on top with the multicolor border is from fmriprep. correlation of the input files: 0.945126

For the reference image, CPAC uses the whole head while fmriprep uses just the brain template. So I can't overlay the two. Also need to investigate why that is the case.

CPAC reference:

image

fmriprep reference:

image
tergeorge commented 1 year ago

These are the two outputs overlaid on top of each other. The green is the fmriprep output. As you can see both of them are pretty bad!!

image

The two outputs have a different dimensions. CPAC - [82x97x82] and fmriprep - [62x76x61].

tergeorge commented 1 year ago

--float 1 means that the output image should be stored as a floating point.

tergeorge commented 1 year ago

fmriprep:

antsApplyTransforms --default-value 0 --float 1 --input /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009/fmriprep_wf/single_subject_PA009_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_bold_trans_wf/bold_reference_wf/enhance_and_skullstrip_bold_wf/combine_masks/ref_bold_corrected_brain_mask_maths.nii.gz --interpolation MultiLabel --output ref_bold_corrected_brain_mask_maths_trans.nii.gz --reference-image /jet/home/tgeorge/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz --transform /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009/fmriprep_wf/single_subject_PA009_wf/anat_preproc_wf/anat_norm_wf/_template_MNI152NLin2009cAsym/registration/ants_t1_to_mniComposite.h5 --transform /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009/fmriprep_wf/single_subject_PA009_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_reg_wf/fsl_bbr_wf/fsl2itk_fwd/affine.txt

Breaking up the command:

antsApplyTransforms

--default-value 0

--float 1

Input : /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009/fmriprep_wf/single_subject_PA009_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_bold_trans_wf/bold_reference_wf/enhance_and_skullstrip_bold_wf/combine_masks/ref_bold_corrected_brain_mask_maths.nii.gz ref: /jet/home/tgeorge/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz

--interpolation MultiLabel

--transform /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009/fmriprep_wf/single_subject_PA009_wf/anat_preproc_wf/anat_norm_wf/_template_MNI152NLin2009cAsym/registration/ants_t1_to_mniComposite.h5

--transform /ocean/projects/med220004p/tgeorge/Leonas_issue/work/fmriprep_2007_sub-PA009/fmriprep_wf/single_subject_PA009_wf/func_preproc_ses_V3W3_task_ovalfamily_wf/bold_reg_wf/fsl_bbr_wf/fsl2itk_fwd/affine.txt

tergeorge commented 1 year ago

The two inputs overlaid.

image

The one on top with the multicolor border is from fmriprep.

tergeorge commented 1 year ago

The two outputs overlaid:

image

The image with multicolor border is from fmriprep.

tergeorge commented 1 year ago

The two references:

image
tergeorge commented 1 year ago

Lucid chart flow diagram of the CPAC and fmriprep work flow. https://lucid.app/lucidchart/373d7542-1de0-4c12-bf84-7de997dd99a5/edit?invitationId=inv_277f6ed3-42da-4573-bb97-791bcb11cde6&page=0_0#