Quantitative DIC

Using the qDIC320.exe Program

20 November 2024

User manual and data description


Program Overview

The program qDICv320.exe is used to integrate the quantitative differential interference contrast microscopy (qDIC) images. It reads raw DIC images and performs an DIC inverse transformation using a procedure based on Wiener deconvolution, and saves the calculated differential phase (delta) and integrated phase (phi) as tiff, ascii and matlab binary files. You can run the executable qDICv320.exe directly, or the batch file qDICv320.bat
to provide a command line window where matlab errors during execution are displayed.

See the publication [1] DOI 10.1016/j.bpj.2013.07.048 for more details of the underlying science.
See an example of qDIC measurements of grooves in photolithographic polymer SU-8 (unpublished) [2].


System Requirements

This program is written in MATLAB R2021a. It is a stand-alone application, so it does not require a full MATLAB installation. The program has been tested under Windows 10 Pro, Intel i5-2400 processor @3.10 GHz and 20 GB of RAM. It is necessary that the MATLAB Compiler Runtime (MCR) version 9.10 (R2021a) is installed. If the MCR is not installed, do the following:


Principle of Operation 

DIC is a measure of the phase difference between two adjacent points in the sample plane. The exact Fourier multiplier of the DIC-like transformation is given in [1], formula (6). The inverse transformation is done using Wiener deconvolution, see [1], supporting material, formula (4). Depending on the assumed signal-to-noise ratio, κ, the result changes, as effectively a high-pass filter is applied to the data in the shear direction: For low κ the integrated images show less integration artefacts and less long-range features, such as phase steps. High κ allows the recovery of the long-range features at the expense of noise related stripes along the shear vector direction.


Input Data


Input Parameters

qDIC Software Window

1. File and Folder Settings

Files and Folders for Single z-Planes

The user needs to specify the location of data files on the hard disk (general folder). Within that folder, the user should create subfolders, "p" and "m", which contain the raw DIC images taken for positive and negative ellipticity of the incident beam respectively. The absolute value of the incident ellipticity for positive and negative phase should be equal; if not the polariser may not have been calibrated correctly during imaging. The filenames are constructed using the default settings of the Hamamatsu camera software. The variable part between prefix and suffix has a fixed number of digits (9 in this case), so the files are img_000000000.tif, img_000000001.tif, etc. The user can browse for data folder using "Browse" button, and can check the filename using "Check" button. Note that the prefix, the number of digits and the suffix are all modifiable so that the user may use their own image naming convention (this must contain digits however).

Usually, several acquisitions of each field of view are taken and averaged together. If these have not been averaged before loading into the qDIC software, the number of acquisitions (1 by default for DIC images) should be specified. These acquisitions are then averaged by the qDIC software before further processing.

The user should take background images in order to subtract the dark counts from the DIC images (these should be stored in a subfolder "b"). As in the case of the positive and negative images, multiple repeats may be taken. If these are not averaged together before running the software, the number of frames should be entered in the "Background" box. Alternatively the user may measure the average dark counts (plus leakage) value throughout the image and input it in "Background, counts" field under the DIC Parameters heading. An error message will appear if no background images are found; the program will still run and use the average dark counts instead. It is not advisable to use both methods of background subtraction at once, which is why the  "Background, counts" field is set to 0 by default. If no background images are used, set the "Background" field to 1 (default).

Files and Folders for Stacks

The user can place single multi-image *.tiff files in the \p\ and \m\ folders, and tick the "Multi image tiff" checkbox and input the filename in the manner described above (Files and folders for single z-planes). To import stacks, tick the box "Import Stack". The tickbox "Retain stack" is automatically activated in stack mode upon hitting run to avoid the re-import of the stack and calculation of the differential phase data. 

The user may also create a stack of integrated images through placing multiple *.tiff images in the \p\ and \m\ folders and unticking the "Multi image tiff" checkbox before hitting "Run". The variable part between the prefix and the suffix changes in a manner described in the section above when the software reads in file names, however the number of images which are read in is limited by the "Number of images in stack" field rather than the "Number of takes" field.

Batch Processing Multiple Data Sets

