Giter VIP home page Giter VIP logo

afni / afni Goto Github PK

View Code? Open in Web Editor NEW
149.0 19.0 100.0 150.8 MB

Official AFNI source and documentation

Home Page: https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/

C 78.46% Shell 4.52% Makefile 0.47% C++ 1.53% Perl 0.03% R 2.18% HTML 0.17% TeX 0.34% Fortran 0.42% Stata 0.01% PostScript 0.18% Clean 0.01% Io 0.01% CMake 0.34% SAS 0.02% Smalltalk 0.01% Assembly 0.01% MATLAB 1.13% Tcl 0.01% Python 10.18%
anatomical-mri dwi fmri fmri-analysis fmri-data-analysis mri quality-control statistical-inference statistics visualization

afni's Introduction

What is AFNI?

AFNI (Analysis of Functional NeuroImages) is a suite of programs for looking at and analyzing MRI brain images at all stages of analysis (planning, setting up acquisition, preprocessing, analysis, quality control and statistical analysis). It contains C, Python and R programs, as well as shell scripts, primarily developed for the analysis and display of multiple MRI modalities:

  • functional MRI (FMRI)
    • resting state, task-based or naturalistic paradigms
    • single- or multi-echo acquisitions
  • anatomical/structural MRI
    • at various field strengths
  • diffusion weighted imaging (DWI)
    • for DTI or HARDI modeling and tractography

Many AFNI programs have been applied and adapted to other modalities, such as ECoG, EEG, MEG, and more.

It has graphical displays for both slice-wise and surface-based viewing. In both cases, many aspects of visualization can be scripted for automatic image generation.

Please visit these websites for more information and to ask questions:

Install AFNI on your computer

You can install AFNI on various Linux, macOS and Windows systems. Detailed instructions for each system are provided here. This is the way most users get the AFNI code to use.

Please make sure to use the AFNI system check to help guide you in the process, as well facilitate asking questions:

afni_system_check.py -check_all

Getting started with AFNI: quick guide links

Additional software collaborations

AFNI benefits from integration and collaboration with several other actively developed neuroimaging software packages. We greatly appreciate the work of (and often the discussions with) their developers, and note some of these projects here. Further useful dependencies are cited within the codebase.

The following software are distributed within AFNI directly:

  • dcm2niix, included as dcm2niix_afni
  • NiiVue, included as niivue_afni.umd.js

AFNI also has several programs and features that complement directly with the following projects:

  • FreeSurfer, via @SUMA_Make_Spec_FS and afni_proc.py
  • LayNii, for layer FMRI processing and visualization
  • tedana, via afni_proc.py
  • TORTOISE, via the FATCAT and other DWI tools in AFNI

One aspect of AFNI's wide usage and motivation for maintaining long-term stability is that it serves as an underlying part within several other software projects and pipeline tools in the field. Some projects that use AFNI include:

  • BrainSuite: Functional Pipeline: open-source workflow for processing FMRI data
  • C-PAC: Configurable Pipeline for the Analysis of Connectomes software package
  • DPABI: Data Processing & Analysis for Brain Imaging software suite
  • ENIGMA HALFpipe: software from a consortium combining imaging and genetics
  • fMRIPrep: FMRI preprocessing pipeline that combines tools from well-known software packages
  • LONI QC: data review platform for neuroimaging studies with one or more centers
  • NeoRS: Neonatal Resting State fMRI data preprocessing pipeline
  • NeuroDebian: an open, turnkey platform for neuroscience, integrating software
  • NeuroDesk: open platform of data analysis environments for reproducible neuroimaging
  • Nipype: an open-source initiative to integrate different packages in a workflow

NIFTI and GIFTI

AFNI developers also lead the maintenance of the following fundamental neuroimaging repositories:

These are the code for the standard volumetric and surface dataset formats, respectively, in MRI. These formats are central to how software input/output standard data, and most neuroimaging packages in the field (including AFNI itself) use at least one of these formats.

NIFTI was first developed by a consortium of neuroimaging developers in 2004, with AFNI's Bob Cox being a primary architect and first author of the format description, which is still so widely used today:

AFNI code directory

Currently, the top directory contains three sub-directories, each with further code stratification:

doc/

documentation for AFNI (though this is outdated; current doc content resides in its own git tree here: https://github.com/afni/afni_doc)

src/

source code for AFNI

src/python_scripts/

Python command programs and library files; distributed together as the afnipy module, which can be imported and used as:

from afnipy import ...

tests/

tests for AFNI codebase

Compilation of AFNI

In addition to standard installation of AFNI on computers, you can also compile the code locally on your computer (e.g., for development). In src/, you need to choose one of the Makefile.* files that is closest to your system, and cp it to be named Makefile. Makefile is set up to install into the INSTALLDIR location, defined in that file -- you should probably change that to be appropriate for your use.

If you are using Mac OS X, choose one of the Makefile.macosx* files.

For later versions of Mac OS X, Apple's C compiler does not support OpenMP, so we recommend downloading and installing a version of gcc from http://hpc.sourceforge.net/ or purchasing a commercial C compiler (e.g., Intel's icc) that does support OpenMP. Several important programs in the AFNI suite are parallelized via OpenMP, and will run much faster if compiled appropriately.

If you are using Linux, try Makefile.linux_openmp_64 first.

To make and install everything do:

make vastness

The command:

make cleanest

will remove all the *.o files, etc.

Making a pull request to the AFNI code base

Notes for making a fork and pull request to AFNI are provided here:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/devdocs/pull_requests/pr_ex.html
Users and developers are also welcome to open up GitHub Issues here:
https://github.com/afni/afni/issues
We also have a very active Message Board for asking questions about using AFNI programs, getting help with installations, seeing new features, staying up-to-date with Bootcamp and other announcements, and more:
https://discuss.afni.nimh.nih.gov/

Online testing notes

image

image

image

afni's People

Contributors

afni-dglen avatar afni-discoraj avatar afni-gangc avatar afni-laurenpd avatar afni-rickr avatar afni-rwcox avatar afni-ziad avatar afnihq avatar ccraddock avatar cesarcaballerogaudes avatar discoraj avatar effigies avatar eurunuela avatar hanayik avatar imnotamember avatar ischwabacher avatar jlisinski avatar leej3 avatar mrneont avatar nno avatar otagoharbour avatar pintohutch avatar pmolfese avatar pn2200 avatar rmarkello avatar roopchansinghv avatar schoffelen avatar shotgunosine avatar thechymera avatar yarikoptic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

afni's Issues

afni_proc difficulties with compression flag on.

When running an afni_proc.py script with the .afnirc flag:
AFNI_COMPRESSOR = GZIP // force all .BRIK output to be compressed
afni proc has an error when running the a portion of the tlrc block.
Error and surrounding text:

# Finished alignment successfully

auto_warp.py -base /home/dowdlelt/abin/MNI152_T1_2009c+tlrc -input sub-8035ctbs_SurfVol_ns+orig -skull_strip_input no -qw_opts -minpatch 11
#++ auto_warp.py version: 0.03
# Output directory /mnt/morpheus/tbs_opiate/models/afni/pain_pre/sub-8035ctbs_volm_TED.results/awpy/
#Script is running (command trimmed):
  mkdir ./awpy/
cd /mnt/morpheus/tbs_opiate/models/afni/pain_pre/sub-8035ctbs_volm_TED.results/awpy/
#Script is running (command trimmed):
  3dcopy /mnt/morpheus/tbs_opiate/models/afni/pain_pre/sub-8035ctbs_volm_TED.results/sub-8035ctbs_SurfVol_ns+orig ./anat.nii
++ 3dcopy: AFNI version=AFNI_18.1.04 (Apr 12 2018) [64-bit]
#Script is running (command trimmed):
  3dUnifize -GM -input ./anat.nii -prefix ./anat.un.nii
++ 3dUnifize: AFNI version=AFNI_18.1.04 (Apr 12 2018) [64-bit]
 + Pre-processing: ADV......UWG
