Ejemplo n.º 1
0
/*--------------- main routine ---------------*/
int main( int argc, char *argv[] )
{
   options_t * opts = &g_opts;
   int         rv;

   if( argc < 2 ) { show_help();  return 0; }

   mainENTRY("3dTto1D main"); machdep(); AFNI_logger("3dTto1D",argc,argv);

   /* process command line arguments (and read dataset and mask) */
   rv = process_opts(opts, argc, argv);
   if( rv ) RETURN(rv < 0); /* only a negative return is considered failure */

   if( check_dims(opts) ) RETURN(1);

   /* evaluation of rv now depends on the method, usually non-zero is bad */
   rv = compute_results(opts);

   /* for 4095_warn, return now, regardless */
   if( opts->method == T21_METH_4095_WARN ) RETURN(rv);

   /* otherwise, any non-zero return is a failure */
   if ( rv ) RETURN(1);

   if( write_results(opts) ) RETURN(1);

   RETURN(0);
}
Ejemplo n.º 2
0
valmatrix<T>& valmatrix<T>::operator += (const valmatrix<T>& other)
{
    check_dims(other);

    for (size_t i = 0; i != this->size(); ++i)
    {
        (*this)[i] += other[i];
    }

    return *this;
}
Ejemplo n.º 3
0
int check_new_op(is_new_op* node)
{
	int errors = 0;

	errors += check_type_object(node->type_object);
	errors += check_dims(node->dims);

	if (errors == 0)
		node->s_type = new_type_decl_object_dims(node->line, node->type_object, node->dims);
	
	return errors;
}
Ejemplo n.º 4
0
valmatrix<T>& valmatrix<T>::operator *= (const valmatrix<T>& other)
{
    check_dims(other);

    valmatrix<T> result(this->size());

    for (size_t i = 0; i < this->size(); i++)
        for (size_t j = 0; j < this->size(); j++)
            for (size_t k = 0; k < this->size(); k++)
            {
                result[i][j] += (*this)[i][k] * other[k][j];
            }

    (*this) = result;
    return *this;
}
Ejemplo n.º 5
0
int main(void)
{
    mihandle_t vol;
    int r;
    midimhandle_t dim[NDIMS];
    int n;
    misize_t coords[NDIMS];
    misize_t count[NDIMS];
    int i,j,k;
    double offset;
    unsigned int voxel;

    /* Write data one voxel at a time. */
    for (i = 0; i < NDIMS; i++) {
        count[i] = 1;
    }

    r = micreate_dimension("time", MI_DIMCLASS_TIME,
                           MI_DIMATTR_NOT_REGULARLY_SAMPLED, CT, &dim[0]);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    for (i = 0; i < CT; i++) {
        offset = (i * i) + 100.0;
        r = miset_dimension_offsets(dim[0], 1, i, &offset);
        if (r < 0) {
            TESTRPT("failed", r);
        }
    }

    r = micreate_dimension("xspace",MI_DIMCLASS_SPATIAL,
                           MI_DIMATTR_REGULARLY_SAMPLED, CX, &dim[1]);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miset_dimension_start(dim[1], XSTART);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miset_dimension_separation(dim[1], XSTEP);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = micreate_dimension("yspace",MI_DIMCLASS_SPATIAL,
                           MI_DIMATTR_REGULARLY_SAMPLED, CY, &dim[2]);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miset_dimension_start(dim[2], YSTART);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miset_dimension_separation(dim[2], YSTEP);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = micreate_dimension("zspace",MI_DIMCLASS_SPATIAL,
                           MI_DIMATTR_REGULARLY_SAMPLED, CZ, &dim[3]);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miset_dimension_start(dim[3], ZSTART);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miset_dimension_separation(dim[3], ZSTEP);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = micreate_volume("tst-dim.mnc", NDIMS, dim, MI_TYPE_UINT,
                        MI_CLASS_REAL, NULL, &vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = micreate_volume_image(vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    check_dims(vol, dim);

    for (i = 0; i < CX; i++) {
        for (j = 0; j < CY; j++) {
            for (k = 0; k < CZ; k++) {
                coords[0] = 0;
                coords[1] = i;
                coords[2] = j;
                coords[3] = k;

                voxel = (i*10000)+(j*100)+k;
                r = miset_voxel_value_hyperslab(vol, 
                                                MI_TYPE_UINT,
                                                coords,
                                                count, 
                                                &voxel);
                if (r < 0) {
                    TESTRPT("Error writing voxel", r);
                }
            }
        }
    }


    r = miclose_volume(vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    /***** 03-Aug-2004: Added two tests for bugs reported by Leila */

    r = miopen_volume("tst-dim.mnc", MI2_OPEN_RDWR, &vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miget_volume_dimension_count(vol, MI_DIMCLASS_ANY,
                                     MI_DIMATTR_REGULARLY_SAMPLED, &n);
    if (r < 0) {
        TESTRPT("failed", r);
    }
    if (n != NDIMS - 1) {
        TESTRPT("wrong result", n);
    }

    r = miget_volume_dimension_count(vol, MI_DIMCLASS_ANY,
                                     MI_DIMATTR_NOT_REGULARLY_SAMPLED, &n);
    if (r < 0) {
        TESTRPT("failed", r);
    }
    if (n != 1) {
        TESTRPT("wrong result", n);
    }

    r = miclose_volume(vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    /* Test #2 - verify that we don't print anything scary if a user
     * closes a volume prematurely.
     */
    r = micreate_dimension("xspace",MI_DIMCLASS_SPATIAL,
                           MI_DIMATTR_REGULARLY_SAMPLED, CX, &dim[0]);
    if (r < 0) {
        TESTRPT("failed", r);
    }
    r = micreate_dimension("yspace",MI_DIMCLASS_SPATIAL,
                           MI_DIMATTR_REGULARLY_SAMPLED, CY, &dim[1]);
    if (r < 0) {
        TESTRPT("failed", r);
    }
    r = micreate_dimension("zspace",MI_DIMCLASS_SPATIAL,
                           MI_DIMATTR_REGULARLY_SAMPLED, CZ, &dim[2]);
    if (r < 0) {
        TESTRPT("failed", r);
    }
    r = micreate_volume("tst-vol.mnc", 3, dim, MI_TYPE_SHORT,
                        MI_CLASS_LABEL, NULL, &vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }

    r = miclose_volume(vol);
    if (r < 0) {
        TESTRPT("failed", r);
    }
    /** End of tests added 03-Aug-2004 **/

    if (error_cnt != 0) {
        fprintf(stderr, "%d error%s reported\n", 
                error_cnt, (error_cnt == 1) ? "" : "s");
    }
    else {
        fprintf(stderr, "No errors\n");
    }
    return (error_cnt);
}