mri_read_ascii error when opening @file for 3dTshift -tpattern

AFNI gurujis–

My goal is use the -tpattern @filename option within afni_proc to do slice-time correction using the slice timings provided in a BIDS .json file. I’ve managed to confound my efforts in two easy steps:

First, read slicenums lines from a BIDS format .json file to get the slice-timing for the EPI data. Dump it into the 1D file slicetimes.1D

    # first set a variable indicating the number of slices
    set slicenums="`3dinfo -nk rest.nii`"
    # next, read slicenums of slice-timing info from the .json
    set slicetimes = "`less rest.json | grep -A ${slicenums} SliceTiming | grep -Eo '[0-9.]{1,}'`"
    echo ${slicetimes} > slicetimes.1D

Second, call up afni_proc and, among several other things, ask it to read the slice-timing from slicetimes.1D -subj_id ${subID} \
    -dsets rest.nii \
    -copy_anat T1.nii \
    -blocks despike tshift align tlrc volreg mask regress \
    -tshift_opts_ts -tpattern @slicetimes.1D \
    -mask_segment_anat yes \
    -mask_segment_erode yes \
    -align_opts_aea -ginormous_move -deoblique on -cost lpc+ZZ \
    -tcat_remove_first_trs 4 \
    -tlrc_NL_warp \
    -tlrc_base MNI152_2009_template.nii.gz \
    -volreg_align_to MIN_OUTLIER \
    -volreg_tlrc_warp \
    -volreg_warp_dxyz 3.0 \
    -regress_motion_per_run \
    -regress_censor_motion 0.3 \
    -regress_censor_outliers 0.1 \
    -regress_apply_mot_types demean deriv \
    -regress_compute_tsnr yes \
    -regress_anaticor_fast \
    -regress_bandpass 0.001 0.198 \

The following error results:
** ERROR: mri_read_ascii: couldn’t open file slicetimes.1D
** FATAL ERROR: Can’t read tpattern file slicetimes.1D

The file is, indeed, readable in other contexts, though. I can 1dplot it and if I use 3dTshift the old-fashioned way, it works fine:
3dTshift -prefix foo -tpattern @slicetimes.1D rest.nii

Something with how the afni_proc wrapper wants to read the file, perhaps? Sorry. Hope I’m not doing something ridiculous but I’m at the bottom of my debug stack…

Oh, and: Precompiled binary linux_ubuntu_16_64: Jun 18 2019 (Version AFNI_19.1.21 ‘Caligula’)


Try specifying the full path to the slicetimes.1D file.

You can try to use -copy_files inside the script setup to copy the necessary slicetimes file like the anatomical is copied. My memory is that this also works.

Thanks, Peter. It’s after work hours here in Sweden but I’ll try tomorrow and report back.

Follow-up: Both options work nicely. Thanks!