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  

|
August 27, 2018 04:26PM
Hello AFNI gurus,
I'm a die-hard shell scripter who makes frequent use of AFNI programs like 1deval and other shell scripting staples like 'awk' for doing basic mathematical operations within my scripts. A big reason I do this is because I hate having to switch to external analysis programs like MATLAB, R, or python for doing something as simple as averaging a column of numbers. For many simple tasks like these, I can rely on AFNI staples like 1d_tool.py, 1deval, or 3dTstat (with the 1D input options). However, one area that frequently gives me trouble is dealing with 2D arrays, like you might see in the regressor text files we input to 3dDeconvolve. For instance, let's say I had a regressor file with onset times in milliseconds and I wanted to convert those times to seconds (I know, you don't actually need to do this for 3dDeconvolve). All I'd need to do is divide all the columns within the text file by 1000. There are actually many ways of doing this using AFNI programs and shell commands, but most of them would require you to specify the operation on each column individually, and none of them are as straightforward as programs like 1deval or 3dcalc (and 1dmatcalc is especially difficult to use and limited in functionality). While I'm aware that you can actually use 3dcalc for operations just like this, the syntax is extremely hairy, and would generally look something like this:
1dcat input.txt\' | 3dcalc -a 1D:stdin\' -expr 'a/1000' -prefix - > output.txt
So instead of this, I personally would love to see a 2dcalc program (and I think many AFNI others users would also find this helpful), that had the basic functionality and syntax of the AFNI 'calc' programs, but worked on 2D arrays of numbers in text or '.csv' files. What do you think?

P.S. If there are currently AFNI programs that do perform this function, other than the ones i've listed above, and I just haven't stumbled across them before, please let me know. I'm certainly open to trying them out.

TL;DR: Would it be possible to create a simple function (perhaps named 2dcalc) which can deal with 2D arrays of numbers like 3dcalc does with 3D datasets?
Subject Author Posted

2dcalc?

jason-avery August 27, 2018 04:26PM

Re: 2dcalc?

Daniel Glen August 27, 2018 06:26PM