The PIPPA workflow

An Appendix to WTC 2014 presentation
“Mathematica in digital subtraction perfusiography of burn wounds”

Iveta Bryjová and Stanislav Hledík

In the following sections, a step-by-step guide of the selected burn case processing will be demonstrated. All pictures presented were created as ex-post cropped screenshots of relevant parts of Mathematica notebook.

Loading the LDI scan batch

First, at least two scans of the burn area taken in different post-traumatic days (PTD) form so-called scan batch. (If a single scan is tried to be loaded, PIPPA will complain about it.) Each scan consists of a single BaseName.ldi file, its text exports BaseName.inty, BaseName.perf containing raw values of intensity and perfusion maps, its image export BaseName.png with area marks (all manually exported using LDPIwin 3.1), and finally BaseName.head containing manually entered respective values of dimensions, resolution, distance, step length, area, date, and (relative) time, all of them again provided by LDPIwin 3.1. The opening dialog pretends loading *.ldi files for user convenience, actually the abovementioned exports are read. This can change in the future versions of PIPPA, as soon as the *.ldi input function is ready. In the screenshots below, the batch consists of three scans of burned left shin in the 5th, 7th and 9th post-traumatic day (the exact times being written in the *.head file):

LDI scan pair selection

By default, PIPPA selects the newest scan as the “head” (or “reference”) and the oldest one as the “hat” (or “sensed”) scan. This behavior can be modified through the interactive panel that provides also preview (not to scale) of photo, intensity and perfusion scans, including some basic perfusion statistics. The perfusion map can be presented in two modes: as a density or contour map. We consider the latter more useful. In the screenshots below, the 7th and 9th PTD were selected (instead of the default 5th and 9th PTD):

Fine aligning intensity maps with photograph

As soon as the two scans to be subtracted are selected, the first crucial point is fine embedding the perfusion map into the photo. Since the perfusion and intensity maps are of exactly the same pixel dimensions, but the latter shares (contrary to the perfusion map) certain morphological features with the photo, the intensity map is ideal for carrying out this task. In the following two screenshots, the initial (default) placement of the intensity map is derived from the crosshair position using the calibration procedure (see below for details). The intensity scan transparency can be changed in full range by the “dissolve” slider:

Unfortunately, the default placement of the intensity map is not always exact, and usually must be tuned by the “x-shift” and “y-shift” sliders. Fiddling about with the sliders must often be interleaved by trial-and-error moving the “dissolve” slider back and forth to reveal common features. In the following two screenshots, the intensity scan is precisely enough embedded in the correct position:

Exactly the same is to be carried out with the “hat” (earlier) scan (see the appearance of the “head”/”hat” tabs). Moreover, the “threshold” slider may be taken into action, but masking does not work satisfactorily enough, and – in our opinion – is not so important (see also the next section). The following two screenshots demonstrate embedding the “hat” scan and setting the mask (which of course can also be done for “head”):

After exactly embedding the intensity scan into the photos, the first set of four parameters – namely the x- and y-translations for both “head” and “hat” become known and are saved for future usage.

Optional step: mask refinement

The masks obtained by thresholding described above are seldom suitable for further application. Their shape is usually ragged, and if one insists on their usage, it is a good idea to smooth them in a very simple way using the interactive morphological manipulations. Operating with the “opening” slider fills the smaller white holes in the black mask area, while subsequent moving the “closing” slider smooths out and extends the unmasked white areas, as demonstrated in the next panels:

If masking is not required, this step can safely be skipped.

Aligning the pair of photos

The second crucial step is registering the “hat” photo into the “head” one – i.e., aligning the photo pair. The standard image registration algorithms usually fail or at least work unreliably because the visual appearance of the burn considerably changes within 24–96 hours. It is then impossible to find necessary key points. Instead of automatic procedure, for our purposes we adopted manual image registration. The panel below left shows the default situation, while the panel below right shows using the “auto scale” feature checkbox that exploits the distances between the scanning chamber and the measured object contained in the *.head files. Based on these data, the “hat” photo is resized according to the calibration curves (see below for more on calibration):

In this particular case, we found the auto scale feature not enough precise (after some playing with the “dissolve” slider and other sliders as well). As a result, the manual “x/y-scale” sliders come into action upon locking the aspect ratio with the “keep aspect” checkbox (only the “x-scale” slider then remains active). In the following four panels, we gradually achieve correct alignment by correct setting the “rotation”, “x-shift” and “y-shift” sliders, while continually checking the correctness by moving the “dissolve” slider back and forth (the last three panels show extreme and the middle position of the “dissolve” slider):