++ Output dataset ./anat.un.nii.gz
++ ===== Elapsed = 14.7 sec
#Script is running (command trimmed):
  3dcopy /home/dowdlelt/abin/MNI152_T1_2009c+tlrc ./base.nii
++ 3dcopy: AFNI version=AFNI_18.1.04 (Apr 12 2018) [64-bit]
#++ Aligning /mnt/morpheus/tbs_opiate/models/afni/pain_pre/sub-8035ctbs_volm_TED.results/awpy/base.nii data to /mnt/morpheus/tbs_opiate/models/afni/pain_pre/sub-8035ctbs_volm_TED.results/awpy/anat.un.nii data
#Script is running (command trimmed):
  @auto_tlrc -base ./base.nii -input ./anat.un.nii -suffix .aff -no_ss -no_pre -init_xform CENTER 
Error: template (or -apar) dset not found: ./base.nii
#**ERROR Failed in affine step
** ERROR - script failed
3dbucket: No match.

Note the end, where the template dataset is not found - if I go to the directory it is looking in (awpy/), I find three files, all compressed.
anat.nii.gz
anat_un.gz
base.nii.gz

Script runs with no error if the compression flag is commented back out.

FYI: https://afni.nimh.nih.gov/pub/dist/data/misc/ is not reachable ATM

although it is for 2018 bootcamp, I saw a link on https://codeconvergence.org/ to the prior test dataset. Thought to prepare datalad dataset with all needed materials (for the past year to start with). but apparently it is NA

$> wget https://afni.nimh.nih.gov/pub/dist/data/misc/UCLA_pamenc20.tgz
--2019-10-10 11:38:07--  https://afni.nimh.nih.gov/pub/dist/data/misc/UCLA_pamenc20.tgz
Resolving afni.nimh.nih.gov (afni.nimh.nih.gov)... 156.40.187.114, 2607:f220:419:4103::114
Connecting to afni.nimh.nih.gov (afni.nimh.nih.gov)|156.40.187.114|:443... failed: Connection timed out.
Connecting to afni.nimh.nih.gov (afni.nimh.nih.gov)|2607:f220:419:4103::114|:443... failed: Network is unreachable.
1 35347 ->4.....................................:Thu 10 Oct 2019 11:38:23 AM EDT:.
hopa:/tmp
$> sudo tcptraceroute afni.nimh.nih.gov 80                                  
[sudo] password for yoh: 
Running:
	traceroute -T -O info -p 80 afni.nimh.nih.gov 
traceroute to afni.nimh.nih.gov (156.40.187.114), 30 hops max, 60 byte packets
 1  _gateway (10.31.176.1)  2.411 ms  2.541 ms  3.003 ms
 2  berry1-crt.border1-rt.dartmouth.edu (129.170.1.42)  1.769 ms  2.626 ms  4.030 ms
 3  i2-cleveland.border1-rt.dartmouth.edu (129.170.9.241)  5.231 ms  5.567 ms  5.987 ms
 4  et-7-0-0.4079.rtsw.bost.net.internet2.edu (162.252.70.97)  10.707 ms  10.735 ms  10.734 ms
 5  et-7-0-0.4079.rtsw.hart2.net.internet2.edu (162.252.70.99)  13.909 ms  13.919 ms  13.915 ms
 6  ae-2.4079.rtsw.newy32aoa.net.internet2.edu (162.252.70.101)  17.212 ms  15.466 ms  13.843 ms
 7  ae-3.4079.rtsw.wash.net.internet2.edu (162.252.70.138)  19.019 ms  19.033 ms  19.001 ms
 8  ae-0.4079.rtsw2.ashb.net.internet2.edu (162.252.70.137)  19.128 ms  19.140 ms  19.167 ms
 9  ae-2.4079.rtsw.ashb.net.internet2.edu (162.252.70.74)  19.161 ms  18.741 ms  18.556 ms
10  et-11-3-0-1275.clpk-core.maxgigapop.net (206.196.177.2)  19.263 ms  19.545 ms  19.815 ms
11  nih-re.demarc.maxgigapop.net (206.196.177.183)  20.745 ms  20.754 ms  20.723 ms
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *

AFNI build system

Hi, for a while I have been trying to package AFNI for Gentoo - see the old discussion on afniHQ and the long standing pull request of AFNI on gentoo-science.

A while ago, I heard setting up a build system (CMake?) is on the to-do list for the AFNI team. This would go a long way in helping create sustainable package atoms on Gentoo (and many other distributions). Do you have any updates or a timeline on this?

question: how affines are applied to oblique datasets

I'm applying an affine transform to a dataset where I artificially rotated the affine.

I get the habitual warning about the dataset>

++ 3dAllineate: AFNI version=AFNI_16.0.01 (Jan 27 2016) [64-bit]
++ Authored by: Zhark the Registrator
** AFNI converts NIFTI_datatype=2 (UINT8) in file someones_anatomy_rot.nii.gz to FLOAT32
     Warnings of this type will be muted for this session.
     Set AFNI_NIFTI_TYPE_WARN to YES to see them all, NO to see none.
*+ WARNING:   If you are performing spatial transformations on an oblique dset, 
  such as someones_anatomy_rot.nii.gz,
  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:someones_anatomy_rot.nii.gz is 5.156967 degrees from plumb.
++ Oblique dataset:someones_anatomy_rot.nii.gz is 5.156967 degrees from plumb.
++ Source dataset: ./someones_anatomy_rot.nii.gz
++ Base dataset:   ./someones_anatomy_rot.nii.gz
++ You might want to use '-master' when using '-1D*_apply'
++ Loading datasets
++ master dataset for output = base
++ OpenMP thread count = 8

The question is: how does 3dAllineate build the dicom 4x4 matrix for moving and reference image? Does it consider both? Looking at the results, the image's affines (ref and moving) seem to be first rotated to zero from plumb.

Bonus question: is there an executable in AFNI to which I input 4 homogeneous coordinates (x, y, z, 1) and returns them after applying the transform matrix (i.e. dot product with a transform given in DICOM 4x4 homogeneous coordinate system).

For a deeper context, check https://github.com/oesteban/BIDS-X5/blob/master/01%20-%20Preparing%20images.ipynb

/bin/sh: 2: Bad substitution but works with /bin/bash on debian sid

My eyes and foo is tired, not sure what it complaints about:

(git)hopa:~exppsy/afni-upstream[nf-ctest]src/XmHTML
$> make -n
( for dir in lib ; do \
    (set -x ; cd $dir ; make  all SHELL='/bin/sh' VERSION='1107' CC='cc' RM='rm -f' AR='ar cq ' MV='mv' CP='cp' LN='ln -sf' RANLIB='ranlib' MAKEDEPEND='gccmakedep' CFLAGS='' LDFLAGS='' CPPFLAGS='-DNDEBUG -DHAVE_REGEX_H -DHAVE_LIBJPEG  -DMotif' INCLUDES='-I. -I../include -I../include/common -I../../include -I../../include/common -I../../../jpeg-6b -I../../include/XmHTML -I/usr/X11R6/include  ' LOADLIBES='-L/usr/X11R6/lib -L../../.. -lXm -lXpm -lXmu -lXt -lXext -lX11 -lSM -lICE -ljpeg -lpng -lz -lm' DMALLOCLIB='' ZLIBLIB='-lz -lm' PLATFORM='Motif' ) ; \
done)
/bin/sh: 2: Bad substitution
Makefile:203: recipe for target 'all' failed
make: *** [all] Error 2

it builds fine after in there

