Dear AFNI experts:
I am new to this software, I have four groups of data, One is sham-Control, the other is after treatment.
Control before, Control after
Treatment before, Treatment after
actually, control before is likely to treatment before
I want to use afni to compare this 4 groups, within group and between group
The data format is img/hdr
I don’t know how to convert it into nii data
I have T2 anatomical data and resting functional data, and I also have the rat atlas wax_rat_T2 downloaded.
also I have watched some videos, but I didn’t see the tutorial of rat data.
Hope someone can give me some help guiding me to analyze correctly.
Thanks a lot.
Hi-
For converting img/hdr files to NIFTI, you can use 3dcopy, for example:
3dcopy FILE_IN.hdr FILE_OUT.nii
In terms of setting up a pipeline for RS-FMRI, using Rick’s tool afni_proc.py is probably the best way to go. There is an interactive GUI for setting up the command the first time, as well as a number of complete examples in the help file for that function; for RS-FMRI, examples #9-11 are the most modern, I believe:
afni_proc.py -hview
or
afni_proc.py -help
I think it might be fair to say that Daniel is the inhuman expert here… I mean, expert on non-human data analyses. As proof, see:
https://afni.nimh.nih.gov/afni/community/board/read.php?1,149239,149239
Perhaps as you develop your pipeline he might be able to weigh in more about rat-specific options/settings that would be useful.
For group analysis, there are tools like 3dttest++, 3dANOVA, 3dMVM, 3dLME, etc. depending on your data and questions of interest. Gang has put several examples of various cases in each of those.
So, those would be the initial places to look, I think, and any questions can be asked here, of course. There might be additionally useful documents/scripts in the AFNI Bootcamp demo, which can be gotten most easily through Step #2 here:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/bootcamp_stuff.html
–pt
Hi
Thank you very much.
I have tried uber_subject.py, but it comes up with error.
the anatomical image I put the atlas
the epi image I put the single session functional data
Should I change the parameters or I have to realign my functional data to my anatomical data, then realign again to the atlas?
Thanks again
Hi-
When getting errors from a function, please copy+paste the exact error so we know what is happening (it is also possible to search the Message Board using the error messages, or even with The Google, as often people have suffered similar woes before, and we might have helped them-- while we try to respond here pretty quickly (even on Federal holidays!!), that might be even faster). Also, having the output from “afni -ver” helps us know what version/system of AFNI you have, which can be necessary information. Note-- I’m afraid the image attachments weren’t working, as far as I can see.
For EPI data, you can put a single set; if you have multiple runs for a single subject that you would like analyzed in concatenated form, that is possible as well.
For anatomical data set, that should probably be the subject’s own anatomical (say, a T1w/MPRAGE or something). You can enter the standard template and use it as a template, separately.
Here are a couple presentations about FMRI (and a bit specifically on RS-FMRI) processing. These are in the afni_handouts directory of the Bootcamp, where there are also a lot more things to read.
https://afni.nimh.nih.gov/pub/dist/edu/latest/afni_handouts/afni16_start_to_finish.pdf
https://afni.nimh.nih.gov/pub/dist/edu/latest/afni_handouts/afni23_restingstate.pdf
and about alignment:
https://afni.nimh.nih.gov/pub/dist/edu/latest/afni_handouts/afni10_volreg_talairach.pdf
And note, if your error message above dealt with not being able to find some package, please see whichever installation instruction suits you best here:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/index.html
for Mac or Linux.
–pt
Hi Daniel
I have tried uber_subject.py to analyze data.
My raw data, both anatomical and functional image are 10 slices, when I click on anat has skull.
It pops up error with image <16 slices, can’t skull stripping.
So I tried to click off this option, following is my error again.
echo auto-generated by afni_proc.py, Tue May 30 10:53:06 2017
auto-generated by afni_proc.py, Tue May 30 10:53:06 2017
echo (version 5.15, April 25, 2017)
(version 5.15, April 25, 2017)
echo execution started: `date`
date
execution started: 2017å¹´ 5æ30æ¥ é±äº 10æ53å07ç§ CST
afni -ver
Precompiled binary macosx_10.7_local: May 2 2017 (Version AFNI_17.1.03)
afni_history -check_date 23 Sep 2016
-- is current: afni_history as new as: 23 Sep 2016
most recent entry is: 02 May 2017
if ( 0 ) then
if ( 0 > 0 ) then
set subj = a1
endif
set output_dir = a1.results
if ( -d a1.results ) then
set runs = ( `count -digits 2 1 1` )
count -digits 2 1 1
mkdir a1.results
mkdir a1.results/stimuli
3dcopy Desktop/Wei_Control/test/T2/T2.nii.gz a1.results/T2
++ 3dcopy: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
e[7m*+ WARNING:e[0m NO spatial transform (neither qform nor sform), in NIfTI file 'Desktop/Wei_Control/test/T2/T2.nii.gz'
3dTcat -prefix a1.results/pb00.a1.r01.tcat Desktop/Wei_Control/test/8/4D.nii.gz[0..$]
++ 3dTcat: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
e[7m*+ WARNING:e[0m NO spatial transform (neither qform nor sform), in NIfTI file 'Desktop/Wei_Control/test/8/4D.nii.gz'
++ elapsed time = 0.4 s
set tr_counts = ( 250 )
cd a1.results
touch out.pre_ss_warn.txt
foreach run ( 01 )
3dToutcount -automask -fraction -polort 4 -legendre pb00.a1.r01.tcat+orig
++ 3dToutcount: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ 10360 voxels passed mask/clip
if ( `1deval -a outcount.r$run.1D"{0}" -expr "step(a-0.4)"` ) then
1deval -a outcount.r01.1D{0} -expr step(a-0.4)
end
cat outcount.r01.1D
foreach run ( 01 )
3dTshift -tzero 0 -quintic -prefix pb01.a1.r01.tshift pb00.a1.r01.tcat+orig
++ 3dTshift: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
e[7m*+ WARNING:e[0m dataset is already aligned in time!
e[7m*+ WARNING:e[0m ==>> output dataset is just a copy of input dataset
end
3dbucket -prefix vr_base pb01.a1.r01.tshift+orig[2]
++ 3dbucket: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
align_epi_anat.py -anat2epi -anat T2+orig -suffix _al_junk -epi vr_base+orig -epi_base 0 -epi_strip 3dAutomask -anat_has_skull no -volreg off -tshift off
#++ align_epi_anat version: 1.57
#++ turning off volume registration
#Script is running:
3dAttribute DELTA /Users/louis/a1.results/vr_base+orig
#Script is running:
3dAttribute DELTA /Users/louis/a1.results/vr_base+orig
#Script is running:
3dAttribute DELTA /Users/louis/a1.results/T2+orig
#++ Multi-cost is lpc
#++ Removing all the temporary files
#Script is running:
\rm -f ./__tt_vr_base*
#Script is running:
\rm -f ./__tt_T2*
#Script is running:
3dcopy /Users/louis/a1.results/T2+orig /Users/louis/a1.results/__tt_T2+orig
++ 3dcopy: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
#Script is running (command trimmed):
3dinfo ./__tt_T2+orig | \grep 'Data Axes Tilt:'|\grep 'Oblique'
#++ Dataset /Users/louis/a1.results/__tt_T2+orig is not oblique
#Script is running (command trimmed):
3dinfo ./vr_base+orig | \grep 'Data Axes Tilt:'|\grep 'Oblique'
#++ Dataset /Users/louis/a1.results/vr_base+orig is not oblique
#++ using 0th sub-brick because only one found
#Script is running (command trimmed):
3dbucket -prefix ./__tt_vr_base_ts ./vr_base+orig'[0]'
++ 3dbucket: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
#++ resampling epi to match anat data
#Script is running (command trimmed):
3dresample -master ./__tt_T2+orig -prefix ./__tt_vr_base_ts_rs -inset ./__tt_vr_base_ts+orig'' -rmode Cu
#++ removing skull or area outside brain
#Script is running (command trimmed):
3dAutomask -apply_prefix ./__tt_vr_base_ts_rs_ns ./__tt_vr_base_ts_rs+orig
++ 3dAutomask: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: Emperor Zhark
++ Loading dataset ./__tt_vr_base_ts_rs+orig
++ Forming automask
+ Fixed clip level = 1140.982544
+ Used gradual clip level = 379.947205 .. 1596.214966
+ Number voxels above clip level = 37570
+ Clustering voxels ...
+ Largest cluster has 36200 voxels
+ Clustering voxels ...
+ Largest cluster has 26772 voxels
+ Filled 254 voxels in small holes; now have 27026 voxels
+ Filled 504 voxels in large holes; now have 27530 voxels
+ Clustering voxels ...
+ Largest cluster has 27526 voxels
+ Clustering non-brain voxels ...
+ Clustering voxels ...
+ Largest cluster has 136305 voxels
+ Mask now has 27535 voxels
++ 27535 voxels in the mask [out of 163840: 16.81%]
++ first 18 x-planes are zero [from L]
++ last 31 x-planes are zero [from R]
++ first 29 y-planes are zero [from P]
++ last 35 y-planes are zero [from A]
++ first 0 z-planes are zero [from I]
++ last 0 z-planes are zero [from S]
++ applying mask to original data
++ Writing masked data
++ CPU time = 0.030000 sec
#++ Computing weight mask
#Script is running (command trimmed):
3dBrickStat -automask -percentile 90.000000 1 90.000000 ./__tt_vr_base_ts_rs_ns+orig
#++ Applying threshold of 3383.000000 on /Users/louis/a1.results/__tt_vr_base_ts_rs_ns+orig
#Script is running (command trimmed):
3dcalc -datum float -prefix ./__tt_vr_base_ts_rs_ns_wt -a ./__tt_vr_base_ts_rs_ns+orig -expr 'min(1,(a/3383.000000))'
++ 3dcalc: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: A cast of thousands
#++ Aligning anat data to epi data
#Script is running (command trimmed):
3dAllineate -lpc -wtprefix ./__tt_T2_al_junk_wtal -weight ./__tt_vr_base_ts_rs_ns_wt+orig -source ./__tt_T2+orig -prefix ./T2_al_junk -base ./__tt_vr_base_ts_rs_ns+orig -nocmass -1Dmatrix_save ./T2_al_junk_mat.aff12.1D -master SOURCE -weight_frac 1.0 -maxrot 6 -maxshf 10 -VERB -warp aff -source_automask+4 -onepass
++ 3dAllineate: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: Zhark the Registrator
++ Source dataset: ./__tt_T2+orig.HEAD
++ Base dataset: ./__tt_vr_base_ts_rs_ns+orig.HEAD
++ Loading datasets
++ 68847 voxels in -source_automask+4
++ Zero-pad: zbot=4 ztop=4
++ 27535 voxels [9.3%] in weight mask
++ Number of points for matching = 27535
++ Local correlation: blok type = 'RHDD(17.1019)'
++ shift param auto-range: -79.6..79.6 -79.6..79.6 -54.6..54.6
+ Range param#4 [z-angle] = -6.000000 .. 6.000000
+ Range param#5 [x-angle] = -6.000000 .. 6.000000
+ Range param#6 [y-angle] = -6.000000 .. 6.000000
+ Range param#1 [x-shift] = -10.000000 .. 10.000000
+ Range param#2 [y-shift] = -10.000000 .. 10.000000
+ Range param#3 [z-shift] = -10.000000 .. 10.000000
+ 12 free parameters
++ Normalized convergence radius = 0.001000
++ OpenMP thread count = 4
++ ======= Allineation of 1 sub-bricks using Local Pearson Correlation Signed =======
++ ========== sub-brick #0 ========== [total CPU to here=0.1 s]
++ *** Fine pass begins ***
+ * Enter alignment setup routine
+ - copying base image
+ - copying source image
+ - copying weight image
+ - using 27535 points from base image [use_all=0]
+ * Exit alignment setup routine
+ 21519 total points stored in 90 'RHDD(17.1645)' bloks
+ - Initial cost = 0.061035
+ - Initial fine Parameters = 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 1.0000 1.0000 0.0000 0.0000 0.0000
+ - Finalish cost = 0.061035 ; 82 funcs
+ - Final cost = 0.061035 ; 117 funcs
+ Final fine fit Parameters:
x-shift= 0.0000 y-shift= 0.0000 z-shift= 0.0000
z-angle= 0.0000 x-angle= 0.0000 y-angle= 0.0000
x-scale= 1.0000 y-scale= 1.0000 z-scale= 1.0000
y/x-shear= 0.0000 z/x-shear= 0.0000 z/y-shear= 0.0000
+ - Fine net CPU time = 0.2 s
++ Computing output image
++ image warp: parameters = 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 1.0000 1.0000 0.0000 0.0000 0.0000
++ Output dataset ./T2_al_junk+orig.BRIK
++ Wrote -1Dmatrix_save ./T2_al_junk_mat.aff12.1D
++ 3dAllineate: total CPU time = 0.3 sec Elapsed = 0.3
++ ###########################################################
++ # Please check results visually for alignment quality #
++ ###########################################################
++ # '-autoweight' is recommended when using -lpc or -lpa #
++ # If your results are not good, please try again. #
++ ###########################################################
#++ Creating final output: anat data aligned to epi
# copy is not necessary
#++ Saving history
#Script is running (command trimmed):
3dNotes -h "align_epi_anat.py -anat2epi -anat T2+orig -suffix _al_junk -epi \
vr_base+orig -epi_base 0 -epi_strip 3dAutomask -anat_has_skull no -volreg \
off -tshift off" ./T2_al_junk+orig
#++ Removing all the temporary files
#Script is running:
\rm -f ./__tt_vr_base*
#Script is running:
\rm -f ./__tt_T2*
# Finished alignment successfully
@auto_tlrc -base TT_N27+tlrc -input T2+orig -no_ss
*********** Warning *************
Dataset centers are 189.464398 mm
apart. If registration fails, or if
parts of the original anatomy gets
cropped, try adding option
-init_xform AUTO_CENTER
to your @auto_tlrc command.
*********************************
Padding ...
++ 3dZeropad: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ output dataset: ./__ats_tmp__ref_TT_N27_40pad+tlrc.BRIK
Resampling ...
++ 3dcalc: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: A cast of thousands
++ 3dcalc: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: A cast of thousands
Clipping 82.999900 32766.000100 ...
++ 3dcalc: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: A cast of thousands
++ 3drefit: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: RW Cox
++ Processing AFNI dataset __ats_tmp___rs_T2+tlrc.HEAD
+ Changed dataset view type and filenames.
++ 3drefit processed 1 datasets
++ 3drefit: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: RW Cox
++ Processing AFNI dataset __ats_tmp__resamp_NN+tlrc.HEAD
+ Changed dataset view type and filenames.
++ 3drefit processed 1 datasets
++ 3drefit: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: RW Cox
++ Processing AFNI dataset __ats_tmp__resamp_edge_art+tlrc.HEAD
+ Changed dataset view type and filenames.
++ 3drefit processed 1 datasets
Registration (linear final interpolation) ...
++ 3dWarpDrive: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: RW Cox
RMS[0] = 112.247 82.1031 ITER = 137/137
112.247
Warping used up maximum iterations of 137
Convergence might not have
been reached.
Doubling number of iterations
++ 3drename: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ THD_rename_dataset_files: rename __ats_tmp__reg_warpdriveout+orig.HEAD -> __ats_tmp__reg_warpdriveout_maxed_iters+orig.HEAD
++ THD_rename_dataset_files: rename __ats_tmp__reg_warpdriveout+orig.BRIK -> __ats_tmp__reg_warpdriveout_maxed_iters+orig.BRIK
++ 3dWarpDrive: AFNI version=AFNI_17.1.03 (May 2 2017) [64-bit]
++ Authored by: RW Cox
RMS[0] = 112.247 82.1031 ITER = 274/274
112.247
Warping used up maximum iterations
even after doubling number of iterations to 274.
Convergence might not have been reached.
If you find the alignment poor, try
rerunning the script with a transform
type of fewer parameters (-xform) or by using
an even higher number of iterations (-maxite).
You can also choose to continue with the
current result (dset: __ats_tmp__reg_warpdriveout+orig
by using the option: -OK_maxite
Script will stop ...
cat_matvec T2+tlrc::WARP_DATA -I
e[7m** ERROR:e[0m THD_read_dvecmat: can't open dataset T2+tlrc
e[7m** FATAL ERROR:e[0m Can't read matrix from 'T2+tlrc::WARP_DATA'
** Program compile date = May 2 2017
I also want to know what kind of parameters (FWHM, motion sensor limit, etc) should I determing to analyze.
My TR is 2000ms.
Further one more question, should I enlarge my image before analyzing?
my resolution is 0.3125 at first, because when using SPM have to enlarge resolution first, so I enlarge into 3.125?
Thanks you again.
Louis