afni_python_wrapper.py error

Dear afni experts:

I came across the attached errors when running the scripts generated by afni_proc.py. Apparently the error is from the following lines in the scripts generated from afni_proc.py.


# write AP uvars into a simple txt file
cat << EOF > out.ap_uvars.txt
  out_limit      : 0.15
  copy_anat      :                                                        \
      sub-0163_ses-01_space-MNI152NLin2009cAsym_desc-preproc_T1w+tlrc.HEAD
  mask_dset      : full_mask.$subj+tlrc.HEAD
  ss_review_dset : out.ss_review.$subj.txt
EOF

# and convert the txt format to JSON
cat out.ap_uvars.txt | afni_python_wrapper.py -eval "data_file_to_json()" \
  > out.ap_uvars.json

Any advice will be appreciated.

Erik Chang

The error message


cat out.ap_uvars.txt
afni_python_wrapper.py -eval data_file_to_json()
gen_ss_review_scripts.py -exit0 -init_uvars_json out.ap_uvars.json -write_uvars_json out.ss_review_uvars.json
Traceback (most recent call last):
  File "/home/tcnl/abin/gen_ss_review_scripts.py", line 3402, in <module>
    sys.exit(main())
  File "/home/tcnl/abin/gen_ss_review_scripts.py", line 3379, in main
    rv = me.process_options()
  File "/home/tcnl/abin/gen_ss_review_scripts.py", line 1115, in process_options
    dfill = UTIL.read_json_file(C.udict_in)
  File "/home/tcnl/abin/afnipy/afni_util.py", line 343, in read_json_file
    return json.loads(textdata)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The afni_proc.py command


# ==========================================================================
# script generated by the command:
#
# afni_proc.py -subj_id sub0163.CSPLIN -script proc.CSPLIN.sub0163                                                                                       \
#     -scr_overwrite -blocks mask blur regress -copy_anat                                                                                                \
#     /media/tcnl/data2/GRIPFORCE/out/fmriprep/sub-0163/ses-01/anat/sub-0163_ses-01_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz                    \
#     -dsets                                                                                                                                             \
#     /media/tcnl/data2/GRIPFORCE/out/fmriprep/sub-0163/ses-01/func/sub-0163_ses-01_task-GFORCE_run-1_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz \
#     /media/tcnl/data2/GRIPFORCE/out/fmriprep/sub-0163/ses-01/func/sub-0163_ses-01_task-GFORCE_run-2_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz \
#     -tcat_remove_first_trs 0 -blur_size 4.0 -regress_stim_times                                                                                        \
#     /media/tcnl/data2/GRIPFORCE/beh/sub-0163_ses-01_task-GFORCE_run-01-40%.1D                                                                          \
#     /media/tcnl/data2/GRIPFORCE/beh/sub-0163_ses-01_task-GFORCE_run-01-60%.1D                                                                          \
#     /media/tcnl/data2/GRIPFORCE/beh/sub-0163_ses-01_task-GFORCE_run-02-40%.1D                                                                          \
#     /media/tcnl/data2/GRIPFORCE/beh/sub-0163_ses-01_task-GFORCE_run-02-60%.1D                                                                          \
#     -regress_stim_labels R40 R60 L40 L60 -regress_basis                                                                                                \
#     'CSPLIN(-4.8,16.8,10)' -regress_extra_stim_files                                                                                                   \
#     /media/tcnl/data2/GRIPFORCE/out/fmriprep/sub-0163/ses-01/func/sub-0163_ses-01_task-GFORCE_desc-confounds_sel_timeseries.1D                         \
#     -regress_extra_stim_labels non_interest -regress_opts_3dD -jobs 20                                                                                 \
#     -num_glt 11 -gltsym 'SYM: L60[3..6] -L40[3..6]' -glt_label 1 L60-L40                                                                               \
#     -gltsym 'SYM: R60[3..6] -R40[3..6]' -glt_label 2 R60-R40 -gltsym 'SYM:                                                                             \
#     L40[3..6] +L60[3..6] -R60[3..6] -R40[3..6]' -glt_label 3 L-R -gltsym                                                                               \
#     'SYM: L60[3..6] +R60[3..6] -L40[3..6] -R40[3..6]' -glt_label 4 60-40                                                                               \
#     -gltsym 'SYM: -1*L60[0..2] +1*L60[3..6]' -glt_label 5 L60_all -gltsym                                                                              \
#     'SYM: -1*R60[0..2] +1*R60[3..6]' -glt_label 6 R60_all -gltsym 'SYM:                                                                                \
#     -1*L40[0..2] +1*L40[3..6]' -glt_label 7 L40_all -gltsym 'SYM:                                                                                      \
#     -1*R40[0..2] +1*R40[3..6]' -glt_label 8 R40_all -gltsym 'SYM: R40[3..6]                                                                            \
#     +R60[3..6] -L40[3..6] -L60[3..6]' -glt_label 9 R-L -gltsym 'SYM:                                                                                   \
#     R60[3..6] -R40[3..6] -L60[3..6] +L40[3..6]' -glt_label 10 int1                                                                                     \
#     -regress_compute_fitts -regress_make_ideal_sum sum_ideal.1D                                                                                        \
#     -regress_est_blur_epits -regress_est_blur_errts -mask_apply epi                                                                                    \
#     -regress_censor_outliers 0.15 -regress_reml_exec


