CoBrALab / RABIES

fMRI preprocessing pipeline and analysis tools adapted for rodent images. Visit the full documentation at https://rabies.readthedocs.io/en/stable/
Other
35 stars 14 forks source link

Weird registration issue during preprocessing #365

Closed geowk closed 6 months ago

geowk commented 6 months ago

Using Rabies 0.5.1 with singularity container:

singularity run -B ${atlas_dir}/:${atlas_dir}/ \
        -B ${rabies_dir}/${o_put}:/tmp/ \
        -B  ${rabies_dir}/${i_put}/:/input_BIDS:ro \
        -B  ${rabies_dir}/${pre_proc}:/preprocess_outputs/ ${rabies_dir}/rabies.sif \
        -p MultiProc --local_threads 5 \
        preprocess /input_BIDS/ /preprocess_outputs  \
        --apply_despiking \
        --anat_template ${atlas_dir}/Atlas_brain.nii.gz \
        --brain_mask ${atlas_dir}/Atlas_brainmask_bin.nii.gz \
        --WM_mask ${atlas_dir}/wm.nii.gz \
        --CSF_mask ${atlas_dir}/vascular.nii.gz \
        --vascular_mask ${atlas_dir}/vascular.nii.gz \
        --labels ${atlas_dir}/Atlas_atlas_v4.01.nii.gz \
        --commonspace_reg masking=true,brain_extraction=true,template_registration=SyN,fast_commonspace=true \
        --anat_autobox \
        --bold_autobox \
        --commonspace_resampling 0.4x0.4x0.4 \
        --anat_inho_cor method=SyN,otsu_thresh=2,multiotsu=false \
        --bold_inho_cor method=SyN,otsu_thresh=2,multiotsu=false

No errors reported from preprocessing

Experience this weird problem that I think originates with the original raw_brain_mask.

Here is example: Same subject, sub-05, from two different sessions.

Session 02 & Session 01 : underlay is the initial_bold_ref file and the overlay is the raw_brain_mask.

As you can see, for session 02 (left), the mask is properly overlay and for session 1 there is a complete mismatch despite processing, dimensions, orientation were the same for both sessions. Ran nibabel.aff2axcodes command on both input datasets and the output was ('R', 'A', 'S'), as well as the Atlas template.

sub-05_ses-02_vs_sub-05_ses-01

Here is the inho_cor output from both sessions where Session-02 looks okay, but Session-01 has mismatch with the mask and results in a bad Final Correction image.

inho_cor sub-05_ses-02 inho_cor sub-05_ses-01

Now this is just one subject's example with two sessions. But ran preprocessing on 8 subjects with 3 sessions on this particular dataset, and about half are good and the other half have this mismatch alignment with the mask. The original t2 and epi datasets are aligned, so not sure where in the preprocessing steps something has gone wrong. Any suggestions would be appreciated.

-g

Gab-D-G commented 6 months ago

The masking failed during inhomogeneity correction because you have ghosting in your images. So sometimes, the ghost is detected as the brain and targeted for registration. You can try using --bold_autobox to automatically remove the bottom part of your images.

geowk commented 6 months ago

Thanks. Actually did some extra cropping of the bottom part of the bold images and then ran preprocessing with both the bold and the anat autobox options. Doing some pre-cropping and still including the autobox options resolved the problem.The inhocor correction steps now work and the masks provide adequate coverage.

Thanks again.

-g