-SHELL     = /bin/sh
+SHELL     = /bin/bash
$> make -n     
( for dir in lib ; do \
    (set -x ; cd $dir ; make  all SHELL='/bin/bash' VERSION='1107' CC='cc' RM='rm -f' AR='ar cq ' MV='mv' CP='cp' LN='ln -sf' RANLIB='ranlib' MAKEDEPEND='gccmakedep' CFLAGS='' LDFLAGS='' CPPFLAGS='-DNDEBUG -DHAVE_REGEX_H -DHAVE_LIBJPEG  -DMotif' INCLUDES='-I. -I../include -I../include/common -I../../include -I../../include/common -I../../../jpeg-6b -I../../include/XmHTML -I/usr/X11R6/include  ' LOADLIBES='-L/usr/X11R6/lib -L../../.. -lXm -lXpm -lXmu -lXt -lXext -lX11 -lSM -lICE -ljpeg -lpng -lz -lm' DMALLOCLIB='' ZLIBLIB='-lz -lm' PLATFORM='Motif' ) ; \
done)
(:1): 
cd lib
(:1): 
make all SHELL=/bin/bash VERSION=1107 CC=cc 'RM=rm -f' 'AR=ar cq ' MV=mv CP=cp 'LN=ln -sf' RANLIB=ranlib MAKEDEPEND=gccmakedep CFLAGS= LDFLAGS= 'CPPFLAGS=-DNDEBUG -DHAVE_REGEX_H -DHAVE_LIBJPEG  -DMotif' 'INCLUDES=-I. -I../include -I../include/common -I../../include -I../../include/common -I../../../jpeg-6b -I../../include/XmHTML -I/usr/X11R6/include  ' 'LOADLIBES=-L/usr/X11R6/lib -L../../.. -lXm -lXpm -lXmu -lXt -lXext -lX11 -lSM -lICE -ljpeg -lpng -lz -lm' DMALLOCLIB= 'ZLIBLIB=-lz -lm' PLATFORM=Motif
make[1]: Entering directory '/home/yoh/deb/gits/pkg-exppsy/afni-upstream/src/XmHTML/lib'
(set -x; cd common; make all  )
(:0): 
cd common
(:0): 
make all
make[2]: Entering directory '/home/yoh/deb/gits/pkg-exppsy/afni-upstream/src/XmHTML/lib/common'
rm -f events.o
cc  -DVERSION=1107 -DNDEBUG -DHAVE_REGEX_H -DHAVE_LIBJPEG  -DMotif -I. -I../include -I../include/common -I../../include -I../../include/common -I../../../jpeg-6b -I../../include/XmHTML -I/usr/X11R6/include   -c events.c
rm -f hash.o
...

Consider the text diffs

The typical approach used currently to test command line tools is to run them and compare the output with a previously saved output to see if changes have occurred. For text files, certain trivial differences occur from run to run. Currently in order to minimize such noise paths, hostname, and username are altered to eliminate these and sources of extraneous difference. Additionally when each line is considered trailing "" and spaces are removed. considering extending these to encompass more trivial differences that we do not wish to detect.

When run in osx, afni_proc.py currently has such an extraneous difference. Consider this as you consider the text diffs.

question: optimal "workflow" for hierarchical(?) model

we have following levels

  • 5 studies (different PIs, different or the same scanners/scanning params, similar designs)
  • ~100 subjects per study
  • up to 2 sessions
  • 2-3 runs (depending on a study, sensored away some runs/subjects so 2 runs are guaranteed to have)

variables of interest

  • basic task contrasts (motor, n-back memory)
  • we will initially start with no additional variables just to check if all is good with a QA condition (motor) but then expand with demographics (per subject/session such as age) and clinical assessments (per session)

notes:

  • within some studies might be different magnets (and their software versions) used for portion of subject/sessions. Not sure if worth adding as a group/level, but worth at least trying to absorb some variance into additional variables of non (or may be of) interest
  • we would start with the a single session, and only 3 studies of the same age group but then would like to use both sessions in studies were available and account/analyze different age groups

What would be the best tool and approach to model this large scale study using AFNI to pull everything together? ;-)

Dependencies for Debian 8

I'm building on Debian 8 for the first time. I've used the suggested 'Makefile.linux_openmp_64' for a Makefile.

So far, these are the packages I've needed to install for make to continue running:

libxmu-dev
libmotif-dev (for MainW.h)
libxmhtml-dev (for libXmHTML.a)

Is there a doc that suggests other deps I may need?

Unbundling imcat

I just nocticed that afni ships its own version of imcat. On Gentoo we have a package for that software. So I will just make AFNI depend on that. However, I would also like to stop AFNI from trying to get/install that file itself. How can I best do this?

Failing ctest using Travis

