medcorrect.c: This program corrects x-ray image files taken by the medoptics detector, but can be easily adapted for other detectors. FEATURES: 1) The images may be dezingered, background subtracted, distortion and/or intensity corrected. Corrections are chosen by command line options. 2) The background images may also be dezingered. This is always done if more than one background image (eventually more than two will be allowed, but not now) 3) Command line substitution can be used to specificy multiple image files. See example (4) NOTE: Although the program allows complete flexibility, the proper correction order is determined when correction files are made (see TV6 command 'cath'). For the medoptics detector intensity correction file medi12b1.tif, this order is raw->dezing -> back sub -> intensity correct -> distortion correct. If using the intensity correction file moi12b1.tif, the order of intensity and distortion correction are swapped. Usage: medcorrect [i|id|d|di] -s[z] image_file(s) [-o output_filename] [-t int_correct_file] [-x x_distortion_file] [-b back_file(s)] [--help] At least two arguments are required: '-s[z]' and an image filename. If present, [i|id|d|di] must come first. Other arguments in any order. OPTIONS: i: intensity correction. uses default intensity correction unless -t is also present d: distortion correction. uses default files unless -x is also present NOTE 1: Correction is done in the order specificied. Make sure that the this order (id vs. di) matches the type of intensity correction file being used. (For the Medoptics decector, see C:\\perm\\README on the Medoptics computer). -t: explicitly name intensity correction file (see NOTE 2) -x: explicitly name only the x-distortion correction file. (see NOTE 2) The y-distortion file must have the same name but with 'y' in place of the final appearance of 'x' in the filename , e.g. medxbin1.tif & medybin1.tif -s[z] image_file(s): if more than one is specified, images are either combined and dezingered (if z is present) or processed sequentially. Current limit of 2 images for dezingering -b background file(s). If more than one is specified, images are combined and dezingered. -o output_file_name. If present, this takes precedence. If not present, then the output filename depends on the action. If multiple images are being corrected but NOT dezingered, then the name is generated from the input file by the insertion of \"_c\" before the extension (e.g. fish.tif -> fish_c.tif, fish -> fish_c). This is useful for correcting a whole sequence of images that do not need to be dezingered in a single command (see example below). If two images are being dezingered, the default name medcorr.out is used unless an explicit filename is specified. NOTE that medcorrect NEVER overwrites files. If the output filename it wants to already exists, medcorrect aborts with a message to that effect. --help: Print this help message and exit NOTE 2: If distortion or intensity correction files are not explicitly named: 1) Look for environment variable CCDCORR_FILES to determine directory in which to look for the correction files named in (default to /usr/local/lib). 2) Filenames found in the CCDCORR_FILES directory are SUPERCEDED by the contents of medcorrect.cfg, if found inthe local directory. This file is written whenever intensity and distortion correction are both performed Successfully opened correction filenames are saved to medcorrect.cfg which, if found in the working directory, supercedes the default files in /usr/local/lib. EXAMPLES: 1) Dezinger a pair of images: >medcorrect -sz image1.tif image2.tif -o image1z2.tif ** or using tcsh command line substitution ** >medcorrect -sz image[12].tif -o image1z2.tif 2) Dezinger two images and backgrounds and subtract the dezingered background from the dezingered image: >medcorrect -sz image1.tif image2.tif -o image1z2.tif -b b1.tif b2.tif ** or using tcsh command line substitution ** >medcorrect -sz image[12].tif -b b[12].tif -o image1z2.tif 3) The whole shabang (dezinger image & backs, then subtract background, then intensity and distortion correct). >medcorrect id -sz image[12].tif -b b[12].tif ** output stored in medcorr.out ** 4) Correct but don't dezinger many files at once. >medcorrect id -s images*.tif -b backround.tif Originally written by Sandor L. Barna Princeton University Physics Department Biophysics Group December 1993 Marian Szebenyi (CHESS) made many modifications, including pedestal, through 2003. Converted from text-menu/prompt to UNIX command-line-option style by Arthur Woll, March 2003 NOTE: The UNIX shell expands wildcard characters like *, ?, and [] before sending the command line to the program. See your sh or csh manual for details. Turbo C++ and Borland C++ expand wildcard characters if the file WILDARG.OBJ is linked with your program. See the manual for details. Almost all UNIX commands use a standard command-line format. This standard has carried over into other environments. A standard UNIX command has the form: command options file1 file1 file3 Please refer to TV6 (Gruner, Eikenberry and Tate) for more information on the correction procedures.