Welcome to the web page 
of Peter Nagy

Experience and experiments with Matlab

What a "user-friendly" application! This was my first impression when I first installed Matlab on my computer and it started up with a screen with a command prompt and basically nothing else. But I gradually began to appreciate the flexibility and power of data analysis and the relative ease of programming of Matlab. I wrote Matlab code for fun and for developing applications for myself or for my colleagues. Below, you can find  a selection of the image analysis utilities I developed.

openpicture: a GUI-based application to open images

The program is a simple application for opening images supported by the "bfopen" command of the BioFormats package in Matlab. Therefore, BioFormats must be installed. Since DipImage is the default output image type, DipImage must also be installed.

Syntax:

  • openpicture (i.e. simply type "openpicture" at the Matlab command prompt). Three GUIs will be displayed consecutively. First, the user must decide if the images are exported into a DipImage image type or numeric array. Then, the user must select which image file to open. Lastly, if the image is a 3D stack, the user must decide if the images are to be exported into the Matlab environment as a stack or as single images.
  • openpicture(fullPathToImage, outputType) - the image which can be found at the location specified by the first input parameter (fullPathToImage) will be read. outputType can be 'dipimage' or 'numeric'. A GUI will be displayed to specify the output image and its type as explained above. If "outputType" is not specified, the type of the output will be DipImage.
  • imageOut=openpicture(fullPathToImage, outputType) - the same as above, but a GUI is not displayed for specifying the output. Instead, the output image will be "imageOut". If the image is 3D, the output will be a 3D stack.
  • imageOut=openpicture - the input will be specified by GUIs, but the output will be saved into the variable specified by the output argument of the function

Download: openpicture.p

Upgrades: At every run of the program it automatically checks for available upgrades and warns the user to press the "Upgrade" button to perform the process.

Draw regions of interests (ROI) in an image: imagegate

Another simple application. You draw a region on interest (ROI) on to an image with a color specified in the GUI. There are two kinds of outputs:

This is how to draw the ROI:

Syntax: type 'imagegate' at the Matlab command prompt
Without input arguments the application will be started in GUI-mode.
If input arguments are given, the GUI won't be shown. Example for syntax when input arguments are present: imagegate(imageToDrawOn,'linecol','b','closeline',1,'timesdilate',0,'roitype',1/2,'radius',2)

Download: imagegate.p

The application checks for updates after it is started.

Evaluation of a mask in an image (mask_evaluate)

A very simple application. A grey-scale image is analyzed in pixels defined by another image called the mask. Only those pixels of the first image (grey-scale image) are analyzed which are "1" in the mask. After pressing 'Analyze' the following parameters are calculated:

You can save the results to a text file or export the results into Matlab variables.

You can use the "imagegate" application, available in this page, to create the mask image.

Syntax: mask_evaluate

Download: mask_evaluate.p

The application checks for updates after it is started.

Manaully-seeded (marker-controlled) watershed segmentation (watershed_segment)

Manually-seeded watershed transformation implemented in Matlab using DipImage functions.

Syntax and help:
[output_type_1,output_type_2]=watershed_segment(image,output_type,connectivity)
OR
[output_type_1,output_type_2]=watershed_segment, i.e. without any input argument.

Output arguments are optional.

Input arguments:

Click on center of cell. Don't forget to mark the background too. SHIFT-click or double-click to exit any time. You can delete regions by CTRL-clicking on a dot. If you aren't satisfied with the result, you can modify the position of each dot. At this stage you can't delete or add any region. You can do this by answering yes to the "More or fewer cells" question at the end.

Download: watershed_segment.p

The application checks for updates after it is started.

Manually-seeded (marker-controlled) watershed segmentation in 3D

The application performs manully-seeded or marker-controlled watershed segmentation in a 3D image stack. An orthogonal view of the 3D stack is shown, and the user places seeds in an arbitrary slice chosen by the mouse scroll wheel.  The result of the watershed segmentation is shown, and the user can merge regions or swap their label.

The program can be run in GUI-mode or command-prompt-mode. Type 'watershed_segment3d' at the Matlab command prompt and a GUI, shown on the left below, will be displayed. If you would like to prevent the program from checking for upgrades, type watershed_segment3d('noupdate'). Alternatively, you can use the following command prompt syntax:
[segmentedImage,seedPos]=watershed_segment3d(imageIn,seeds,circleRadius,circleColor,aspectRatio,minArea,outputType)

The program requires DipImage that can be downloaded from here.

Download: watershed_segment3d.p

The program checks for updates after it is started in GUI-mode.