To facilitate the analysis of large numbers of data sets with the same parameters, the batch processing option is available. To use it, first check the "Batch process" checkbox. Note that the label for the directory textbox will change from "General folder" to "Batch file", and the "Run" button will change to "Run batch" to indicate the change in mode.

Next, a *.txt file must be created with a list of folders to be used for the analysis. An example of this is shown below.

Each of the folders listed in the text file must follow the standard structure, with subfolders for the positive, negative and background images (named "p", "m", and "b" by default) and files named according to the naming system entered into the software.

Next, enter the file path for the file containing the folder list into the qDIC software.

Once this is done, the integration parameters are entered the same way as when processing a single data set, outlined in the sections below. Note that the software will use the same analysis parameters for every data set on the list; if some data requires different settings, these should be split into separate files. Once the correct parameters have been entered, click "Run batch". The software will then process the data in each folder on the list sequentially.

Load Delta

An option exists to integrate a differential phase (delta) image directly, rather than first generating the differential phase image from a pair of positive and negative DIC images, and then integrating. This mode is activated by checking the "Load delta" checkbox. These delta images should be in the "out" subfolder, named delta.mat, and be formatted to match the qDIC software output, with the name of the differential phase variable in the .mat file set to "delta_out".
  

2. DIC Parameters

In this section, the user needs to enter the settings relating to the acquisition of the DIC images during the original measurements session. Specifically, this includes the numerical aperture of the system (usually equal to the numerical aperture of the objective), the polariser angle used, the pixel size (determined by the objective, tube lens, and camera used), the size of the DIC shear vector, the direction of the DIC shear, the mean illumination wavelength, and the background counts (only needed if a background image is not used). Information on the pixel size for different objective and tube lens combinations is available for the Ettore and Galileo microscopes. Measured DIC shear vectors for N2 and NR DIC prisms are available here.

3. Integration Parameters

Signal-to-Noise Ratio

The signal-to-noise ratio of the Wiener deconvolution determines the low spatial frequency cut-off of the reconstruction. The user should look at the resulting integrated images and see if the degree of noise is tolerable. The value of 4000 was found to be a good trade-off for the Galileo microscope and the 0.75NA objective with 1.5× multiplier.

k-Filter Factor

Spatial frequencies that are above the Nyquist limit of the optical setup can be filtered out using the k-filter - a cosine apodisation from 1 to 0 is used to smoothly reduce the Fourier amplitudes for spatial frequencies above the k-max value to zero (k-max is the Nyquist limit of the optical system). The k-filter factor defines the range of spatial frequencies over which the apodisation function is used. The size of this range is determined through multiplying the k-filter factor with k-max. NOTE: k-max is the central value of the user defined range over which the apodisation function is used, so values above and below k-max are apodised and some spatial frequencies above k-max will have a non-zero amplitude. There is a checkbox to enable this feature and it is used by default.

This function can also be used to suppress the data at spatial frequencies corresponding to the inverse of the DIC shear, which leads to increase in noise with a period of the sheer. For this goal, the NA setting has to be set lower so that the spatial resolution \(\lambda/(2\mathrm{NA})\)  is above the shear. For the N2 DIC slider shear of 238nm, and 550nm wavelength, this requires setting the NA to 1.1 or lower at a filter factor of 0.1 or lower.

Data Padding (Apodisation vs Flip Method)

In order to reduce artefacts in the integrated images caused by the periodicity of the Fourier transform, the software offers two methods of padding the data prior to the integration.

In either case, the padded area is automatically cropped out following integration.

Full Inversion / Linearisation

This option allows the user to use a linearised version of the equation for extracting differential phase from the composite DIC image as opposed to the fully invertible equation (full inversion is recommended by default, see qDIC example for details).

c-Factor

This is a checkbox which is used to make the mean values of the background subtracted positive and negative polarisation DIC images equal through multiplying both images by a factor. This checkbox is checked as default and it compensates to first-order different mean values of positive and negative polarisation DIC images due to inaccurate phase offset settings and setup drifts.

Image Shifting

This feature shifts the the "p" and "m" images relative to one another in pixel steps to counter the misalignment of objects between images caused by focal drift - this is done by varying the "X shift" and "Y shift" parameters and ticking the "Image shifting" checkbox.