(Issue was originally posted on the AFNI message board: https://afni.nimh.nih.gov/afni/community/board/read.php?1,155735,155735#msg-155735)

ctest shows failures on the travis ci environment (see [travis-ci.org]):

23.28s$ ctest
Test project /home/travis/build/afni/afni/testing
Start 1: afni:start
1/2 Test #1: afni:start ....................... Passed 5.98 sec
Start 2: do.examples
2/2 Test #2: do.examples ......................***Failed 17.24 sec
50% tests passed, 1 tests failed out of 2
Label Time Summary:
GLX = 17.24 sec
Total Test time (real) = 23.23 sec
The following tests FAILED:
2 - do.examples (Failed)
Errors while running CTest
The command "ctest" exited with 8.

As for the underlying cause, I noticed that the issue seems to have started when travis changed from the older "Precise" to the newer "Trustry" environment. A temporary fix would thus be to explicitly set the environnment to be "Precise" as explained here: https://docs.travis-ci.com/user/precise-to-trusty-migration-guide/. This would require just adding a single line to .travis.yml, and then travis is again useful to catch compilation errors (amongst other things).

For the long term it would be preferably to find out why the second do.examples fails and fix the underlying issue - that way the tests also work using Trusty, and use of travis to test AFNI is more "future-proof".

ping @yarikoptic: any ideas how we can diagnose the issue? Can we get more verbose output when running the ctest tests?

Add documentation of setting up for, running, adding, and maintaining tests

Add a guide for the testing process in AFNI.
Current rough. guideline is described [here].(https://docs.google.com/document/d/1j8DxfA215sxC77Spcn_Ap0Xd8QYY3CBFCeL6jkxA-RU/edit?usp=sharing)

A good place to write some more extensive docs is here though. Requires sphinx know how to add the docs.

Apart from extending and cleaning up the current rough guide one could:

  • Add some images to guide one through the process.
  • Discuss installation of dependencies (as in briefly describe docker execution and Conda env creation, make sure environment specification will work on osx and linux).

Add some useful example pytest/datalad/annex commands. This can largely be references to the appropriate online resources but some standalone examples might help too.

Error while using 3dICC

Good afternoon AFNI experts.

I'm attempting to look at two different ways to quantify diffusion FA scalars while examining some other factors (e.g. differences across sites and demographic info related to noise), but I get the following error in the output:

Error in $<-.data.frame(*tmp*, "InputFile", value = character(0)) :
replacement has 0 rows, data has 630
Calls: $&lt;- -&gt; $&lt;-.data.frame
Execution halted

It looks like an issue with moving between data frames in R but I am unsure of what exactly is wrong. Input file (info redacted) and output file attached.
ICC_Files_exp.txt
FBIRN_ICC_output.txt

add warning when --sample_save_output flag is used with pytest outside dev container

The current approach to testing extensively compares most of the output of any tool that tests are added for. The extent may have to be reduced but for now this is the approach.

In order to decrease the noisiness of any such diffs, the host, user, and paths in any text output are replaced with a template. Despite this, some small trivial diffs do still occur between systems. While these can be eliminated slowly on a test by test basis and by adding some more heuristics to reduce the noisiness, it may be a good idea to create sample output in a consistent compute environment. The development docker container is an ideal candidate for this. Time will tell whether such an approach is required but since this is the environment that circleci will be using it would be useful to at least add a warning if sample output is saved to the test data repository when the container was not used.

Get python code's test coverage working with circleci

coverage.py is a widely used tool for gather coverage metrics for testing python code. It's mechanism is described here. The configuration needs to be tweaked to get this working for AFNI's testing. The fact that the python code is put on the path and executed rather than installed as a package may be causing problems. A couple of quick attempts at trying to get this working failed by either including all python code across all site-packages that were used, or not including everything.

Add more tests

Test coverage stands at a mighty 5%. Much code is part of a GUI and so more difficult to test, other 3rd party code that has been included in the stats, or python code that does actually have some tests but is not currently included in the metrics. Nevertheless, there is much room for improvement. Some basic tests for some of the most popular tools would be especially helpful. All one needs is a text editor, a little time, some courage, and a little guidance.

If you so choose, a guide to adding tests can be found here.

When choosing what to test you could consider the rating for the estimated utility of each tool provided here. Alternatively if you know of something that you think might be broken, formulate a test for it that would pass if said functionality worked as you expected.

3dvolreg incorrect exit code and "ERROR: nifti_image_write_hdr_img: NBL does not match nim"

3dvolreg exits with code 0 despite errors, produces empty file

root@c1af530c4591:/workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/motion_correct# 3dvolreg -Fourier -twopass -1Dfile sub-1211283_task-rest_run-05_echo-1_bold.1D -1Dmatrix_save sub-1211283_task-rest_run-05_echo-1_bold.aff12.1D -prefix sub-1211283_task-rest_run-05_echo-1_bold_volreg.nii.gz -base /workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/gen_ref/ref_image.nii.gz -zpad 4 -maxdisp1D sub-1211283_task-rest_run-05_echo-1_bold_md.1D /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz
++ 3dvolreg: AFNI version=AFNI_17.3.03 (Nov  9 2017) [64-bit]
++ Authored by: RW Cox
** AFNI converts NIFTI_datatype=4 (INT16) in file /workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/gen_ref/ref_image.nii.gz to FLOAT32
     Warnings of this type will be muted for this session.
     Set AFNI_NIFTI_TYPE_WARN to YES to see them all, NO to see none.
*+ WARNING:   If you are performing spatial transformations on an oblique dset,
  such as /workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/gen_ref/ref_image.nii.gz,
  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:/workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/gen_ref/ref_image.nii.gz is 5.458872 degrees from plumb.

** WARNING: NIfTI file /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz dimensions altered since AFNI extension was added
++ Oblique dataset:/workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz is 5.458872 degrees from plumb.
++ Coarse del was 10, replaced with 5
++ Max displacement in automask = 0.65 (mm) at sub-brick 191
++ Max delta displ  in automask = 0.12 (mm) at sub-brick 159
** ERROR: nifti_image_write_hdr_img: NBL does not match nim
root@c1af530c4591:/workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/motion_correct# echo $?
0
root@c1af530c4591:/workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/motion_correct# ls -al sub-1211283_task-rest_run-05_echo-1_bold*
-rwxr-xr-x 1 root root 10962 Feb 22 19:58 sub-1211283_task-rest_run-05_echo-1_bold.1D
-rwxr-xr-x 1 root root 34154 Feb 22 19:58 sub-1211283_task-rest_run-05_echo-1_bold.aff12.1D
-rwxr-xr-x 1 root root  2096 Feb 22 19:58 sub-1211283_task-rest_run-05_echo-1_bold_md.1D
-rwxr-xr-x 1 root root  2095 Feb 22 19:58 sub-1211283_task-rest_run-05_echo-1_bold_md_delt.1D
-rwxr-xr-x 1 root root     0 Feb 22 19:58 sub-1211283_task-rest_run-05_echo-1_bold_volreg.nii.gz

Exit codes aside. ** WARNING: NIfTI file /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz dimensions altered since AFNI extension was added could be indicative of the source of the problem. I tried to figure out what could be wrong with the input file:

root@c1af530c4591:/workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/motion_correct# nifti_tool -check_hdr -infiles /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz
header IS GOOD for file /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz
root@c1af530c4591:/workdir/workflow_enumerator/funcMRIQC/fMRI_HMC_afni/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/motion_correct# 3dinfo /workdir/workflow_enumer
ator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.nii.gz                                   
++ 3dinfo: AFNI version=AFNI_17.3.03 (Nov  9 2017) [64-bit]                                                                                                                                               
                                                                                                                                                                                                          
** WARNING: NIfTI file /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1
_bold.nii.gz dimensions altered since AFNI extension was added                                                                                                                                            
                                                                                                                                                                                                          
Dataset File:    /workdir/workflow_enumerator/funcMRIQC/_in_file_..data..sub-1211283..func..sub-1211283_task-rest_run-05_echo-1_bold.nii.gz/reorient_and_discard/sub-1211283_task-rest_run-05_echo-1_bold.
nii.gz                                                                                                                                                                                                    
Identifier Code: XYZ_EJN5zDF2d61ciZLni3tslw  Creation Date: Mon Aug 29 11:02:35 2016                                                                                                                      
Template Space:  ORIG                                                                                                                                                                                     
Dataset Type:    Echo Planar (-epan)                                                                                                                                                                      
Byte Order:      LSB_FIRST {assumed} [this CPU native = LSB_FIRST]                                                                                                                                        
Storage Mode:    NIFTI                                                                                                                                                                                    
Storage Space:   96,816,384 (97 million [mega]) bytes                                                                                                                                                     
Geometry String: "MATRIX(3,0,0,-107.1,0,2.986394,0.285395,-126.892,0,-0.285395,2.986394,-80.7645):72,72,46"                                                                                               
Data Axes Tilt:  Oblique (5.459 deg. from plumb)                                                                                                                                                          
Data Axes Approximate Orientation:                                                                                                                                                                        
  first  (x) = Left-to-Right                                                                                                                                                                              
  second (y) = Posterior-to-Anterior                                                                                                                                                                      
  third  (z) = Inferior-to-Superior   [-orient LPI]                                                                                                                                                       
R-to-L extent:  -107.100 [R] -to-   105.900 [L] -step-     3.000 mm [ 72 voxels]                                                                                                                          
A-to-P extent:  -127.858 [A] -to-    85.142 [P] -step-     3.000 mm [ 72 voxels]                                                                                                                          
I-to-S extent:  -101.028 [I] -to-    33.972 [S] -step-     3.000 mm [ 46 voxels]                                                                                                                          
Number of time steps = 204  Time step = 3.00000s  Origin = 0.00000s  Number time-offset slices = 46  Thickness = 3.000                                                                                    
  -- At sub-brick #0 '?' datum type is short:            0 to         16328                                                                                                                               
  -- At sub-brick #1 '?' datum type is short:            0 to         13029                                                                                                                               
  -- At sub-brick #2 '?' datum type is short:            0 to         13109                                                                                                                               
** For info on all 203 sub-bricks, use '3dinfo -verb' **                                                                                                                                                  
                                                                                                                                                                                                          
----- HISTORY -----                                                                                                                                                                                       
[[email protected]: Mon Aug 29 11:02:33 2016] to3d -prefix run05.e01.nii -time:zt 46 204 3.0sec alt+z 000001_b86a.dcm 000002_b86b.dcm 000003_b86c.dcm ... 009383_25d3.dcm 009384_25d6.dcm

Ideas?

SUMA: Intercepted X11 error: BadWindow (invalid Window parameter)

cmake build, as of AFNI_19.3.12-13-g8673efbd6 (currently fix_suma_and_add_system_install_management branch of https://github.com/leej3/afni
), suma fails to start with

(git)lena:…ppsy/afni-upstream[fix_suma_and_add_system_install_management]obj-build
$> src/suma                 

suma: 
     No input specified, loading some toy surfaces...
     Use '.' and ',' to cycle between them.
     See suma -help for assistance.

oo     Warning SUMA_XErrHandler (../src/SUMA/SUMA_display.c:4148):
Intercepted X11 error: BadWindow (invalid Window parameter)
Will attempt to proceed but trouble might ensue.
++     Notice SUMA_XErrHandler (../src/SUMA/SUMA_display.c:4150 @11:32:49):
Trace At Xerr
    SUMA_XErrHandler
   SUMA_X_SurfaceViewer_Create
  suma
 Bottom of Debug Stack
oo     Warning SUMA_XErrHandler (../src/SUMA/SUMA_display.c:4148):
Intercepted X11 error: BadWindow (invalid Window parameter)
Will attempt to proceed but trouble might ensue.
++     Notice SUMA_XErrHandler (../src/SUMA/SUMA_display.c:4150 @11:32:49):
Trace At Xerr
    SUMA_XErrHandler
   SUMA_X_SurfaceViewer_Create
  suma
 Bottom of Debug Stack
oo     Warning SUMA_XErrHandler (../src/SUMA/SUMA_display.c:4148):
Intercepted X11 error: BadWindow (invalid Window parameter)
Will attempt to proceed but trouble might ensue.
++     Notice SUMA_XErrHandler (../src/SUMA/SUMA_display.c:4150 @11:32:49):
Trace At Xerr
    SUMA_XErrHandler
   SUMA_X_SurfaceViewer_Create
  suma
 Bottom of Debug Stack
Error: No realize class procedure defined

it was built on debian testing/sid with

mkdir -p obj-build && cd obj-build && cmake -GNinja -DBUILD_BINARIES=ON -DBUILD_X_DEPENDENT_GUI_PROGS=ON -DBUILD_OPENGL_DEPENDENT_GUI_PROGS=ON -DBUILD_PLUGINS=ON -DUSE_OMP=ON -DUSE_SYSTEM_XMHTML=ON .. && time ninja && ninja pytest

happen you decide to reproduce

Any ideas on how to troubleshoot it? Just in case:

ldd on suma
$> ldd src/suma                                                                                                                                                                                                
	linux-vdso.so.1 (0x00007ffeabf6d000)
	libmrix.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libmrix.so (0x00007f16f9c45000)
	libmri.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libmri.so (0x00007f16f8b80000)
	libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f16f8a0d000)
	libXt.so.6 => /lib/x86_64-linux-gnu/libXt.so.6 (0x00007f16f89a2000)
	libglut.so.3 => /lib/x86_64-linux-gnu/libglut.so.3 (0x00007f16f8955000)
	libGLw.so.1 => /lib/x86_64-linux-gnu/libGLw.so.1 (0x00007f16f874e000)
	libSUMA.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libSUMA.so (0x00007f16f78f0000)
	libOpenGL.so.0 => /lib/x86_64-linux-gnu/libOpenGL.so.0 (0x00007f16f78bf000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f16f76ff000)
	libcoxplot.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libcoxplot.so (0x00007f16f75b5000)
	libXmHTML.so.1.1 => /lib/x86_64-linux-gnu/libXmHTML.so.1.1 (0x00007f16f7335000)
	libXm.so.4 => /lib/x86_64-linux-gnu/libXm.so.4 (0x00007f16f6e67000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f16f6d20000)
	libnetcdf.so.13 => /lib/x86_64-linux-gnu/libnetcdf.so.13 (0x00007f16f6bdf000)
	lib3DEdge.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/lib3DEdge.so (0x00007f16f6bc4000)
	libeispack.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libeispack.so (0x00007f16f6b7e000)
	libvolpack.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libvolpack.so (0x00007f16f6b1c000)
	libnifti2.so.2.8.9 => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libnifti2.so.2.8.9 (0x00007f16f6aea000)
	libf2cdir.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libf2cdir.so (0x00007f16f6ac8000)
	libnifticdf.so.2.8.9 => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libnifticdf.so.2.8.9 (0x00007f16f6aa2000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f16f6a85000)
	libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f16f6a5b000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f16f6a56000)
	libSM.so.6 => /lib/x86_64-linux-gnu/libSM.so.6 (0x00007f16f6a49000)
	libICE.so.6 => /lib/x86_64-linux-gnu/libICE.so.6 (0x00007f16f682c000)
	libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f16f6798000)
	libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f16f6586000)
	libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007f16f6376000)
	libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f16f6170000)
	libtrack_tools.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libtrack_tools.so (0x00007f16f6054000)
	libsegtools.so => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libsegtools.so (0x00007f16f6033000)
	libGLU.so.1 => /lib/x86_64-linux-gnu/libGLU.so.1 (0x00007f16f5fc2000)
	libXmu.so.6 => /lib/x86_64-linux-gnu/libXmu.so.6 (0x00007f16f5fa5000)
	libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f16f5f71000)
	libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f16f5eb4000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f16f9de6000)
	libXpm.so.4 => /lib/x86_64-linux-gnu/libXpm.so.4 (0x00007f16f5ca0000)
	libXft.so.2 => /lib/x86_64-linux-gnu/libXft.so.2 (0x00007f16f5a8a000)
	libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f16f5a44000)
	libjpeg.so.62 => /lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f16f57db000)
	libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f16f57a2000)
	libhdf5_serial_hl.so.100 => /lib/x86_64-linux-gnu/libhdf5_serial_hl.so.100 (0x00007f16f577a000)
	libhdf5_serial.so.103 => /lib/x86_64-linux-gnu/libhdf5_serial.so.103 (0x00007f16f53f5000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f16f53d4000)
	libcurl-gnutls.so.4 => /lib/x86_64-linux-gnu/libcurl-gnutls.so.4 (0x00007f16f5346000)
	libznz.so.2.8.9 => /home/yoh/deb/gits/pkg-exppsy/afni-upstream/obj-build/src/libznz.so.2.8.9 (0x00007f16f5341000)
	libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f16f513b000)
	libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f16f4f35000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f16f4f2c000)
	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f16f4f12000)
	libgsl.so.23 => /lib/x86_64-linux-gnu/libgsl.so.23 (0x00007f16f4c89000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f16f4aae000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f16f4a94000)
	libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f16f49d5000)
	libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f16f47cb000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f16f479e000)
	libsz.so.2 => /lib/x86_64-linux-gnu/libsz.so.2 (0x00007f16f4797000)
	libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f16f476f000)
	libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f16f474f000)
	librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f16f4730000)
	libssh2.so.1 => /lib/x86_64-linux-gnu/libssh2.so.1 (0x00007f16f4702000)
	libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f16f46ef000)
	libnettle.so.7 => /lib/x86_64-linux-gnu/libnettle.so.7 (0x00007f16f46b2000)
	libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f16f44ed000)
	libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f16f44a1000)
	libldap_r-2.4.so.2 => /lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f16f444c000)
	liblber-2.4.so.2 => /lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f16f443b000)
	libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f16f442d000)
	libgslcblas.so.0 => /lib/x86_64-linux-gnu/libgslcblas.so.0 (0x00007f16f43ea000)
	libaec.so.0 => /lib/x86_64-linux-gnu/libaec.so.0 (0x00007f16f43e1000)
	libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f16f425f000)
	libhogweed.so.5 => /lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007f16f4226000)
	libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f16f41a3000)
	libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f16f4084000)
	libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f16f3f54000)
	libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f16f3f3e000)
	libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f16f3e5e000)
	libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f16f3e2d000)
	libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f16f3e27000)
	libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f16f3e16000)
	libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f16f3e0f000)
	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f16f3df7000)
	libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f16f3dda000)
	libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f16f3db7000)
	libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f16f3d92000)
	libffi.so.6 => /lib/x86_64-linux-gnu/libffi.so.6 (0x00007f16f3d88000)