Graphical user interface of the program

Membranes (boundaries) overlaid on the gray-scale stack shown during the segmentation.

Result of the segmentation: orthogonal view of the cells and the membranes (red)

Dijkstra-Nagy algorithm for image segmentation

Some images are notoriously complicated regarding segmentation. Dijkstra's algorithm is an approach to find the shortest path between nodes in a graph. I have modified this algorithm to find the path with the highest mean intensity between two pixels in an image. I took the liberty to call it Dijkstra-Nagy algorithm which works nicely to find the cell membrane.

The program is GUI-controlled. The user is asked to provide the input image and to specify other parameters followed by clicking at a couple of different locations along the membrane of cells to be identified. The program exports the membrane mask and/or the cell mask.

The program requires DipImage. The exported membrane and cell masks are DipImage-format images.

DownloadDijkstraNagy.p

The program automatically upgrades itself.

Find clusters in an image: clusterfind

Clusterfind is an application, requiring DipImage, which can be used to identify protein clusters in microscopic images. Clusters are identified by k-means clustering or edge detection (Sobel, Prewitt, Roberts, LoG, Canny). The segmented image can be fine-tuned: non-closed contours ("lines") can be removed, empty closed contours can be flood filled or manually-seeded watershed segmentation can be carried out to improve the result. You can even change the value of single pixels manually ("make-up"). The whole analysis procedure can be carried out on two images of the same size, and cluster statistics (including overlap %) are calculated.

Syntax: clusterfind

Help is available from the program.

Download: clusterfind.zip containing M-files and FIG-files

Analyze patch intensity distribution: analQDTI

The program analyzes the distribution of diffraction-limited fluorescent spots in a microscope image. The name derives from quantum dot triexciton imaging, an approach which significantly improves the resolution limit of confocal microscopes:

But the program can not only be applied to QDTI experiments...
Based on the distribution of fluorescent spots (i.e. their relative distances from each other) each spot is assigned to a large-scale cluster. Two spots are classified to belong to the same large-scale cluster if their distance is smaller than a user-defined distance. The centers of fluorescent spots are first identified by the program by searching for local minima. Then the user can modify these centers by manually deleting them or adding new ones. This step is followed by fitting of 2D Gaussians on every fluorescent spot. Initial values for the background and variance of the Gaussian are either estimated from the image by the program or given by the user. Fitting is performed either by a least-squares algorithm or maximum likelihood estimation. If peaks are closer to each other than a user-specified distance, the peaks are fitted simultaneously. The total fluorescence intensity in each spot is calculated from the fitted parameters (variance and height of the Gaussian) which can be used to estimate if the peak contains a monomer, dimer, trimer, etc. The program package can analyze homoclustering and heteroclustering as well. In the latter case two input images are required (fluorophore A and fluorophore B) and each identified peak is fitted in both images. In order to fit the observed total intensity distributions two monomer histograms are required corresponding to the (1:0) and (0:1) monomers, i.e. monomer of fluorophore A and monomer of fluorophore B) recoded in both fluorescence channels.

Syntax:

Help: available from within the program

Registration is required to run the main application (analQDTI). When running it for the first time, it will generate a code, which has to be emailed to me (peter.v.nagy@gmail.com) and I will send you a countercode.

Download the ZIP-file containing all the P-files of the application.

The application checks for updates after it is started.

Analyze RICS experiments: rics_tools

The program analyzes a RICS (raster image correlation spectroscopy) experiment which was described in Biophysical Journal in 2005 by the group of Enrico Gratton (Measuring fast dynamics in solutions and cells with a laser scanning microscope. Biophys J 89:1317-1327).The whole sequence of analysis can be performed by the program from reading the images to fitting the autocorrelation function.

Syntax: rics_tools

Help: available from within the program

Registrationis required to run the main application (rics_tools). When running it for the first time, it will generate a code, which has to be emailed to me (peter.v.nagy@gmail.com) and I will send you a countercode.

Download: ZIP file containing all the P-files of the application.

Orthogonal view of confocal stacks: confortho

The program generates an orthogonal view of a 3D confocal microscopic image stack. This functionality is similar to the one available in Zeiss LSM Image Browser, Leica LAS AF or Olympus FluoView. You might need confortho when you have to do image processing in MATLAB, and then you would like to view the processed images in the same way as you are used to. The program accepts images in MATLAB or DipImage (www.diplib.org) format.

Syntax: confortho

A brief help is available in the program.

Download: ZIP-file containing the program (P-file, FIG-file and help)

The program is also available in MATLAB Central.