4. Save Options

Saving Single z-Planes

The program saves all resulting files in the subfolder with name given by the "Output folder" field within the "General folder". Multiple runs of the program in single image mode will overwrite the previous version of the files, so it is recommended to copy them elsewhere or to change the "Output folder" location.

The user can choose to save differential phase delta and/or integrated phase phi. For each phase, three files are saved: a tiff image (in either 8, 16, or 32-bit format), a *.dat file (ascii), and a *.mat file (binary Matlab format). All files contain absolute values of the phase in radians, unless either the 8 or 16-bit checkbox is checked then the tiff image is in unsigned 8 or 16-bit format respectively. However, this can be scaled using the min/max values in the metadata under the 'ImageDescription' tag.

If the "Import stack" tick box is unchecked, the contrast and integrated images are saved automatically after processing (as in previous versions).

Saving Stacks

Stacks are saved as 8/16/32-bit multipage tiff format after analysing stacks and hitting the "Save button" (stacks will not be saved otherwise!). In addition to the option to save the differential phase delta and integrated phase phi, an option to save the squared image is also available for stacks. If z-planes are not integrated, they are not saved within the outputted contrast/integral/squared images. A string of data is saved along with the image stacks (one each for phase, contrast and squared images) that indicates the length of the original image stack, and the integrated images - for example if the 2nd z-plane is integrated, a value of 1 is recorded at position 2 within the string, if it remains unintegrated a value of 0 is recorded at position 2 within the string. This string of data also "inflates" the z stack to its proper size upon reloading the data in qDIC.

The parameters used in for each z-plane are saved in a *.mat file named "Stack_parameters.mat" upon hitting the "Save Stacks" button.

Format

Single images / image stacks can be saved in either 8-bit, 16-bit, or 32-bit format by using the checkboxes under the "Save" heading. Using 16-bit format approximately halves the data size relative to 32-bit, and using 8-bit halves it again. For 8 or 16-bit images, the minimum and maximum values are saved in the metadata of the TIFF files under the metadata Tag "ImageDescription".

An ImageJ/Fiji macro to automatically read this information and apply the correct intensity scaling, PixelCalibration_v2.ijm, has been developed by Lukas Payne, and is available here. Note however that this calibration method (using the built-in "Calibrate" tool in ImageJ/Fiji) is not compatible with hyperstacks; concatenating stacks into a hyperstack changes the intensity calibration to incorrect values.

5. Other Options

Background Subtraction

This feature corrects slowly varying background changes (often seen in the direction of the shear vector), and is activated by a tick box named "Correct Background".

Dirt Filtering

Small, high contrast objects in the DIC images can cause significant artefacts in the integrated image, along the shear direction, particularly at high values of the signal-to-noise integration parameter. Such artefacts may interfere with measurements elsewhere in the image, and so it is sometimes desirable to remove such objects. The dirt filter allows the user to manually select regions of the image containing unwanted structures, and replace them with a region that is mostly smooth and featureless (a similar procedure as the apodisation is used, see PhD of J.B.Williams) which should not produce significant artefacts.


Dirt filter specific controls in the qDIC software.

To use the dirt filter, check the "Dirt filter" checkbox before clicking "Run". When the dirt filter is checked, a number of additional buttons, textboxes and checkboxes will appear which control the functions related to the dirt filter; these are shown in the figure above. Once the user clicks "Run", these buttons will become enabled, and, after the polynomial background correction is complete, the processing of the image will pause to allow the user to filter the image as desired.

To apply a filter to a region, draw a rectangle on the image, adjust it as desired, and then click "Apply Filter". The image will be updated immediately to show the image after filtering, and the number displayed in the "Total Filters" box will increase by one. To undo one of the filters applied to the image, use the "Filter No" textbox to select a previous filter and click the "Delete Filter" button. The corresponding filtered region will then have its original values restored, and the index of the filters of higher number will be reduced by one.

To facilitate the application of the filters, zoom and contrast adjustment options are available. To use the zoom, simply use the rectangular selection to select a region of the image to zoom in to and click the "Zoom In" button. To cycle between several enhanced contrast presets, click "Contrast". The "Zoom Out" button restores the full field of view.

