How to create tSNR or global SNR maps?

Hi,

I am looking for ways to generate tSNR or global SNR maps of NIFTI files outside of fMRIprep or other QC pipelines. Could someone point me to available code or existing packages that could do this?

Thanks!
Maddy

There are a multitude of ways different groups compute tSNR. It’s important to consider what the “signal” and what the “noise” are really. Whether the data has been motion corrected, baseline removal, noise removal, censoring,…, all have a big impact on the numbers and the meaning of those numbers that come out of this seemingly simple computation. AFNI has 3dTstat to compute tSNR maps. There are still a number of options to choose among that allow for detrending of the baseline for the standard deviation computation, the noise part of the calculation.

Here is an example using afni tools, based off of afni_proc.py:

## Output TSNR map
out_tsnr () {
    # pushd $analysis_directory (e.g. $BIDSDIR/derivatives/afni)
    # out_tsnr $out_file $errts "${inputs[@]}"

    local out=$1
    local errts=$2
    shift 2
    local inputs
    read -r -a inputs <<< "$@"

    # All_runs dataset
    3dTcat -overwrite -prefix tmp_all_runs.nii.gz ${inputs[@]}

    # Mean signal
    3dTstat -overwrite -mean -prefix tmp_signal_all.nii.gz tmp_all_runs.nii.gz

    # Noise
    3dTstat -overwrite -prefix tmp_noise_all.nii.gz -stdev $errts

    # Noise Calculation (mean signal over noise)
    3dcalc -overwrite -prefix $out \
        -a tmp_signal_all.nii.gz -b tmp_noise_all.nii.gz -expr 'a/b'

    # Delete temp files
    find ./ -maxdepth 1 -type f -name "tmp_*all.nii.gz" -delete
}   

# Example
pushd $afni_analysis_dir

3dDeconvolve -input smooth_scaled_1.nii.gz smooth_scaled_2.nii.gz \
    -fitts fitts.nii.gz \
    -errts errts,nii.gz \
    -bucket stats.nii.gz \
    ${decon_args}

out_tsnr tsnr_map.nii.gz errts.nii.gz smooth_scaled_1.nii.gz smooth_scaled_2.nii.gz
1 Like

@dglen @ajschadler Thank you both for your help!

1 Like