Commit b0888d01 authored by Mark Hymers's avatar Mark Hymers

New upstream version 20190829

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
#include "mrilib.h"
#include "mri_genalign.c"
int main( int argc , char *argv[] )
{
mat44 qmat ;
int npar ; float parvec[12] ;
int iarg=1 ;
char lab[2048] ;
/*--- help the pitiful luser ---*/
if( argc < 2 || strncasecmp(argv[1],"-h",2) == 0 ){
printf("\n"
"Usage: 1dApar2mat dx dy dz a1 a2 a3 sx sy sz hx hy hz\n"
"\n"
"* This program computes the affine transformation matrix\n"
" from the set of 3dAllineate parameters.\n"
"\n"
"* The result is printed to stdout, and can be captured\n"
" by Unix shell redirection (e.g., '|', '>', '>>', etc.).\n"
" See the EXAMPLE, far below.\n"
"\n"
"* One use for 1dApar2mat is to take a set of parameters\n"
" from '3dAllineate -1Dparam_save', alter them in some way,\n"
" and re-compute the corresponding matrix. For example,\n"
" compute the full affine transform with 12 parameters,\n"
" but then omit the final 6 parameters to see what the\n"
" 'pure' shift+rotation matrix looks like.\n"
"\n"
"* The 12 parameters are, in the order used on the 1dApar2mat command line\n"
" (the same order as output by 3dAllineate):\n"
" x-shift in mm\n"
" y-shift in mm\n"
" z-shift in mm\n"
" z-angle (roll) in degrees (not radians!)\n"
" x-angle (pitch) in degrees\n"
" y-angle (yaw) in degrees\n"
" x-scale unitless factor, in [0.10,10.0]\n"
" y-scale unitless factor, in [0.10,10.0]\n"
" z-scale unitless factor, in [0.10,10.0]\n"
" y/x-shear unitless factor, in [-0.3333,0.3333]\n"
" z/x-shear unitless factor, in [-0.3333,0.3333]\n"
" z/y-shear unitless factor, in [-0.3333,0.3333]\n"
"\n"
"* Parameters omitted from the end of the command line get their\n"
" default values (0 except for scales, which default to 1).\n"
"\n"
"* At least 1 parameter must be given, or you get this help message :)\n"
" The minimum command line is\n"
" 1dApar2mat 0\n"
" which will output the identity matrix.\n"
"\n"
"* Legal scale and shear factors have limited ranges, as\n"
" described above. An input value outside the given range\n"
" will be reset to the default value for that factor (1 or 0).\n"
"\n"
"* UNUSUAL SPECIAL CASES:\n"
" If you used 3dAllineate with any of the options described\n"
" under 'CHANGING THE ORDER OF MATRIX APPLICATION' or you\n"
" used the '-EPI' option, then the order of parameters inside\n"
" 3dAllineate will no longer be the same as the parameter order\n"
" in 1dApar2mat. In such a situation, the matrix output by\n"
" this program will NOT agree with that output by 3dAllineate\n"
" for the same set of parameter numbers :(\n"
"\n"
"* EXAMPLE:\n"
" 1dApar2mat 0 1 2 3 4 5\n"
" to get a rotation matrix with some shifts; the output is:\n"
" # mat44 1dApar2mat 0 1 2 3 4 5 :\n"
" 0.994511 0.058208 -0.086943 0.000000\n"
" -0.052208 0.996197 0.069756 1.000000\n"
" 0.090673 -0.064834 0.993768 2.000000\n"
" If you wish to capture this matrix all on one line, you can\n"
" combine various Unix shell and command tricks/tools, as in\n"
" echo `1dApar2mat 0 1 2 3 4 5 | tail -3` > Fred.aff12.1D\n"
" This 12-numbers-in-one-line is the format output by '-1Dmatrix_save'\n"
" in 3dAllineate and 3dvolreg.\n"
"\n"
"* FANCY EXAMPLE:\n"
" Tricksy command line stuff to compute the inverse of a matrix\n"
" set fred = `1dApar2mat 0 0 0 3 4 5 1 1 1 0.2 0.1 0.2 | tail -3`\n"
" cat_matvec `echo $fred | sed -e 's/ /,/g' -e 's/^/MATRIX('/`')' -I\n"
"\n"
"* ALSO SEE: Programs cat_matvec and 1dmatcalc for doing\n"
" simple matrix arithmetic on such files.\n"
"\n"
"* OPTIONS: This program has no options. Love it or leave it :)\n"
"\n"
"* AUTHOR: Zhark the Most Affine and Sublime - April 2019\n"
"\n"
) ;
exit(0) ;
}
/* initialize parvec (not really necessary) */
for( npar=0 ; npar < 3 ; npar++ ){
parvec[0+npar] = parvec[3+npar] = parvec[9+npar] = 0.0f ;
parvec[6+npar] = 1.0f ; /* scale factors */
}
/* get parvec from command line, and make an informative label */
strcpy(lab,"1dApar2mat ") ;
for( npar=0 ; iarg < argc && npar < 12; iarg++,npar++ ){
parvec[npar] = (float)strtod(argv[iarg],NULL) ;
strcat(lab,argv[iarg]) ; strcat(lab," ") ;
}
/* do the work */
qmat = GA_setup_affine( npar , parvec ) ;
/* dump the work */
DUMP_MAT44(lab,qmat) ;
exit(0) ;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define LBUF 262144
#define ISPMD(c) ( (c)=='+' || (c)=='-' || (c)=='.' )
#define ISGOOD(c) ( isdigit(c) || ISPMD(c) )
int main( int argc , char **argv )
{
size_t nbuf ; int ii ; char *buf ;
buf = (char *)malloc(sizeof(char)*LBUF) ;
if( argc > 1 && strcasecmp(argv[1],"-help") == 0 ){
printf("Usage: 1dAstrip < input > output\n"
"\n"
"This very simple program strips non-numeric characters\n"
"from a file, so that it can be processed by other AFNI\n"
"1d programs. For example, if your input is\n"
" x=3.6 y=21.6 z=14.2\n"
"then your output would be\n"
" 3.6 21.6 14.2\n"
"\n"
"* Non-numeric characters are replaced with blanks.\n"
"* The letter 'e' is preserved if it is preceeded\n"
" or followed by a numeric character. This is\n"
" to allow for numbers like '1.2e-3'.\n"
"* Numeric characters, for the purpose of this\n"
" program, are defined as the digits '0'..'9',\n"
" and '.', '+', '-'.\n"
"* The program is simple and can easily end up leaving\n"
" undesired junk characters in the output. Sorry.\n"
"* This help string is longer than the rest of the\n"
" source code to this program!\n"
) ;
exit(0) ;
}
while(1){
nbuf = fread( buf , 1 , LBUF , stdin ) ;
if( nbuf == 0 ) exit(0) ;
for( ii=0 ; ii < nbuf ; ii++ ){
if( isspace(buf[ii]) ) continue ;
if( isdigit(buf[ii]) ) continue ;
if( buf[ii] == 'e' || buf[ii] == 'E' ){
if( ii < nbuf-1 && ii > 0 && ISGOOD(buf[ii+1]) && ISGOOD(buf[ii-1]) ) continue ;
if( ii == 0 && nbuf > 1 && ISGOOD(buf[ii+1]) ) continue ;
if( ii == nbuf-1 && nbuf > 1 && ISGOOD(buf[ii-1]) ) continue ;
}
if( ISPMD(buf[ii]) ){
if( (ii < nbuf-1 && ii > 0) &&
(isspace(buf[ii-1]) || buf[ii-1]==buf[ii]) &&
(isspace(buf[ii+1]) || buf[ii+1]==buf[ii]) ) buf[ii] = ' ' ;
continue ;
}
buf[ii] = ' ' ;
}
(void)fwrite( buf , 1 , LBUF , stdout ) ;
}
}
#include "mrilib.h"
int main( int argc , char * argv[] )
{
MRI_IMAGE *inim , *ortim=NULL ;
float **vec , **ort=NULL ; int iv , nx,ny , nopt, nort=0 , do_norm=0 ;
int qdet=2 ; float dt=1.0f , fbot,ftop ;
/*-- help? --*/
if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
printf("Usage: 1dBandpass [options] fbot ftop infile\n"
"\n"
" * infile is an AFNI *.1D file; each column is processed\n"
" * fbot = lowest frequency in the passband, in Hz\n"
" [can be 0 if you want to do a lowpass filter only,]\n"
" but the mean and Nyquist freq are always removed ]\n"
" * ftop = highest frequency in the passband (must be > fbot)\n"
" [if ftop > Nyquist freq, then we have a highpass filter only]\n"
" * You cannot construct a 'notch' filter with this program!\n"
" * Output vectors appear on stdout; redirect as desired\n"
" * Program will fail if fbot and ftop are too close for comfort\n"
" * The actual FFT length used will be printed, and may be larger\n"
" than the input time series length for the sake of efficiency.\n"
"\n"
"Options:\n"
" -dt dd = set time step to 'dd' sec [default = 1.0]\n"
" -ort f.1D = Also orthogonalize input to columns in f.1D\n"
" [only one '-ort' option is allowed]\n"
" -nodetrend = Skip the quadratic detrending of the input\n"
" -norm = Make output time series have L2 norm = 1\n"
"\n"
"Example:\n"
" 1deval -num 1000 -expr 'gran(0,1)' > r1000.1D\n"
" 1dBandpass 0.025 0.20 r1000.1D > f1000.1D\n"
" 1dfft f1000.1D - | 1dplot -del 0.000977 -stdin -plabel 'Filtered |FFT|'\n"
"\n"
"Goal:\n"
" * Mostly to test the functions in thd_bandpass.c -- RWCox -- May 2009\n"
) ;
PRINT_COMPILE_DATE ; exit(0) ;
}
machdep() ;
nopt = 1 ;