When using the dirt filter with stacks, the user will be presented with a prompt asking if the user wants to use the same filter regions on each frame:

If the user clicks "Yes", the user will be allowed to select any number of regions to filter on the first frame, and then these same regions will be automatically filtered on all subsequent frames in the stack. If the user clicks "No", the user will be allowed to select different regions to filter for each individual frame in the stack.

Loading Integration Parameters

The qDIC software has two methods of loading in integration parameters:

    1. Loading the previous software state via the "Load Parameters" button

When carrying out any integration on a single frame image, or saving the results of an integration on an image stack, the saved .mat files include a variable called "Metadata" which records every setting of the qDIC software when the integration was carried out. Each time the analysis is rerun or a stack is saved, the settings stored in the .mat data files are overwritten. However, each time the analysis is run, a separate .mat file is also created named with the name format settings_YYMMDD_hhmm.mat, where YYMMDD_hhmm refers to the date and time the analysis was run, so previously used settings can still be accessed and reapplied.

To load in settings used for any previous analysis, click the "Load Parameters" button located under the "Browse" button near the top right of the GUI. Click any file (either a settings file, or a delta or phi .mat file) to load in the settings stored in that file.

    2. Loading in frame specific settings for stacks using the "Use loaded parameters (stack)" checkbox.

A previously implemented system for loading parameters that only works on stacks is the "Use loaded parameters (stack)" checkbox. This function uses the "Stack_parameters.mat" file that is saved alongside stacks, and differs from the "Load Parameters" button in its ability to apply different settings to each slice of a stack. This may be useful when trying to test different integration parameters, or if the imaging parameters changed between frames.

This mode is used by just ticking the "Use loaded parameters (stack)" checkbox, and hitting "Run". NOTE: to use parameters saved from previous session on a stack that has not yet been analysed, place a copy of the "Stack_parameters.mat" in a folder named "out" (if the default value for "in folder" is unchanged) - place this folder in the same directory as the "p", "m" and "b" files.

6. Stack Specific Settings

To run the program on a stack of images, check the "Import Stack" checkbox. The software has two modes for handling stacks.

Default Mode

The default method takes a stack of N positive polarisation images from the "p" folder (still named according to the system described above, so img_000000000.tif by default), and a corresponding stack of N negative polarisation images from the "m" folder, and will then run through all the frames in these stacks, taking the ith positive image and the ith negative image and generating delta and phi images from them in the same way as for single image mode, ultimately producing output delta and phi stacks with N frames.

Time Course Mode (Single Polarisation Stacks)

The software can also be used to integrate stacks taken at a single polarisation, such as time course measurements or z-stacks. This analysis mode is enabled by checking the "Time course" checkbox in the top left region of the GUI. Time course data will consist of a stack of consecutive images taken at the same polariser angle , and two reference single-frame images taken at and , named I+ and I-, while z-stack data will consist only of a stack taken at a single polarisation at different z-planes. Note that the time course or z-stack *.tif file should be placed in a subfolder named "s" and named according to the standard format. For the time course, the I+ and I- images should be saved in folders "p" and "m" as usual in the general folder.

There are three options for calculating the contrast image. When the user runs the analysis with the time course option checked, they will be asked to choose between these three settings from a dialogue box.

In the first option, designed for time course data, a time shifted image is subtracted from each frame, as described in the equation below: $$I_c=\frac{2(I_{n+\Delta}-I_n)}{I_+ + I_-}$$ where Ic is the contrast image, In is the nth image in the time course, \(\Delta\) is a user defined number of images for the time shift, and I+ and I- are the positive and negative reference images respectively.

The second option is designed for analysing single polarisation z-stacks. This option uses two frames shifted from the focal plane by a set amount for referencing. The contrast image for each slice, z is given by: $$I_c = \frac{4I_{z} - 2(I_{z+\Delta} + I_{z-\Delta})}{2I_{z} + I_{z+\Delta} + I_{z-\Delta}}$$ where again Ic is the contrast image, Iz is the image at focal plane z, and Δ is the user defined number of frames to shift by in the analysis. Note that unlike the other referencing options in the software, this analysis mode does not require anything in the "p" or "m" folders; only the stack (and background) is needed. The stack may be taken at either positive or negative orientation.

