Public Lab Wiki documentation



Spectral Workbench Operations

This is a revision from January 07, 2016 17:17. View all revisions
2 | 15 | | #12568

A major change in Spectral Workbench 2.0 is a system called Operations (previously known as PowerTags). When you save a spectrum, you usually have to perform additional operations, sometimes setting a cross section, certainly calibrating, and sometimes then smoothing or otherwise manipulating the data. But for various reasons, you often want to record and even revert some of those changes. Maybe you want to do them differently, or to recalibrate.

Operations are the new way to do this. Each time you apply an Operation, the resulting dataset is saved in a Snapshot, so that a copy is archived and available in the database without having to run each calculation every time. Operations typically feature a key:value pair. Creating operations is easy; the Tools pane below each spectrum guides you through creating them with a simple form, and adds your Operation when you click Apply. Some Operations reference other spectra, for comparison or subtraction. You'll be presented with a menu and search form to find the right spectrum to use.

Operations include:

calibrate

calibrate:<id> - Copies calibration from spectrum with given <id>.

linearCalibration

linearCalibration:<b2>,<g2> - Manually calibrated with two reference points <b2> and <g2>, which correspond to known positions 435.83 and 546.07, respectively. This should be the first operation, as it works best on sharp, full-width data that has not been range-limited or smoothed.

range

range:<min>-<max> - Limits wavelength range to specified <min>-<max>, in nanometers, or if data is uncalibrated, then in pixels.

smooth

smooth:<amount> - Rolling average smoothing by given # <amount> of pixels.

forked

forked:<id> - Spectrum is a forked copy of the Spectrum with given <id>.

subtract

subtract:<id> - Subtracts spectrum with given <id> from the current spectrum. Should point at a specific snapshot with syntax subtract:<id>#<snapshot_id>

crossSection

crossSection:<height> - Sets the row of pixels, counting pixels from top row, used to generate the graph. The default for any spectrum is the top row of pixels, the equivalent of crossSection:0, whereas crossSection:20 would measure the brightness of each pixel in the 21st row down from the top (since we begin counting at 0).

flip

flip - Indicates that the spectrum image has been flipped horizontally. This can be necessary if your spectrometer webcam is installed backwards, which would place the red end of the spectrum (with higher wavelengths) to the left, instead of to the right, as is the standard in Spectral Workbench. flip is also copied over if a spectum marked with it is used as a calibration for another spectrum, with the calibrate:<id> Operation, below.

transform

transform:<expression> - Filters this spectrum with a math <expression>, by running the brightness of each pixel through the math expression. More on this soon.

blend

blend:<expression> - Filters this spectrum with a math <expression>, like transform:, but in combination with data from a given second spectrum. This allows for, for example, multiplying or dividing two spectra.


Passive Operations

Some Operations don't affect the data at all; it's not clear if we're going to make these appear in the Tags listing instead. For now, these two are generated along with calibrationQuality and provide metadata about the spectrum, but aren't used to change the data:

error

error:<amount> - Scores a calibration 'fit' by comparison to a known reference; lower is better, zero is perfect.

calibrationQuality

calibrationQuality:<quality> - Roughly indicates how good a calibration 'fit' is, in qualitative terms good for <12, medium for <16 and poor for anything higher/worse.


Contributing

The Operations framework is designed to be flexible and extensible, as we add more abilities to Spectral Workbench. Please contact the developers list with ideas and suggestions for new features and future versions, and check out Spectral Workbench on Github at https://github.com/publiclab/spectral-workbench.

Also check out our Contributing to Public Lab Software page.