/* %W% %G% */ /*----------------------------------------------------------------------------- Copyright (C) 1993, Molecular Structure Group of Biochemestry Dept. at University of California at San Francisco. These coded instructions, statements, and computer programs comprise unpublished proprietary information of the Molecular Structure Group of the Biochemistry Department at University of California at San Francisco, and are protected by Federal copyright law. They may not be disclosed to third parties, copied or duplicated in any form - in whole or in part - without the prior written consent of Molecular Structure Group of Biochemistry Department at University of California at San Francisco. -------------------------------------------------------------------------*/ #include "ip.h" #include "IWInclude.h" #include "WMInclude.h" #include /* sqrt */ int isComplex = 0; /* Need to determine whether output is complex or not. */ static void InitProc() { int headerNXYZ[3]; int headerMXYZ[3]; float headerMMM[3]; int pixelType; IMRdHdr(two, headerNXYZ, headerMXYZ, &pixelType, &headerMMM[0], &headerMMM[1], &headerMMM[2]); isComplex = IW_COMPLEX == pixelType || IW_COMPLEX_SHORT == pixelType; } void ProcData(int nxyz[3], float dmmm[3]) { int nxy = nxyz[0] * nxyz[1]; float *des = (float*) IPGetDataPtr(one); int i; /* Calculate the min, max, and mean for the selected region. For complex data use the amplitude. */ if (isComplex) { for (i = 0; i < nxy; i += 2) { float amplitude = sqrt(des[i] * des[i] + des[i + 1] * des[i + 1]); if (amplitude < dmmm[0]) { dmmm[0] = amplitude; } if (amplitude > dmmm[1]) { dmmm[1] = amplitude; } dmmm[2] += amplitude; } } else { for (i = 0; i < nxy; i++) { if (des[i] < dmmm[0]) { dmmm[0] = des[i]; } if (des[i] > dmmm[1]) { dmmm[1] = des[i]; } dmmm[2] += des[i]; } } } IPAppSpecifics() { IPSetMenuTitle("Region Select"); IPSetMenuLoc(450, 400); /* Simple copy, so there's no need to have separate arrays for the input and output. */ IPSetIncoreProc(); IPAddInput(one, " In:", True, False, NULL, NULL); IPAddOutput(two, "Out:", True, False, NULL, NULL); IPSetCustRoutine(INIT_PROC, InitProc, NULL); IPSetCustRoutine(PROC_FUNC, ProcData, NULL); }