wishlist: few new tags and a 'milestone'

Would be nice to have 'testing' tag so in the future you could annotate PR
And then it might be worth adding few Milestones:

  • "cmake build"
  • "comprehensive test coverage"

looking forward for some bright future when those things would happen ;)

warning: rewriting history in the AFNI repo

@zsaad @nno @ccraddock @kaczmarj @Shotgunosine @pintohutch @yarikoptic @jlisinski @CesarCaballeroGaudes @imnotamember @pmolfese @hjmjohnson @roopchansinghv @dillonplunkett @DavidEWarrenPhD @rdvincent Hi all, this is a quick warning to anyone working with the AFNI/afni repo.
@leej3 is about to reduce this repo size, which will rewrite the commit history, basically breaking any currently existing branch (except for those who particularly like to suffer).
Once this change is made, if you want to make edits, start with a fresh copy (fork/clone/pull/whatever) of the repo, before your changes are introduced.
If there is any reason this would be problematic for you, please let us know by Thursday. Otherwise, the destruction will commence on Friday. Thanks!

Return error code when to3d quits due to -quit_on_err flag

When to3d (called via Dimon) exits because of an error that throws the -quit_on_err flag, it returns with a successful return code (0) rather than an error code. This makes it difficult to detect a failure programmatically when using Dimon as part of a larger workflow.