Hi Erik,

Ah, that is something I will have to check for, sorry. There should not be any line wrappers applied when generating out.ap_uvars.txt (in this case, since the copy_anat name is long). You can manually fix the proc scripts by putting those lines back together, in this case reading

copy_anat : sub-0163_ses-01_space-MNI152NLin2009cAsym_desc-preproc_T1w+tlrc.HEAD

I will fix this and put out new binaries today.

Thanks for bringing it up,

  • rick

Hi Rick,

The latest update of afni_proc.py (version 7.39 on May 10) solved the problem. Thanks for taking care of it.

Cheers,
Erik

Great, thanks a lot, Erik!

  • rick

Hi Rick,

I wonder if another error message immediately following the afni_python_wrapper.py command is relevant to this stream:


afni_python_wrapper.py -eval data_file_to_json()
gen_ss_review_scripts.py -exit0 -init_uvars_json out.ap_uvars.json -write_uvars_json out.ss_review_uvars.json
** guess tcat: failed to determine subject ID from pb00 files
** failed to guess subject ID
** failed to init basics...

Input to the gen_ss_review_scripts.py, out.ap_uvas.json, has the following contents:


 out_limit      : 0.15
  copy_anat      : sub-0128_ses-01_space-MNI152NLin2009cAsym_desc-preproc_T1w+tlrc.HEAD
  mask_dset      : full_mask.sub0128.CSPLIN+tlrc.HEAD
  ss_review_dset : out.ss_review.sub0128.CSPLIN.txt

The output out.ss_review_uvars.json is not created due to the error.
The pb00 files in the same folder are:


pb00.sub0128.CSPLIN.r01.tcat+tlrc.BRIK	pb00.sub0128.CSPLIN.r02.tcat+tlrc.BRIK
pb00.sub0128.CSPLIN.r01.tcat+tlrc.HEAD	pb00.sub0128.CSPLIN.r02.tcat+tlrc.HEAD

Erik

Hi Erik,

I had forgotten about it, but that check for subject IDs is assuming orig space, not allowing for tlrc. I will make an update for it.

Just to be sure though, are your input datasets indeed already in standard space, or is that a conversion issue with NIFTI?

Thanks,

  • rick

Hi rick,

my input dataset are from the fmriprep preprocessing pipeline, and already in MNI152NLin2009cAsym standard space.

Best,
Erik

Okay, thanks, Erik.

I’ve been a bit distracted, sorry, but updated binaries are compiling right now, and should be available in the next couple of hours.

  • rick