Esempio n. 1
0
rsZeropaddingParameters *rsZeropaddingParseParams(int argc, char * argv[]) {

    rsZeropaddingParameters *p = rsZeropaddingInitParameters();
    p->callString = rsMergeStringArray(argc, argv);
    
    rsZeropaddingBuildInterface(p);
    
    // parse
    BOOL parsingSuccessful = rsUIParse(p->interface, argc, argv, (void*)p);
    
    if ( ! parsingSuccessful ) {
        return p;
    }
    
    // check if the required arguments have been provided
    if ( p->inputpath == NULL ) {
        fprintf(stderr, "No input volume specified!\n");
        return p;
    }
    
    if ( p->outputpath == NULL ) {
        fprintf(stderr, "An output volume must be specified!\n");
        return p;
    }

    p->parametersValid = parsingSuccessful;
    return p;
}
Esempio n. 2
0
rsFitParameters *rsFitParseParams(int argc, char * argv[])
{

    rsFitParameters *p = rsFitInitParameters();
    p->callString = rsMergeStringArray(argc, argv);
    
    rsFitBuildInterface(p);
    
    // parse
    BOOL parsingSuccessful = rsUIParse(p->interface, argc, argv, (void*)p);
    
    if ( ! parsingSuccessful ) {
        return p;
    }
    
    if ( p->inputpath == NULL ) {
        fprintf(stderr, "No input volume specified(--input)!\n");
        return p;
    }
    
    if ( p->targetpath == NULL ) {
        fprintf(stderr, "No target volume specified(--target)!\n");
        return p;
    }
    
    if ( p->betaspath == NULL ) {
        fprintf(stderr, "No betas volume specified(--betas)!\n");
        return p;
    }
    
    p->parametersValid = parsingSuccessful;
    return p;
}
rsApplyTransformationParameters *rsApplyTransformationParseParams(int argc, char * argv[]) {

    rsApplyTransformationParameters *p = rsApplyTransformationInitParameters();
    p->callString = rsMergeStringArray(argc, argv);
    
    rsApplyTransformationBuildInterface(p);
    
    // parse
    BOOL parsingSuccessful = rsUIParse(p->interface, argc, argv, (void*)p);
    
    if ( ! parsingSuccessful ) {
        return p;
    }
    
    // check if the required arguments have been provided
    if (p->inputpath == NULL) {
        fprintf(stderr, "No input volume specified!\n");
        return p;
    }
    
    if (p->outputpath == NULL) {
        fprintf(stderr, "An output volume must be specified!\n");
        return p;
    }

    if (p->referencepath == NULL) {
        fprintf(stderr, "A reference volume must be specified!\n");
        return p;
    }

    if (p->transformations == NULL || g_strv_length(p->transformations) < 1) {
        fprintf(stderr, "At least one transformation needs to be specified!\n");
        return p;
    }

    if (p->coordinateSpaceTypeInput == NULL || strstr(p->coordinateSpaceTypeInput, "input") != NULL) {
        p->coordinateSpaceType = -1;
    } else if (strstr(p->coordinateSpaceTypeInput, "unknown") != NULL) {
        p->coordinateSpaceType = NIFTI_XFORM_UNKNOWN;
    } else if (strstr(p->coordinateSpaceTypeInput, "scanner") != NULL) {
        p->coordinateSpaceType = NIFTI_XFORM_SCANNER_ANAT;
    } else if (strstr(p->coordinateSpaceTypeInput, "aligned") != NULL) {
        p->coordinateSpaceType = NIFTI_XFORM_ALIGNED_ANAT;
    } else if (strstr(p->coordinateSpaceTypeInput, "talairach") != NULL) {
        p->coordinateSpaceType = NIFTI_XFORM_TALAIRACH;
    } else if (strstr(p->coordinateSpaceTypeInput, "mni") != NULL) {
        p->coordinateSpaceType = NIFTI_XFORM_MNI_152;
    } else {
        fprintf(stderr, "'%s' is not a valid value for the coordinate space\n");
        return p;
    }

    p->nTransformations = g_strv_length(p->transformations);

    p->parametersValid = parsingSuccessful;
    return p;
}
Esempio n. 4
0
rsInfoParameters* rsInfoParseParams(int argc, char * argv[])
{
    rsInfoParameters *p = rsInfoInitParameters();
    rsInfoBuildInterface(p);
    
    // parse
    BOOL parsingSuccessful = rsUIParse(p->interface, argc, argv, (void*)p);
    
    if ( ! parsingSuccessful ) {
        return p;
    }
    
    // check if the required arguments have been provided
    if ( p->inputpath == NULL ) {
        fprintf(stderr, "No input volume specified(--input)!\n");
        return p;
    }

    p->parametersValid = parsingSuccessful;
    return p;
}
Esempio n. 5
0
rsOrientationParameters *rsOrientationParseParams(int argc, char * argv[]) {

    rsOrientationParameters *p = rsOrientationInitParameters();
    p->callString = rsMergeStringArray(argc, argv);
    
    rsOrientationBuildInterface(p);
    
    // parse
    BOOL parsingSuccessful = rsUIParse(p->interface, argc, argv, (void*)p);
    
    if ( ! parsingSuccessful ) {
        return p;
    }
    
    // check if the required arguments have been provided
    if ( p->inputpath == NULL ) {
        fprintf(stderr, "No input volume specified!\n");
        return p;
    }
    
    if ( p->outputpath == NULL ) {
        fprintf(stderr, "An output volume must be specified!\n");
        return p;
    }

    if (p->orientation == NULL) {
        p->orientation = "LPI";
    }

    BOOL validOrientation = strlen(p->orientation) == 3;

    // validate and normalize orientation code
    if (validOrientation) {

        BOOL LRpresent = FALSE;
        BOOL PApresent = FALSE;
        BOOL ISpresent = FALSE;

        // make all uppercase
        p->orientation = rsString(p->orientation);
        for(short i = 0; p->orientation[i]; i++){
            p->orientation[i] = toupper(p->orientation[i]);
        }

        // check if we got a letter for each direction
        for (short i=0; i<3; i++) {
            const char code = p->orientation[i];
            if (code=='L' || code=='R') {
                LRpresent = TRUE;
            } else if (code=='P' || code=='A') {
                PApresent = TRUE;
            } else if (code=='I' || code=='S') {
                ISpresent = TRUE;
            }
        }
        validOrientation = LRpresent && PApresent && ISpresent;
    }

    if (!validOrientation) {
        fprintf(stderr, "The parameter --orientation (-a) needs to be a three letter code containing the letters (L, R, P, A, I, S)!\n");
        return p;
    }
    
    p->parametersValid = parsingSuccessful;
    return p;
}