Concatenate affine transforms

Following up on #116, now that I'm capable of replicating deoblique matrices AFNI calculates, my next step would be composing them with another transform (even identity).

Is there any AFNI tool to compose WARPDRIVE_MATVEC_FOR_000000 and WARPDRIVE_MATVEC_INV_000000 with some other affine in the middle?
Ideally, I could have a 3dallineate file with 3 rows and the tool would give me 1 row. Whatever other solution is also fine.

Finally I would check the following:

  1. Apply the original transform with the original oblique datasets.
  2. Deoblique the datasets (moving/reference, input/base) and then apply the transform coming from combining the (de)oblique matrices as described above.

Both should give the same result (or very close) if nearest is used in interpolation.

Orientation matrix changes when using volreg block in afni_proc.py

Hello,

For multi-echo processing, I use the convenient afni_proc.py to prepare & execute processing steps. In this case : tshift, volreg.
After converting back to Nifti files at the end using 3dAFNItoNIFTI, I noticed the orientation matrix changed. And I don't see why.

Here is the afni_proc.py code :

 cd /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04; 
 afni_proc.py -subj_id 2019_05_20_NEUROTOPLEX_Sujet04 \
 -out_dir /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni \
 -scr_overwrite \
 -dsets_me_run /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/e*.nii \
 -dsets_me_run /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/e*.nii \
 -blocks tshift volreg \
 -tshift_interp -heptic \
 -tshift_opts_ts -TR 1.3 -tpattern @/mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/sliceonsets.txt \
 -reg_echo 1                  \
 -volreg_align_to first       \
 -volreg_interp -quintic      \
 -volreg_zpad 4               \
 -execute \
 
 3dAFNItoNIFTI -verb -verb -prefix /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/vte1.nii /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni/pb02.2019_05_20_NEUROTOPLEX_Sujet04.r01.e01.volreg+orig 
 3dAFNItoNIFTI -verb -verb -prefix /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/vte2.nii /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni/pb02.2019_05_20_NEUROTOPLEX_Sujet04.r01.e02.volreg+orig 
 3dAFNItoNIFTI -verb -verb -prefix /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/vte3.nii /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni/pb02.2019_05_20_NEUROTOPLEX_Sujet04.r01.e03.volreg+orig 
 3dAFNItoNIFTI -verb -verb -prefix /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/vte1.nii /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni/pb02.2019_05_20_NEUROTOPLEX_Sujet04.r02.e01.volreg+orig 
 3dAFNItoNIFTI -verb -verb -prefix /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/vte2.nii /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni/pb02.2019_05_20_NEUROTOPLEX_Sujet04.r02.e02.volreg+orig 
 3dAFNItoNIFTI -verb -verb -prefix /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1/vte3.nii /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/afni/pb02.2019_05_20_NEUROTOPLEX_Sujet04.r02.e03.volreg+orig 

Here is the orientation matrix:


benoit.beranger@icm-cenir-le33: /mnt/data/benoit/project/job_meica_afni/neurotoplex/nifti/2019_05_20_NEUROTOPLEX_Sujet04/S12_Run_Visuel_1 $ mrinfo e1.nii vte1.nii 
************************************************
Image:               "e1.nii"
************************************************
  Dimensions:        74 x 74 x 48 x 696
  Voxel size:        3 x 3 x 3 x 1300
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1
  Data type:         unsigned 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0        -108
                               -0      0.9751     -0.2215      -80.29
                               -0      0.2215      0.9751       -77.1
************************************************
Image:               "vte1.nii"
************************************************
  Dimensions:        74 x 74 x 48 x 696
  Voxel size:        3 x 3 x 3 x 1.3
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1          -0          -0        -108
                                0           1          -0      -80.29
                               -0           0           1       -77.1

Before I was using -volreg_align_to MIN_OUTLIER and in some rare cases, the the brain as cropped because of shifted down.
Now I changed to first and it seem to be more stable, no brain cropped.
But still, I would like to know why the orientation changes.

Best,
Benoît

Add tests to confirm that the test infrastructure is working.

Currently the approach to testing is to run command line tools and then to test the outputs of the tool to varying degrees of resolution. So for example, with certain patterns ignored, text fails are compared and changes will cause the test to fail. Or for an output nifty file, the data matrix is compared against a previous example output and deviation in values outside of a specified tolerance will cause the test to fail. These various file comparison approaches should have tests written for them to make sure that any changes will not breaking pre-existing functionality.

A basic start has been made on this in test_testing_infrastructure.py but a more rigorous set of tests will be useful. These would just make sure that as the various approaches to diffing evolve an array of known output comparisons raise errors or pass appropriately.

unexpected exit using 3dWarp -verb -card2oblique

Hello everyone,

With this version Dec 22 2017 {AFNI_17.3.09:linux_openmp_64}, I had no problem (described bellow).
I just updated the binaries with Jun 3 2018 {AFNI_18.1.24:linux_openmp_64} and this problem appeared with this command :

3dWarp -verb -card2oblique ./run001_e001.nii[0] -overwrite -newgrid 1.000000 -prefix ./anat_ob.nii.gz /mnt/data/img/Pilote001/meica/anat_ns.nii.gz | \grep -A 4 '# mat44 Obliquity Transformation ::' > run001_e001_obla2e_mat.1D

With the old version, no problem.

With the new version, the script (generated by meica.py) exits, and the file run001_e001_obla2e_mat.1D is empty.

Cheers,
Benoît

merge conflict creeped in

$> grep -3 '^=======$' doc/afni_sphinx/background_install/install_instructs/steps_linux_ubuntu.rst 
                               gsl-bin netpbm gnome-tweak-tool libjpeg62
       sudo apt-get update
<<<<<<< HEAD
=======
       sudo ln -s /usr/lib/x86_64-linux-gnu/libgsl.so /usr/lib/libgsl.so.0
>>>>>>> 31d43c483a998f37b1db449973bf51b52eab8650

from fefd528

Add tests for test data directory submodules behavior for a git checkout of previous commits.

The tests will likely require mocking a code repo containing a submodule that is a Datalad repo.

Any issues arising from the wrong submodule version being checked out or a dirty working tree, should only be reported/ causes issues when running tests.

Upon running a test session the appropriate data tree should be checked out seamlessly.

Consider the optimal behavior for dealing with a dirty working tree in the test data repo. Likely, running tests with a dirty data tree should be allowed but a failure should occur early if running with --save_sample_output or running when a checkout to an older commit is required. It could possibly be reported at the end of a test session too and give some guidance.

Afni website not accessible

There seems to be a problem with https://afni.nimh.nih.gov
Depending on the browser I get messages like "This site can’t provide a secure connection" and "ERR_SSL_PROTOCOL_ERROR" on every computer.

While the site is not accessible, is there an alternative source to download the AFNI binaries (for Mac OS)?

3dSkullStrip linking to X server libraries?

We have noticed that, except for AFNI 16.0.00 through 16.2.07, some X server libraries are linked (libGLU I think) and 3dSkullStrip will not run if a viable $DISPLAY is not available. The typical symptoms were reported here before.

This problem is particularly hard on headless setups, where an X server is generally not running. One could try to use Xvfb on a random display port, but this solution is not very robust. And once in a while you would get errors like:

