AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
February 03, 2017 03:22PM
Hello,

Recently, I've attempted to add non-linear warping via auto_warp.py to our single-subject preprocessing. Given the results below, I've clearly done something very wrong. I'm at a loss for what even happened with this error, so any help would be appreciated!

Below is, in order:
1. The output containing the error text
2. The code that was run - the script also contains blurring, masking, etc after the section posted below, but this is where I've seen the error.
3. The command executed to run the code.

Thanks!



3dNwarpApply -source anat_mprage_unif+orig -master anat_final.ERwD004+orig -ainterp wsinc5 -nwarp anat.aff.qw_WARP.nii anat.aff.Xat.1D anat_mprage_unif_al_keep_mat.aff12.1D -prefix anat_w_skull_warped
++ 3dNwarpApply: AFNI version=AFNI_17.0.06 (Feb 1 2017) [64-bit]
++ Authored by: Zhark the Warped
*+ WARNING: If you are performing spatial transformations on an oblique dset,
such as ./anat_mprage_unif+orig.BRIK,
or viewing/combining it with volumes of differing obliquity,
you should consider running:
3dWarp -deoblique
on this and other oblique datasets in the same session.
See 3dWarp -help for details.
++ Oblique dataset:./anat_mprage_unif+orig.BRIK is 1.489115 degrees from plumb.
++ opened source dataset 'anat_mprage_unif+orig'
++ -master dataset is 'anat_final.ERwD004+orig'
++ Processing -nwarp *** Error in `3dNwarpApply': free(): invalid next size (fast): 0x0000000001c993d0 ***
======= Backtrace: =========
/usr/lib64/libc.so.6(+0x7d023)[0x7fc7b6f74023]
/usr/lib64/libz.so.1(gzclose_r+0x44)[0x7fc7b77cbc84]
3dNwarpApply[0x7e91f6]
3dNwarpApply[0x7d540e]
3dNwarpApply[0x7da4af]
3dNwarpApply[0x7e82c9]
3dNwarpApply[0x615fb2]
3dNwarpApply[0x5605b5]
3dNwarpApply[0x57194d]
3dNwarpApply[0x476940]
3dNwarpApply[0x47e85a]
3dNwarpApply[0x4801ca]
/usr/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fc7b6f18b15]
3dNwarpApply[0x408399]
======= Memory map: ========
00400000-009a9000 r-xp 00000000 fd:01 10226500 /opt/afni/3dNwarpApply
00ba8000-00bf3000 rw-p 005a8000 fd:01 10226500 /opt/afni/3dNwarpApply
00bf3000-00c38000 rw-p 00000000 00:00 0
01c85000-01ca6000 rw-p 00000000 00:00 0 [heap]
7fc7b0000000-7fc7b0021000 rw-p 00000000 00:00 0
7fc7b0021000-7fc7b4000000 ---p 00000000 00:00 0
7fc7b596d000-7fc7b5982000 r-xp 00000000 fd:01 6462588 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc7b5982000-7fc7b5b81000 ---p 00015000 fd:01 6462588 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc7b5b81000-7fc7b5b82000 r--p 00014000 fd:01 6462588 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc7b5b82000-7fc7b5b83000 rw-p 00015000 fd:01 6462588 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc7b5b83000-7fc7b5baa000 r-xp 00000000 fd:01 6426976 /usr/lib64/libexpat.so.1.6.0
7fc7b5baa000-7fc7b5daa000 ---p 00027000 fd:01 6426976 /usr/lib64/libexpat.so.1.6.0
7fc7b5daa000-7fc7b5dac000 r--p 00027000 fd:01 6426976 /usr/lib64/libexpat.so.1.6.0
7fc7b5dac000-7fc7b5dad000 rw-p 00029000 fd:01 6426976 /usr/lib64/libexpat.so.1.6.0
7fc7b5dad000-7fc7b5dce000 r-xp 00000000 fd:01 6427036 /usr/lib64/libxcb.so.1.1.0
7fc7b5dce000-7fc7b5fcd000 ---p 00021000 fd:01 6427036 /usr/lib64/libxcb.so.1.1.0
7fc7b5fcd000-7fc7b5fce000 r--p 00020000 fd:01 6427036 /usr/lib64/libxcb.so.1.1.0
7fc7b5fce000-7fc7b5fcf000 rw-p 00021000 fd:01 6427036 /usr/lib64/libxcb.so.1.1.0
7fc7b5fcf000-7fc7b5fd3000 r-xp 00000000 fd:01 6426692 /usr/lib64/libuuid.so.1.3.0
7fc7b5fd3000-7fc7b61d2000 ---p 00004000 fd:01 6426692 /usr/lib64/libuuid.so.1.3.0
7fc7b61d2000-7fc7b61d3000 r--p 00003000 fd:01 6426692 /usr/lib64/libuuid.so.1.3.0
7fc7b61d3000-7fc7b61d4000 rw-p 00004000 fd:01 6426692 /usr/lib64/libuuid.so.1.3.0
7fc7b61d4000-7fc7b61d6000 r-xp 00000000 fd:01 6427006 /usr/lib64/libXau.so.6.0.0
7fc7b61d6000-7fc7b63d6000 ---p 00002000 fd:01 6427006 /usr/lib64/libXau.so.6.0.0
7fc7b63d6000-7fc7b63d7000 r--p 00002000 fd:01 6427006 /usr/lib64/libXau.so.6.0.0
7fc7b63d7000-7fc7b63d8000 rw-p 00003000 fd:01 6427006 /usr/lib64/libXau.so.6.0.0
7fc7b63d8000-7fc7b63e1000 r-xp 00000000 fd:01 6450711 /usr/lib64/libXrender.so.1.3.0
7fc7b63e1000-7fc7b65e0000 ---p 00009000 fd:01 6450711 /usr/lib64/libXrender.so.1.3.0
7fc7b65e0000-7fc7b65e1000 r--p 00008000 fd:01 6450711 /usr/lib64/libXrender.so.1.3.0
7fc7b65e1000-7fc7b65e2000 rw-p 00009000 fd:01 6450711 /usr/lib64/libXrender.so.1.3.0
7fc7b65e2000-7fc7b6682000 r-xp 00000000 fd:01 6426603 /usr/lib64/libfreetype.so.6.10.0
7fc7b6682000-7fc7b6881000 ---p 000a0000 fd:01 6426603 /usr/lib64/libfreetype.so.6.10.0
7fc7b6881000-7fc7b6887000 r--p 0009f000 fd:01 6426603 /usr/lib64/libfreetype.so.6.10.0
7fc7b6887000-7fc7b6888000 rw-p 000a5000 fd:01 6426603 /usr/lib64/libfreetype.so.6.10.0
7fc7b6888000-7fc7b68c2000 r-xp 00000000 fd:01 6438009 /usr/lib64/libfontconfig.so.1.7.0
7fc7b68c2000-7fc7b6ac1000 ---p 0003a000 fd:01 6438009 /usr/lib64/libfontconfig.so.1.7.0
7fc7b6ac1000-7fc7b6ac3000 r--p 00039000 fd:01 6438009 /usr/lib64/libfontconfig.so.1.7.0
7fc7b6ac3000-7fc7b6ac4000 rw-p 0003b000 fd:01 6438009 /usr/lib64/libfontconfig.so.1.7.0
7fc7b6ac4000-7fc7b6ada000 r-xp 00000000 fd:01 6425165 /usr/lib64/libpthread-2.17.so
7fc7b6ada000-7fc7b6cda000 ---p 00016000 fd:01 6425165 /usr/lib64/libpthread-2.17.so
7fc7b6cda000-7fc7b6cdb000 r--p 00016000 fd:01 6425165 /usr/lib64/libpthread-2.17.so
7fc7b6cdb000-7fc7b6cdc000 rw-p 00017000 fd:01 6425165 /usr/lib64/libpthread-2.17.so
7fc7b6cdc000-7fc7b6ce0000 rw-p 00000000 00:00 0
7fc7b6ce0000-7fc7b6cf6000 r-xp 00000000 fd:01 6427209 /usr/lib64/libgomp.so.1.0.0
7fc7b6cf6000-7fc7b6ef5000 ---p 00016000 fd:01 6427209 /usr/lib64/libgomp.so.1.0.0
7fc7b6ef5000-7fc7b6ef6000 r--p 00015000 fd:01 6427209 /usr/lib64/libgomp.so.1.0.0
7fc7b6ef6000-7fc7b6ef7000 rw-p 00016000 fd:01 6427209 /usr/lib64/libgomp.so.1.0.0
7fc7b6ef7000-7fc7b70ad000 r-xp 00000000 fd:01 6425139 /usr/lib64/libc-2.17.so
7fc7b70ad000-7fc7b72ad000 ---p 001b6000 fd:01 6425139 /usr/lib64/libc-2.17.so
7fc7b72ad000-7fc7b72b1000 r--p 001b6000 fd:01 6425139 /usr/lib64/libc-2.17.so
7fc7b72b1000-7fc7b72b3000 rw-p 001ba000 fd:01 6425139 /usr/lib64/libc-2.17.so
7fc7b72b3000-7fc7b72b8000 rw-p 00000000 00:00 0
7fc7b72b8000-7fc7b72bb000 r-xp 00000000 fd:01 6425145 /usr/lib64/libdl-2.17.so
7fc7b72bb000-7fc7b74ba000 ---p 00003000 fd:01 6425145 /usr/lib64/libdl-2.17.so
7fc7b74ba000-7fc7b74bb000 r--p 00002000 fd:01 6425145 /usr/lib64/libdl-2.17.so
7fc7b74bb000-7fc7b74bc000 rw-p 00003000 fd:01 6425145 /usr/lib64/libdl-2.17.so
7fc7b74bc000-7fc7b75bd000 r-xp 00000000 fd:01 6425147 /usr/lib64/libm-2.17.so
7fc7b75bd000-7fc7b77bc000 ---p 00101000 fd:01 6425147 /usr/lib64/libm-2.17.so
7fc7b77bc000-7fc7b77bd000 r--p 00100000 fd:01 6425147 /usr/lib64/libm-2.17.so
7fc7b77bd000-7fc7b77be000 rw-p 00101000 fd:01 6425147 /usr/lib64/libm-2.17.so
7fc7b77be000-7fc7b77d3000 r-xp 00000000 fd:01 6426593 /usr/lib64/libz.so.1.2.7
Fatal Signal 6 (SIGABRT) received
THD_open_nifti
THD_open_one_dataset
THD_open_dataset
CW_read_dataset_warp
IW3D_read_nwarp_catlist
3dNwarpApply
Bottom of Debug Stack
** Command line was:
3dNwarpApply -source anat_mprage_unif+orig -master anat_final.ERwD004+orig -ainterp wsinc5 -nwarp anat.aff.qw_WARP.nii anat.aff.Xat.1D anat_mprage_unif_al_keep_mat.aff12.1D -prefix anat_w_skull_warped
** AFNI version = AFNI_17.0.06 Compile date = Feb 1 2017
** [[Precompiled binary linux_openmp_64: Feb 1 2017]]
** Program Death **
** If you report this crash to the AFNI message board,
** please copy the error messages EXACTLY, and give
** the command line you used to run the program, and
** any other information needed to repeat the problem.
** You may later be asked to upload data to help debug.
** Crash log is appended to file /home/usr/andersonn/.afni.crashlog



#!/bin/tcsh -xef

# execute via :
#   tcsh -xef proc.ERwD_Preprocessing_Sequential |& tee output.proc.ERwD_Preprocessing_Sequential

echo "(version 4.67, June 16, 2016)"
echo "execution started: `date`"

####################################################################################################
# There are two primary blocks to change in this script.
# The first is a pair of lines, just below this note.
# The second is a large block, farther down and also marked.
####################################################################################################


##################################################
# ***CHANGE***
# This is the list of subjects (VCnumbers, etc) you'd like to loop through
foreach subj_number (ERwD004 ERwD005 ERwD006 ERwD007 ERwD008 ERwD009 ERwD010 ERwD011 ERwD012 ERwD013 ERwD014 ERwD015 ERwD017 ERwD018)
# foreach subj_number (vc12345, vc12346, vc12347, vc12348, vc12349, vc12350)
##################################################

echo $subj_number

##################################################
# ***CHANGE***
# This is is the initial directory where all analyses will be saved.
cd /data/nil-external/mcl/Anderson/All_Script_Testing
##################################################

# mkdir $subj_number
#
# cd $subj_number
if ( -d subject_results ) then
	echo "subject_results directory already exists!"
else
	mkdir subject_results
endif

cd subject_results

# mkdir group.ERwD
#
# cd group.ERwD

mkdir subj.$subj_number

cd subj.$subj_number








# =========================== auto block: setup ============================
# script setup

# take note of the AFNI version
afni -ver

# check that the current AFNI version is recent enough
afni_history -check_date 28 Oct 2015
if ( $status ) then
	echo "** this script requires newer AFNI binaries (than 28 Oct 2015)"
	echo "   (consider: @update.afni.binaries -defaults)"
	exit
endif

# the user may specify a single subject to run with
if ( $#argv > 0 ) then
	set subj = $argv[1]
else
	set subj = $subj_number
endif

# assign output directory name
set output_dir = $subj.results

# verify that the results directory does not yet exist
if ( -d $output_dir ) then
	echo output dir "$subj.results" already exists
	exit
endif

# create results and stimuli directories
mkdir $output_dir
mkdir $output_dir/stimuli


echo "$output_dir"


##################################################
# ***CHANGE***

# This is the directory where each individual subject's data is kept (updates for each participant loop)
set input_dir='/data/nil-external/mcl/Anderson/All_Script_Testing/'"$subj"

# This is the MNI template file (does not update for each participant loop)
# Note: there is no need to change this unless you are not running on the Icarus server.
set mask_dir='/data/nil-external/mcl/tools/afni/MNI152_T1_2009c+tlrc'

# set list of runs
set runs = (`count -digits 2 1 9`) # the final digit is your number of runs (2 1 6 reads: 2 digit numbers, 1 through 6)

# and make note of repetitions (TRs) per run
set tr_counts = ( 314 314 314 314 314 314 314 314 314 )

# You only need to change the file extension after #$input_dir
# This is where each individual subject's T1 is located (updates for each participant loop)
3dcopy $input_dir/anat/coT1_"$subj".nii \
	$output_dir/anat_mprage


# ============================ auto block: tcat ============================
# apply 3dTcat to copy input dsets to results dir, while
# removing the first 0 TRs

# Change only the second part of each line (the absolute path to each individual subject's run data (updates for each participant loop)
# Make sure the number of runs match your run number. If you copy/paste, make sure to increment the run number (e.g.pb00.$subj.r08) in the first line
3dTcat -prefix+orig $output_dir/pb00.$subj.r01.tcat \
    $input_dir/func/Run01_"$subj"Encoding1.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r02.tcat \
    $input_dir/func/Run02_"$subj"Retrieval1a.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r03.tcat \
    $input_dir/func/Run03_"$subj"Retrieval1b.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r04.tcat \
    $input_dir/func/Run04_"$subj"Encoding2.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r05.tcat \
    $input_dir/func/Run05_"$subj"Retrieval2a.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r06.tcat \
    $input_dir/func/Run06_"$subj"Retrieval2b.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r07.tcat \
    $input_dir/func/Run07_"$subj"Encoding3.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r08.tcat \
    $input_dir/func/Run08_"$subj"Retrieval3a.nii'[0..$]'
3dTcat -prefix+orig $output_dir/pb00.$subj.r09.tcat \
    $input_dir/func/Run09_"$subj"Retrieval3b.nii'[0..$]'


# ***END OF CHANGES***
##################################################




# -------------------------------------------------------
# enter the results directory (can begin processing data)
cd $output_dir


# ========================= uniformity correction ==========================
# perform 'unifize' uniformity correction on anatomical dataset
3dUnifize -prefix anat_mprage_unif anat_mprage+orig


# ========================== auto block: outcount ==========================
# data check: compute outlier fraction for each volume
touch out.pre_ss_warn.txt
foreach run ( $runs )
	3dToutcount -automask -fraction -polort 3 -legendre                     \
				pb00.$subj.r$run.tcat+orig > outcount.r$run.1D

	# outliers at TR 0 might suggest pre-steady state TRs
	if ( `1deval -a outcount.r$run.1D"{0}" -expr "step(a-0.4)"` ) then
		echo "** TR #0 outliers: possible pre-steady state TRs in run $run" \
			>> out.pre_ss_warn.txt
	endif
end

# catenate outlier counts into a single time series
cat outcount.r*.1D > outcount_rall.1D


# ================================ despike =================================
# apply 3dDespike to each run
foreach run ( $runs )
    3dDespike -NEW -nomask -prefix pb01.$subj.r$run.despike         pb00.$subj.r$run.tcat+orig
end


## ================================= tshift =================================
## time shift data so all slice timing is the same
# foreach run ( $runs )
#     3dTshift -tzero 0 -quintic -prefix pb02.$subj.r$run.tshift \
#              pb01.$subj.r$run.despike
# end

### If above slice timing correction is unnecessary
### Simply create pb02 as an identical copy of pb01
### NOTE: DO NOT use slice timing correction if your scans use multiband sequences
foreach run ( $runs )
	3dcopy pb01.$subj.r$run.despike pb02.$subj.r$run.tshift
end



# --------------------------------
# extract volreg registration base
3dbucket -prefix vr_base pb02.$subj.r01.tshift+orig"[2]"


# ================================= align ==================================
# for e2a: compute anat alignment transformation to EPI registration base
# (new anat will be intermediate, stripped, anat_mprage_ns+orig)
align_epi_anat.py -anat2epi -anat anat_mprage_unif+orig  \
       -suffix _al_keep                             \
	   -epi vr_base+orig -epi_base 0                \
	   -epi_strip 3dAutomask                        \
	   -volreg off -tshift off						\
	   -cost lpc+zz


# ================================== tlrc ==================================
# warp anatomy to standard space
auto_warp.py -base MNI152_T1_2009c+tlrc -input anat_mprage_unif_al_keep+orig \
             -skull_strip_input no -unifize_input no

# move results up out of the awpy directory
# (NL-warped anat, affine warp, NL warp)
# (use typical standard space name for anat)
# (wildcard is a cheap way to go after any .gz)
3dbucket -prefix anat_mprage_unif_al_keep                           \
    awpy/anat_mprage_unif_al_keep.aw.nii*
mv awpy/anat.aff.Xat.1D .
mv awpy/anat.aff.qw_WARP.nii .


# ================================= volreg =================================
# align each dset to base volume
foreach run ( $runs )
    # register each volume to the base
    3dvolreg -verbose -zpad 1 -base vr_base+orig                         \
             -1Dfile dfile.r$run.1D -prefix pb03.$subj.r$run.volreg      \
             -cubic                                                      \
             pb02.$subj.r$run.tshift+orig
end

# make a single file of registration params
cat dfile.r*.1D > dfile_rall.1D

# compute motion magnitude time series: the Euclidean norm
# (sqrt(sum squares)) of the motion parameter derivatives
1d_tool.py -infile dfile_rall.1D -set_nruns 9                            \
           -derivative  -collapse_cols euclidean_norm                    \
           -write motion_${subj}_enorm.1D

# create an anat_final dataset, aligned with stats
3dcopy anat_mprage_unif_al_keep+orig anat_final.$subj

# -----------------------------------------
# warp anat follower datasets (non-liner)
3dNwarpApply -source anat_mprage_unif+orig                              \
             -master anat_final.$subj+orig                               \
             -ainterp wsinc5 -nwarp anat.aff.qw_WARP.nii anat.aff.Xat.1D \
             anat_mprage_unif_al_keep_mat.aff12.1D                      \
             -prefix anat_w_skull_warped



tcsh -xef proc.ERwD_Preprocessing_Sequential | & tee output.proc.ERwD_Preprocessing_Sequential
Subject Author Posted

Fatal error using 3dNwarpApply

nlanderson9 February 03, 2017 03:22PM

Re: Fatal error using 3dNwarpApply

Daniel Glen February 04, 2017 10:23PM

Re: Fatal error using 3dNwarpApply

nlanderson9 February 07, 2017 05:30PM

Re: Fatal error using 3dNwarpApply

nlanderson9 February 09, 2017 01:39PM

Re: Fatal error using 3dNwarpApply

Daniel Glen February 09, 2017 04:05PM

Re: Fatal error using 3dNwarpApply

nlanderson9 February 14, 2017 10:45AM