When the third option is selected, a positive reference is subtracted from each frame instead, as in the following equation: $$I_c=\frac{2(I_n-I_+)}{I_+ + I_-}$$In each case, the background image is subtracted from all images I before the contrast image is generated.

Retain Stack

This checkbox allows the user to retain contrast/integrated images and integration parameters used within a stack for the current session. If the user needs to clear these images, this checkbox should be unchecked.

Load Stacks

This button will load integrated stacks from a previous session. The stack parameters will also be loaded (if a 'Stack_parameters.mat' file is present) and will be present upon changing the Z-number display parameter.

Z-number display (stacks)

This field is used in order to view analysed data from the current analysis session e.g. to view the integrated image created for the third set of images in a stack input 3 into this field. The values used to integrate this image are also displayed upon varying the value in this field.  The "Contrast/Integral" slider may be used to view the contrast and integral images for each z-plane.

Z-min and Z-max (stacks)

The user can specify which z-planes within the stack are to be analysed through using the "Z-min" and "Z-max" fields. Through this function, the user can integrate each (or multiple images) with a particular set of integration parameters.

7. Post Processing

Energy Minimisation

The energy minimisation panel appears, and the user can load a "delta" and "phi" image through a browse button. The pixel size, shear direction and shear magnitude fields are filled with the same values as those that are in the main qDIC window, but can be changed by the user.

GPU

GPU mode can now be used for energy minimisation on computers with suitable graphics cards. The GPU option is automatically enabled if a suitable GPU can be used. In the GPU mode, a range of smoothing factors between \(10^{-{q_{min}}}\) and \(10^{-{q_{max}}}\)  can be tested. The smoothing factors \(S=10^{-q}\) are generated using the set of integers \(q=\{q_{min},q_{min}+1,\ldots,q_{max}-1,q_{max}\}\), where \(q_{min},q_{max}\in \mathbb{Z}\)  and \(0<q_{min}<q_{max}\). DIC images can be loaded after integrating single plane images and loading the *.mat files into the Energy minimisation software. *.tif images can also be used. If using the GPU mode for high speed computation, images should not be displayed frequently, as gathering the image from the GPU and displaying these images in the panel is a slow process.


Running the Program

  1. Install MATLAB Compiler Runtime if it has not been installed before.
  2. Place your images in a single folder (in a manner described in Input data).
  3. Start qDIC320.exe. Any MATLAB errors are displayed in the command window.
  4. Change the Input parameters as required.
  5. Hit the RUN button.
  6. This will integrate the images in the specified directory, and create a new subfolder named "out" to contain the output images.
  7. You can hit RUN again if you wish to change the input parameters or load in a new image.
  8. Close the program.
  9. Hit any key to close the command window.

Update Log

Version 2.20

Version 2.21 (bugfix and new minor features)

Version 2.22 (k-filter and c-factor)

Version 3.00 (Energy minimisation and time course functionality)

Version 3.01 (Bug fix)

Version 3.10 (Bug fixes, dirt-filter improvement, saving of settings, batch processing)

Version 3.20 (New stack processing mode, 8-bit saving option, delta image direct integration option, bug fixes)

Implementations To Do


Created by George Zorinyants, 17/12/2013. Edited by GZ 02/02/2016, WL 31/03/2016, JW 14/11/2016, 06/02/2017, 01/06/2017, 19/10/2017, 13/07/2018, 28/10/2020, 09/07/2021 WL 25/12/2020, JW 22/07/2021, WL 14/07/2021, DR 27/11/2023, WL 10/12/2023, 16/12/2023, DR 20/11/2024, WL 07/12/2024

The content of these pages cannot be shared with third parties, and if you make copies you have to protect them from unauthorised access. If you want to share information, you need to remove any confidential information such as financing and offers, passwords for access, e-mail conversations and unprotected IP etc. You also need to the agreement of Wolfgang Langbein or Paola Borri for that beforehand.