Mercurial > hg > aim92
view saitools/findintervals_sai.c @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
line wrap: on
line source
/* Copyright (c) Applied Psychology Unit, Medical Research Council. 1993 =========================================================================== Permission to use, copy, modify, and distribute this software without fee is hereby granted for research purposes, provided that this copyright notice appears in all copies and in all supporting documentation, and that the software is not redistributed for any fee (except for a nominal shipping charge). Anyone wanting to incorporate all or part of this software in a commercial product must obtain a license from the Medical Research Council. The MRC makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*------------------------------------------------------------------------*/ /* findintervals_sai.c * ----------------------- * * M.Akeroyd. Summer 1993. Revised Winter 1994. */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include "tip.h" extern struct Peak peak[MAX_PEAKS]; /* all channels */ extern short interval[MAX_CHANNELS][MAX_DATA]; extern short clip[MAX_CHANNELS]; extern int weightflag; /*------------------------------------------------------------------------*/ void find_intervals(int total_peaks, int channel, int maximum_interval) { /* WARNING! Reverse */ int gap_samples; int n; for(n=2; n <= total_peaks; n++){ gap_samples = peak[n-1].sample - peak[n].sample; if (gap_samples >= maximum_interval) gap_samples = maximum_interval -1; interval[channel][gap_samples]++; /*---------------------------------*/ /* weighting options */ if (weightflag == OFF) interval[channel][gap_samples]++; else if (weightflag == NORMAL_WEIGHTING) interval[channel][gap_samples] += (short) (peak[n-1].mag + peak[n].mag) / 2 ; else if (weightflag == LOG_WEIGHTING) interval[channel][gap_samples] += (short) log((peak[n-1].mag + peak[n].mag)/2)/log(10.0); /*---------------------------------*/ /* clip check */ if ((interval[channel][gap_samples] > 32765) || (interval[channel][gap_samples] < 0)){ if (clip[channel] == OFF) { fprintf(stderr, " \nclipping: channel %i, interval %i samples.\n ", channel, gap_samples); clip[channel] = ON;} interval[channel][gap_samples] = 32765; } } } /* The End */ /*------------------------------------------------------------------------*/