3dSkullStrip -input /usr/local/src/mriqc/work/workflow_enumerator/anatMRIQCT1w/AFNISkullStripWorkflow/_in_file_..data..sub-11..ses-day2..anat..sub-11_ses$
freeglut (3dSkullStrip): failed to open display ':1286930384'

with return code 1.

We are aware that there is a wrapper to Xvfb in AFNI called @chauffeur_afni that addresses this very issue. But the question is: is it really necessary linking these libraries for 3dSkullStrip to work? If not, it would be very much appreciated to clean up those links for a robuster performance on head-less settings.

[wishlist] Unique names for AFNI commands

FWIW, in light of #58 , my whining -- it is because of such commands with generic names we force ppl to source /etc/afni/afni.sh. Ideally, mimicking git etc, all afni commands should have a unique prefix (e.g. afni-) and an entry point helper (well, afni is taken but could be afni-command echoing wb_command of connectome workbench which took similar approach)

Documentation Discrepancy in unWarpEPI.py

In /abin/unWarpEPI.py, the help text notes that the script can be used to undistort EPI images using a B0 map:

Routine to unwarp EPI data set using another data set with opposite polarity or B0 field map

However, the source doesn't contain any facilities for doing so and there are no command line arguments to do so. Is there a function to undistort B0's related to unWarpEPI.py? And if not, could the documentation be rewritten to reflect that it must be a reverse phase encode?

Thanks so much!

[wishlist] afni data repository

Now that you are all git/github, I wondered if it would be sensible to ask you to also take care about data files (atlases, templates, ...) in a similar version controlled manner one way or another, so that we could prepare NeuroDebian afni pkgs releases without scavenging through binary AFNI releases .

