While running the script I am getting output of each ROI and 850 value in seed_ts_1.1D file but my gPPI_1_Fixation.!D and other condition files are empty that means no interaction. I have no idea where I am wrong.
Let me know how to solve this.
++ 3dcalc: AFNI version=AFNI_25.1.00 (Apr 6 2025) [64-bit]
++ Authored by: A cast of thousands
++ Output dataset ./ROI_1.nii.gz
++ 3dmaskave: AFNI version=AFNI_25.1.00 (Apr 6 2025) [64-bit]
+++ 3526 voxels survive the mask
Processing condition: Fixation
Onset file: /home/alnu/MRS_data/ant/gPPI/onsets_fixation.1D
** Time series file /home/alnu/MRS_data/ant/gPPI/onsets_fixation.1D is too short!
Generated: gppi_1_Fixation.1D
++ 3dDeconvolve: AFNI version=AFNI_25.1.00 (Apr 6 2025) [64-bit]
++ Authored by: B. Douglas Ward, et al.
** ERROR: mri_read_ascii: can't read any valid data from file gppi_1_Fixation.1D
** FATAL ERROR: 3dDeconvolve dies: Unable to read time series file: gppi_1_Fixation.1D
** Program compile date = Apr 6 2025
✅ Finished gPPI for Fixation in ROI 1 for S0226
Processing condition: Press0
Onset file: /home/alnu/MRS_data/ant/gPPI/onsets_press0.1D
** Time series file /home/alnu/MRS_data/ant/gPPI/onsets_press0.1D is too short!
Generated: gppi_1_Press0.1D
++ 3dDeconvolve: AFNI version=AFNI_25.1.00 (Apr 6 2025) [64-bit]
++ Authored by: B. Douglas Ward, et al.
** ERROR: mri_read_ascii: can't read any valid data from file gppi_1_Press0.1D
** FATAL ERROR: 3dDeconvolve dies: Unable to read time series file: gppi_1_Press0.1D
Are these being generated something like the cmd.ppi.2.make.regs script? You will have to provide some details of that.
But also, it is concerning that the regressor is called fixation. Fixation is generally considered a baseline condition that is not even modeled, at least not explicitly, as there are baseline and drift terms in the model.
for group_dir in "$patient_dir" "control_dir"; do
group_name=(basename "$group_dir")
for subj_dir in "group_dir"/*; do
subj_id=(basename "$subj_dir")
subj_out_dir="output_dir/{group_name}/${subj_id}"
mkdir -p "$subj_out_dir"
cd "$subj_out_dir" || exit
# Functional dataset
func_dset="${subj_dir}/ProcData.nii.gz"
ortvec="${subj_dir}/${subj_id}_X.nocensor.1D"
censor="${subj_dir}/${subj_id}_censor.1D"
[[ ! -f "$func_dset" ]] && echo "❌ Missing BOLD: $func_dset" && continue
# Generate seed time series for each ROI (1-166)
for roi_index in {1..166}; do
roi_mask="ROI_${roi_index}.nii.gz"
3dcalc -a "$atlas" -expr "equals(a,${roi_index})" -prefix "$roi_mask"
# Extract seed time series
3dmaskave -quiet -mask "$roi_mask" "$func_dset" > "seed_ts_${roi_index}.1D"
# Loop through conditions and process gPPI
for cond in "${conditions[@]}"; do
onset_file="${onsets_dir}/onsets_${cond,,}.1D"
duration=$(get_duration "$cond")
echo "Processing condition: $cond"
echo "Onset file: $onset_file"
if [[ ! -f "$onset_file" ]]; then
echo "❌ Missing onset file: $onset_file"
continue
fi
# Generate gPPI time series using 1deval
1deval -a "seed_ts_${roi_index}.1D" -b "$onset_file" -expr 'a*b' > "gppi_${roi_index}_${cond}.1D"
echo "Generated: gppi_${roi_index}_${cond}.1D"
# Run 3dDeconvolve for PPI analysis
3dDeconvolve \
-input "$func_dset" \
-censor "$censor" \
-num_stimts 1 \
-stim_file 1 "gppi_${roi_index}_${cond}.1D" -stim_label 1 "PPI_${cond}" \
-gltsym 'SYM: PPI_Press0 -PPI_Fixation' -glt_label 1 "PPI_Press0_vs_Fixation" \
-gltsym 'SYM: PPI_PressOddEven -PPI_Fixation' -glt_label 2 "PPI_PressOddEven_vs_Fixation" \
-x1D X_gppi_${roi_index}_${cond}.xmat.1D \
-bucket "ROI_${roi_index}_gppi_${cond}_stats+tlrc"
done
done
echo "🎯 gPPI completed for $subj_id in group: $group_name"
for cond in "{conditions[@]}"; do
for comp in "{comparisons[@]}"; do
mkdir -p "$group_comparison_dir/$cond/$comp"
echo "Running Group Comparison: $comp for Condition: $cond"
patient_files=($(find "$output_dir/SZ" -name "*gppi_${cond}_stats+tlrc.BRIK.gz"))
control_files=($(find "$output_dir/HC" -name "*gppi_${cond}_stats+tlrc.BRIK.gz"))
if [[ ${#patient_files[@]} -eq 0 || ${#control_files[@]} -eq 0 ]]; then
echo "❌ Missing datasets for $comp and $cond"
continue
fi
3dttest++ -prefix "$group_comparison_dir/$cond/$comp/${comp}_${cond}_group+tlrc" \
-setA "${patient_files[@]}" \
-setB "${control_files[@]}"
echo "✅ Group comparison done for $comp and $cond"
done
done
echo " All gPPI analysis completed!"
In this script, the gPPI (generalized psychophysiological interaction) analysis is performed for each subject, across all ROIs and task conditions. The process involves:
Seed time series extraction:
Based on the atlas, 166 ROIs are defined by creating individual masks.
For each ROI, the average time series is extracted from the subject’s functional BOLD data using 3dmaskave.
gPPI time series creation:
Each condition’s onset timing file (onsets_condition.1D) is multiplied with the seed time series using 1deval.
This results in a condition-specific PPI regressor: gppi_ROI_condition.1D.
PPI modeling using 3dDeconvolve:
The 3dDeconvolve command uses the gPPI regressor as input.
It includes predefined contrasts (e.g., Press0 vs Fixation).
Statistical output is generated per ROI and condition.
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.