After exactly registering the pair of photos, the second set of five parameters – namely the x- and y-translations, x- and y-scales, and the rotation angle of the “hat” photo becomes known and is saved for the DSP computations.

Running DSP

At this point, we collected sufficient enough information for running the DSP: the first set of parameters from the intensity-to-photo alignment, and the second set of parameters from the pair of photos alignment. These parameters are passed to the DSP module to use them for correct alignment of perfusion maps: to resize, translate, rotate and interpolate them, and finally produce the subtraction map. The computation is started manually by clicking the button as shown here:

After finishing the DSP computations, everything is prepared for displaying the results in the form of perfusion maps and perfusion subtraction maps.

Perfusion maps and perfusion subtraction map overlay

The following panels show the last PIPPA dialog panel in its default form: display of “head” perfusion map in the form of density map, optionally in the form of contour map (which we prefer and consider to make the default in future versions). The transparency is set near-mid by default:

The three panels below only demonstrate transparency control and optional masking (“mask” checkbox):

The panel below left only summarizes the perfusion map for the “hat” (older) scan. All features described for the five “head” panel tabs above apply for the “hat” alike.

The essential innovation of PIPPA is demonstrated in the remaining five panels, starting from the one below right. In this panel, the default form of the subtraction (change) map is shown. Notice that the vertical color scale in the right column has changed: now it spans twice the range, from negative to positive values. The negative perfusion change values are now coded with cold tones of blue, while the positive ones remain in warm yellow-red tones. The number of colors for subtraction contour maps is twice the number for perfusion contour maps minus one.

In our opinion, better visual perception can be achieved using the contour maps. In the panel below left, the full range is used by default, but such option can fail for close enough perfusion maps, resulting in almost monochrome subtraction map. The “close fitting” button forces the full color scale to dwindle to the difference range: the subtraction map receives more colors, and the color scale gets revalued. This is perhaps the most valuable presentation of perfusion subtraction map.

In clinical practice, the knowledge of perfusion change per suitable time unit may be desirable. For that reason the “total” (default), “per day” and “per hour” radio buttons were implemented – they just adjust the color scale gauge but leave the map itself untouched:

Note: unchecking the “realtime controls” checkbox (checked by default) just suppresses any action during manipulating with continuous controls; the changes are applied as soon as the handling the control is ended. This makes adjusting trickier because of lack of visual feedback but may be useful on weak computers.

PIPPA calibration

It has been empirically found that the horizontal and vertical scan steps dx and dy are not exactly equal although the LDPIwin 3.1 presents common value for both directions. In addition, for the purposes of rescaling the perfusion maps the information about the real dimensions of scans and real dimensions of the objects in photographs (they are not available at all) is needed. Finally, for initial placement of the perfusion map we need to know the crosshair position. The solution is calibration which consists of three steps.

1.  Real photo dimensions fit

The dependence of real dimensions of the photo (Subscript[L, x]) and (Subscript[L, y]) on the scanning chamber-scanned object distance r was subject to linear fitting procedure. The dimensions (Subscript[L, x]) and (Subscript[L, y]) are resolution-independent and were obtained as follows. The graph paper was scanned by PeriScan for 11 different distances r in the range 310 mm down to 85 mm. The real photo dimensions were established from the photos themselves (see subsection “Graph paper photo sequence” below), resulting in the following linear fit:

2.  Scanning step fit

The dependence of scanning steps (Subscript[d, x]) (blue) and (Subscript[d, y]) (red) on the scanning chamber-scanned object distance r was subject to linear fitting procedure for Low (left figure) and Medium (right figure); High and VeryHigh resolutions were not fitted for not enough data to provide credible results. The data for fitting procedure were extracted from all scans available. Green dots represent the common step value provided by the device, and written in the *.head files.

3.  Crosshair position fit

The dependence of crosshair relative position hx (blue) and hy (red) from the left lower corner of the photo, both between 0 and 1 inclusive, on the scanning chamber-scanned object distance r was subject to quadratic (linear) fitting procedure for Low (left figure) and Medium (right figure); High and VeryHigh resolutions were not fitted for not enough data to provide credible results. The data for fitting procedure were again extracted from all scans available via semiautomatic procedure PeriScanPIM3.nb written in Mathematica.

Graph paper photo sequence

Raster graph paper photos used for calibration (in the order of decreasing distance starting from r = 310 mm, ending with r = 85 mm). Observe how the crosshair position moves from near center to the right edge:

All results of calibration are saved (in the form of functional prescriptions) in the PeriScanPIM3.m package loaded by PIPPA on start. Gradual collecting further scans enables more precise calibration and consequently updating the PeriScanPIM3.m package, thus resulting in better accuracy performance of PIPPA.