Overall possible setup could be -- a separate afni/data git repository with those, added as a submodule within afni/afni repo. Ideally you might even want that repository be a git-annex repository (so with time, when/if files change you don't make repository "unmanageable"), so data files themselves wouldn't be pushed to github but to some other publicly available git repo (e.g. on nih's http server).

You could even make it not as a submodule but straight within this repository I guess (if git-annex repo, so there is no heavy impact on codebase .git/objects). If just directly to git, then submodule would be preferable, so that you still have clear versioned association between code and data, but not demanding cloning all the data when getting the source code base. git submodules though require some practice to get used to work with.

If you think that it is a sensible strategy to proceed (and which one -- with submodule or without, with git-annex or without), we could prepare a PR and outline instructions on how to manage it in the future. In either case it should help to keep afni "github source distribution" complete and sufficient to build it in full.

afni_proc.py using volreg when the field of view changed

Hello,

During a scan, the subject had to get out of the magnet between 2 fMRI scans of the same task.
So the orientation differs a bit between the two runs.

Here is the orientation matrix, and a screenshot of the volume :

************************************************
Image:               "S12_Run_Visuel_1/e2.nii"
************************************************
  Dimensions:        74 x 74 x 48 x 698
  Voxel size:        3 x 3 x 3 x 1300
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1
  Data type:         unsigned 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0        -108
                               -0      0.9641     -0.2656      -64.58
                               -0      0.2656      0.9641      -68.89
************************************************
Image:               "S20_Run_Visuel_2/e2.nii"
************************************************
  Dimensions:        74 x 74 x 48 x 699
  Voxel size:        3 x 3 x 3 x 1300
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1
  Data type:         unsigned 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0        -108
                               -0      0.9641     -0.2656      -73.83
                               -0      0.2656      0.9641      -90.48

run1_run2_raw

After run afni_proc.py with the same workflow as #107 (comment), the new orientation matrix and screenshot of the volume are :

************************************************
Image:               "S12_Run_Visuel_1/vte2.nii"
************************************************
  Dimensions:        74 x 74 x 48 x 698
  Voxel size:        3 x 3 x 3 x 1.3
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1          -0          -0        -108
                                0           1          -0      -64.58
                               -0           0           1      -68.89
************************************************
Image:               "S20_Run_Visuel_2/vte2.nii"
************************************************
  Dimensions:        74 x 74 x 48 x 699
  Voxel size:        3 x 3 x 3 x 1.3
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1          -0          -0        -108
                                0           1          -0      -73.83
                               -0           0           1      -90.48

run1_run2_after_tshift_volreg

I know volreg block using 3dvolreg & 3dAllineate did job as expected.
However, there must be a trick to avoid this brain cropped.
Maybe 3drefit have some options ?
Or something else ?

What would be recommended ?

Best,
Benoît

please unify -help vs --help in Python scripts (fat_ are too specially more standard)

Majority of scripts seems to understand -help:

$> for f in *.py; do if [ -x "$f" ]; then ./$f -help >/dev/null || echo "$f failed with $?"; fi; done
fat_lat_csv.py failed with 2
fat_mat_sel.py failed with 2
fat_mvm_gridconv.py failed with 2
fat_mvm_prep.py failed with 2
fat_mvm_review.py failed with 2
fat_mvm_scripter.py failed with 2
fat_roi_row.py failed with 2

but those fat_ ones go with classical gnu style of --help:

$> ./fat_lat_csv.py -help


** Error reading options. Try looking at the helpfile:
     $  fat_mvm_prep.py -h

2 13965 ->2.....................................:Sat 27 Aug 2016 10:12:26 PM EDT:.
hopa:/usr/lib/afni/bin
$> ./fat_lat_csv.py --help | head


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

    ++ Oct, 2014.  Written by PA Taylor (UCT/AIMS).  
    ++ Perform factor analysis on quantitative CSV data to find 
       latent variables.

    This program is designed to help prep subject data (clinical,
    neurophysiological, test scores, etc.) for statistical analysis,

Please minimize number of f2c.h spread out through the code to 1 or (better) 0

ATM

$> find -iname f2c.h
./src/f2c.h
./src/f2cdir/f2c.h
./src/eispack/f2c.h

$> find -iname f2c.h -ls
  8828829      8 -rw-------   1 yoh      yoh          4819 Apr 27  2016 ./src/f2c.h
  8828890      8 -rw-------   1 yoh      yoh          4829 Apr 27  2016 ./src/f2cdir/f2c.h
  8828820      8 -rw-------   1 yoh      yoh          4766 Apr 27  2016 ./src/eispack/f2c.h

$> diff ./src/f2c.h ./src/f2cdir/f2c.h                    
21d20
< #ifndef _SUNPERF_COMPLEX
23d21
< #endif
230a229,231
> 
> #undef complex
> #define complex complexxx

$> diff  ./src/f2cdir/f2c.h ./src/eispack/f2c.h    
11,12c11
< #undef complex
< #define complex complexxx
---
> #define complex complexxx  /* RWCox */
229,232c228
< 
< #undef complex
< #define complex complexxx
< #endif  /* F2C_INCLUDE */
---
> #endif

ideally it should (allow to) use system-wide available f2c and be within-AFNI consistent

ENH: allow plugout_drive to access FIM graph menu

I'd like to be able to add additional timeseries to the graph window via plugout_drive in order to improve on the @epi_review.$subj script. Currently, when I'm reviewing a subject's data, I have to carefully cross reference any anomalies I observe in the data with the list of time points that have already been censored. It would be much quicker if I could simply look at the graph to determine whether action is required on my part.

Preliminary prodding suggests that the internal plumbing already exists and only needs to be connected up to the external driver plumbing, but I haven't looked at it in depth yet. If it turns out to be easy, I might put in a PR.

3dAFNItoNIFTI in afni_proc.py ?

Hello,

Is it planned to incorporate an option in afni_proc.py to convert the HEAD/BRIK files to NIFTI after the last processing step ?

Best,
Benoît

nibabel under meica.libs need update

Hello,
There is some recent update in numpy which causes nibabel to fail to load data (see this issue: nipy/nibabel#697). I think nibabel has fixed it. The nibabel version in meica.libs/ seems to include an older version of nibabel which tedana.py will import by default. I have confirmed that by removing the nibabel folder in meica.libs/ folder while having an updated nibabel installed can fix this problem when using the tedana wrapper in AFNI. I suggest updating the nibabel folder to the newest one in meica.libs/
Thanks!

how to avoid Error: XtCreateWidget "glxarea" requires non-NULL widget class

this is pretty much unrelated to your build, although I think I replicate it if I use other_builds/Makefile.linux_ubuntu_12_64 instead of other_builds/Makefile.linux_openmp_64_trusty on my Debian stretch/sid box.

1056	   if (!SUMA_X_SurfaceViewer_Create ()) {
(gdb) s
Error: XtCreateWidget "glxarea" requires non-NULL widget class
[Inferior 1 (process 32571) exited with code 01]

do you know what particular change in the build instructions "resolves" this issue... (I have an idea but so far knowing that didn't help ;))

thanks in advance for the hints

[Request] Echo times in 3dinfo

I tried to find this in the help text and couldn't, and grep'd the verbose output, so have concluded it's not there. Could we get the echo times out of 3dinfo? Happy to help with this if needed/desired. I took a quick look through the source of 3dinfo.c and there are no references to it, but I assume the information exists somewhere in the .HEAD file. If not, maybe we could update the spec?

3dUnifize sets qform/sform codes to 3 (Talairach aligned)

#!/bin/bash
echo "Run 3dUnifize"
3dUnifize -clfrac 0.4 -prefix out_file.nii.gz -T2 -input in_file.nii.gz

echo; echo "Input file qform/sform"
fslhd in_file.nii.gz | grep -A 14 qform_name

echo; echo "Output file qform/sform"
fslhd out_file.nii.gz | grep -A 14 qform_name

Output:

Run 3dUnifize
++ 3dUnifize: AFNI version=Debian-16.2.07~dfsg.1-5~nd16.04+1 (Jun 12 2017) [64-bit]
 + Pre-processing: IADVUWI
++ Output dataset ./out_file.nii.gz
++ ===== Elapsed = 0.3 sec

Input file qform/sform
qform_name     Scanner Anat
qform_code     1
qto_xyz:1      -3.125000  0.000000  -0.000000  97.931519
qto_xyz:2      0.000000  3.125000  -0.000000  -68.019211
qto_xyz:3      0.000000  0.000000  4.000000  -106.650566
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Right-to-Left
qform_yorient  Posterior-to-Anterior
qform_zorient  Inferior-to-Superior
sform_name     Aligned Anat
sform_code     2
sto_xyz:1      -3.125000  0.000000  0.000000  98.909752
sto_xyz:2      0.000000  3.125000  0.000000  -110.716141
sto_xyz:3      0.000000  0.000000  4.000000  -51.800713
sto_xyz:4      0.000000  0.000000  0.000000  1.000000

Output file qform/sform
qform_name     Talairach
qform_code     3
qto_xyz:1      -3.125000  -0.000000  -0.000000  98.909752
qto_xyz:2      0.000000  3.125000  -0.000000  -110.716141
qto_xyz:3      -0.000000  0.000000  4.000000  -51.800713
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Right-to-Left
qform_yorient  Posterior-to-Anterior
qform_zorient  Inferior-to-Superior
sform_name     Talairach
sform_code     3
sto_xyz:1      -3.125000  -0.000000  -0.000000  98.909752
sto_xyz:2      -0.000000  3.125000  -0.000000  -110.716141
sto_xyz:3      0.000000  0.000000  4.000000  -51.800713
sto_xyz:4      0.000000  0.000000  0.000000  1.000000

3dUnifize should not, as far as I understand, modify the qform or sform, so this seems to me likely to be a bug.

AFNI interpolation functions aren't smooth

This might be a feature rather than a bug— I did a little bit of digging into the interpolation literature when I first noticed this, and realized it was less clear-cut than I'd thought initially. But I'm going to have considerably less free time come next year, so I may as well report this while I can. Do with it what you will.

I noticed that the AFNI interpolation functions (which are duplicated across many source files) invariably use Lagrange polynomials for interpolation. Lagrange interpolants are strange because the special property they satisfy is that they take the correct values at integer points outside their domain of application, which doesn't seem useful. Perhaps they should be replaced with a smoother spline that still sums to 1 when shifted?

Plot of AFNI heptic polynomial interpolant

This plot was created by the following code (compare hept_shift in thd_shift2.c)

In [1]: %pylab
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib

In [2]: import seaborn as sns
/study/cook-lab/lib/python3.4/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))

In [3]: S_M3 = lambda x: (x*(x*x-1.0)*(x*x-4.0)*(x-3.0)*(4.0-x)*0.0001984126984)

In [4]: S_M2 = lambda x: (x*(x*x-1.0)*(x-2.0)*(x*x-9.0)*(x-4.0)*0.001388888889)

In [5]: S_M1 = lambda x: (x*(x-1.0)*(x*x-4.0)*(x*x-9.0)*(4.0-x)*0.004166666667)

In [6]: S_00 = lambda x: ((x*x-1.0)*(x*x-4.0)*(x*x-9.0)*(x-4.0)*0.006944444444)

In [7]: S_P1 = lambda x: (x*(x+1.0)*(x*x-4.0)*(x*x-9.0)*(4.0-x)*0.006944444444)

In [8]: S_P2 = lambda x: (x*(x*x-1.0)*(x+2.0)*(x*x-9.0)*(x-4.0)*0.004166666667)

In [9]: S_P3 = lambda x: (x*(x*x-1.0)*(x*x-4.0)*(x+3.0)*(4.0-x)*0.001388888889)

In [10]: S_P4 = lambda x: (x*(x*x-1.0)*(x*x-4.0)*(x*x-9.0)*0.0001984126984)

In [11]: FINS = lambda x: f[np.clip(x, 0, n-1)]

In [12]: n = 11

In [13]: af = np.linspace(-(n//2), n//2, (n-1)*10+1)

In [14]: f = np.zeros(n)

In [15]: f[n//2] = 1

In [16]: af = -af ; ia = np.floor(af).astype(int)

In [17]: aa = af - ia

In [18]: wt_m1 = S_M1(aa) ; wt_00 = S_00(aa)

In [19]: wt_p1 = S_P1(aa) ; wt_p2 = S_P2(aa)

In [20]: wt_m2 = S_M2(aa) ; wt_p3 = S_P3(aa)

In [21]: wt_m3 = S_M3(aa) ; wt_p4 = S_P4(aa)

In [22]: ii = np.arange(n, dtype=int)

In [23]: ix = ii[:, np.newaxis] + ia

In [24]: lcbuf = (wt_m2 * FINS(ix-2) + wt_m1 * FINS(ix-1) + wt_00 * FINS(ix)
   ....:        + wt_p1 * FINS(ix+1) + wt_p2 * FINS(ix+2) + wt_p3 * FINS(ix+3)
   ....:        + wt_m3 * FINS(ix-3) + wt_p4 * FINS(ix+4))

In [25]: plt.plot(np.transpose([S_M3(af-3), S_M2(af-2), S_M1(af-1), S_00(af), S_P1(af+1), S_P2(af+2), S_P3(af+3), S_P4(af+4)]), 'k-', linewidth=1)
Out[25]: 
[<matplotlib.lines.Line2D at 0x7f0c8b598160>,
 <matplotlib.lines.Line2D at 0x7f0c8b598358>,
 <matplotlib.lines.Line2D at 0x7f0c8b5985f8>,
 <matplotlib.lines.Line2D at 0x7f0c8b598828>,
 <matplotlib.lines.Line2D at 0x7f0c8b598a58>,
 <matplotlib.lines.Line2D at 0x7f0c8b598c88>,
 <matplotlib.lines.Line2D at 0x7f0c8b598eb8>,
 <matplotlib.lines.Line2D at 0x7f0c8b59c128>]

In [26]: plt.plot(lcbuf[n//2, :], 'r-')
Out[26]: [<matplotlib.lines.Line2D at 0x7f0c8b555b38>]

In [27]: plt.ylim([-1, 2])
Out[27]: (-1, 2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.