source: tags/release-1.1.1/docs/executionFlow.tex @ 1455

Last change on this file since 1455 was 303, checked in by Matthew Whiting, 17 years ago
  • Update the Outputs chapter to mention the use of F_tot.
  • Fixed comments in pgplot_related.c
  • Added distribution text to tex files.
File size: 30.1 KB
Line 
1% -----------------------------------------------------------------------
2% executionFlow.tex: Section detailing each of the main algorithms
3%                    used by Duchamp.
4% -----------------------------------------------------------------------
5% Copyright (C) 2006, Matthew Whiting, ATNF
6%
7% This program is free software; you can redistribute it and/or modify it
8% under the terms of the GNU General Public License as published by the
9% Free Software Foundation; either version 2 of the License, or (at your
10% option) any later version.
11%
12% Duchamp is distributed in the hope that it will be useful, but WITHOUT
13% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15% for more details.
16%
17% You should have received a copy of the GNU General Public License
18% along with Duchamp; if not, write to the Free Software Foundation,
19% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
20%
21% Correspondence concerning Duchamp may be directed to:
22%    Internet email: Matthew.Whiting [at] atnf.csiro.au
23%    Postal address: Dr. Matthew Whiting
24%                    Australia Telescope National Facility, CSIRO
25%                    PO Box 76
26%                    Epping NSW 1710
27%                    AUSTRALIA
28% -----------------------------------------------------------------------
29\secA{What \duchamp is doing}
30\label{sec-flow}
31
32Each of the steps that \duchamp goes through in the course of its
33execution are discussed here in more detail. This should provide
34enough background information to fully understand what \duchamp is
35doing and what all the output information is. For those interested in
36the programming side of things, \duchamp is written in C/C++ and makes
37use of the \textsc{cfitsio}, \textsc{wcslib} and \textsc{pgplot}
38libraries.
39
40\secB{Image input}
41\label{sec-input}
42
43The cube is read in using basic \textsc{cfitsio} commands, and stored
44as an array in a special C++ class. This class keeps track of the list
45of detected objects, as well as any reconstructed arrays that are made
46(see \S\ref{sec-recon}). The World Coordinate System
47(WCS)\footnote{This is the information necessary for translating the
48pixel locations to quantities such as position on the sky, frequency,
49velocity, and so on.} information for the cube is also obtained from
50the FITS header by \textsc{wcslib} functions \citep{greisen02,
51calabretta02}, and this information, in the form of a \texttt{wcsprm}
52structure, is also stored in the same class.
53
54A sub-section of a cube can be requested by defining the subsection
55with the \texttt{subsection} parameter and setting
56\texttt{flagSubsection = true} -- this can be a good idea if the cube
57has very noisy edges, which may produce many spurious detections.
58
59There are two ways of specifying the \texttt{subsection} string. The
60first is the generalised form
61\texttt{[x1:x2:dx,y1:y2:dy,z1:z2:dz,...]}, as used by the
62\textsc{cfitsio} library. This has one set of colon-separated numbers
63for each axis in the FITS file. In this manner, the x-coordinates run
64from \texttt{x1} to \texttt{x2} (inclusive), with steps of
65\texttt{dx}. The step value can be omitted, so a subsection of the
66form \texttt{[2:50,2:50,10:1000]} is still valid. In fact, \duchamp
67does not make use of any step value present in the subsection string,
68and any that are present are removed before the file is opened.
69
70If the entire range of a coordinate is required, one can replace the
71range with a single asterisk, \eg \texttt{[2:50,2:50,*]}. Thus, the
72subsection string \texttt{[*,*,*]} is simply the entire cube. Note
73that the pixel ranges for each axis start at 1, so the full pixel
74range of a 100-pixel axis would be expressed as 1:100. A complete
75description of this section syntax can be found at the
76\textsc{fitsio} web site%
77\footnote{%
78\href%
79{http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c\_user/node91.html}%
80{http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c\_user/node91.html}}.
81
82
83Making full use of the subsection requires knowledge of the size of
84each of the dimensions. If one wants to, for instance, trim a certain
85number of pixels off the edges of the cube, without examining the cube
86to obtain the actual size, one can use the second form of the
87subsection string. This just gives a number for each axis, \eg
88\texttt{[5,5,5]} (which would trim 5 pixels from the start \emph{and}
89end of each axis).
90
91All types of subsections can be combined \eg \texttt{[5,2:98,*]}.
92
93
94\secB{Image modification}
95\label{sec-modify}
96
97Several modifications to the cube can be made that improve the
98execution and efficiency of \duchamp (their use is optional, governed
99by the relevant flags in the parameter file).
100
101\secC{BLANK pixel removal}
102\label{sec-blank}
103
104If the imaged area of a cube is non-rectangular (see the example in
105Fig.~\ref{fig-moment}, a cube from the HIPASS survey), BLANK pixels
106are used to pad it out to a rectangular shape. The value of these
107pixels is given by the FITS header keywords BLANK, BSCALE and
108BZERO. While these pixels make the image a nice shape, they will take
109up unnecessary space in memory, and so to potentially speed up the
110processing we can trim them from the edge. This is done when the
111parameter \texttt{flagTrim = true}. If the above keywords are not
112present, the trimming will not be done (in this case, a similar effect
113can be accomplished, if one knows where the ``blank'' pixels are, by
114using the subsection option).
115
116The amount of trimming is recorded, and these pixels are added back in
117once the source-detection is completed (so that quoted pixel positions
118are applicable to the original cube). Rows and columns are trimmed one
119at a time until the first non-BLANK pixel is reached, so that the
120image remains rectangular. In practice, this means that there will be
121some BLANK pixels left in the trimmed image (if the non-BLANK region
122is non-rectangular). However, these are ignored in all further
123calculations done on the cube.
124
125\secC{Baseline removal}
126
127Second, the user may request the removal of baselines from the
128spectra, via the parameter \texttt{flagBaseline}. This may be
129necessary if there is a strong baseline ripple present, which can
130result in spurious detections at the high points of the ripple. The
131baseline is calculated from a wavelet reconstruction procedure (see
132\S\ref{sec-recon}) that keeps only the two largest scales. This is
133done separately for each spatial pixel (\ie for each spectrum in the
134cube), and the baselines are stored and added back in before any
135output is done. In this way the quoted fluxes and displayed spectra
136are as one would see from the input cube itself -- even though the
137detection (and reconstruction if applicable) is done on the
138baseline-removed cube.
139
140The presence of very strong signals (for instance, masers at several
141hundred Jy) could affect the determination of the baseline, and would
142lead to a large dip centred on the signal in the baseline-subtracted
143spectrum. To prevent this, the signal is trimmed prior to the
144reconstruction process at some standard threshold (at $8\sigma$ above
145the mean). The baseline determined should thus be representative of
146the true, signal-free baseline. Note that this trimming is only a
147temporary measure which does not affect the source-detection.
148
149\secC{Ignoring bright Milky Way emission}
150
151Finally, a single set of contiguous channels can be ignored -- these
152may exhibit very strong emission, such as that from the Milky Way as
153seen in extragalactic \hi cubes (hence the references to ``Milky
154Way'' in relation to this task -- apologies to Galactic
155astronomers!). Such dominant channels will produce many detections
156that are unnecessary, uninteresting (if one is interested in
157extragalactic \hi) and large (in size and hence in memory usage), and
158so will slow the program down and detract from the interesting
159detections.
160
161The use of this feature is controlled by the \texttt{flagMW}
162parameter, and the exact channels concerned are able to be set by the
163user (using \texttt{maxMW} and \texttt{minMW} -- these give an
164inclusive range of channels). When employed, these channels are
165ignored for the searching, and the scaling of the spectral output (see
166Fig.~\ref{fig-spect}) will not take them into account. They will be
167present in the reconstructed array, however, and so will be included
168in the saved FITS file (see \S\ref{sec-reconIO}). When the final
169spectra are plotted, the range of channels covered by these parameters
170is indicated by a green hashed box.
171
172\secB{Image reconstruction}
173\label{sec-recon}
174
175The user can direct \duchamp to reconstruct the data cube using the
176\atrous wavelet procedure. A good description of the procedure can be
177found in \citet{starck02:book}. The reconstruction is an effective way
178of removing a lot of the noise in the image, allowing one to search
179reliably to fainter levels, and reducing the number of spurious
180detections. This is an optional step, but one that greatly enhances
181the source-detection process, with the payoff that it can be
182relatively time- and memory-intensive.
183
184\secC{Algorithm}
185
186The steps in the \atrous reconstruction are as follows:
187\begin{enumerate}
188\item The reconstructed array is set to 0 everywhere.
189\item The input array is discretely convolved with a given filter
190  function. This is determined from the parameter file via the
191  \texttt{filterCode} parameter -- see Appendix~\ref{app-param} for
192  details on the filters available.
193\item The wavelet coefficients are calculated by taking the difference
194  between the convolved array and the input array.
195\item If the wavelet coefficients at a given point are above the
196  requested threshold (given by \texttt{snrRecon} as the number of
197  $\sigma$ above the mean and adjusted to the current scale -- see
198  Appendix~\ref{app-scaling}), add these to the reconstructed array.
199\item The separation between the filter coefficients is doubled. (Note
200  that this step provides the name of the procedure\footnote{\atrous
201  means ``with holes'' in French.}, as gaps or holes are created in
202  the filter coverage.)
203\item The procedure is repeated from step 2, using the convolved array
204  as the input array.
205\item Continue until the required maximum number of scales is reached.
206\item Add the final smoothed (\ie convolved) array to the
207  reconstructed array. This provides the ``DC offset'', as each of the
208  wavelet coefficient arrays will have zero mean.
209\end{enumerate}
210
211The reconstruction has at least two iterations. The first iteration
212makes a first pass at the wavelet reconstruction (the process outlined
213in the 8 stages above), but the residual array will likely have some
214structure still in it, so the wavelet filtering is done on the
215residual, and any significant wavelet terms are added to the final
216reconstruction. This step is repeated until the change in the measured
217standard deviation of the background (see note below on the evaluation
218of this quantity) is less than some fiducial amount.
219
220It is important to note that the \atrous decomposition is an example
221of a ``redundant'' transformation. If no thresholding is performed,
222the sum of all the wavelet coefficient arrays and the final smoothed
223array is identical to the input array. The thresholding thus removes
224only the unwanted structure in the array.
225
226Note that any BLANK pixels that are still in the cube will not be
227altered by the reconstruction -- they will be left as BLANK so that
228the shape of the valid part of the cube is preserved.
229
230\secC{Note on Statistics}
231
232The correct calculation of the reconstructed array needs good
233estimators of the underlying mean and standard deviation of the
234background noise distribution. These statistics are estimated using
235robust methods, to avoid corruption by strong outlying points. The
236mean of the distribution is actually estimated by the median, while
237the median absolute deviation from the median (MADFM) is calculated
238and corrected assuming Gaussianity to estimate the underlying standard
239deviation $\sigma$. The Gaussianity (or Normality) assumption is
240critical, as the MADFM does not give the same value as the usual rms
241or standard deviation value -- for a Normal distribution
242$N(\mu,\sigma)$ we find MADFM$=0.6744888\sigma$, but this will change
243for different distributions. Since this ratio is corrected for, the
244user need only think in the usual multiples of the rms when setting
245\texttt{snrRecon}. See Appendix~\ref{app-madfm} for a derivation of
246this value.
247
248When thresholding the different wavelet scales, the value of the rms
249as measured from the wavelet array needs to be scaled to account for
250the increased amount of correlation between neighbouring pixels (due
251to the convolution). See Appendix~\ref{app-scaling} for details on
252this scaling.
253
254\secC{User control of reconstruction parameters}
255
256The most important parameter for the user to select in relation to the
257reconstruction is the threshold for each wavelet array. This is set
258using the \texttt{snrRecon} parameter, and is given as a multiple of
259the rms (estimated by the MADFM) above the mean (which for the wavelet
260arrays should be approximately zero). There are several other
261parameters that can be altered as well that affect the outcome of the
262reconstruction.
263
264By default, the cube is reconstructed in three dimensions, using a
2653-dimensional filter and 3-dimensional convolution. This can be
266altered, however, using the parameter \texttt{reconDim}. If set to 1,
267this means the cube is reconstructed by considering each spectrum
268separately, whereas \texttt{reconDim=2} will mean the cube is
269reconstructed by doing each channel map separately. The merits of
270these choices are discussed in \S\ref{sec-notes}, but it should be
271noted that a 2-dimensional reconstruction can be susceptible to edge
272effects if the spatial shape of the pixel array is not rectangular.
273
274The user can also select the minimum scale to be used in the
275reconstruction. The first scale exhibits the highest frequency
276variations, and so ignoring this one can sometimes be beneficial in
277removing excess noise. The default is to use all scales
278(\texttt{minscale = 1}).
279
280Finally, the filter that is used for the convolution can be selected
281by using \texttt{filterCode} and the relevant code number -- the
282choices are listed in Appendix~\ref{app-param}. A larger filter will
283give a better reconstruction, but take longer and use more memory when
284executing. When multi-dimensional reconstruction is selected, this
285filter is used to construct a 2- or 3-dimensional equivalent.
286
287\secB{Smoothing the cube}
288\label{sec-smoothing}
289
290An alternative to doing the wavelet reconstruction is to smooth the
291cube.  This technique can be useful in reducing the noise level
292slightly (at the cost of making neighbouring pixels correlated and
293blurring any signal present), and is particularly well suited to the
294case where a particular signal size (\ie a certain channel width or
295spatial size) is believed to be present in the data.
296
297There are two alternative methods that can be used: spectral
298smoothing, using the Hanning filter; or spatial smoothing, using a 2D
299Gaussian kernel. These alternatives are outlined below. To utilise the
300smoothing option, set the parameter \texttt{flagSmooth=true} and set
301\texttt{smoothType} to either \texttt{spectral} or \texttt{spatial}.
302
303\secC{Spectral smoothing}
304
305When \texttt{smoothType = spectral} is selected, the cube is smoothed
306only in the spectral domain. Each spectrum is independently smoothed
307by a Hanning filter, and then put back together to form the smoothed
308cube, which is then used by the searching algorithm (see below). Note
309that in the case of both the reconstruction and the smoothing options
310being requested, the reconstruction will take precedence and the
311smoothing will \emph{not} be done.
312
313There is only one parameter necessary to define the degree of
314smoothing -- the Hanning width $a$ (given by the user parameter
315\texttt{hanningWidth}). The coefficients $c(x)$ of the Hanning filter
316are defined by
317\[
318c(x) =
319  \begin{cases}
320   \frac{1}{2}\left(1+\cos(\frac{\pi x}{a})\right) &|x| \leq (a+1)/2\\
321   0                                               &|x| > (a+1)/2.
322  \end{cases},\ a,x \in \mathbb{Z}
323\]
324Note that the width specified must be an
325odd integer (if the parameter provided is even, it is incremented by
326one).
327
328\secC{Spatial smoothing}
329
330When \texttt{smoothType = spatial} is selected, the cube is smoothed
331only in the spatial domain. Each channel map is independently smoothed
332by a two-dimensional Gaussian kernel, put back together to form the
333smoothed cube, and used in the searching algorithm (see below). Again,
334reconstruction is always done by preference if both techniques are
335requested.
336
337The two-dimensional Gaussian has three parameters to define it,
338governed by the elliptical cross-sectional shape of the Gaussian
339function: the FWHM (full-width at half-maximum) of the major and minor
340axes, and the position angle of the major axis. These are given by the
341user parameters \texttt{kernMaj, kernMin} \& \texttt{kernPA}. If a
342circular Gaussian is required, the user need only provide the
343\texttt{kernMaj} parameter. The \texttt{kernMin} parameter will then
344be set to the same value, and \texttt{kernPA} to zero.  If we define
345these parameters as $a,b,\theta$ respectively, we can define the
346kernel by the function
347\[
348k(x,y) = \exp\left[-0.5 \left(\frac{X^2}{\sigma_X^2} +
349                              \frac{Y^2}{\sigma_Y^2}   \right) \right]
350\]
351where $(x,y)$ are the offsets from the central pixel of the gaussian
352function, and
353\begin{align*}
354X& = x\sin\theta - y\cos\theta&
355  Y&= x\cos\theta + y\sin\theta\\
356\sigma_X^2& = \frac{(a/2)^2}{2\ln2}&
357  \sigma_Y^2& = \frac{(b/2)^2}{2\ln2}\\
358\end{align*}
359
360\secB{Input/Output of reconstructed/smoothed arrays}
361\label{sec-reconIO}
362
363The smoothing and reconstruction stages can be relatively
364time-consuming, particularly for large cubes and reconstructions in
3653-D (or even spatial smoothing). To get around this, \duchamp provides
366a shortcut to allow users to perform multiple searches (\eg with
367different thresholds) on the same reconstruction/smoothing setup
368without re-doing the calculations each time.
369
370To save the reconstructed array as a FITS file, set
371\texttt{flagOutputRecon = true}. The file will be saved in the same
372directory as the input image, so the user needs to have write
373permissions for that directory.
374
375The filename will be derived from the input filename, with extra
376information detailing the reconstruction that has been done. For
377example, suppose \texttt{image.fits} has been reconstructed using a
3783-dimensional reconstruction with filter \#2, thresholded at $4\sigma$
379using all scales. The output filename will then be
380\texttt{image.RECON-3-2-4-1.fits} (\ie it uses the four parameters
381relevant for the \atrous reconstruction as listed in
382Appendix~\ref{app-param}). The new FITS file will also have these
383parameters as header keywords. If a subsection of the input image has
384been used (see \S\ref{sec-input}), the format of the output filename
385will be \texttt{image.sub.RECON-3-2-4-1.fits}, and the subsection that
386has been used is also stored in the FITS header.
387
388Likewise, the residual image, defined as the difference between the
389input and reconstructed arrays, can also be saved in the same manner
390by setting \texttt{flagOutputResid = true}. Its filename will be the
391same as above, with \texttt{RESID} replacing \texttt{RECON}.
392
393If a reconstructed image has been saved, it can be read in and used
394instead of redoing the reconstruction. To do so, the user should set
395the parameter \texttt{flagReconExists = true}. The user can indicate
396the name of the reconstructed FITS file using the \texttt{reconFile}
397parameter, or, if this is not specified, \duchamp searches for the
398file with the name as defined above. If the file is not found, the
399reconstruction is performed as normal. Note that to do this, the user
400needs to set \texttt{flagAtrous = true} (obviously, if this is
401\texttt{false}, the reconstruction is not needed).
402
403To save the smoothed array, set \texttt{flagOutputSmooth = true}. The
404name of the saved file will depend on the method of smoothing used. It
405will be either \texttt{image.SMOOTH-1D-a.fits}, where a is replaced by
406the Hanning width used, or \texttt{image.SMOOTH-2D-a-b-c.fits}, where
407the Gaussian kernel parameters are a,b,c. Similarly to the
408reconstruction case, a saved file can be read in by setting
409\texttt{flagSmoothExists = true} and either specifying a file to be
410read with the \texttt{smoothFile} parameter or relying on \duchamp to
411find the file with the name as given above.
412
413
414\secB{Searching the image}
415\label{sec-detection}
416
417\secC{Technique}
418
419The basic idea behind detection in \duchamp is to locate sets of
420contiguous voxels that lie above some threshold. No size or shape
421requirement is imposed upon the detections -- that is, \duchamp does
422not fit \eg a Gaussian profile to each source. All it does is find
423connected groups of bright voxels.
424
425One threshold is calculated for the entire cube, enabling calculation
426of signal-to-noise ratios for each source (see
427Section~\ref{sec-output} for details). The user can manually specify a
428value (using the parameter \texttt{threshold}) for the threshold,
429which will override the calculated value. Note that this only applies
430for the first of the two cases discussed below -- the FDR case ignores
431any manually-set threshold value.
432
433The cube is searched one channel map at a time, using the
4342-dimensional raster-scanning algorithm of \citet{lutz80} that
435connects groups of neighbouring pixels. Such an algorithm cannot be
436applied directly to a 3-dimensional case, as it requires that objects
437are completely nested in a row (when scanning along a row, if an
438object finishes and other starts, you won't get back to the first
439until the second is completely finished for the
440row). Three-dimensional data does not have this property, hence the
441need to treat the data on a 2-dimensional basis.
442
443Although there are parameters that govern the minimum number of pixels
444in a spatial and spectral sense that an object must have
445(\texttt{minPix} and \texttt{minChannels} respectively), these
446criteria are not applied at this point. It is only after the merging
447and growing (see \S\ref{sec-merger}) is done that objects are rejected
448for not meeting these criteria.
449
450Finally, the search only looks for positive features. If one is
451interested instead in negative features (such as absorption lines),
452set the parameter \texttt{flagNegative = true}. This will invert the
453cube (\ie multiply all pixels by $-1$) prior to the search, and then
454re-invert the cube (and the fluxes of any detections) after searching
455is complete. All outputs are done in the same manner as normal, so
456that fluxes of detections will be negative.
457
458\secC{Calculating statistics}
459
460A crucial part of the detection process is estimating the statistics
461that define the detection threshold. To determine a threshold, we need
462to estimate from the data two parameters: the middle of the noise
463distribution (the ``noise level''), and the width of the distribution
464(the ``noise spread''). For both cases, we again use robust methods,
465using the median and MADFM.
466
467The choice of pixels to be used depend on the analysis method. If the
468wavelet reconstruction has been done, the residuals (defined
469in the sense of original $-$ reconstruction) are used to estimate the
470noise spread of the cube, since the reconstruction should pick out
471all significant structure. The noise level (the middle of the
472distribution) is taken from the original array.
473
474If smoothing of the cube has been done instead, all noise parameters
475are measured from the smoothed array, and detections are made with
476these parameters. When the signal-to-noise level is quoted for each
477detection (see \S\ref{sec-output}), the noise parameters of the
478original array are used, since the smoothing process correlates
479neighbouring pixels, reducing the noise level.
480
481If neither reconstruction nor smoothing has been done, then the
482statistics are calculated from the original, input array.
483
484The parameters that are estimated should be representative of the
485noise in the cube. For the case of small objects embedded in many
486noise pixels (\eg the case of \hi surveys), using the full cube will
487provide good estimators. It is possible, however, to use only a
488subsection of the cube by setting the parameter \texttt{flagStatSec =
489true} and providing the desired subsection to the \texttt{StatSec}
490parameter. This subsection works in exactly the same way as the pixel
491subsection discussed in \S\ref{sec-input}. Note that this subsection
492applies only to the statistics used to determine the threshold. It
493does not affect the calculation of statistics in the case of the
494wavelet reconstruction.
495
496\secC{Determining the threshold}
497
498Once the statistics have been calculated, the threshold is determined
499in one of two ways. The first way is a simple sigma-clipping, where a
500threshold is set at a fixed number $n$ of standard deviations above
501the mean, and pixels above this threshold are flagged as detected. The
502value of $n$ is set with the parameter \texttt{snrCut}. As before, the
503value of the standard deviation is estimated by the MADFM, and
504corrected by the ratio derived in Appendix~\ref{app-madfm}.
505
506The second method uses the False Discovery Rate (FDR) technique
507\citep{miller01,hopkins02}, whose basis we briefly detail here. The
508false discovery rate (given by the number of false detections divided
509by the total number of detections) is fixed at a certain value
510$\alpha$ (\eg $\alpha=0.05$ implies 5\% of detections are false
511positives). In practice, an $\alpha$ value is chosen, and the ensemble
512average FDR (\ie $\langle FDR \rangle$) when the method is used will
513be less than $\alpha$.  One calculates $p$ -- the probability,
514assuming the null hypothesis is true, of obtaining a test statistic as
515extreme as the pixel value (the observed test statistic) -- for each
516pixel, and sorts them in increasing order. One then calculates $d$
517where
518\[
519d = \max_j \left\{ j : P_j < \frac{j\alpha}{c_N N} \right\},
520\]
521and then rejects all hypotheses whose $p$-values are less than or
522equal to $P_d$. (So a $P_i<P_d$ will be rejected even if $P_i \geq
523j\alpha/c_N N$.) Note that ``reject hypothesis'' here means ``accept
524the pixel as an object pixel'' (\ie we are rejecting the null
525hypothesis that the pixel belongs to the background).
526
527The $c_N$ value here is a normalisation constant that depends on the
528correlated nature of the pixel values. If all the pixels are
529uncorrelated, then $c_N=1$. If $N$ pixels are correlated, then their
530tests will be dependent on each other, and so $c_N = \sum_{i=1}^N
531i^{-1}$. \citet{hopkins02} consider real radio data, where the pixels
532are correlated over the beam. For the calculations done in \duchamp,
533$N=2B$, where $B$ is the beam size in pixels, calculated from the FITS
534header (if the correct keywords -- BMAJ, BMIN -- are not present, the
535size of the beam is taken from the parameter \texttt{beamSize}). The
536factor of 2 comes about because we treat neighbouring channels as
537correlated. In the case of a two-dimensional image, we just have
538$N=B$.
539
540The theory behind the FDR method implies a direct connection between
541the choice of $\alpha$ and the fraction of detections that will be
542false positives. These detections, however, are individual pixels,
543which undergo a process of merging and rejection (\S\ref{sec-merger}),
544and so the fraction of the final list of detected objects that are
545false positives will be much smaller than $\alpha$. See the discussion
546in \S\ref{sec-notes}.
547
548%\secC{Storage of detected objects in memory}
549%
550%It is useful to understand how \duchamp stores the detected objects in
551%memory while it is running. This makes use of nested C++ classes, so
552%that an object is stored as a class that includes the set of detected
553%pixels, plus all the various calculated parameters (fluxes, WCS
554%coordinates, pixel centres and extrema, flags,...). The set of pixels
555%are stored using another class, that stores 3-dimensional objects as a
556%set of channel maps, each consisting of a $z$-value and a
557%2-dimensional object (a spatial map if you like). This 2-dimensional
558%object is recorded using ``run-length'' encoding, where each row (a
559%fixed $y$ value) is stored by the starting $x$-value and the length
560
561\secB{Merging and growing detected objects}
562\label{sec-merger}
563
564The searching step produces a list of detected objects that will have
565many repeated detections of a given object -- for instance, spectral
566detections in adjacent pixels of the same object and/or spatial
567detections in neighbouring channels. These are then combined in an
568algorithm that matches all objects judged to be ``close'', according
569to one of two criteria.
570
571One criterion is to define two thresholds -- one spatial and one in
572velocity -- and say that two objects should be merged if there is at
573least one pair of pixels that lie within these threshold distances of
574each other. These thresholds are specified by the parameters
575\texttt{threshSpatial} and \texttt{threshVelocity} (in units of pixels
576and channels respectively).
577
578Alternatively, the spatial requirement can be changed to say that
579there must be a pair of pixels that are \emph{adjacent} -- a stricter,
580but perhaps more realistic requirement, particularly when the spatial
581pixels have a large angular size (as is the case for
582\hi surveys). This
583method can be selected by setting the parameter
584\texttt{flagAdjacent} to 1 (\ie \texttt{true}) in the parameter
585file. The velocity thresholding is done in the same way as the first
586option.
587
588Once the detections have been merged, they may be ``grown''. This is a
589process of increasing the size of the detection by adding nearby
590pixels (according to the \texttt{threshSpatial} and
591\texttt{threshVelocity} parameters) that are above some secondary
592threshold. This threshold is lower than the one used for the initial
593detection, but above the noise level, so that faint pixels are only
594detected when they are close to a bright pixel. The value of this
595threshold is a possible input parameter (\texttt{growthCut}), with a
596default value of $2\sigma$.
597
598The use of the growth algorithm is controlled by the
599\texttt{flagGrowth} parameter -- the default value of which is
600\texttt{false}. If the detections are grown, they are sent through the
601merging algorithm a second time, to pick up any detections that now
602overlap or have grown over each other.
603
604Finally, to be accepted, the detections must span \emph{both} a
605minimum number of channels (enabling the removal of any spurious
606single-channel spikes that may be present), and a minimum number of
607spatial pixels. These numbers, as for the original detection step, are
608set with the \texttt{minChannels} and \texttt{minPix} parameters. The
609channel requirement means there must be at least one set of
610\texttt{minChannels} consecutive channels in the source for it to be
611accepted.
Note: See TracBrowser for help on using the repository browser.