Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIXED func mask overestimates, REMOVED filtering for multi-echo #114

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Binary file added ._.DS_Store
Binary file not shown.
Binary file added ._micapipe
Binary file not shown.
Binary file added functions/._init.sh
Binary file not shown.
35 changes: 19 additions & 16 deletions functions/02_proc-func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# and incorporation to mica-pipe by Raul (August-September 2020)
# and addition of a bunch of fancy flags by Jessica (October-November 2020)
# and updated mapping by Jordan (March 2023)
#
#

# Resting state fMRI processing with bash:
#
# Preprocessing workflow for func.
Expand Down Expand Up @@ -82,7 +83,8 @@ else
BIDSanat="${idBIDS}"
dir_anat="${proc_struct}"
fi
subject_dir


dir_volum="${subject_dir}/parc"
T1_seg_subcortex="${dir_volum}/${BIDSanat}_space-nativepro_T1w_atlas-subcortical.nii.gz"
T1_seg_cerebellum="${dir_volum}/${BIDSanat}_space-nativepro_T1w_atlas-cerebellum.nii.gz"
Expand Down Expand Up @@ -454,19 +456,15 @@ if [[ ! -f "${func_volum}/${idBIDS}${func_lab}_preproc".nii.gz ]]; then
tmp_t1w_brain_res="${tmp}/nativepro_brain_rescaled.nii.gz"
tmp_affineStr="${tmp}/from-nativepro_to-mainScan01_"
tmp_aff_mat="${tmp_affineStr}0GenericAffine.mat"
tmp_func_strip="${tmp}/mainScan01_mean_stripped.nii.gz"
tmp_func_mask="${tmp}/mainScan01_mean_mask.nii.gz"

# Create a loose mask for tedana
# Create a tight mask for tedana
fslmaths "${scans4tedana[0]}" -Tmean "${tmp_func_mean}"
voxels=$(mrinfo "${tmp_func_mean}" -spacing); voxels="${voxels// /,}"
Do_cmd flirt -applyisoxfm "${voxels}" -in "${T1nativepro_brain}" -ref "${T1nativepro_brain}" -out "${tmp_t1w_brain_res}"
# [fixedImage,movingImage,initializationFeature]
centeralign="[${tmp_func_mean},${tmp_t1w_brain_res},0]"
Do_cmd antsRegistrationSyNQuick.sh -d 3 -m "$tmp_t1w_brain_res" -f "$tmp_func_mean" -o "$tmp_affineStr" -t a -n "$threads" -p d -i ${centeralign}
Do_cmd antsApplyTransforms -d 3 -i "$T1nativepro_mask" -r "$tmp_func_mean" -t "$tmp_aff_mat" -o "${tmp_func_mask}" -u int
Do_cmd mri_synthstrip -i "${tmp_func_mean}" -o "${tmp_func_strip}" -m "${tmp_func_mask}"

# Run tedana
tedana -d $(printf "%s " "${scans4tedana[@]}") -e $(printf "%s " "${EchoTime[@]}") --out-dir "${tedana_dir}" --mask "${tmp_func_mask}"
tedana -d $(printf "%s " "${scans4tedana[@]}") -e $(printf "%s " "${EchoTime[@]}") --out-dir "${tedana_dir}" --mask "${tmp_func_mask}"

# Overwite the motion corrected to insert this into topup.
## TODO: func_topup should take proper input arguments instead of relying on architecture implemented in other functions.
Expand Down Expand Up @@ -507,13 +505,18 @@ else
Info "Subject ${id} has a brain masked from func"; ((Nsteps++)); ((N++))
fi

# High-pass filter - Remove all frequencies EXCEPT those in the range
if [[ ! -f "${func_volum}/${idBIDS}${func_lab}_tSNR.nii.gz" ]]; then ((N++))
Info "High pass filter"
Do_cmd 3dTproject -input "${func_nii}" -prefix "$fmri_HP" -passband 0.01 666
if [[ -f "${fmri_HP}" ]] ; then ((Nsteps++)); fi
# High-pass filter - Remove all frequencies in the range (only for single echo processing)
# retaining frequencies above 0.01Hz
if [[ ${acq} == "se" ]]; then
if [[ ! -f "${func_volum}/${idBIDS}${func_lab}_tSNR.nii.gz" ]]; then ((N++))
Info "High pass filter"
Do_cmd 3dTproject -input "${func_nii}" -prefix "$fmri_HP" -stopband 0 0.0099
if [[ -f "${fmri_HP}" ]] ; then ((Nsteps++)); fi
else
Info "Subject ${id} has Highpass filter"; ((Nsteps++)); ((N++))
fi
else
Info "Subject ${id} has High-pass filter"; ((Nsteps++)); ((N++))
fmri_HP=${func_nii} # no need to filter post tedana
fi

#------------------------------------------------------------------------------#
Expand Down
Empty file modified functions/init.sh
100755 → 100644
Empty file.
Empty file modified micapipe
100755 → 100644
Empty file.