diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b08050ac8..f9d214c8b7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,8 +4,8 @@ jobs: machine: true steps: - checkout - - run: docker build -t afni/afni_dev:$CIRCLE_BUILD_NUM-${CIRCLE_SHA1:0:6} -f Dockerfile.dev . - - run: + - run: docker build -t afni/afni_dev:$CIRCLE_BUILD_NUM-${CIRCLE_SHA1:0:6} --build-arg AFNI_WITH_COVERAGE=1 . + - run: no_output_timeout: 2h command: | ci_env=`bash <(curl -s https://codecov.io/env)` @@ -13,11 +13,11 @@ jobs: - run: command: | - set +o pipefail - if [ $DOCKER_USER == 'afni' ] + set +o pipefail + if [ $DOCKER_USER == 'afni' ] then docker login -u $DOCKER_USER -p $DOCKER_PASS - docker build -t afni/afni:$CIRCLE_BUILD_NUM-${CIRCLE_SHA1:0:6} -f Dockerfile . + docker build -t afni/afni:$CIRCLE_BUILD_NUM-${CIRCLE_SHA1:0:6} . docker tag afni/afni_dev:$CIRCLE_BUILD_NUM-${CIRCLE_SHA1:0:6} afni/afni_dev:latest docker push afni/afni_dev docker tag afni/afni:$CIRCLE_BUILD_NUM-${CIRCLE_SHA1:0:6} afni/afni:latest diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..94143827ed --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile diff --git a/.gitignore b/.gitignore index 85c5fc9589..2ccb523837 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,11 @@ ___* # Octave workspace octave-workspace /Debug/ + +# Python +__pycache__ +*.pyc + +# Test and coverage artifacts +.pytest_cache +.coverage diff --git a/Dockerfile b/Dockerfile index b4f88f0c2f..ad765e1072 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,70 @@ FROM ubuntu:bionic-20180526@sha256:c8c275751219dadad8fa56b3ac41ca6cb22219ff117ca98fe82b42f24e1ba64e -USER root -RUN apt-get update -y ; apt-get upgrade -y -ENV DEBIAN_FRONTEND=noninteractive +ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get install -y tcsh vim -RUN apt-get install -y libxmu-dev libxt-dev libmotif-dev -RUN apt-get install -y libxpm-dev libxi-dev libxmhtml-dev -RUN apt-get install -y libglw1-mesa-dev libglu1-mesa-dev -RUN apt-get install -y libglib2.0-dev libgsl-dev -RUN apt-get install -y r-base m4 -RUN apt-get install -y python-qt4 git -RUN apt-get install -yq --no-install-recommends gcc -RUN apt-get install -yq --no-install-recommends g++ +RUN apt-get update -y -qq \ + && apt-get install -yq --no-install-recommends \ + ca-certificates \ + curl \ + g++ \ + gcc \ + git \ + libglib2.0-dev \ + libglu1-mesa-dev \ + libglw1-mesa-dev \ + libgsl-dev \ + libmotif-dev \ + libxi-dev \ + libxmhtml-dev \ + libxmu-dev \ + libxpm-dev \ + libxt-dev \ + m4 \ + python-matplotlib \ + python-numpy \ + python-qt4 \ + python-rpy2 \ + python-tk \ + r-base \ + tcsh \ + vim \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -####################################### -# this copies source code from the host -# into the image and invalidates the cache -RUN mkdir /usr/afni_build_dir -WORKDIR /usr/afni_build_dir -RUN mkdir src .git -ADD src src -ADD .git .git +# Copy AFNI source code. This can invalidate the build cache. +ARG AFNI_ROOT=/opt/afni +COPY [".", "$AFNI_ROOT/"] -ENV PATH=$PATH:/usr/afni_build_dir/src/afni_src/abin -ARG VERSION -# RUN git checkout "${VERSION}" -WORKDIR /usr/afni_build_dir/src +ARG AFNI_MAKEFILE_SUFFIX=linux_ubuntu_16_64 +ARG AFNI_WITH_COVERAGE="0" -# o files are ignored by the repo but will -# cause the build to fail. -RUN make -f Makefile.linux_ubuntu_16_64 afni_src.tgz \ - && tar zxvf afni_src.tgz \ - && cd afni_src \ - && cp Makefile.linux_ubuntu_16_64 Makefile -WORKDIR /usr/afni_build_dir/src/afni_src -# RUN make libmri.so -RUN make itall && mv linux_ubuntu_16_64 /opt/abin -WORKDIR /opt/abin \ No newline at end of file +WORKDIR "$AFNI_ROOT/src" +RUN \ + if [ "$AFNI_WITH_COVERAGE" != "0" ]; then \ + echo "Adding testing and coverage components" \ + && sed -i 's/# CPROF = /CPROF = -coverage /' Makefile.$AFNI_MAKEFILE_SUFFIX \ + && curl -fsSL https://bootstrap.pypa.io/get-pip.py | python3 - --no-cache-dir \ + && pip3 install --no-cache-dir \ + codecov \ + pytest \ + pytest-cov; \ + fi \ + \ + # Clean AFNI src directory (*.o files can cause build to fail). + && make -f Makefile.$AFNI_MAKEFILE_SUFFIX afni_src.tgz \ + && mv afni_src.tgz .. \ + && cd .. \ + \ + # Empty the src directory, and replace with the contents of afni_src.tgz + && rm -rf src/ && mkdir src \ + && tar -xzf afni_src.tgz -C $AFNI_ROOT/src --strip-components=1 \ + && rm afni_src.tgz \ + \ + # Build AFNI. + && cd src \ + && cp Makefile.$AFNI_MAKEFILE_SUFFIX Makefile \ + && make itall \ + && mv $AFNI_MAKEFILE_SUFFIX $AFNI_ROOT/abin + +ENV PATH="$AFNI_ROOT/abin:$PATH" +WORKDIR "$AFNI_ROOT" diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index 9f83ed0cc8..0000000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,47 +0,0 @@ -FROM ubuntu:bionic-20180526@sha256:c8c275751219dadad8fa56b3ac41ca6cb22219ff117ca98fe82b42f24e1ba64e -USER root -RUN apt-get update -y ; apt-get upgrade -y - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get install -y tcsh vim -RUN apt-get install -y libxmu-dev libxt-dev libmotif-dev -RUN apt-get install -y libxpm-dev libxi-dev libxmhtml-dev -RUN apt-get install -y libglw1-mesa-dev libglu1-mesa-dev -RUN apt-get install -y libglib2.0-dev libgsl-dev -RUN apt-get install -y r-base m4 -RUN apt-get install -y python-qt4 git -RUN apt-get install -yq --no-install-recommends gcc -RUN apt-get install -yq --no-install-recommends g++ -RUN apt-get install -y python3-pip && pip3 install pytest pytest-cov codecov - -####################################### -# this copies source code from the host -# into the image and invalidates the cache -RUN mkdir /usr/afni_build_dir -WORKDIR /usr/afni_build_dir -RUN mkdir src .git tests -ADD src src -ADD .git .git -ADD tests tests - -ENV PATH=$PATH:/usr/afni_build_dir/src/afni_src/abin -ARG VERSION -# RUN git checkout "${VERSION}" -WORKDIR /usr/afni_build_dir/src - -# make changes to add coverage flags to makefile -RUN sed -i 's/# CPROF = /CPROF = -coverage /' Makefile.linux_ubuntu_16_64 - -# o files are ignored by the repo but will -# cause the build to fail. -RUN make -f Makefile.linux_ubuntu_16_64 afni_src.tgz \ - && tar zxvf afni_src.tgz \ - && cd afni_src \ - && cp Makefile.linux_ubuntu_16_64 Makefile -WORKDIR /usr/afni_build_dir/src/afni_src -# RUN make libmri.so -RUN make itall && mv linux_ubuntu_16_64 /opt/abin -ENV PATH="/opt/abin:${PATH}" - -WORKDIR /opt/abin \ No newline at end of file diff --git a/README.rst b/README.rst index 520cf5a0bc..f476f41c84 100644 --- a/README.rst +++ b/README.rst @@ -11,13 +11,14 @@ purposes as well. See https://afni.nimh.nih.gov/afni for more fun. AFNI directory -------------- -Currently top directory contains only two sub-directories +Currently top directory contains three sub-directories doc/ documentation for AFNI src/ source code for AFNI - +tests/ + tests for AFNI Relevant git-ology for AFNI --------------------------- @@ -90,7 +91,7 @@ To make and install everything do:: make vastness The command:: - + make cleanest - + will remove all the *.o files, etc. diff --git a/src/3dmaxima.c b/src/3dmaxima.c index 05f84c30e0..71f4b17347 100644 --- a/src/3dmaxima.c +++ b/src/3dmaxima.c @@ -3,7 +3,7 @@ of Wisconsin, 1994-2000, and are released under the Gnu General Public License, Version 2. See the file README.Copyright for details. ******************************************************************************/ - + static char * g_history[] = { "History:", @@ -452,4 +452,3 @@ ENTRY("process_args"); RETURN(0); } - diff --git a/src/SUMA/SUMA_3dSurf2Vol.c b/src/SUMA/SUMA_3dSurf2Vol.c index 04a9bacafa..28a2b71e30 100644 --- a/src/SUMA/SUMA_3dSurf2Vol.c +++ b/src/SUMA/SUMA_3dSurf2Vol.c @@ -49,13 +49,13 @@ * examples: * * 3dSurf2Vol -spec SubjectA.spec \ - * -sv SubjectA_spgr+orig \ + * -sv SubjectA_spgr+orig \ * -grid_parent SubjA_EPI+orig \ * -map_func mask2 \ * -prefix SubjA_mask * * 3dSurf2Vol -spec SubjectA.spec \ - * -sv SubjectA_spgr+orig \ + * -sv SubjectA_spgr+orig \ * -cmask '-a SubjA.func+orig[2] -expr step(a-0.6)' \ * -grid_parent SubjA_EPI+orig \ * -map_func mask2 \ @@ -137,7 +137,7 @@ static char g_history[] = "3.9 September 13, 2018 [rickr]\n" " - return 0 on terminal options\n" "----------------------------------------------------------------------\n"; - + #define VERSION "version 3.9 (September 13, 2018)" @@ -179,7 +179,7 @@ int main( int argc , char * argv[] ) s2v_opts_t sopt; opts_t opts; int ret_val; - + mainENTRY("3dSurf2Vol main"); machdep(); AFNI_logger("3dSurf2Vol",argc,argv); @@ -201,7 +201,7 @@ int main( int argc , char * argv[] ) fprintf( stderr, "** failed to initialize spec\n" ); return(-1); } - + /* read surface files */ ret_val = read_surf_files(&opts, ¶ms, &spec, &sopt, &node_list); @@ -210,13 +210,13 @@ int main( int argc , char * argv[] ) /* free memory */ final_clean_up( &node_list ); - + /* free the spec ZSS Jan 9 06*/ if (!SUMA_FreeSpecFields(&spec)) { fprintf( stderr, "** failed to free spec\n" ); return(-1); } - + return ret_val; } @@ -323,7 +323,7 @@ ENTRY("s2v_nodes2volume"); DSET_delete( dout ); RETURN(NULL); } - + /* allocate an array of ints for functional counting */ if ( (cdata = (int *)malloc(nvox * sizeof(int))) == NULL ) { @@ -356,7 +356,7 @@ ENTRY("s2v_nodes2volume"); RETURN(NULL); } } - + dsize = mri_datum_size(sopt->datum); /* create the sub-brick data for output */ for ( sub = 0; sub < p->nsubs; sub++ ) @@ -933,7 +933,7 @@ ENTRY("insert_value"); * < 0 on error *---------------------------------------------------------------------- */ -int make_point_list( THD_fvec3 * list, THD_fvec3 * p1, THD_fvec3 * pn, +int make_point_list( THD_fvec3 * list, THD_fvec3 * p1, THD_fvec3 * pn, s2v_opts_t * sopt ) { float rat1, ratn; @@ -1082,7 +1082,7 @@ ENTRY("set_node_list_data"); RETURN(0); } else if ( p->sdata_im ) { - + /* else sdata exists: check column, and copy data from sdata_im */ if ( col > (p->sdata_im->nx - 2) && !p->parser.pcode ) { @@ -1103,7 +1103,7 @@ ENTRY("set_node_list_data"); } else if ( p->parser.pcode && col != 0 ) /* let's be safe */ { - fprintf(stderr,"** snld error: cannot use parser with col = %d\n", + fprintf(stderr,"** snld error: cannot use parser with col = %d\n", col); RETURN(-1); } @@ -1111,7 +1111,7 @@ ENTRY("set_node_list_data"); /* hmmmm, we're still missing something... oh yes, data! */ fp = MRI_FLOAT_PTR( p->sdata_im ) + col+1; /* offset by column number */ - + for ( c = 0; c < N->ilen; c++ ) { if ( p->parser.pcode ) @@ -1132,7 +1132,7 @@ ENTRY("set_node_list_data"); fprintf(stderr,"** snld error: Failed to get col %d from dset\n", col); RETURN(-1); - } + } for ( c = 0; c < N->ilen; c++ ) { if ( p->parser.pcode ) @@ -1142,7 +1142,7 @@ ENTRY("set_node_list_data"); p->parser.atoz[lposn] = (float) SUMA_GetDsetValInCol2(p->dset, lposn, c); - N->fdata[c] = PARSER_evaluate_one(p->parser.pcode, + N->fdata[c] = PARSER_evaluate_one(p->parser.pcode, p->parser.atoz); } else @@ -1153,8 +1153,8 @@ ENTRY("set_node_list_data"); fprintf(stderr,"** snld error: This NULLity should not be.\n"); RETURN(-1); } - - + + RETURN(0); } @@ -1564,7 +1564,7 @@ ENTRY("final_clean_up"); /*---------------------------------------------------------------------- - * + * *---------------------------------------------------------------------- */ int read_surf_files ( opts_t * opts, param_t * p, SUMA_SurfSpecFile * spec, @@ -1713,12 +1713,12 @@ ENTRY("verify_parser_expr"); fprintf(stderr,"** vpe: invalid params (%p,%p)\n", opts, p); RETURN(-1); } - + /* if no parser code, there is nothing to do */ if ( ! p->parser.pcode ) RETURN(0); - + for ( max_used = 25; max_used >= 0; max_used-- ) if ( p->parser.has_sym[max_used] ) break; @@ -1726,14 +1726,14 @@ ENTRY("verify_parser_expr"); p->parser.max_sym = max_used; /* if the expression is not constant, we need some data */ - if ( !p->sdata_im && !p->dset) + if ( !p->sdata_im && !p->dset) { fprintf(stderr, "** parser expression requires surface data\n" " (see '-sdata_1D' or '-sdata')\n"); RETURN(-1); } - if (p->sdata_im) - { + if (p->sdata_im) + { if ( max_used > 0 ) { if ( max_used > p->sdata_im->nx - 1 ) @@ -1749,8 +1749,8 @@ ENTRY("verify_parser_expr"); if ( opts->debug > 1 ) fprintf(stderr,"-- surf_vals = %d, expr_vals = %d\n", p->sdata_im ? (p->sdata_im->nx - 1) : 0, max_used); - } else if (p->dset) - { + } else if (p->dset) + { if ( max_used > 0 ) { if ( max_used > SDSET_VECNUM(p->dset) ) @@ -1767,7 +1767,7 @@ ENTRY("verify_parser_expr"); fprintf(stderr,"-- surf_vals = %d, expr_vals = %d\n", p->dset ? SDSET_VECNUM(p->dset) : 0, max_used); } - + RETURN(0); } @@ -1922,18 +1922,18 @@ ENTRY("sdata_from_niml"); if ( !opts || !N || !p ) RETURN(-1); - if ( !(p->dset = SUMA_LoadDset_s(opts->sdata_file_niml, + if ( !(p->dset = SUMA_LoadDset_s(opts->sdata_file_niml, &form, 0)) ) { fprintf(stderr,"** failed to read file '%s'\n", opts->sdata_file_niml); RETURN(-2); } if (!(SUMA_PopulateDsetNodeIndexNel(p->dset,1))) { - fprintf(stderr,"** failed to populate node indices in '%s'\n", + fprintf(stderr,"** failed to populate node indices in '%s'\n", opts->sdata_file_niml); RETURN(-2); } if (!(nind = SDSET_NODE_INDEX_COL(p->dset))) { - fprintf(stderr,"** No node index column in '%s'\n", + fprintf(stderr,"** No node index column in '%s'\n", opts->sdata_file_niml); RETURN(-2); } @@ -1942,7 +1942,7 @@ ENTRY("sdata_from_niml"); if ( opts->debug > 0 ) fprintf(stderr,"++ read surface dset file '%s' (nx = %d, ny = %d)\n", opts->sdata_file_niml, SDSET_VECNUM(p->dset), N->ilen ); - + /* only allocate space ilist */ if ( (N->ilist = (int *)malloc(N->ilen*sizeof(int))) == NULL ) { @@ -1960,7 +1960,7 @@ ENTRY("sdata_from_niml"); /*---------------------------------------------------------------------- * read surfaces (much stolen from SUMA_suma.c - thanks Ziad!) - * + * * return 0 on success *---------------------------------------------------------------------- */ @@ -2437,7 +2437,7 @@ ENTRY("validate_options"); int check_datum_type ( char * datum_str, int default_type ) { int c, dt = -1; - + ENTRY("check_datum_type"); if ( datum_str ) @@ -3415,7 +3415,7 @@ ENTRY("disp_param_t"); , p, p->gpar, ISVALID_DSET(p->gpar) ? "valid" : "invalid", p->oset, ISVALID_DSET(p->oset) ? "valid" : "invalid", - p->sxyz_im, p->sdata_im, + p->sxyz_im, p->sdata_im, p->dset, p->f3mm_min.xyz[0], p->f3mm_min.xyz[1], p->f3mm_min.xyz[2], p->f3mm_max.xyz[0], p->f3mm_max.xyz[1], p->f3mm_max.xyz[2], @@ -3490,7 +3490,7 @@ ENTRY("disp_s2v_opts_t"); sopt->debug, sopt->dnode, sopt->dvox, sopt->stop_gap, sopt->sxyz_ori_gpar, sopt->cmask, sopt->f_steps, sopt->f_index, - sopt->f_p1_fr, sopt->f_pn_fr, sopt->f_p1_mm, sopt->f_pn_mm + sopt->f_p1_fr, sopt->f_pn_fr, sopt->f_p1_mm, sopt->f_pn_mm ); RETURN(0); @@ -3648,4 +3648,3 @@ ENTRY("integral_doubles"); RETURN(1); } - diff --git a/src/SUMA/SUMA_3dVol2Surf.c b/src/SUMA/SUMA_3dVol2Surf.c index 74a8018b37..53eb6672bc 100644 --- a/src/SUMA/SUMA_3dVol2Surf.c +++ b/src/SUMA/SUMA_3dVol2Surf.c @@ -43,11 +43,11 @@ * * examples: * - * 3dVol2Surf -spec SubjA.spec -sv SubjA_anat+orig \ + * 3dVol2Surf -spec SubjA.spec -sv SubjA_anat+orig \ * -grid_par SubjA_EPI+orig -map_func mask > output.txt * * 3dVol2Surf -spec SubjectA.spec \ - * -sv SubjectA_spgr+orig \ + * -sv SubjectA_spgr+orig \ * -grid_par SubjA_EPI+orig \ * -cmask '-a SubjA.func+orig[2] -expr step(a-0.6)' \ * -map_func midpoint \ @@ -58,7 +58,7 @@ /* define program history for -hist option */ -static char g_history[] = +static char g_history[] = "----------------------------------------------------------------------\n" "history:\n" @@ -484,15 +484,15 @@ ENTRY("check_norm_dirs"); " maxs0 : %f, %f, %f\n" " maxs1 : %f, %f, %f\n" " maxs2 : %f, %f, %f\n", - min[0], min[1], min[2], - fmin[0], fmin[1], fmin[2], - coords[min[0]].x, coords[min[0]].y, coords[min[0]].z, - coords[min[1]].x, coords[min[1]].y, coords[min[1]].z, - coords[min[2]].x, coords[min[2]].y, coords[min[2]].z, - max[0], max[1], max[2], - fmax[0], fmax[1], fmax[2], - coords[max[0]].x, coords[max[0]].y, coords[max[0]].z, - coords[max[1]].x, coords[max[1]].y, coords[max[1]].z, + min[0], min[1], min[2], + fmin[0], fmin[1], fmin[2], + coords[min[0]].x, coords[min[0]].y, coords[min[0]].z, + coords[min[1]].x, coords[min[1]].y, coords[min[1]].z, + coords[min[2]].x, coords[min[2]].y, coords[min[2]].z, + max[0], max[1], max[2], + fmax[0], fmax[1], fmax[2], + coords[max[0]].x, coords[max[0]].y, coords[max[0]].z, + coords[max[1]].x, coords[max[1]].y, coords[max[1]].z, coords[max[2]].x, coords[max[2]].y, coords[max[2]].z); /* now count the number of normals pointing "away from" the center */ @@ -529,7 +529,7 @@ ENTRY("check_norm_dirs"); /* or do we just warn the user? */ if ( (ncount == 1) || (ncount == 5) ) fprintf(stderr,"** warning: only 83%% sure of direction of normals\n"); - + /* do we need to reverse the direction? */ if ( ncount < 2 ) { @@ -952,7 +952,7 @@ ENTRY("final_clean_up"); int read_surf_files ( opts_t * opts, SUMA_SurfSpecFile * spec ) { int debug, rv; /* v3.5 [rickr] */ - + ENTRY("read_surf_files"); debug = (opts->debug > 2); @@ -1374,7 +1374,7 @@ ENTRY("init_options"); opts->skip_cols |= V2S_SKIP_K; else if ( ! strncmp(argv[ac], "-skip_col_vals", 13) ) opts->skip_cols |= V2S_SKIP_NVALS; - else if ( ! strncmp(argv[ac], "-skip_col_results", 13) || + else if ( ! strncmp(argv[ac], "-skip_col_results", 13) || ! strncmp(argv[ac], "-outcols_1_result", 14) ) opts->skip_cols |= V2S_SKIP_VALS; else if ( ! strncmp(argv[ac], "-spec", 3) ) @@ -2604,7 +2604,7 @@ ENTRY("usage"); fputs(gv2s_history, stdout); else if ( level == V2S_USE_VERSION ) fprintf(stderr,"%s : %s, compile date: %s\n", prog, VERSION, __DATE__); - else + else fprintf( stderr, "usage called with illegal level <%d>\n", level ); RETURN(-1); @@ -2706,4 +2706,3 @@ ENTRY("disp_opts_t"); RETURN(0); } - diff --git a/src/SUMA/SUMA_ScaleToMap.c b/src/SUMA/SUMA_ScaleToMap.c index 8ab2f82feb..4b3e57f843 100644 --- a/src/SUMA/SUMA_ScaleToMap.c +++ b/src/SUMA/SUMA_ScaleToMap.c @@ -5,11 +5,11 @@ { static char FuncName[]={"SUMA_ScaleToMap_usage"}; char * s = NULL; - + SUMA_ENTRY; - + s = SUMA_help_basics(); - fprintf (SUMA_STDOUT, + fprintf (SUMA_STDOUT, "\nUsage: ScaleToMap <-input IntFile icol vcol> \n" " [-cmap MapType] [-cmapfile Mapfile] [-cmapdb Palfile] [-frf] \n" " [-clp/-perc_clp clp0 clp1] [-apr/-anr range]\n" @@ -28,9 +28,9 @@ " Example: -input NodeVal.1D 1 3\n" " for a 1D file containing node indices in\n" " the SECOND column and node values in the \n" -" FOURTH column (index counting begins at 0)\n" +" FOURTH column (index counting begins at 0)\n" " -v and -iv options are now obsolete.\n" -" Use -input option instead.\n" +" Use -input option instead.\n" " -cmap MapName: (optional, default RGYBR20) \n" " choose one of the standard colormaps available with SUMA:\n" " RGYBR20, BGYR19, BW20, GRAY20, MATLAB_DEF_BYR64, \n" @@ -54,7 +54,7 @@ " ***PALETTES deco [13]\n" " should be accessed with -cmap deco_n13\n" " ***PALETTES deco [13+]\n" -" should be accessed with -cmap deco_p13\n" +" should be accessed with -cmap deco_p13\n" " -cmapfile Mapfile: read color map from Mapfile.\n" " Mapfile:1D formatted ascii file containing colormap.\n" " each row defines a color in one of two ways:\n" @@ -90,74 +90,74 @@ " 'no color' will be masked as with the -msk option.\n" " If your 1D color file has more than three or 4 columns,\n" " you can use the [] convention adopted by AFNI programs\n" -" to select the columns you need.\n" +" to select the columns you need.\n" " -frf: (optional) first row in file is the first color.\n" " As explained in the -cmapfile option above, the first \n" " or bottom (indexed 0 )color of the colormap should be \n" " at the bottom of the file. If the opposite is true, use\n" " the -frf option to signal that.\n" -" This option is only useful with -cmapfile.\n" +" This option is only useful with -cmapfile.\n" " -clp/-perc_clp clp0 clp1: (optional, default no clipping)\n" " clips values in IntVect. if -clp is used then values in vcol\n" -" < clp0 are clipped to clp0 and > clp1 are clipped to clp1\n" +" < clp0 are clipped to clp0 and > clp1 are clipped to clp1\n" " if -perc_clp is used them vcol is clipped to the values \n" " corresponding to clp0 and clp1 percentile.\n" -" The -clp/-prec_clp options are mutually exclusive with -apr/-anr.\n" +" The -clp/-prec_clp options are mutually exclusive with -apr/-anr.\n" " -apr range: (optional) clips the values in IntVect to [0 range].\n" " This option allows range of colormap to be set as in AFNI, \n" " with Positive colorbar (Pos selected).\n" " This option is mutually exclusive with -clp/-perc_clp).\n" " set range = 0 for autoranging.\n" " If you use -apr and your colormap contains fractions, you\n" -" must use a positive range colormap.\n" +" must use a positive range colormap.\n" " -anr range: (optional) clips the values in IntVect to [-range range].\n" " This option allows range of colormap to be set as in AFNI, \n" " with Negative colorbar (Pos NOT selected).\n" " This option is mutually exclusive with -clp/-perc_clp).\n" " set range = 0 for autoranging.\n" " If you use -anr and your colormap contains fractions, you\n" -" must use a negative range colormap.\n" +" must use a negative range colormap.\n" " -interp: (default) use color interpolation between colors in colormap\n" " If a value is assigned between two colors on the colorbar,\n" " it receives a color that is an interpolation between those two colors.\n" " This is the default behaviour in SUMA and AFNI when using the continuous\n" -" colorscale. Mutually exclusive with -nointerp and -direct options.\n" +" colorscale. Mutually exclusive with -nointerp and -direct options.\n" " -nointerp: (optional) turns off color interpolation within the colormap\n" " Color assigniment is done a la AFNI when the paned colormaps are used.\n" -" Mutually exclusive with -interp and -direct options.\n" +" Mutually exclusive with -interp and -direct options.\n" " -direct: (optional) values (typecast to integers) are mapped directly\n" -" to index of color in color maps. Example: value 4 is assigned\n" +" to index of color in color maps. Example: value 4 is assigned\n" " to the 5th (index 4) color in the color map (same for values\n" " 4.2 and 4.7). This mapping scheme is useful for ROI indexed type\n" " data. Negative data values are set to 0 and values >= N_col \n" -" (the number of colors in the colormap) are set to N_col -1\n" +" (the number of colors in the colormap) are set to N_col -1\n" " -msk_zero: (optional) values that are 0 will get masked no matter\n" " what colormaps or mapping schemes you are using. \n" -" AFNI masks all zero values by default.\n" +" AFNI masks all zero values by default.\n" " -msk msk0 msk1: (optinal, default is no masking) \n" -" Values in vcol (BEFORE clipping is performed) \n" -" between [msk0 msk1] are masked by the masking color.\n" +" Values in vcol (BEFORE clipping is performed) \n" +" between [msk0 msk1] are masked by the masking color.\n" " -msk_col R G B: (optional, default is 0.3 0.3 0.3) \n" -" Sets the color of masked voxels.\n" +" Sets the color of masked voxels.\n" " -nomsk_col: do not output nodes that got masked.\n" " It does not make sense to use this option with\n" -" -msk_col.\n" +" -msk_col.\n" " -br BrightFact: (optional, default is 1) \n" " Applies a brightness factor to the colors \n" -" of the colormap and the mask color.\n" -" -h or -help: displays this help message.\n" -"\n" -" The following options are for debugging and sanity checks.\n" -" -verb: (optional) verbose mode.\n" +" of the colormap and the mask color.\n" +" -h or -help: displays this help message.\n" +"\n" +" The following options are for debugging and sanity checks.\n" +" -verb: (optional) verbose mode.\n" " -showmap: (optional) print the colormap to the screen and quit.\n" " This option is for debugging and sanity checks.\n" " You can use MakeColorMap in Usage3 to write out a colormap\n" -" in its RGB form.\n" +" in its RGB form.\n" " -showdb: (optional) print the colors and colormaps of AFNI\n" -" along with any loaded from the file Palfile.\n" +" along with any loaded from the file Palfile.\n" "%s" "\n", s); - SUMA_free(s); s = NULL; + SUMA_free(s); s = NULL; s = SUMA_New_Additions(0, 1); printf("%s\n", s);SUMA_free(s); s = NULL; fprintf (SUMA_STDOUT, " Ziad S. Saad SSCC/NIMH/NIH saadz@mail.nih.gov \n" " July 31/02 \n" @@ -168,8 +168,8 @@ int main (int argc,char *argv[]) {/* Main */ static char FuncName[]={"ScaleToMap"}; - char *IntName = NULL, *Prfx, h[9], - *CmapFileName = NULL, *dbfile = NULL, *MapName=NULL; + char *IntName = NULL, *Prfx, h[9], + *CmapFileName = NULL, *dbfile = NULL, *MapName=NULL; MRI_IMAGE *im = NULL; float *far=NULL; int N_V, N_Int, kar, k, ii, i, icol=-1, vcol=-1, Sgn, interpmode, k3; @@ -188,20 +188,20 @@ int main (int argc,char *argv[]) SUMA_Boolean FromAFNI = NOPE; int imap, isPmap, isNmap; SUMA_Boolean LocalHead = NOPE; - - + + SUMA_STANDALONE_INIT; SUMAg_CF->isGraphical = YUP; SUMA_mainENTRY; - + /* this is placed down here to */ - /* + /* if (argc < 3) { SUMA_ScaleToMap_usage(); exit (1); } */ - + kar = 1; brfact = 1; /* the brightness factor */ MaskColor[0] = MaskColor[1] = MaskColor[2] = 0.3; @@ -229,16 +229,16 @@ int main (int argc,char *argv[]) /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/ if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0) { SUMA_ScaleToMap_usage(); - exit (1); + exit (0); } - + SUMA_SKIP_COMMON_OPTIONS(brk, kar); - + if (!brk && strcmp(argv[kar], "-verb") == 0) { LocalHead = NOPE; brk = YUP; } - + if (!brk && strcmp(argv[kar], "-ionot") == 0) { SUMA_SL_Err("-ionot is obsolete. \n" "Use -trace option."); @@ -246,12 +246,12 @@ int main (int argc,char *argv[]) SUMA_INOUT_NOTIFY_ON; brk = YUP; } - + if (!brk && strcmp(argv[kar], "-msk_zero") == 0) { MaskZero = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-input") == 0)) { kar ++; if (kar+2 >= argc) { @@ -260,11 +260,11 @@ int main (int argc,char *argv[]) } IntName = argv[kar]; kar ++; icol = atoi(argv[kar]); kar ++; - vcol = atoi(argv[kar]); + vcol = atoi(argv[kar]); inopt = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-apr") == 0)) { if (arange >= 0) { fprintf (SUMA_STDERR, "range has already been specified.\n"); @@ -284,7 +284,7 @@ int main (int argc,char *argv[]) alaAFNI = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-anr") == 0)) { if (arange >= 0) { fprintf (SUMA_STDERR, "range has already been specified.\n"); @@ -300,12 +300,12 @@ int main (int argc,char *argv[]) fprintf (SUMA_STDERR, "range must be positive.\n"); exit (1); } - + Sgn = -1; alaAFNI = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-v") == 0)) { fprintf (SUMA_STDERR, "\n -v option is now obsolete.\nUse -input option instead.\n"); exit (1); @@ -317,8 +317,8 @@ int main (int argc,char *argv[]) IntName = argv[kar]; Vopt = YUP; brk = YUP; - } - + } + if (!brk && (strcmp(argv[kar], "-iv") == 0)) { fprintf (SUMA_STDERR, "\n -iv option is now obsolete.\nUse -input option instead.\n"); exit (1); @@ -330,8 +330,8 @@ int main (int argc,char *argv[]) IntName = argv[kar]; iVopt = YUP; brk = YUP; - } - + } + if (!brk && (strcmp(argv[kar], "-br") == 0)) { kar ++; if (kar >= argc) { @@ -341,47 +341,47 @@ int main (int argc,char *argv[]) brfact = atof(argv[kar]); brk = YUP; - } - + } + if (!brk && (strcmp(argv[kar], "-frf") == 0)) { frf = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-showmap") == 0)) { ShowMap = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-showdb") == 0)) { ShowMapdb = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-nointerp") == 0)) { if (interpmode != SUMA_UNDEFINED_MODE) { fprintf (SUMA_STDERR, "Color interpolation mode already set.\n"); } interpmode = SUMA_NO_INTERP; brk = YUP; - } - + } + if (!brk && (strcmp(argv[kar], "-direct") == 0)) { if (interpmode != SUMA_UNDEFINED_MODE) { fprintf (SUMA_STDERR, "Color interpolation mode already set.\n"); } interpmode = SUMA_DIRECT; brk = YUP; - } - + } + if (!brk && (strcmp(argv[kar], "-interp") == 0)) { if (interpmode != SUMA_UNDEFINED_MODE) { fprintf (SUMA_STDERR, "Color interpolation mode already set.\n(-nointerp, -direct and -interp are mutually exclusive.\n"); } interpmode = SUMA_INTERP; brk = YUP; - } - + } + if (!brk && (strcmp(argv[kar], "-clp") == 0)) { kar ++; if (kar+1 >= argc) { @@ -393,7 +393,7 @@ int main (int argc,char *argv[]) IntRange[1] = atof(argv[kar]); brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-perc_clp") == 0)) { kar ++; if (kar+1 >= argc) { @@ -405,7 +405,7 @@ int main (int argc,char *argv[]) IntRange[1] = atof(argv[kar]); brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-msk") == 0)) { kar ++; if (kar+1 >= argc) { @@ -417,12 +417,12 @@ int main (int argc,char *argv[]) MaskRange[1] = atof(argv[kar]); brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-nomsk_col") == 0)) { NoMaskCol = YUP; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-msk_col") == 0)) { kar ++; if (kar+2 >= argc) { @@ -435,7 +435,7 @@ int main (int argc,char *argv[]) MaskColor[2] = atof(argv[kar]); brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-cmapfile") ==0)) { if (MapSpecified) { fprintf (SUMA_STDERR, "Color map already specified.\n-cmap and -cmapfile are mutually exclusive\n"); @@ -447,23 +447,23 @@ int main (int argc,char *argv[]) fprintf (SUMA_STDERR, "need 1 arguments after -cmapfile "); exit (1); } - + CmapFileName = argv[kar]; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-cmapdb") ==0)) { kar ++; if (kar >= argc) { fprintf (SUMA_STDERR, "need 1 arguments after -cmapdb "); exit (1); } - + dbfile = argv[kar]; brk = YUP; } - - + + if (!brk && (strcmp(argv[kar], "-cmap") ==0)) { if (MapSpecified) { fprintf (SUMA_STDERR, "Color map already specified.\n-cmap and -cmapfile are mutually exclusive\n"); @@ -476,22 +476,22 @@ int main (int argc,char *argv[]) exit (1); } MapName = argv[kar]; - + brk = YUP; } - + if (!brk) { fprintf (SUMA_STDERR,"Error %s: Option %s not understood. Try -help for usage\n", FuncName, argv[kar]); exit (1); - } else { + } else { brk = NOPE; kar ++; } - + }/* loop accross command ine options */ - + /* Get your colors straightened out */ - if (!SUMAg_CF->scm) { + if (!SUMAg_CF->scm) { SUMAg_CF->scm = SUMA_Build_Color_maps(); if (!SUMAg_CF->scm) { SUMA_SL_Err("Failed to build color maps.\n"); @@ -508,33 +508,33 @@ int main (int argc,char *argv[]) exit(1); } } - + FromAFNI = NOPE; /* assume colormap is not coming from SAC (the colormap database structure) */ - if (CmapFileName) { + if (CmapFileName) { /* load the color map */ CM = SUMA_Read_Color_Map_1D (CmapFileName); if (CM == NULL) { SUMA_S_Err("Could not load colormap.\n"); - exit (1); + exit (1); } if (frf) { SUMA_LH("Flipping colormap"); SUMA_Flip_Color_Map (CM); - } + } - if (!CM->Sgn) CM->Sgn = Sgn; + if (!CM->Sgn) CM->Sgn = Sgn; }else{ /* dunno what kind of map yet. Try default first */ if (MapName) { CM = SUMA_FindNamedColMap (MapName); freecm = 0; if (CM) { - /* good, sign it and out you go */ + /* good, sign it and out you go */ CM->Sgn = Sgn; } else { SUMA_S_Err("Could not get standard colormap.\n"); - exit (1); + exit (1); } } else { SUMA_LH("An AFNI color map "); @@ -543,13 +543,13 @@ int main (int argc,char *argv[]) imap = SUMA_Find_ColorMap ( MapName, SAC->CMv, SAC->N_maps, -2); if (imap < 0) { SUMA_S_Errv("Could not find colormap %s.\n", MapName); - exit (1); + exit (1); } CM = SAC->CMv[imap]; } } - - + + /* show the colromap on STDERR */ if (ShowMap) { fprintf (SUMA_STDERR, "%s: Colormap used:\n", FuncName); @@ -558,13 +558,13 @@ int main (int argc,char *argv[]) SUMA_SurfaceObject *SO = NULL; float orig[3] = { SUMA_CMAP_ORIGIN }; float topright[3] = { SUMA_CMAP_TOPLEFT }; - + SO = SUMA_Cmap_To_SO (CM, orig, topright, 2); if (SO) SUMA_Free_Surface_Object(SO); } exit(0); } - + /* show all the colors and colormaps in SAC on STDERR */ if (ShowMapdb) { fprintf (SUMA_STDERR, "%s: AFNI colormaps found in db:\n", FuncName); @@ -578,77 +578,77 @@ int main (int argc,char *argv[]) fprintf (SUMA_STDERR,"Error %s: No input file specified.\n", FuncName); exit(1); } - + /* default interpolation mode */ - if (interpmode == SUMA_UNDEFINED_MODE) interpmode = SUMA_INTERP; - + if (interpmode == SUMA_UNDEFINED_MODE) interpmode = SUMA_INTERP; + /* check input */ if (!SUMA_filexists (IntName)) { fprintf (SUMA_STDERR,"Error %s: File %s could not be found.\n", FuncName, IntName); exit(1); } - + if (frf && !CmapFileName) { fprintf (SUMA_STDERR,"Error %s: -frf option is only valid with -cmapfile.\n", FuncName); exit(1); } - + if (ApplyPercClip && ApplyClip) { fprintf (SUMA_STDERR,"Error %s: Simultaneous use of -clp and -perc_clp. You should be punished.\n", FuncName); exit(1); } - + if ((ApplyPercClip || ApplyClip) && arange >= 0.0) { fprintf (SUMA_STDERR,"Error %s: Simultaneous use of -clp/-perc_clp and -apr/anr.\n Read the help.\n", FuncName); exit(1); } - + if (iVopt || Vopt) { fprintf (SUMA_STDERR,"Error %s: -v and -iv are obsolete.\n Use -input option instead.\n", FuncName); exit(1); } - + if (!inopt) { fprintf (SUMA_STDERR,"Error %s: -input option must be specified.\n", FuncName); exit(1); } - + im = mri_read_1D (IntName); - + if (!im) { SUMA_S_Err("Failed to read file"); exit (1); } - + if (vcol < 0) { fprintf (SUMA_STDERR,"Error %s: vcol must be > 0\n", FuncName); exit(1); } - + far = MRI_FLOAT_PTR(im); if (icol < 0 && icol != -1) { fprintf (SUMA_STDERR,"Error %s: icol(%d) can only have -1 for a negative value\n", FuncName, icol); exit(1); } - + if (icol >= im->ny || vcol >= im->ny) { fprintf (SUMA_STDERR,"Error %s: icol(%d) and vcol(%d) must be < %d\nwhich is the number of columns in %s\n", FuncName, icol, vcol, im->ny, IntName); exit(1); } - - + + if (brfact <=0 || brfact > 1) { fprintf (SUMA_STDERR,"Error %s: BrightFact must be > 0 and <= 1.\n", FuncName); exit (1); } - + if (MaskColor[0] < 0 || MaskColor[0] > 1 || MaskColor[1] < 0 || MaskColor[1] > 1 || MaskColor[2] < 0 || MaskColor[2] > 1) { fprintf (SUMA_STDERR,"Error %s: MaskColor values must be >=0 <=1.\n", FuncName); exit(1); } - - + + N_V = im->nx; V = (float *) SUMA_calloc (N_V, sizeof(float)); iV = (int *) SUMA_calloc (N_V, sizeof(int)); @@ -656,77 +656,77 @@ int main (int argc,char *argv[]) fprintf (SUMA_STDERR,"Error %s: Could not allocate for V or iV.\n", FuncName); exit(1); } - + if (icol < 0) { for (ii=0; ii < N_V; ++ii) { - iV[ii] = ii; - V[ii] = far[vcol*N_V+ii]; - } + iV[ii] = ii; + V[ii] = far[vcol*N_V+ii]; + } } else { for (ii=0; ii < N_V; ++ii) { - iV[ii] = (int)far[icol*N_V+ii]; - V[ii] = far[vcol*N_V+ii]; + iV[ii] = (int)far[icol*N_V+ii]; + V[ii] = far[vcol*N_V+ii]; } } - + mri_free(im); im = NULL; /* read values per node */ /* SUMA_disp_vect (V, 3); */ - + /* find the min/max of V */ SUMA_MIN_MAX_VEC(V, N_V, Vmin, Vmax, Vminloc, Vmaxloc) - /* fprintf (SUMA_STDERR,"%s: Vmin=%f, Vmax = %f\n", FuncName, Vmin, Vmax);*/ - + /* fprintf (SUMA_STDERR,"%s: Vmin=%f, Vmax = %f\n", FuncName, Vmin, Vmax);*/ + if (arange == 0.0) { if (fabs((double)Vmin) > fabs((double)Vmax)) arange = (float)fabs((double)Vmin); else arange = (float)fabs((double)Vmax); } /* figure out the range if PercRange is used */ if (ApplyPercClip) { - + fprintf (SUMA_STDERR,"%s: Percentile range [%f..%f] is equivalent to ", FuncName, IntRange[0], IntRange[1]); Vsort = SUMA_PercRange (V, NULL, N_V, IntRange, IntRange, NULL); fprintf (SUMA_STDERR,"[%f..%f]\n", IntRange[0], IntRange[1]); ApplyClip = YUP; - + if (Vsort) SUMA_free(Vsort); else { fprintf (SUMA_STDERR,"Error %s: Error in SUMA_PercRange.\n", FuncName); exit(1); } } - - + + /* get the options for creating the scaled color mapping */ OptScl = SUMA_ScaleToMapOptInit(); if (!OptScl) { fprintf (SUMA_STDERR, "Error %s: Could not get scaling option structure.\n", FuncName); - exit (1); + exit (1); } - + /* work the options a bit */ if (ApplyMask) { OptScl->ApplyMask = ApplyMask; - OptScl->MaskRange[0] = MaskRange[0]; - OptScl->MaskRange[1] = MaskRange[1]; - OptScl->MaskColor[0] = MaskColor[0]; - OptScl->MaskColor[1] = MaskColor[1]; + OptScl->MaskRange[0] = MaskRange[0]; + OptScl->MaskRange[1] = MaskRange[1]; + OptScl->MaskColor[0] = MaskColor[0]; + OptScl->MaskColor[1] = MaskColor[1]; OptScl->MaskColor[2] = MaskColor[2]; } - + if (ApplyClip) { OptScl->ApplyClip = YUP; OptScl->IntRange[0] = IntRange[0]; OptScl->IntRange[1] = IntRange[1]; } OptScl->interpmode = interpmode; - + OptScl->BrightFact = brfact; - + if (MaskZero) OptScl->MaskZero = YUP; - + /* map the values in V to the colormap */ /* allocate space for the result */ SV = SUMA_Create_ColorScaledVect(N_V, 0); @@ -735,7 +735,7 @@ int main (int argc,char *argv[]) "Error %s: Could not allocate for SV.\n", FuncName); exit(1); } - + /* finally ! */ if (alaAFNI) { if (LocalHead) { @@ -753,7 +753,7 @@ int main (int argc,char *argv[]) exit(1); } } - + if (Sgn) { if (Sgn != CM->Sgn) { SUMA_S_Warn ("Mixing positive maps (all fractions > 0) " @@ -768,7 +768,7 @@ int main (int argc,char *argv[]) exit(1); } } else { - if (LocalHead) + if (LocalHead) fprintf (SUMA_STDERR,"%s: Calling SUMA_ScaleToMap\n", FuncName); if (!SUMA_ScaleToMap (V, N_V, Vmin, Vmax, CM, OptScl, SV)) { fprintf (SUMA_STDERR, @@ -776,27 +776,27 @@ int main (int argc,char *argv[]) exit(1); } } - + /* Now write the colored vector back to disk */ if (NoMaskCol) { for (k=0; k < N_V; ++k) { k3 = 3*k; - if (!SV->isMasked[k]) - fprintf (SUMA_STDOUT, "%d %f %f %f\n", + if (!SV->isMasked[k]) + fprintf (SUMA_STDOUT, "%d %f %f %f\n", iV[k], SV->cV[k3 ], SV->cV[k3+1], SV->cV[k3+2]); } } else { for (k=0; k < N_V; ++k) { k3 = 3*k; - fprintf (SUMA_STDOUT, "%d %f %f %f\n", + fprintf (SUMA_STDOUT, "%d %f %f %f\n", iV[k], SV->cV[k3 ], SV->cV[k3+1], SV->cV[k3+2]); } } - + /* freeing time */ if (V) SUMA_free(V); if (iV) SUMA_free(iV); - if (!FromAFNI && freecm) if (CM) SUMA_Free_ColorMap (CM); /* only free CM if + if (!FromAFNI && freecm) if (CM) SUMA_Free_ColorMap (CM); /* only free CM if it was a pointer copy from a map in SAC */ if (OptScl) SUMA_free(OptScl); if (SV) SUMA_Free_ColorScaledVect (SV); @@ -805,8 +805,7 @@ int main (int argc,char *argv[]) #else SAC = NULL; /* freeing is done in SUMAg_CF */ #endif - SUMA_Free_CommonFields(SUMAg_CF); - - SUMA_RETURN (0); -} + SUMA_Free_CommonFields(SUMAg_CF); + SUMA_RETURN (0); +} diff --git a/src/SUMA/SUMA_inspec.c b/src/SUMA/SUMA_inspec.c index d0bc7dd7e3..b8e990efe2 100644 --- a/src/SUMA/SUMA_inspec.c +++ b/src/SUMA/SUMA_inspec.c @@ -4,13 +4,13 @@ void usage_SUMA_inspec() { static char FuncName[]={"usage_SUMA_inspec"}; char * s = NULL; - + printf ( "\n" "Usage: inspec <-spec specfile> \n" " [-detail d] [-prefix newspecname] \n" " [-LRmerge leftspec rightspec]\n" " [-h/-help]\n" - "Outputs information found from specfile.\n" + "Outputs information found from specfile.\n" " -spec specfile: specfile to be read\n" " -prefix newspecname: rewrite spec file.\n" " -detail d: level of output detail default is 1 in general,\n" @@ -25,7 +25,7 @@ void usage_SUMA_inspec() s = SUMA_New_Additions(0, 1); printf("%s\n", s);SUMA_free(s); s = NULL; printf ( " Ziad S. Saad SSCC/NIMH/NIH saadz@mail.nih.gov \n" " Dec 2 03\n" - "\n"); + "\n"); return; } int main (int argc,char *argv[]) @@ -33,12 +33,12 @@ int main (int argc,char *argv[]) static char FuncName[]={"inspec"}; int detail, kar; char *spec_name=NULL, *spec_name_right=NULL,*outname=NULL, *state_rm=NULL; - SUMA_SurfSpecFile Spec; + SUMA_SurfSpecFile Spec; SUMA_Boolean brk; SUMA_Boolean LocalHead = NOPE; - + SUMA_mainENTRY; - + /* allocate space for CommonFields structure */ SUMAg_CF = SUMA_Create_CommonFields (); if (SUMAg_CF == NULL) { @@ -46,13 +46,13 @@ int main (int argc,char *argv[]) "Error %s: Failed in SUMA_Create_CommonFields\n", FuncName); exit(1); } - + if (argc < 3) { usage_SUMA_inspec (); exit (1); } - + kar = 1; brk = NOPE; detail = -1; @@ -62,7 +62,7 @@ int main (int argc,char *argv[]) /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/ if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0) { usage_SUMA_inspec(); - exit (1); + exit (0); } if (!brk && (strcmp(argv[kar], "-prefix") == 0)) { kar ++; @@ -81,7 +81,7 @@ int main (int argc,char *argv[]) } spec_name = argv[kar]; if (!SUMA_filexists(spec_name)) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "File %s not found or not readable.\n", spec_name); exit(1); } @@ -108,12 +108,12 @@ int main (int argc,char *argv[]) spec_name = argv[kar]; kar ++; spec_name_right = argv[kar]; if (!SUMA_filexists(spec_name)) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "File %s not found or not readable.\n", spec_name); exit(1); } if (!SUMA_filexists(spec_name_right)) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "File %s not found or not readable.\n", spec_name_right); exit(1); } @@ -133,28 +133,28 @@ int main (int argc,char *argv[]) } brk = YUP; } - + if (!brk) { fprintf (SUMA_STDERR, - "Error %s: Option %s not understood. Try -help for usage\n", + "Error %s: Option %s not understood. Try -help for usage\n", FuncName, argv[kar]); exit (1); - } else { + } else { brk = NOPE; kar ++; } } - + if (spec_name_right && detail < 0) detail = 0; - + if (detail < 0) detail = 1; - + if (!outname && !detail) { SUMA_SL_Err("No detail, or output file requested.\n" "Nothing to do here."); exit(1); } - + if (!spec_name) { SUMA_SL_Err("-spec option must be specified.\n"); exit(1); @@ -183,27 +183,27 @@ int main (int argc,char *argv[]) SUMA_FreeSpecFields(&Spec); Spec = SpecM; SUMA_FreeSpecFields(&SpecR); } - + if (state_rm) { SUMA_RemoveSpecState(&Spec, state_rm, 0, NULL); } - + /* showme the contents */ if (detail && !SUMA_ShowSpecStruct (&Spec, NULL, detail)) { SUMA_SL_Err("Failed in SUMA_ShowSpecStruct\n"); exit(1); } - + if (outname) { SUMA_Write_SpecFile(&Spec, outname, NULL, NULL); SUMA_free(outname); outname = NULL; } if (!SUMA_FreeSpecFields(&Spec)) { SUMA_S_Err("Error freeing"); exit(1); } - + if (!SUMA_Free_CommonFields(SUMAg_CF)) { fprintf(SUMA_STDERR,"Error %s: SUMAg_CF Cleanup Failed!\n", FuncName); exit(1); } - + SUMA_RETURN(0); }/* main inspec */ diff --git a/src/SUMA/SUMA_quickspec.c b/src/SUMA/SUMA_quickspec.c index 8ed974bc4b..07755b3f8a 100644 --- a/src/SUMA/SUMA_quickspec.c +++ b/src/SUMA/SUMA_quickspec.c @@ -5,8 +5,8 @@ void usage_SUMA_quickspec(SUMA_GENERIC_ARGV_PARSE *ps) static char FuncName[]={"usage_SUMA_quickspec"}; char * s = NULL, *sio=NULL; sio = SUMA_help_IO_Args(ps); - - printf ( + + printf ( "\nUsage: quickspec \n" " <-tn TYPE NAME> ...\n" " <-tsn TYPE STATE NAME> ...\n" @@ -37,7 +37,7 @@ void usage_SUMA_quickspec(SUMA_GENERIC_ARGV_PARSE *ps) " Default is quick.spec\n" " The program will only overwrite \n" " quick.spec (the default) spec file.\n" -" -h or -help: This message here.\n" +" -h or -help: This message here.\n" "\n" " You can use any combinaton of -tn and -tsn options.\n" " Fields in the spec file that are (or cannot) be specified\n" @@ -49,17 +49,17 @@ void usage_SUMA_quickspec(SUMA_GENERIC_ARGV_PARSE *ps) s = SUMA_New_Additions(0, 1); printf("%s\n", s);SUMA_free(s); s = NULL; printf(" Ziad S. Saad SSCC/NIMH/NIH saadz@mail.nih.gov \n\t\t Tue Dec 30\n" "\n"); - return; + return; } int main (int argc,char *argv[]) -{/* Main */ +{/* Main */ static char FuncName[]={"quickspec"}; int detail, kar, i, j, N_surf, N_name, idefstate; FILE *fid = NULL; char *spec_name, stmp[500], *Unique_st; SUMA_SO_File_Type TypeC[SUMA_MAX_N_SURFACE_SPEC]; - static char + static char *State[SUMA_MAX_N_SURFACE_SPEC], *Name_coord[SUMA_MAX_N_SURFACE_SPEC], *Name_topo[SUMA_MAX_N_SURFACE_SPEC], @@ -69,9 +69,9 @@ int main (int argc,char *argv[]) *LABEL[SUMA_MAX_N_SURFACE_SPEC]; SUMA_GENERIC_ARGV_PARSE *ps; SUMA_Boolean brk; - + SUMA_mainENTRY; - + /* allocate space for CommonFields structure */ SUMAg_CF = SUMA_Create_CommonFields (); if (SUMAg_CF == NULL) { @@ -79,15 +79,15 @@ int main (int argc,char *argv[]) "Error %s: Failed in SUMA_Create_CommonFields\n", FuncName); exit(1); } - + ps = SUMA_Parse_IO_Args(argc, argv, "-t;"); - + if (argc < 3) { usage_SUMA_quickspec (ps); exit (1); } - + kar = 1; brk = NOPE; detail = 1; @@ -98,7 +98,7 @@ int main (int argc,char *argv[]) /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/ if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0) { usage_SUMA_quickspec(ps); - exit (1); + exit (0); } if (!brk && (strcmp(argv[kar], "-spec") == 0)) { kar ++; @@ -108,7 +108,7 @@ int main (int argc,char *argv[]) } spec_name = argv[kar]; if (!THD_ok_overwrite() && SUMA_filexists(spec_name)) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "File %s exists, choose another one.\n", spec_name); exit(1); } @@ -117,7 +117,7 @@ int main (int argc,char *argv[]) if (!brk && (strcmp(argv[kar], "-tn") == 0)) { if (N_surf >= SUMA_MAX_N_SURFACE_SPEC) { SUMA_SL_Err("Exceeding maximum number of allowed surfaces..."); - exit(1); + exit(1); } /* get the type */ kar ++; @@ -126,13 +126,13 @@ int main (int argc,char *argv[]) exit (1); } TypeC[N_surf] = SUMA_SurfaceTypeCode(argv[kar]); - if (TypeC[N_surf] == SUMA_FT_ERROR || + if (TypeC[N_surf] == SUMA_FT_ERROR || TypeC[N_surf] == SUMA_FT_NOT_SPECIFIED) { fprintf (SUMA_STDERR, "%s is a bad file type.\n", argv[kar]); exit(1); } /* get the name */ - if (TypeC[N_surf] == SUMA_SUREFIT || TypeC[N_surf] == SUMA_VEC) + if (TypeC[N_surf] == SUMA_SUREFIT || TypeC[N_surf] == SUMA_VEC) N_name = 2; else N_name = 1; if (kar+N_name >= argc) { @@ -142,19 +142,19 @@ int main (int argc,char *argv[]) kar ++; Name_coord[N_surf] = argv[kar]; if (N_name == 2) { kar ++; Name_topo[N_surf] = argv[kar]; - } else { + } else { Name_topo[N_surf] = NULL; } State[N_surf] = NULL; Anat[N_surf] = 'Y'; LDP[N_surf] = NULL; - ++N_surf; + ++N_surf; brk = YUP; } if (!brk && (strcmp(argv[kar], "-tsn") == 0)) { if (N_surf >= SUMA_MAX_N_SURFACE_SPEC) { SUMA_SL_Err("Exceeding maximum number of allowed surfaces..."); - exit(1); + exit(1); } /* get the type */ kar ++; @@ -163,7 +163,7 @@ int main (int argc,char *argv[]) exit (1); } TypeC[N_surf] = SUMA_SurfaceTypeCode(argv[kar]); - if ( TypeC[N_surf] == SUMA_FT_ERROR || + if ( TypeC[N_surf] == SUMA_FT_ERROR || TypeC[N_surf] == SUMA_FT_NOT_SPECIFIED) { fprintf (SUMA_STDERR, "%s is a bad file TYPE.\n", argv[kar]); exit(1); @@ -171,14 +171,14 @@ int main (int argc,char *argv[]) /* get the state */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "STATE argument must follow TYPE with -tsn \n"); exit (1); } State[N_surf] = argv[kar]; - + /* get the name */ - if ( TypeC[N_surf] == SUMA_SUREFIT || + if ( TypeC[N_surf] == SUMA_SUREFIT || TypeC[N_surf] == SUMA_VEC) N_name = 2; else N_name = 1; if (kar+N_name >= argc) { @@ -188,20 +188,20 @@ int main (int argc,char *argv[]) kar ++; Name_coord[N_surf] = argv[kar]; if (N_name == 2) { kar ++; Name_topo[N_surf] = argv[kar]; - } else { + } else { Name_topo[N_surf] = NULL; } - + Anat[N_surf] = 'Y'; LDP[N_surf] = NULL; - ++N_surf; + ++N_surf; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-tsnad") == 0)) { if (N_surf >= SUMA_MAX_N_SURFACE_SPEC) { SUMA_SL_Err("Exceeding maximum number of allowed surfaces..."); - exit(1); + exit(1); } /* get the type */ kar ++; @@ -210,7 +210,7 @@ int main (int argc,char *argv[]) exit (1); } TypeC[N_surf] = SUMA_SurfaceTypeCode(argv[kar]); - if ( TypeC[N_surf] == SUMA_FT_ERROR || + if ( TypeC[N_surf] == SUMA_FT_ERROR || TypeC[N_surf] == SUMA_FT_NOT_SPECIFIED) { fprintf (SUMA_STDERR, "%s is a bad file TYPE.\n", argv[kar]); exit(1); @@ -218,14 +218,14 @@ int main (int argc,char *argv[]) /* get the state */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "STATE argument must follow TYPE with -tsnad \n"); exit (1); } State[N_surf] = argv[kar]; - + /* get the name */ - if ( TypeC[N_surf] == SUMA_SUREFIT || + if ( TypeC[N_surf] == SUMA_SUREFIT || TypeC[N_surf] == SUMA_VEC) N_name = 2; else N_name = 1; if (kar+N_name >= argc) { @@ -235,15 +235,15 @@ int main (int argc,char *argv[]) kar ++; Name_coord[N_surf] = argv[kar]; if (N_name == 2) { kar ++; Name_topo[N_surf] = argv[kar]; - } else { + } else { Name_topo[N_surf] = NULL; } - - + + /* get the anatomical flag */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "Anatomical flag must follow NAME with -tsnad \n"); exit (1); } @@ -255,20 +255,20 @@ int main (int argc,char *argv[]) /* get the LDP */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "LocalDomainParent must follow Anatomical flag with -tsnad \n"); exit (1); } LDP[N_surf] = argv[kar]; - - ++N_surf; + + ++N_surf; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-tsnadm") == 0)) { if (N_surf >= SUMA_MAX_N_SURFACE_SPEC) { SUMA_SL_Err("Exceeding maximum number of allowed surfaces..."); - exit(1); + exit(1); } /* get the type */ kar ++; @@ -277,7 +277,7 @@ int main (int argc,char *argv[]) exit (1); } TypeC[N_surf] = SUMA_SurfaceTypeCode(argv[kar]); - if ( TypeC[N_surf] == SUMA_FT_ERROR || + if ( TypeC[N_surf] == SUMA_FT_ERROR || TypeC[N_surf] == SUMA_FT_NOT_SPECIFIED) { fprintf (SUMA_STDERR, "%s is a bad file TYPE.\n", argv[kar]); exit(1); @@ -285,14 +285,14 @@ int main (int argc,char *argv[]) /* get the state */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "STATE argument must follow TYPE with -tsnad \n"); exit (1); } State[N_surf] = argv[kar]; - + /* get the name */ - if ( TypeC[N_surf] == SUMA_SUREFIT || + if ( TypeC[N_surf] == SUMA_SUREFIT || TypeC[N_surf] == SUMA_VEC) N_name = 2; else N_name = 1; if (kar+N_name >= argc) { @@ -302,15 +302,15 @@ int main (int argc,char *argv[]) kar ++; Name_coord[N_surf] = argv[kar]; if (N_name == 2) { kar ++; Name_topo[N_surf] = argv[kar]; - } else { + } else { Name_topo[N_surf] = NULL; } - - + + /* get the anatomical flag */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "Anatomical flag must follow NAME with -tsnad \n"); exit (1); } @@ -322,28 +322,28 @@ int main (int argc,char *argv[]) /* get the LDP */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "LocalDomainParent must follow Anatomical flag with -tsnad \n"); exit (1); } LDP[N_surf] = argv[kar]; - + /* get the nodeMarker */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "LocalDomainParent must follow Anatomical flag with -tsnad \n"); exit (1); } MARK[N_surf] = argv[kar]; - ++N_surf; + ++N_surf; brk = YUP; } - + if (!brk && (strcmp(argv[kar], "-tsnadl") == 0)) { if (N_surf >= SUMA_MAX_N_SURFACE_SPEC) { SUMA_SL_Err("Exceeding maximum number of allowed surfaces..."); - exit(1); + exit(1); } /* get the type */ kar ++; @@ -352,7 +352,7 @@ int main (int argc,char *argv[]) exit (1); } TypeC[N_surf] = SUMA_SurfaceTypeCode(argv[kar]); - if ( TypeC[N_surf] == SUMA_FT_ERROR || + if ( TypeC[N_surf] == SUMA_FT_ERROR || TypeC[N_surf] == SUMA_FT_NOT_SPECIFIED) { fprintf (SUMA_STDERR, "%s is a bad file TYPE.\n", argv[kar]); exit(1); @@ -360,14 +360,14 @@ int main (int argc,char *argv[]) /* get the state */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "STATE argument must follow TYPE with -tsnad \n"); exit (1); } State[N_surf] = argv[kar]; - + /* get the name */ - if ( TypeC[N_surf] == SUMA_SUREFIT || + if ( TypeC[N_surf] == SUMA_SUREFIT || TypeC[N_surf] == SUMA_VEC) N_name = 2; else N_name = 1; if (kar+N_name >= argc) { @@ -377,15 +377,15 @@ int main (int argc,char *argv[]) kar ++; Name_coord[N_surf] = argv[kar]; if (N_name == 2) { kar ++; Name_topo[N_surf] = argv[kar]; - } else { + } else { Name_topo[N_surf] = NULL; } - - + + /* get the anatomical flag */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "Anatomical flag must follow NAME with -tsnad \n"); exit (1); } @@ -397,35 +397,35 @@ int main (int argc,char *argv[]) /* get the LDP */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "LocalDomainParent must follow Anatomical flag with -tsnad \n"); exit (1); } LDP[N_surf] = argv[kar]; - + /* get the nodeMarker */ kar ++; if (kar >= argc) { - fprintf (SUMA_STDERR, + fprintf (SUMA_STDERR, "LocalDomainParent must follow Anatomical flag with -tsnad \n"); exit (1); } LABEL[N_surf] = argv[kar]; - ++N_surf; + ++N_surf; brk = YUP; } - + if (!brk) { fprintf (SUMA_STDERR, - "Error %s: Option %s not understood. Try -help for usage\n", + "Error %s: Option %s not understood. Try -help for usage\n", FuncName, argv[kar]); exit (1); - } else { + } else { brk = NOPE; kar ++; } } - + /* write out the comments */ if (!spec_name) { fid = fopen("quick.spec", "w"); @@ -438,8 +438,8 @@ int main (int argc,char *argv[]) } fprintf(fid,"# define the group\n"); fprintf(fid,"\tGroup = QuickSpec\n"); - - + + /* now create a list of unique states */ idefstate = 0; if (!State[0]) { @@ -450,11 +450,11 @@ int main (int argc,char *argv[]) Unique_st = SUMA_copy_string (stmp); } for (i=1; i < N_surf; ++i) { - if (!State[i]) { + if (!State[i]) { ++idefstate; sprintf(stmp,"\tStateDef = S_%d\n", idefstate); Unique_st = SUMA_append_replace_string (Unique_st, stmp, "", 1); - } else { + } else { if (SUMA_iswordin(Unique_st, State[i]) != 1) { sprintf(stmp, "\tStateDef = %s\n", State[i]); Unique_st = SUMA_append_replace_string(Unique_st, stmp, "", 1); @@ -463,11 +463,11 @@ int main (int argc,char *argv[]) } fprintf (fid, "# define the various States\n"); fprintf (fid, "%s\n", Unique_st); - + /* check on LDP correctness */ for (i=0; i < N_surf; ++i) { if (LDP[i]) { - if (!strcmp(LDP[i],"same") || !strcmp(LDP[i],"Same")) + if (!strcmp(LDP[i],"same") || !strcmp(LDP[i],"Same")) SUMA_TO_UPPER(LDP[i]); if (strcmp(LDP[i],"SAME")) { j= 0; @@ -483,13 +483,13 @@ int main (int argc,char *argv[]) } } } - } + } /* now loop accross surfaces and write out the results */ idefstate = 0; for (i=0; i < N_surf; ++i) { fprintf(fid, "\nNewSurface\n"); fprintf(fid, "\tSurfaceType = %s\n", SUMA_SurfaceTypeString(TypeC[i])); - if (!State[i]) { + if (!State[i]) { ++idefstate; fprintf(fid, "\tSurfaceState = S_%d\n", idefstate); } else fprintf(fid, "\tSurfaceState = %s\n", State[i]); @@ -497,7 +497,7 @@ int main (int argc,char *argv[]) fprintf(fid, "\tCoordFile = %s\n", Name_coord[i]); fprintf(fid, "\tTopoFile = %s\n", Name_topo[i]); } else { - fprintf(fid, "\tSurfaceName = %s\n", Name_coord[i]); + fprintf(fid, "\tSurfaceName = %s\n", Name_coord[i]); } /* add LocalDomainParent */ if (LDP[i]) fprintf(fid, "\tLocalDomainParent = %s\n", LDP[i]); @@ -508,7 +508,7 @@ int main (int argc,char *argv[]) /* add nodeMarker */ if (MARK[i]) fprintf(fid, "\tNodeMarker = %s\n", MARK[i]); if (LABEL[i]) fprintf(fid, "\tLabelDset = %s\n", LABEL[i]); - + /* binary ? */ switch (TypeC[i]) { case SUMA_FREE_SURFER: @@ -520,11 +520,11 @@ int main (int argc,char *argv[]) break; } } - + fclose(fid); fid = NULL; - + if (Unique_st) SUMA_free(Unique_st); Unique_st = NULL; - + if (ps) SUMA_FreeGenericArgParse(ps); ps = NULL; if (!SUMA_Free_CommonFields(SUMAg_CF)) { fprintf(SUMA_STDERR,"Error %s: SUMAg_CF Cleanup Failed!\n", FuncName); @@ -532,5 +532,5 @@ int main (int argc,char *argv[]) } SUMA_RETURN(0); - + }/* main quickspec */ diff --git a/src/rickr/Dimon.c b/src/rickr/Dimon.c index 70612a2031..3016d8a418 100644 --- a/src/rickr/Dimon.c +++ b/src/rickr/Dimon.c @@ -445,7 +445,7 @@ int main( int argc, char * argv[] ) int ret_val; mainENTRY("Dimon"); - + /* validate inputs and init options structure */ if ( (ret_val = init_options( p, ac, argc, argv )) != 0 ) return ret_val; @@ -468,7 +468,7 @@ int main( int argc, char * argv[] ) * * This function runs until either a volume is located, or an * error occurs. - * + * * return: 0 : on success * else : error *---------------------------------------------------------------------- @@ -569,31 +569,31 @@ static int find_first_volume( vol_t * v, param_t * p, ART_comm * ac ) fprintf(stderr,"\n-- first volume found (%d slices)\n",v->nim); if ( gD.level > 1 ) idisp_vol_t( "+d first volume : ", v ); } - + /* allow reading up to 4 volumes at a time */ if( p->max2read > 0 && p->max2read < 4 * v->nim ) update_max2read(p, 4*v->nim); - + /* use this volume to complete the geh.orients string */ if ( complete_orients_str( v, p ) < 0 ) return -1; - + /* use this volume to note the byte order of image data */ if ( check_im_byte_order( &ac->byte_order, v, p ) < 0 ) return -1; - + v->seq_num = 1; /* if wanted, verify afni link, send image info and first volume */ if ( ac->state == ART_STATE_TO_OPEN ) ART_open_afni_link( ac, 5, 0, gD.level ); - + if ( ac->state == ART_STATE_TO_SEND_CTRL ) ART_send_control_info( ac, v, gD.level ); - + if ( ac->state == ART_STATE_IN_USE ) ART_send_volume( ac, v, gD.level ); - + /* update status on included images, and set new search point */ update_states(p, v->fs_1, v->fs_1+v->nim-1, IFM_FSTATE_DONE, 1); p->fim_start = v->fs_1+v->nim; @@ -620,7 +620,7 @@ int update_max2read(param_t * p, int max) if( max <= 0 ) return 1; p->max2read = max; - + return 0; } @@ -629,7 +629,7 @@ int update_max2read(param_t * p, int max) * find_more_volumes: given first volume, keep scanning for others * * This function runs until a fatal error occurs. - * + * * return: 0 : on success * else : error *---------------------------------------------------------------------- @@ -831,11 +831,11 @@ int nap_for_ms(int ms) * * - start should be at the expected beginning of a volume! * - *fl_start may be returned as a new starting index into fnames - * + * * state: 0 : < 2 slices found (in the past) * 1 : >= 2 slices (new 'bound') * 2 : >= 2 slices (repeated 'bound', may be one volume run) - * + * * return: -2 : on programming error * -1 : on data error * 0 : on success - no volume yet @@ -1236,7 +1236,7 @@ static int num_slices_ok( int num_slices, int nfound, char * mesg ) * volume_match: scan p->fim_o for a matching volume * * - start should be at the expected beginning of a volume! - * + * * return: -4 : fatal error: die * -3 : small error: no data check needed * -2 : small error: want to nap @@ -1431,7 +1431,7 @@ static int check_error( int * retry, float tr, char * note ) /* so calling function should print error, but start over */ - *retry = IFM_NUM_RETRIES; + *retry = IFM_NUM_RETRIES; return 1; } @@ -1451,7 +1451,7 @@ static int check_error( int * retry, float tr, char * note ) * (so a TR's worth could be accumulated, say) * - apply any sort based on image info: fim_o => fim->s * - process unprocessed images - * + * * return: < 0 : on error * 0 : nothing to process * 1 : something new happened @@ -1532,7 +1532,7 @@ static int make_sorted_fim_list(param_t * p) * fim_start should be incremented with completed volumes. * Sort the remaining pointers pulling any "completed" ones * down early (FAILED, SKIP, UNKNOWN, DONE (should not happen)). - * + * * For now, warn about any images that are not TO_PROC or _READ. */ @@ -1606,7 +1606,7 @@ static int make_sorted_fim_list(param_t * p) p->fim_start += index; } break; - } + } if( gD.level > 0 ) fprintf(stderr, "** bad image state: ind %d, errs %d, state %d (%s), file %s\n", @@ -1651,7 +1651,7 @@ static int finfo_order_as_zt(param_t * p, finfo_t * flist, int n2sort) fprintf(stderr,"** order_as_zt: (ns=%d*nt=%d = %d) != n2sort %d\n", ns, nt, ns*nt, n2sort); } - + /* noting to do? */ if( nt < 2 ) return 0; @@ -1947,7 +1947,7 @@ int geme_find_block_end(param_t * p, int start) memin = p->fim_o[start].gex.ge_me_index; memax = memin; imax = start; - + for( c = start+1; c < p->nfim; c++ ) { meind = p->fim_o[c].gex.ge_me_index; @@ -2042,7 +2042,7 @@ int nfim2proc(param_t * p) * - if states differ, sort on state * (state values are arranged to make sorting appropriate) * - if state != TO_PROC, sort on findex (i.e. leave as found) - * - + * - * state: FAILED, SKIP, DONE, UNKNOWN (should not happen) TO_PROC, TO_READ * * return < 0, 0, > 0, according to direction of p0 vs p1 @@ -2188,7 +2188,7 @@ int append_new_finfo_entry(param_t * p, char * fname) if( gD.level > 3 ) fprintf(stderr,"++ creating new finfo for %s\n", fname); /* might need to allocate space */ - if( p->nfim >= p->nfalloc ) { + if( p->nfim >= p->nfalloc ) { int step = 50; p->nfalloc += step; p->fim_o = (finfo_t *)realloc(p->fim_o, p->nfalloc*sizeof(finfo_t)); @@ -2464,7 +2464,7 @@ static int read_new_images( param_t * p ) /* if( stat && gD.level && !(nread%stat) ) fputc('.', stderr); */ if( stat && gD.level && !(nread%stat) ) fprintf(stderr,"%s %3d%%", back5, (int)(100.0*nread/n2read)); - + if( p->max2read > 0 && nread >= p->max2read ) { if( gD.level > 2 ) fprintf(stderr, "-- RNI: read max of %d images", nread); @@ -3357,7 +3357,7 @@ static int init_options( param_t * p, ART_comm * A, int argc, char * argv[] ) } if ( ! IM_IS_GEMS(p->ftype) ) - { + { if( ! p->opts.dicom_glob && ! p->opts.infile_list ) { fprintf(stderr,"** missing -infile_pattern option\n"); @@ -3475,7 +3475,7 @@ static int init_extras( param_t * p, ART_comm * ac ) ac->mode = AFNI_OPEN_CONTROL_MODE; ART_open_afni_link( ac, 2, 1, gD.level ); } - + /* check directory depth of start_file against glob_dir */ if ( p->opts.start_file != NULL ) { @@ -3718,7 +3718,7 @@ static int read_dicom_image( char * pathname, finfo_t * fp, int get_data ) int rv = 0, ind; /* now use mri_read_dicom() directly 4 Jan 2011 */ - /* im = r_mri_read_dicom( pathname, gD.level, + /* im = r_mri_read_dicom( pathname, gD.level, get_data ? &fp->image : NULL); */ /* init globals to be used in mri_read_dicom.c 4 Jan 2011 */ @@ -3757,7 +3757,7 @@ static int read_dicom_image( char * pathname, finfo_t * fp, int get_data ) /* --------------------------------------------------------------- */ /* process any siemens timing info only once 15 Apr 2011 - * + * * Process the times by calling populate_g_siemens_times() after * reading a single DICOM file. If valid, g_siemens_timing_nused * and g_siemens_timing_times[] will be set. @@ -3786,7 +3786,7 @@ static int read_dicom_image( char * pathname, finfo_t * fp, int get_data ) pathname, g_image_info.study, g_image_info.series, g_image_info.image, g_image_info.image_index, g_image_info.acq_time, - g_image_info.is_obl, g_image_info.is_mosaic, + g_image_info.is_obl, g_image_info.is_mosaic, g_image_info.mos_nx, g_image_info.mos_ny, g_image_info.mos_nslice ); fprintf(stderr," GIPx, GIPy, GIPz (M_z) (%6.1f, %6.1f, %6.1f (%f))\n", @@ -4005,7 +4005,7 @@ static int read_ge_image( char * pathname, finfo_t * fp, /* nuke mosaic structs */ memset(&fp->minfo, 0, sizeof(mosaic_info)); - + if( gehp == NULL ) return -1; /* bad */ gehp->good = 0 ; /* not good yet */ if( pathname == NULL || @@ -4168,7 +4168,7 @@ static int read_ge_image( char * pathname, finfo_t * fp, fread( &uv17 , 4, 1 , imfile ) ; if( swap ) swap_4(&uv17) ; /* printf ("%d ", (int)uv17); */ - gehp->uv17 = (int)uv17; + gehp->uv17 = (int)uv17; /* printf ("\n"); */ /* store the ge_extra info */ @@ -4182,7 +4182,7 @@ static int read_ge_image( char * pathname, finfo_t * fp, gexp->ge_nim_acq = -1; memcpy( gexp->xyz, xyz, sizeof(xyz) ); - + gehp->good = 1 ; /* this is a good file */ } /* end of actually reading image header */ @@ -4415,7 +4415,7 @@ static int disp_ftype( char * info, int ftype ) if ( info ) fputs(info, stream); fprintf(stream, "%s (%d)\n", ftype_string(ftype), ftype); - + fflush(stream); return 0; @@ -4603,7 +4603,7 @@ static int idisp_mosaic_info( char * info, mosaic_info * I ) } /*---------------------------------------------------------------------- - * usage + * usage *---------------------------------------------------------------------- */ static int usage ( char * prog, int level ) @@ -4930,7 +4930,7 @@ prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog ); - + printf( " notes:\n" "\n" @@ -5932,7 +5932,7 @@ static int create_gert_dicom( stats_t * s, param_t * p ) /* If the user did not give a slice pattern string, use the default * * (default is "FROM_IMAGE" if siemens timing info). * Check that siemens timing info has correct nz. 15 Apr 2011 */ - + spat = (g_siemens_timing_nused > 0) ? "FROM_IMAGE" : IFM_SLICE_PAT; if ( opts->sp ) spat = opts->sp; @@ -6028,14 +6028,14 @@ static int create_gert_dicom( stats_t * s, param_t * p ) } /* if gert_format = 1, write as NIfTI */ - fprintf(fp, "%*sto3d%s%s -prefix %s%s%s%s \\\n", + fprintf(fp, "%*sto3d%s%s -prefix %s%s%s%s \\\n", indent, "", opts->assume_dicom_mosaic==1 ? " -assume_dicom_mosaic" : "", opts->gert_quiterr==1 ? " -quit_on_err" : "", pname, /* if multi-chan, use either prefix or _chan_, else "" */ - opts->num_chan > 1 ? - opts->chan_prefix ? opts->chan_prefix : "_chan_" + opts->num_chan > 1 ? + opts->chan_prefix ? opts->chan_prefix : "_chan_" : "", opts->num_chan > 1 ? "$chan" : "", opts->gert_format==1 ? ".nii" : "" ); @@ -6191,7 +6191,7 @@ FILE * get_file_pointer(char * fname, char * mesg, int index) else sprintf(fnew, "%s.%d.txt", fname, index); if(gD.level>0) fprintf(stderr,"-- writing details to %s...\n", fnew); } else fnew = fname; - + fp = fopen(fnew, "w"); if( !fp ) { fprintf(stderr,"** failed to open '%s' for writing\n",fnew); @@ -6284,7 +6284,7 @@ static int create_file_list( param_t *p, char *fname, int details, char *mesg ) fprintf(fp, "%s\n", p->fim_o[c].fname); if( fp != stderr && fp != stdout ) fclose(fp); - + if( gD.level > 2 ) fprintf(stderr,"-- file list written for %s\n", fname ? fname : "def=stderr"); @@ -6478,7 +6478,7 @@ static int show_run_stats( stats_t * s ) } /* check image file type */ - + if ( s->mos_nslices > 1 ) { if ( IM_IS_AFNI(gP.ftype) ) tstr = "(AFNI volume)"; else if ( IM_IS_DICOM(gP.ftype) ) tstr = "(DICOM mosaic)"; @@ -6827,7 +6827,7 @@ static int complete_orients_str( vol_t * v, param_t * p ) v->geh.orients[5] = 'P'; } break; - + case 3: /* IS */ if ( v->z_delta > 0 ) { @@ -6840,7 +6840,7 @@ static int complete_orients_str( vol_t * v, param_t * p ) v->geh.orients[5] = 'I'; } break; - + default: { fprintf(stderr, "** COS failure: kk (%d) not in [1,3]\n", kk); @@ -6850,7 +6850,7 @@ static int complete_orients_str( vol_t * v, param_t * p ) } if ( gD.level > 2 ) fprintf(stderr,"'%s'\n", v->geh.orients); - + return 0; } @@ -7033,4 +7033,3 @@ int disp_obl_info(char * mesg) return 0; } - diff --git a/src/rickr/Dimon1.c b/src/rickr/Dimon1.c index 7848187028..88f545b40d 100644 --- a/src/rickr/Dimon1.c +++ b/src/rickr/Dimon1.c @@ -358,7 +358,7 @@ int main( int argc, char * argv[] ) int ret_val; mainENTRY("Dimon"); - + /* validate inputs and init options structure */ if ( (ret_val = init_options( p, ac, argc, argv )) != 0 ) return ret_val; @@ -381,7 +381,7 @@ int main( int argc, char * argv[] ) * * This function runs until either a volume is located, or an * error occurs. - * + * * return: 0 : on success * else : error *---------------------------------------------------------------------- @@ -496,9 +496,9 @@ static int find_first_volume( vol_t * v, param_t * p, ART_comm * ac ) } } } - + /* make sure there is enough memory for bad volumes */ - if ( p->nalloc < (4 * v->nim) ) + if ( p->nalloc < (4 * v->nim) ) { p->nalloc = 4 * v->nim; p->flist = (finfo_t *)realloc( p->flist, @@ -509,29 +509,29 @@ static int find_first_volume( vol_t * v, param_t * p, ART_comm * ac ) "structs!\n", p->nalloc ); return -1; } - + if ( gD.level > 2 ) idisp_param_t( "++ final realloc of flist : ", p ); } - + /* use this volume to complete the geh.orients string */ if ( complete_orients_str( v, p ) < 0 ) return -1; - + /* use this volume to note the byte order of image data */ if ( check_im_byte_order( &ac->byte_order, v, p ) < 0 ) return -1; - + /* if wanted, verify afni link, send image info and first volume */ if ( ac->state == ART_STATE_TO_OPEN ) ART_open_afni_link( ac, 5, 0, gD.level ); - + if ( ac->state == ART_STATE_TO_SEND_CTRL ) ART_send_control_info( ac, v, gD.level ); - + if ( ac->state == ART_STATE_IN_USE ) ART_send_volume( ac, v, gD.level ); - + if ( gD.level > 2 ) { ART_idisp_ART_comm( "-- first vol ", ac ); @@ -551,7 +551,7 @@ static int find_first_volume( vol_t * v, param_t * p, ART_comm * ac ) * find_more_volumes: given first volume, keep scanning for others * * This function runs until a fatal error occurs. - * + * * return: 0 : on success * else : error *---------------------------------------------------------------------- @@ -761,11 +761,11 @@ static int find_more_volumes( vol_t * v0, param_t * p, ART_comm * ac ) * * - start should be at the expected beginning of a volume! * - *fl_start may be returned as a new starting index into fnames - * + * * state: 0 : < 2 slices found (in the past) * 1 : >= 2 slices (new 'bound') * 2 : >= 2 slices (repeated 'bound', may be one volume run) - * + * * return: -2 : on programming error * -1 : on data error * 0 : on success - no volume yet @@ -1123,7 +1123,7 @@ static int num_slices_ok( int num_slices, int nfound, char * mesg ) * volume_match: scan p->flist for a matching volume * * - start should be at the expected beginning of a volume! - * + * * return: -2 : fatal error * -1 : recoverable data error * 0 : on success - no volume yet @@ -1201,7 +1201,7 @@ static int volume_match( vol_t * vin, vol_t * vout, param_t * p, int start ) else /* unknown error - find start of next volume */ { /* search for a next starting point */ - next_start = find_next_zoff( p, start+count, vin->z_first, + next_start = find_next_zoff( p, start+count, vin->z_first, vin->nim ); if ( next_start < 0 ) /* come back and try again later */ return 0; @@ -1239,7 +1239,7 @@ static int volume_match( vol_t * vin, vol_t * vout, param_t * p, int start ) /* check last slice - count and fp should be okay*/ if ( (p->nused - start) <= vin->nim ) /* no more images to check */ return 0; /* wait for more data */ - + fp_test = fp + 1; /* check next image */ if ( fabs( vin->z_first - fp_test->geh.zoff ) < gD_epsilon ) { @@ -1270,7 +1270,7 @@ static int volume_match( vol_t * vin, vol_t * vout, param_t * p, int start ) else /* unknown error - find start of next volume */ { /* search for a next starting point */ - next_start = find_next_zoff( p, start+count+1, vin->z_first, + next_start = find_next_zoff( p, start+count+1, vin->z_first, vin->nim ); if ( next_start < 0 ) /* come back and try again later */ @@ -1386,7 +1386,7 @@ static int check_error( int * retry, float tr, char * note ) * - decide number of files to scan (max == 0 implies the rest) * - allocate necessary p->flist memory * - read GE structures - * + * * return: < 0 : on error * files read : on success *---------------------------------------------------------------------- @@ -1474,7 +1474,7 @@ static int read_ge_files( return 0; } } - + if ( gD.level > 4 ) { int fnum; @@ -1671,7 +1671,7 @@ static int scan_ge_files ( rv = read_dicom_image( p->fnames[fnum], fp, 1 ); else if ( IM_IS_AFNI(p->ftype) ) rv = read_afni_image( p->fnames[fnum], fp, 1 ); - else + else rv = read_ge_image( p->fnames[fnum], fp, 1, need_M ); /* don't lose any allocated memory, regardless of the return value */ @@ -1773,7 +1773,7 @@ static int dicom_order_files( param_t * p ) } else if( p->nfiles < 2 ) { fprintf(stderr,"** but ordering only 1 file is easy...\n"); return 0; - } + } if ( ! IM_IS_DICOM(p->ftype) ) { fprintf(stderr,"** Dimon: needs update to sort '%s' files\n", @@ -1867,7 +1867,7 @@ static int dicom_order_files( param_t * p ) scount++; /* count sort inversions, say */ if( bad == 1 ){ free(flist); return -1; } - + /* if we don't accomplish anything, return 0, else 1 */ if( scount == 0 && p->nfiles == dcount ) rv = 0; else rv = 1; @@ -2626,7 +2626,7 @@ static int init_options( param_t * p, ART_comm * A, int argc, char * argv[] ) } if ( ! IM_IS_GEMS(p->ftype) ) - { + { if( ! p->opts.dicom_glob && ! p->opts.infile_list ) { fprintf(stderr,"** missing -infile_pattern option\n"); @@ -2696,7 +2696,7 @@ static int init_extras( param_t * p, ART_comm * ac ) ac->mode = AFNI_OPEN_CONTROL_MODE; ART_open_afni_link( ac, 2, 1, gD.level ); } - + /* check directory depth of start_file against glob_dir */ if ( p->opts.start_file != NULL ) { @@ -2921,7 +2921,7 @@ static int read_dicom_image( char * pathname, finfo_t * fp, int get_data ) int rv = 0, ind; /* now use mri_read_dicom() directly 4 Jan 2011 */ - /* im = r_mri_read_dicom( pathname, gD.level, + /* im = r_mri_read_dicom( pathname, gD.level, get_data ? &fp->image : NULL); */ /* init globals to be used in mri_read_dicom.c 4 Jan 2011 */ @@ -2959,7 +2959,7 @@ static int read_dicom_image( char * pathname, finfo_t * fp, int get_data ) /* --------------------------------------------------------------- */ /* process any siemens timing info only once 15 Apr 2011 - * + * * Process the times by calling populate_g_siemens_times() after * reading a single DICOM file. If valid, g_siemens_timing_nused * and g_siemens_timing_times[] will be set. @@ -2988,7 +2988,7 @@ static int read_dicom_image( char * pathname, finfo_t * fp, int get_data ) pathname, g_image_info.study, g_image_info.series, g_image_info.image, g_image_info.image_index, g_image_info.acq_time, - g_image_info.is_obl, g_image_info.is_mosaic, + g_image_info.is_obl, g_image_info.is_mosaic, g_image_info.mos_nx, g_image_info.mos_ny, g_image_info.mos_nslice ); fprintf(stderr," GIPx, GIPy, GIPz (M_z) (%6.1f, %6.1f, %6.1f (%f))\n", @@ -3219,7 +3219,7 @@ static int read_ge_image( char * pathname, finfo_t * fp, /* nuke mosaic structs */ memset(&fp->minfo, 0, sizeof(mosaic_info)); - + if( hi == NULL ) return -1; /* bad */ hi->good = 0 ; /* not good yet */ if( pathname == NULL || @@ -3382,7 +3382,7 @@ static int read_ge_image( char * pathname, finfo_t * fp, fread( &uv17 , 4, 1 , imfile ) ; if( swap ) swap_4(&uv17) ; /* printf ("%d ", (int)uv17); */ - hi->uv17 = (int)uv17; + hi->uv17 = (int)uv17; /* printf ("\n"); */ /* store the ge_extra info */ @@ -3394,7 +3394,7 @@ static int read_ge_image( char * pathname, finfo_t * fp, fp->gex.kk = kk; memcpy( fp->gex.xyz, xyz, sizeof(xyz) ); - + hi->good = 1 ; /* this is a good file */ } /* end of actually reading image header */ @@ -3610,7 +3610,7 @@ static int disp_ftype( char * info, int ftype ) if ( info ) fputs(info, stdout); printf("%s (%d)\n", ftype_string(ftype), ftype); - + fflush(stdout); return 0; @@ -3753,7 +3753,7 @@ static int idisp_mosaic_info( char * info, mosaic_info * I ) } /*---------------------------------------------------------------------- - * usage + * usage *---------------------------------------------------------------------- */ static int usage ( char * prog, int level ) @@ -4067,7 +4067,7 @@ static int usage ( char * prog, int level ) prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog ); - + printf( " notes:\n" "\n" @@ -4887,7 +4887,7 @@ static int create_gert_dicom( stats_t * s, param_t * p ) /* If the user did not give a slice pattern string, use the default * * (default is "FROM_IMAGE" if siemens timing info). * Check that siemens timing info has correct nz. 15 Apr 2011 */ - + spat = (g_siemens_timing_nused > 0) ? "FROM_IMAGE" : IFM_SLICE_PAT; if ( opts->sp ) spat = opts->sp; @@ -4984,7 +4984,7 @@ static int create_gert_dicom( stats_t * s, param_t * p ) else nspaces = 0; /* if gert_format = 1, write as NIfTI */ - fprintf(fp, "to3d%s -prefix %s%s \\\n", + fprintf(fp, "to3d%s -prefix %s%s \\\n", opts->gert_quiterr==1 ? " -quit_on_err" : "", pname, opts->gert_format==1 ? ".nii" : "" ); @@ -5203,7 +5203,7 @@ static int show_run_stats( stats_t * s ) /* note image file type and set type string */ ftypestr = get_ftype_str(gP.ftype); - + if ( s->mos_nslices > 1 ) { if ( IM_IS_AFNI(gP.ftype) ) tstr = "(AFNI volume)"; else if ( IM_IS_DICOM(gP.ftype) ) tstr = "(DICOM mosaic)"; @@ -5596,7 +5596,7 @@ static int complete_orients_str( vol_t * v, param_t * p ) v->geh.orients[5] = 'P'; } break; - + case 3: /* IS */ if ( v->z_delta > 0 ) { @@ -5609,7 +5609,7 @@ static int complete_orients_str( vol_t * v, param_t * p ) v->geh.orients[5] = 'I'; } break; - + default: { fprintf(stderr, "** COS failure: kk (%d) not in [1,3]\n", kk); @@ -5621,7 +5621,7 @@ static int complete_orients_str( vol_t * v, param_t * p ) v->geh.orients[6] = '\0'; if ( gD.level > 2 ) fprintf(stderr,"'%s'\n", v->geh.orients); - + return 0; } @@ -5790,4 +5790,3 @@ int disp_obl_info(char * mesg) return 0; } - diff --git a/src/scripts_install/@measure_bb_thick b/src/scripts_install/@measure_bb_thick index 63879b4029..43da8a8855 100755 --- a/src/scripts_install/@measure_bb_thick +++ b/src/scripts_install/@measure_bb_thick @@ -1,4 +1,4 @@ -#/bin/tcsh +#!/bin/tcsh # h_view help instead of regular help (opens editor with -help output) @global_parse `basename $0` "$*" ; if ($status) exit 0 @@ -26,7 +26,7 @@ HELP: echo "@measure_bb_thick -maskset maskset -surfset surfacedset.gii -outdir thickdir" echo echo "where maskset is the dataset to find thickness" - echo " using the largest non-zero value in the mask." + echo " using the largest non-zero value in the mask." echo " If dataset has values -2,-1 and 1 for different regions, this script" echo " calculates the thickness only for voxels with a value of 1" echo "surfset is a surface to use to find normals into the volume" @@ -119,8 +119,8 @@ while ( $ac <= $#argv ) endif set thickdir = $argv[$ac] @ ac ++; continue; - - # now tweak the options + + # now tweak the options else if ( "$argv[$ac]" == "-resample" ) then @ ac ++ if ( $ac > $#argv ) then @@ -135,8 +135,8 @@ while ( $ac <= $#argv ) if ("$status" != "0") then echo "resample set to $argv[$ac] is not valid" exit 1 - endif - echo "resample voxel size to $resample mm" + endif + echo "resample voxel size to $resample mm" endif @ ac ++; continue; else if ( "$argv[$ac]" == "-increment" ) then @@ -150,7 +150,7 @@ while ( $ac <= $#argv ) if ("$status" != "0") then echo "increment set to $argv[$ac] is not valid" exit 1 - endif + endif @ ac ++; continue; else if ( "$argv[$ac]" == "-maxthick" ) then @ ac ++ @@ -223,7 +223,7 @@ while ( $ac <= $#argv ) @ ac ++; continue; # unknown options - exit - else + else if ("$ignore_unknown_options" != "yes") then echo "** unknown option $argv[$ac]" exit 1 @@ -254,7 +254,7 @@ endif # do everything in a new directory for simplicity mkdir $thickdir -# put original dataset into output directory with specific name +# put original dataset into output directory with specific name # this is easier and allows for mask range selectors, sub-brick selectors, and NIFTI 3dTcat -prefix $thickdir/allmaskset.nii.gz -overwrite $maskset if ($surfset != "") then @@ -270,7 +270,7 @@ set maskset = maskset.nii.gz set vrange = `3dBrickStat -non-zero -min -max allmaskset.nii.gz` if ($vrange[1] != $vrange[2]) then # can do in-out, but use a simpler mask for the other methods - 3dTcat -overwrite -prefix maskset.nii.gz allmaskset.nii.gz"<${vrange[2]}>" + 3dTcat -overwrite -prefix maskset.nii.gz allmaskset.nii.gz"<${vrange[2]}>" else # just a single value mask - can't do in-out calculation rm maskset.nii.gz @@ -283,7 +283,7 @@ if ("$resample" != "") then if ("$resample" == "auto") then set voxsize = `ccalc -expr "${voxsize}/2"` else - set voxsize = $resample + set voxsize = $resample endif 3dresample -rmode NN -prefix maskset_rs.nii.gz -overwrite \ -bound_type SLAB -dxyz $voxsize $voxsize $voxsize -input $maskset @@ -325,7 +325,7 @@ while ($donext ) set rthick = `ccalc "$rad*2+$voxsize"` 3dLocalstat -nbhd "SPHERE($rad)" -stat filled -mask $maskset -fillvalue $rthick \ -prefix fill_r$rad.nii.gz -overwrite $maskset - # all spheres MUST be filled. + # all spheres MUST be filled. # If the spheres are too big, then no spheres are found, and we can stop growing. set anytherer = `3dBrickStat -max fill_r$rad.nii.gz` set anythere = `ccalc -int "step($anytherer)"` @@ -380,7 +380,7 @@ else -prefix maxfill_spheresonly.nii.gz -overwrite \ -expr "step(b)*max(a,$voxsize)" - # max of cubes + # max of cubes 3dMean -max -prefix _tt_maxfill_cubesonly.nii.gz -overwrite fill_c*.nii.gz 3dcalc -a _tt_maxfill_cubesonly.nii.gz -b $maskset \ -prefix maxfill_cubesonly.nii.gz -overwrite \ @@ -389,7 +389,7 @@ else 3dMean -max -prefix tmaxfill.nii.gz -overwrite maxfill_spheresonly.nii.gz maxfill_cubesonly.nii.gz endif -# all voxels should have at least a thickness of a voxel size +# all voxels should have at least a thickness of a voxel size # (don't need a 3dLocalstat for that) 3dcalc -a tmaxfill.nii.gz -b $maskset -expr "step(b)*max(a,$voxsize)" \ -prefix maxfill.nii.gz -overwrite @@ -401,13 +401,13 @@ endif # sort coordinates from smallest to largest thickness sort -n -k 4 sphere_centers_pre.1D > sphere_centers_sorted.1D -# calculate radius again - need this for 3dUndump -1deval -a sphere_centers_sorted.1D'[3]' -expr "(a-${voxsize})/2" > radii.1D -# 1D file is "i j k thickness radius" sorted by radius +# calculate radius again - need this for 3dUndump +1deval -a sphere_centers_sorted.1D'[3]' -expr "(a-${voxsize})/2" > radii.1D +# 1D file is "i j k thickness radius" sorted by radius 1dcat sphere_centers_sorted.1D radii.1D > sphere_centers.1D if ("$balls_only" == "true") then - set thickvol = bb_thick.nii.gz + set thickvol = bb_thick.nii.gz else set thickvol = bb_spheresonly_thick.nii.gz endif @@ -423,14 +423,14 @@ if ("$balls_only" != "true") then # put boxes back down at each coordinate starting at the maximum radius # write out all the coordinates in the mask with the current thickness 3dmaskdump -mask maxfill_cubesonly.nii.gz -nozero maxfill_cubesonly.nii.gz > cube_centers_pre.1D - + # sort coordinates from smallest to largest thickness sort -n -k 4 cube_centers_pre.1D > cube_centers_sorted.1D - # calculate radius again - need this for 3dUndump - 1deval -a cube_centers_sorted.1D'[3]' -expr "(a-${voxsize})/2" > radii.1D - # 1D file is "i j k thickness radius" sorted by radius + # calculate radius again - need this for 3dUndump + 1deval -a cube_centers_sorted.1D'[3]' -expr "(a-${voxsize})/2" > radii.1D + # 1D file is "i j k thickness radius" sorted by radius 1dcat cube_centers_sorted.1D radii.1D > cube_centers.1D - + # fill cubes around centers with 1/2 thickness radii and values of the thickness # minimum value in mask should be voxsize 3dUndump -master $maskset -overwrite -prefix bb_cubesonly_thick.nii.gz \ @@ -471,7 +471,7 @@ if($surfset != "") then #-use_norms -norm_len -$depthsearch \ #-dnode -1 -out_niml bb_thick_max.niml.dset -overwrite - ## smooth data on surface + ## smooth data on surface ## (HEAT_05 method is more robust from quick tests than HEAT_07 method ## recommended in help for SurfSmooth) #SurfSmooth -spec quick.spec -surf_A anat.gii -met HEAT_05 \ @@ -492,14 +492,14 @@ if($surfset != "") then -oob_value $voxsize -oom_value $voxsize \ -use_norms -norm_len -$depthsearch \ -dnode -1 -out_niml bb_thick.niml.dset -overwrite - # smooth data on surface + # smooth data on surface # (HEAT_05 method is more robust from quick tests than HEAT_07 method # recommended in help for SurfSmooth but HEAT_07 gives smoother # results that look reasonable) SurfSmooth -spec quick.spec -surf_A anat.gii -met $heat_method \ -input bb_thick.niml.dset -fwhm $surfsmooth \ -output bb_thick_smooth.niml.dset -overwrite -endif +endif # unless the user is a hoarder, trash the intermediate files if ("$keep_temp_files" != "keep") then diff --git a/src/scripts_install/@measure_erosion_thick b/src/scripts_install/@measure_erosion_thick index cb8917a4b2..b7dcd5b786 100755 --- a/src/scripts_install/@measure_erosion_thick +++ b/src/scripts_install/@measure_erosion_thick @@ -1,5 +1,5 @@ -#/bin/tcsh -# @measure_erosionthick +#!/bin/tcsh +# @measure_erosion_thick # erode a dataset repeatedly to separate datasets until nothing left # add up all the erosions at the end to get erosion_levels depth dataset # and normalize to get erosionnorm dataset @@ -31,7 +31,7 @@ HELP: echo "@measure_erosion_thick -maskset maskset -surfset surfacedset.gii -outdir thickdir" echo echo "where maskset is the dataset to find thickness" - echo " using the largest non-zero value in the mask." + echo " using the largest non-zero value in the mask." echo " If dataset has values -2,-1 and 1 for different regions, this script" echo " calculates the thickness only for voxels with a value of 1" echo "surfset is a surface to use to find normals into the volume" @@ -119,8 +119,8 @@ while ( $ac <= $#argv ) endif set thickdir = $argv[$ac] @ ac ++; continue; - - # now tweak the options + + # now tweak the options else if ( "$argv[$ac]" == "-resample" ) then @ ac ++ if ( $ac > $#argv ) then @@ -135,8 +135,8 @@ while ( $ac <= $#argv ) if ("$status" != "0") then echo "resample set to $argv[$ac] is not valid" exit 1 - endif - echo "resample voxel size to $resample mm" + endif + echo "resample voxel size to $resample mm" endif @ ac ++; continue; else if ( "$argv[$ac]" == "-maxthick" ) then @@ -207,7 +207,7 @@ while ( $ac <= $#argv ) @ ac ++; continue; # unknown options - exit - else + else if ("$ignore_unknown_options" != "yes") then echo "** unknown option $argv[$ac]" exit 1 @@ -238,7 +238,7 @@ endif # do everything in a new directory for simplicity mkdir $thickdir -# put original dataset into output directory with specific name +# put original dataset into output directory with specific name # this is easier and allows for mask range selectors, sub-brick selectors, and NIFTI 3dTcat -prefix $thickdir/allmaskset.nii.gz -overwrite $maskset if ($surfset != "") then @@ -256,7 +256,7 @@ set maskset = maskset.nii.gz set vrange = `3dBrickStat -non-zero -min -max allmaskset.nii.gz` if ($vrange[1] != $vrange[2]) then # can do in-out, but use a simpler mask for the other methods - 3dTcat -overwrite -prefix maskset.nii.gz allmaskset.nii.gz"<${vrange[2]}>" + 3dTcat -overwrite -prefix maskset.nii.gz allmaskset.nii.gz"<${vrange[2]}>" else # just a single value mask - can't do in-out calculation rm maskset.nii.gz @@ -269,7 +269,7 @@ if ("$resample" != "") then if ("$resample" == "auto") then set voxsize = `ccalc -expr "${voxsize}/2"` else - set voxsize = $resample + set voxsize = $resample endif 3dresample -rmode NN -prefix maskset_rs.nii.gz -overwrite \ -bound_type SLAB -dxyz $voxsize $voxsize $voxsize -input $maskset @@ -295,7 +295,7 @@ while ( $nvox != 0 ) -b a+i -c a-i -d a+j -e a-j -f a+k -g a-k \ -expr 'and(a,b,c,d,e,f,g)' \ -prefix __tt_erode_${iterp1}.nii.gz -overwrite - + set iter = $iterp1 set iterp1 = `ccalc -form "%2.2d" "$iterp1+1"` @@ -350,9 +350,9 @@ rm -rf erosion_depth_vox.nii.gz erosion_depth.nii.gz erosion_thick.nii.gz erosio # sort coordinates from smallest to largest thickness sort -n -k 4 sphere_centers_pre.1D > sphere_centers_sorted.1D -# calculate radius again - need this for 3dUndump -1deval -a sphere_centers_sorted.1D'[3]' -expr "(a-${voxsize})/2" > radii.1D -# 1D file is "i j k thickness radius" sorted by radius +# calculate radius again - need this for 3dUndump +1deval -a sphere_centers_sorted.1D'[3]' -expr "(a-${voxsize})/2" > radii.1D +# 1D file is "i j k thickness radius" sorted by radius 1dcat sphere_centers_sorted.1D radii.1D > sphere_centers.1D # fill spheres around centers with 1/2 thickness radii and values of the thickness @@ -384,7 +384,7 @@ if($surfset != "") then -oob_value $voxsize -oom_value $voxsize \ -out_niml erosion_thick.niml.dset -overwrite - # smooth data on surface + # smooth data on surface # (HEAT_05 method is more robust from quick tests than HEAT_07 method # recommended in help for SurfSmooth, but HEAT_07 gives smoother # results that look reasonable) @@ -396,7 +396,7 @@ endif # unless the user is a hoarder, trash the intermediate files if ("$keep_temp_files" != "keep") then # cleanup all the erosion iterations and the voxel level erosions - rm -f __tt_* erosion_depth_vox.nii.gz sphere_centers*.1D *.smrec + rm -f __tt_* erosion_depth_vox.nii.gz sphere_centers*.1D *.smrec endif echo "#\!/bin/tcsh" > @show_thick diff --git a/tests/pytest_tests/test_afni_proc.py b/tests/pytest_tests/test_afni_proc.py new file mode 100644 index 0000000000..9dd02d4d20 --- /dev/null +++ b/tests/pytest_tests/test_afni_proc.py @@ -0,0 +1,97 @@ +"""Automated tests for afni_proc.py + +To run: + python3 afni_proc.py +""" + +import os +import shutil +import subprocess + +here = os.path.abspath(os.path.dirname(__file__)) +AFNI_TEST_DATA_PATH = os.path.join(here, 'afni_test_data') +FT_PATH = os.path.join(AFNI_TEST_DATA_PATH, "AFNI_data6", "FT_analysis", "FT") + +_subj = "FT" + +def _get_afni_proc_path(): + loc = shutil.which('afni_proc.py') + if loc is None: + raise Exception("Cannot find afni_proc.py") + return loc + + +def test_handout_realcase2(): + """Test the command in the afni_proc.py handout (real case 2).""" + + cmd = """coverage run {afni_proc} -subj_id {subj} \ + -script proc.{subj} -scr_overwrite \ + -blocks tshift align tlrc volreg blur mask scale regress \ + -copy_anat {data}/FT_anat+orig \ + -dsets \ + {data}/FT_epi_r1+orig.HEAD \ + {data}/FT_epi_r2+orig.HEAD \ + {data}/FT_epi_r3+orig.HEAD \ + -volreg_align_to MIN_OUTLIER \ + -volreg_align_e2a \ + -volreg_tlrc_warp \ + -blur_size 4.0 \ + -tcat_remove_first_trs 2 \ + -regress_stim_times \ + {data}/AV1_vis.txt \ + {data}/AV2_aud.txt \ + -regress_stim_labels \ + vis aud \ + -regress_basis 'BLOCK(20,1)' \ + -regress_censor_motion 0.3 \ + -regress_opts_3dD \ + -jobs 2 \ + -gltsym 'SYM: vis -aud' -glt_label 1 V-A \ + -gltsym 'SYM: 0.5*vis +0.5*aud' -glt_label 2 mean.VA \ + -regress_compute_fitts \ + -regress_make_ideal_sum sum_ideal.1D \ + -regress_est_blur_epits \ + -regress_est_blur_errts \ + -regress_run_clustsim yes""" + cmd = cmd.format( + afni_proc=_get_afni_proc_path(), + subj=_subj, + data=FT_PATH) + # Raises error on failure. + subprocess.run(cmd.split(), check=True) + + procfile = "proc.{}".format(_subj) + assert os.path.isfile(procfile) + + +def test_handout_realcase3(): + cmd = """coverage run {afni_proc} -subj_id {subj} \ + -script proc.{subj} -scr_overwrite \ + -blocks tshift align tlrc volreg blur mask scale regress \ + -copy_anat {data}/FT_anat+orig \ + -dsets \ + {data}/FT_epi_r1+orig.HEAD \ + {data}/FT_epi_r2+orig.HEAD \ + {data}/FT_epi_r3+orig.HEAD \ + -volreg_align_to MIN_OUTLIER \ + -volreg_align_e2a \ + -volreg_tlrc_warp \ + -blur_size 4.0""" + cmd = cmd.format( + afni_proc=_get_afni_proc_path(), + subj=_subj, + data=FT_PATH) + # Raises error on failure. + subprocess.run(cmd.split(), check=True) + + procfile = "proc.{}".format(_subj) + assert os.path.isfile(procfile) + + +def main(): + test_handout_realcase2() + test_handout_realcase3() + + +if __name__ == '__main__': + main() diff --git a/tests/pytest_tests/test_help_messages.py b/tests/pytest_tests/test_help_messages.py new file mode 100644 index 0000000000..489095383b --- /dev/null +++ b/tests/pytest_tests/test_help_messages.py @@ -0,0 +1,115 @@ +"""Show the help messages of all AFNI programs. Fail test if showing help +message fails or if program is not found. + +To run: + python3 test_help_messages.py +""" + +import os +import pathlib +import shutil +import subprocess + +here = os.path.realpath(os.path.dirname(__file__)) + +# This assumes we are in afni_root/tests/pytest_tests directory. +AFNI_ROOT = os.path.join(here, '..', '..') + +SHOULD_NOT_BE_EXECUTABLE = [ + 'afni_fs_aparc+aseg_2000.txt', + 'afni_fs_aparc+aseg_2009.txt', + 'demo.fixed.niml.do', + 'demo.mobile.niml.do'] + +KNOWN_BROKEN_HELP = [ + '3dmaxima', + '@Install_D99_macaque', + '@Install_NIH_Marmoset', + '@auto_align', + '@djunct_4d_slices_to_3d_vol', + '@djunct_vol_3slice_select', + '@xyz_to_ijk', + 'Dimon', + 'Dimon1', + 'FD2', + 'Ifile', + 'MakeColorMap', + 'ScaleToMap', + 'SurfMeasures', + 'afni_run_R', + 'balloon', + 'cjpeg', + 'column_cat', + 'djpeg', + 'fat_mvm_gridconv.py', + 'fat_mvm_prep.py', + 'fat_mvm_review.py', + 'fat_mvm_scripter.py', + 'fat_roi_row.py', + 'get_afni_model_PRF', + 'imcat', + 'inspec', + 'mpeg_encode', + 'myget', + 'qdelaunay', + 'qhull', + 'quickspec', + 'rbox'] + + +def _get_programs(afni_root): + """Return list of AFNI programs, given path to AFNI's root directory, + right above src. + """ + p = pathlib.Path(afni_root).absolute() + # Create list of AFNI programs. + subprocess.run( + ['make', 'prog_list'], stdout=subprocess.DEVNULL, cwd=str(p / 'src')) + # Parse and return list of AFNI programs. + prog_list = p / 'src' / 'prog_list.txt' + with prog_list.open() as fp: + progs = fp.readlines() + progs = [j.strip() for j in progs] + return [j for j in progs if j and not j.startswith('#')] + + +def test_prog_list_helps(): + programs = _get_programs(AFNI_ROOT) + not_found = [] + no_success = [] + + for prog in programs: + if prog in SHOULD_NOT_BE_EXECUTABLE or prog in KNOWN_BROKEN_HELP: + continue + if shutil.which(prog) is None: # Program does not exist. + not_found.append(prog) + continue + + # Run program's help. + process = subprocess.run( + [prog, '-help'], stderr=subprocess.PIPE, stdout=subprocess.DEVNULL) + if process.returncode != 0: + msg = "return code {}".format(process.returncode) + if process.stderr: + msg = process.stderr.splitlines()[-1].decode() + no_success.append( + "{} ({})".format(prog, msg)) + + if not_found: + print("PROGRAMS NOT FOUND:") + print(" " + "\n ".join(not_found)) + + if no_success: + print("PROGRAMS THAT FAILED:") + print(" " + "\n ".join(no_success)) + + if not_found or no_success: + assert False + + +def main(): + test_prog_list_helps() + + +if __name__ == '__main__': + main() diff --git a/tests/run_tests.sh b/tests/run_tests.sh index b19b2ebe3c..4436e3d2a9 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -1,8 +1,28 @@ -#! /bin/bash -git clone https://github.com/nih-fmrif/afni_test_data /usr/afni_build_dir/tests/pytest_tests/afni_test_data -cd /usr/afni_build_dir/tests +#!/bin/bash +# +# usage: run_tests.sh + +# Exit on any errors. +set -ex + +here="$(dirname $(readlink -f $0))" +AFNI_ROOT="$(readlink -f $here/..)" +AFNI_TEST_DATA_PATH="$here/pytest_tests/afni_test_data" +echo "AFNI test data path: $AFNI_TEST_DATA_PATH" + +# Download data. +if [ ! -d $AFNI_TEST_DATA_PATH ]; then + git clone https://github.com/nih-fmrif/afni_test_data $AFNI_TEST_DATA_PATH +fi +if [ ! -d $AFNI_TEST_DATA_PATH/AFNI_data6 ]; then + echo "Downloading AFNI data 6 ..." + curl -fsSL https://afni.nimh.nih.gov/pub/dist/edu/data/AFNI_data6.tgz | tar xzC $AFNI_TEST_DATA_PATH +fi + +# Run tests. +cd $here # Just in case test script is run from some other directory. pytest afni_system_check.py -check_all -cd /usr/afni_build_dir/src/afni_src +cd $AFNI_ROOT/src gcov *.c -codecov \ No newline at end of file +codecov