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