SQL
This logic can be used to perform database related operations on header keys of one or two stacks of images to filter them for certain criteria.
Usage
In order to filter a stack of images SQL syntax can be applied. SQL is a powerful language used to filter large datasets. To learn more about SQL please see https://www.sqlite.org/docs.html for detailed information.
Example
- Reproduce the input (default value)
SELECT *, FROM t0
- Rename
SELECT *,classID as clusterMember FROM t0
- Perfom arithmetic on certain header value
SELECT *, (referenceData -120) as referenceData FROM t0
- Count distinct values, example given by referanceData from alignment. t0 := projections, t1 := ali images
SELECT DISTINCT t0.*, COUNT(t1.referenceData) as counter FROM t0, t1 WHERE t1.referenceData == t0.imageID GROUP BY t1.referenceData
- Select only even images (repleace =0 with =1 for odd images)
SELECT * FROM t0 where img%2=0
- Calculate the average of parameter imageID for a given condition (where clause)
SELECT sum(imageID)/count(imageID) as sum FROM t0 where imageID >10 and imageID < 20
- Count the number of distinct values for the header key croppedFromFile and order the output by that key, output will consist of 1 image per unique value
SELECT *, COUNT(croppedFromFile) FROM t0 GROUP BY croppedFromFile
- Select all images from t0 input where eulerBeta = 130 and eulerGamma is between 190 and 195
SELECT * FROM t0 WHERE eulerBeta = 130 AND eulerGamma BETWEEN 190 AND 195
- Mirror the euler angles of particles (for angular distribution plot with eulerBeta and eulerGamma in Value Viewer)
SELECT *, (180-eulerBeta) AS eulerBeta,
CASE
WHEN eulerGamma >= 180 THEN eulerGamma-180
ELSE eulerGamma+180
END
AS eulerGamma FROM t0
Parameters and I/O
Parameters | Description |
---|---|
Statement | This is the actual SQL statement used to filter the input(s) |
Write 1D images | Writes a 1D image for every header key. Every value in the output image is the header value of one particular image of the input dataset. |
Input | Description |
---|---|
Input table t0 | Stack of input images |
Input table t1 | Stack of input images |
Output | Description |
---|---|
Output result | Stack of output images |
New/Changed Header Values | Description |
---|
New or changed header values depend on how this logic is used, since header values can be added or modified by this logic.
Concept
This module creates a database which is basically the union of all input header values. Then the given SQL statement is applied onto this database and the resulting header keys (with the corresponding images) are written to the output.