pdf version
last update 2/8/09
pv (‘picture view’) is a Matlab program for viewing images. It was written for analyzing time lapse movies and z-stack movies. Images can be aligned, smoothed, cropped, masked, denoised, and background subtracted. Regions of interest (ROIs) can be selected in several ways, and a variety of measurements can be performed on ROIs. Advanced techniques include erosion/dilation, watershed, and custom routines. A special routine allows for graphical display of data, and includes smoothing, chopping, and curve fitting.

The program requires 3 files. They should be loaded in a directory named ‘work’, which should be created in the Matlab directory. The main code is in pv.m. The instructions for creating the graphical interfaces are contained in pv.fig and pvplot.fig.When the Matlab program is run, a command window opens. To run pv, simply type ‘pv’ in the command window, and press ENTER.

The first task is to make a list of images to be loaded. The command window will display the current directory, and the number of images in the list (if any). Below this is a MENU. Type an appropriate letter and press ENTER to make or modify the list. When the list is complete, just press ENTER and the images will be displayed.

To make a list, use the menu. If you in the appropriate directory, type the appropriate name of the file(s). Use wild cards liberally. For example, if the directory contains a time lapse movie of 100 individual images, named img001.tif to img100.tif, you could type ‘img*.tif’ to put them all in the list. The asterisk (*) is a wild card, and means ‘any letters or numbers’.

If you want to change directory, type ‘cd’, and press ENTER. A window opens, and you can navigate to the window that contains your images. When you get to that window, double click on any file (you are only selecting the directory, not the files). Then make the image list. A list can be modified in several ways.

x, ENTER: the list will be erased.

e, ENTER: the list will be displayed in a separate window. You can edit it as you like. Be sure to save it when finished. Then close the window, and press ENTER in the command window.

sk, ENTER: some images in the list will be skipped. Three numbers are entered. The first (n1) will remove the first n1 images from the list. The second (n2) will take the next n2 images, and then skip the thid (n3) images. Then n2 will be kept, and n3 skipped through the entire list.

c, ENTER: type any text, and any file in the list that contains that text will be removed.

cc, ENTER: type any text, and only files that contain the text will be kept. Other options:

d (or ls), ENTER: displays names of all files in the current directory.

s, ENTER: displays the current image list

i, ENTER: provides information about images in the list. Another window asks which image number should have information displayed (enter 0 to see information for all images).

b, ENTER: base names (ignore this)

z, ENTER: makes an RGB movie from 3 separate grayscale images (ignore this). Press ENTER when the list is complete. A window like this will open:

The program is now run from the buttons and sliders displayed.

The red numbers in the image above refer to the descriptions below.

How to control the display: 1. Image number and name. This button displays information about the displayed image: its number in the list and its name. Its size (in pixels) is displayed to the right of the button. LEFT CLICK on the button to display the previous image; RIGHT CLICK to display the next image in the list.

2. Play/Swing toggle: Click this button to play the movie. Click again and the movie will ‘swing’ (back and forth). To stop the movie, click the slider described below.

3. Image number slider: This slider shows the image number in the list that is displayed. After Play/Swing is clicked, the slider will move each time a new image is displayed. Click this slider to stop a movie from playing. Move the slider to a new position and the new image will display.

4. Pause 1. This button toggles on and off a 1 second pause at the first image when the movie plays. The button to its right (pause end) toggles a 1 second pause at the last image.

5. FigSize. This slider determines the size of the displayed image. The value (relative to the actual size of the image, in pixels) is displayed on the button. NOTE: To make the image display at its actual size (FigSize 1), pull the slider all the way to the left.

6. pause 0. This slider sets the display time (in seconds) of each image while the movie plays. A pause of zero means the movie plays as fast as possible. A pause of 0.1 puts a 0.1 second delay before the next image is displayed. Click the button to set the pause of each image in the list independently.

7. frame step 1. While the previous slider slows the movie display, this slider makes it go faster. The movie simply skips frames, depending on the setting of this slider. For example, a setting of 3 means that every third frame is displayed.

8. first 1. This slider and the next (to the right) determine which images are displayed in the movie. For example, if ‘first’ is set to 10 and ‘last’ is set to 15, then only frames 10 to 15 will be displayed. These settings also determine actions for other buttons. For example, if the ‘save’ button is pressed, only images between ‘first’ and ‘last’ are saved. Same for ‘clone’ – the new window will display only images between ‘first’ and ‘last’.

9. color (gray.lut). This popup allows you to change the ‘look up table’ (lut) that pseudocolors the images. First you decide whether to select from a prexisting list or make a custom lut.

To make a custom lut, a new window, like the one at the left, opens. There are four tools for adjusting the lut.

A shows 3 radiobuttons. Select the one(s) that you want to adjust, and then left click, hold, and drag in the graph. Those values will change as you drag.

B is a slider that determines the amount of smoothing as you drag (it uses the Matlab function interp1). The number above (10 here) shows the number of points to the left and right over which smoothing (interpolation) occurs (thus, in this example, 21 points will be smoothed).

C allows you to load a lut from the menu and store the custom one.

D allows you to view the lut and edit individual values. The data table contains 3 columns (red, blue, green). Values must be between 0 (color off) and 1 (full on).

10. Collapse. This will ‘collapse’ all of the images in the list into one. It is useful for several purposes. For example, if you have a time lapse series, and you want to get an idea of the amount of drift (non-alignment), collapse them into one image, and you will see how the image shows the ‘blur’ of movement. When you click this button, a new window opens, asking for 3 numbers:

* Brightest or average? As the stack is collapsed, you can choose to keep the brightest pixel at each location, or average all pixels at each location.

* How to manage the collapse process. If you enter 0, the collapsed image will be displayed, but the original image stack will not be changed. Thus, when you change the display (for example, by clicking the image slider (#3 above)), the collapsed image disappears. If you enter a positive number n, then the nth image will be replaced with the collapsed image. If you enter a negative number, something different happens. This is used when you have multiple z-stacks, and you want to collapse them into one. In this case, enter the negative of the number of images per stack. The result will collapse all first images into one, all second images into one, and so forth. A new window will open with the collapsed stack.

* The third number applies only to multiple z-stacks. If you choose, this will rearrange the stacks, and open a new window with the images in the new order. For example, if you have 5 stacks of 10 images each, in the new window the first 5 images will be the first image from each of the 5 stacks, and the last 5 images will be the last image in each stack.

11. crop. Rubber band a rectangle, left click, and the selected area will be cut out, and a new window opened with the cropped region.

12. mask. This routine is for masking out unwanted regions of an image. After the mask is made, a new window opens with the mask applied (the original window is not changed). First, a dialog box with 2 lines opens. The top line asks how you want to make the mask: pick, draw, or auto threshold. These are described below. Ignore the lower line (it is used in ROI, #18 below). If more than one window is open, a new dialog box opens, asking which window you want to use for applying the mask. The window number is shown at the top of each window.

* Pick. Do not choose this option (it is used for ROI, #18 below)

* Draw. To draw an area, left click, hold the button down, and draw. When the button is released, the area will be closed automatically. A dialog box then asks if you want to keep or discard the area. Then another dialog box asks if you want to draw another area. If yes, then repeat the process. If no, then a dialog box with 3 lines opens. The top line asks whether the region inside or outside the area(s) should be filled. The middle line should be set to 1 (open new window). The bottom line asks for the value to use for masking (0=black). NOTE: If you have previously drawn a mask, these areas will be shown, and you can use them again, or not. You can also move and delete individual areas. Left click on one area and drag it to a new position. Right click on an area to delete it. Finally, when you click on the all button or then none button, then you must draw a new area (left click, hold, and drag), even if you do not want another area. When finished drawing this ‘dummy’ area, just say ‘no’ when asked if you want to keep it.

* Auto. Two green sliders appear. The left hand slider sets the minimum size of areas selected. The right hand slider sets the threshold. In the image, regions that satisfy both slider conditions are outlined in red. When finished selecting the mask, click ‘OK’. a dialog box with 3 lines opens. The top line asks whether the region inside or outside the area(s) should be filled. The middle line should be set to 1 (open new window). The bottom line asks for the value to use for masking (0=black). NOTE: If you have previously created a mask, these areas will be shown, and you can use it again, or not.

A new window will open with the images masked.

Example: Masking a time lapse series of images. Suppose your images are in window #. Begin by smoothing the images (#17 below). This will create a new window (#2) with a slightly blurred image. Then, in window #2, click ‘mask’, choose automatic (a), and have the mask applied to window #1. Set the min and thresh sliders, click OK, and a new window will open with the original data (window #1) masked according to the mask in window #2.

13. Zoom. This activates the zoom function in Matlab (and the zoom button turns red). Left click in the image to zoom in, right click to zoom out. Click the zoom button again to turn off zooming.

14. Label. Images can be labeled. Click this button, then left click in the image and a dialog box opens. Type the label in the top line; other lines determine color, font, alignment, etc. To edit a label, double click on it. To move a label, click ‘Tools’ on the toolbar at the top of the Matlab window, then ‘Edit Plot’. Now when you click on the label it can be moved. Turn off ‘Edit Plot’ when finished. Turn of the Label button when finished. NOTE: Labels do not become part of the image (they ‘float’ in layers above the image). Thus, if you save your images (#21 below), labels will not be saved unless you ‘drop’ them into the image (replace image pixel values with label pixel values). To drop labels, click the Misc popup (right side of window) and select ‘Drop Labels’.

15. Erase. Click this button to erase labels, lines, and other text.

16. 1 pixel. This routine is useful for examining a time lapse series ‘on the fly’, as it shows, when you click on a pixel, the values at that position through the entire stack. A dialog box asks for the ‘radius’ of the square scan area (this number of pixels will be added to each side of the central pixel; thus, a the radius is 0, the area will be restricted to 1 pixel only; a radius of 2 will sample (average) the values in a 5x5 square, centered on the selected pixel). The dialog box also asks if you want to see plots for the 8 surrounding areas. If so, then when you click, 9 graphs will be displayed. Type 0 and no neighbors will be shown. A non-zero number n will cause 9 graphs, and frames n through the end will be fit with a linear fit.

17. Smooth. This will lowpass filter the images. The dialog box asks for 3 values. The first value asks whether to do a 3d smoothing of all frames (slow) or 2d smoothing of each frame (faster). The second value is the ‘radius’ of the square used for the moving bin average. See #16 above for the definition of ‘radius’. The 3rd line asks for the standard deviation (in pixels) of the gaussian smoothing function. Entering zero will cause all pixels in the smoothing square to be weighted equally.

18. ROI. This routine is for measuring regions of interest; results are plotted as a graph, and can be exported to other programs. The first dialog box asks for the method to be used to select ROIs (pick, draw, or auto threshold by brightness) (and whether the values returned should be the average of all pixels or the brightest pixel in each region). If you select draw or auto threshold as the method to select ROIs, follow the instructions given for masking (#12 above). If you select pick, then you will select square ROIs, as follows: a new dialog box asks for the ‘radius’ of the area (see #16 above for the definition of ‘radius’), and for some other values that are not used often (for example, you can measure values in concentric square disks). Pick areas by left clicking; right click to finish. A graph window will open and the results will be plotted. The instructions for navigating through the graph window are given at the end. 19. Align. Time lapse images often show ‘drift’, and must be aligned before they can be analyzed properly. The align button provides three different methods to align images:

* Auto align: Select a region by drawing out a rectangle. This region of each image will be moved one pixel at a time up to n pixels (you select n) left, right, up, and down over the ‘base’ image, keeping track of the least squares difference at each position. The position with the smallest least square difference will be the new position of the image. The larger the rectangle, and the larger the value of n, the slower the alignment process. A dialog box opens asking for 6 inputs: Line 1. Weighting factor for no movement. This has a value between 0 and 1. Larger values bias the alignment against moving a frame. Line 2. Maximum movement (n). The test image rectangle will be moved one pixel at a time in all four directions up to n, looking for the smallest least square difference. Line 3. Base image. Select the image to be used as the ‘base’ (the image against which others will be aligned. Type 0 to align with the previous image in the stack. Lines 4 and 5. Regions can be smoothed before least square values are determined (using a moving bin average of ‘radius’ and standard deviation given by these values). Type 0 in line 4 for no smoothing. Line 6. Mutual info alignment. If you select this mode, the alignment is done using the technique of ‘mutual information’, rather than least squares. This is an experimental technique whose results have not been as useful as least squares.

* Manual align by selecting image feature. In this routine, you select (left click) on the same image feature as each image in the list is displayed. The pixel you select will be aligned to the same position in each image.

* Manual align by sliding images. In this routine, the ‘base’ image is displayed in the red frame buffer, and the ‘test’ image is displayed in the green frame buffer. The test image is moved with the arrow keys, and when the alignment is satisfactory, a new test image is chosen. The values of the current test image/total number of images, and the current least square difference are displayed on the image. Instructions are displayed. The relevant keys are as follows: move the test image with the arrow keys or press ‘0’ to go to the initial position or ‘r’ to repeat the movement of the previous image. To go to the next test image: press ENTER to save the current position or ESC to discard the current position (no movement); press ‘backspace’ to discard the current position and back up one frame; press ‘z’ to use the current test image as the new base image; press ‘x’ to exit.

20. Color Bar. Click to place a color bar on the image. You can choose from 8 different positions. Click this button again to erase the color bar.

21. save. This will save images to disk. The images that will be saved are determined by the ‘first’ and ‘last’ display sliders (see slider #8). A dialog box asks for the base name (the format (e.g., jpg, avi) does not matter at this point). The next dialog box asks for the format. Choose tif, jpg, or avi. Tif and jpg will save each image individually; avi will make a single file movie of all images. If you choose avi, another dialog box will open, asking for 7 values, as follows: Line 1: Frame rate. Lines 2 and 3: Pause at start and end? If yes, a one second pause will be appended to the first and/or last image. Lines 4-6: If you would like a one second pause at other locations in the movie, type the frame number(s) here. Line 7: Compression (type one of the names shown).

22. Keyboard. This is a Matlab command that pauses the program for debugging. While paused, the program offers access to all variables. To resume, type the word ‘return’ in the command window, and press ENTER.

23. Close. This will close the window.

24. Image contrast and format (green sliders and buttons). The top panel displays the image type (’16 bits’ in the image above). The button below toggles between manual and AUTO mode (in AUTO mode, each image is displayed with the full range of brightness; thus, dim images will appear as bright as bright images). In manual mode, this button shows the low and high values of the lookup table. The top slider determines the low value cutoff , and the bottom slider the high value cutoff of the lookup table. Pixels with values lower than the low value cutoff will appear ‘black’, and pixels with values higher than the high value cutoff will appear maximally bright. NOTE: These sliders do not change the actual pixel values of the image; they merely change the lookup table that determines how the pixel values are displayed. The bottom green buttons (‘clip’ and ‘cnvt’) will, however, change pixel values. The ‘clip’ button will do 2 things. First, it will reduce any pixel value greater that the high cutoff to the high cutoff. Second, it will subtract the low value cutoff from each pixel (making the minimum pixel value zero). The ‘cnvt’ button will convert 8 bit images to 16 bits, and vice versa, and will convert RGB images to 8 bit (grayscale) images. For both ‘clip’ and ‘cnvt’, the new images will appear in a new window; the original window will not be changed.

NOTE: For RGB images, there are 3 sliders instead of 2, one each for red, green, and blue color planes.

The MISC popup group. When you click on the ‘misc’ popup button, a menu of options appears, as shown below: 1. Clock: A circular or rectangular clock can be placed on the images.

2. Clone: The images in the current window, are copied to a new window. NOTE: Only the images determined by the ‘first’ and ‘last’ sliders (#8 above) are cloned.

3. Resize/Pad: The size of the image (not just how it is displayed) can be changed. Type the factor by which the size is multiplied. The images can also be padded: pixels will be added to the right side and/or bottom. A new window opens with the new images.

4. Montage. This will ‘tile’ images from different windows. You first select the window numbers (shown at the top of the window – the last number on the right) and then set the maximum width of the montage. For example suppose that you have multiple windows open, and you want to make a montage of numbers 2 , 5, and 6, each 300 pixels in width. Then you would enter 2 5 6 to select these 3 windows. If you want the images to be side-by-side, be sure that the montage width that you enter is more than 900. If you want the images in a vertical column, be sure that the montage width is less than 600.

5. Subtract frame. This routine will average one or more consecutive images, and subtract the result from each frame, or vice versa (subtract each frame from the average). In the dialog box, you enter the first and last frames to be averaged, and direct how the subtraction should be performed (a-b or b-a).

6. Drop labels. This will drop any labels into one or more images, as determined in the dialog box.

7. Concatenate. Just as montage will ‘tile’ images from different windows, this will connect them serially into one long stack. A new window will open.

8. Flip. This will reverse images top-bottom and/or left right.

9. 2 Frame Diff. This routine takes 2 images (determined by the ‘first’ and ‘last’ sliders (#8 above)), and makes a scatter plot of the pixel values of each image, plotting the values of the first image on the X axis, and the values of the second image on the Y axis.

10. Digitize. If your image is a picture of a graph, you can determine the values of points using this digitizer. You first select the position of the origin, then some x value, then some y value. Then, when you left click, the x and y values of that point are printed. Right click to quit. The resulting values can be copied to the clipboard for export to another program.

11 -13. Cut-fill/Cut-move/Copy. With these routines you select a rectangular region and fill it with some color (cut-fill), or move it to a new location (cut-move), or copy it to a new location (copy).

14. 3D. Not working right now...

15. Rev order will reverse the order of the images in the stack.

16. Rev color will reverse the color lookup table (black becomes white, etc.)

17. Interp frames will insert n frames between each existing frame. You enter n. The new frames will linearly interpolate pixel values between existing frames.

18. Cull selected frames allows you to remove frames from the current image stack. I works like the Skip function in making a list of images for the original stack (see 'sk' on page 1).

19. Edge detector applies Matlab edge detector routines to the image stack.

20. Bwmorph applies this Matlab function. You choose between 16 options.

21. Fake spH movie is a special routine for simulating single quanta release.

The IMAGE PROCESS popup group (the lower popup button): When you click on the ‘img process’ popup button, a menu of options appears, as shown below: 1. Subtract Background. Draw a background region (left click, hold, and draw; the area will be closed automatically). The average pixel value inside this region, measured for each image, will be subtracted from that imate. A new window will open.

2. Add Multiply data. You can change all pixel values by adding a value and/or multiplying by a value. A new window will open.

3. FFT makes a 2D FFT of each image. Two windows are opened. One shows the FFT (low frequencies at center) and a graph shows the line profile from the center to the lower right corner.

4. Erode-Dilate is useful for segmenting images according to size of objects. For example, if you have a clump of cells with slender processes growing out, the clump and processes can be separated. Each operation (erosion, followed by dilation) moves a 2D mask (Matlab calls it a structure element) of shape (e.g., square, disk, diamond) and size (e.g., 5 pixels) that you choose over the displayed image. Erosion places the minimum value under the mask in the center position. Thus, if the width of the slender processes is 5 pixels, then it will be erased if the mask is 3 or more pixels in width. Since the clumps of cells are larger, they will be eroded, but will not disappear entirely. The resulting image is then dilated using the same mask. Since the processes are gone, they do not reappear; the clumps, however, are dilated back to something close to their original size. The new window contains 3 images: the clumps, the processes, and the processes individually colored. To see the individual processes in the third image, apply a random color lookup table (#9 above), such as ‘colorcube’. You then can determine whether the segmentation was successful. To analyze the regions, see below (Regionprops).

5. Regionprops is a Matlab routine that returns information about distinct regions in an image. What are distinct regions? They are regions in which every pixel is greater than zero. Thus, to perform regionprops, all pixels between regions of interest must be set to zero. A variety of properties (area, eccentricity, orientation, length, etc.) can be calculated for each area (as you select). Results are displayed as a table of numbers: each row represents one distinct region, and each colum is a property (area, length,etc.). The table can be copied to the clipboard for export to another program. For example, in the erode/dilate process above, the third image marks each process with a single pixel value (all 1’s for the first process, all 2’s for the second, and so on), with each surrounded by pixels of value zero. Displaying this image, and clicking on Regionprops will cause each separate process to be analyzed.

6. Contour – not working now.

7. Outliers – not working now

8. Gaussian Fit will perform a 2D Gaussian fit to selected regions. The routine will either follow one region through the stack, or do multiple regions in the displayed image. Regions are selected by rubber banding rectangles.

9. WATERSHED. This function will find regions in the displayed image that are determined by Matlab's watershed function (2D). Think of a topographic map. Watershed finds the outline of each river - its watershed. However, for measuring bright spots in fluorescence images (equivalent to moutain peaks on a map), we need the inverse of watershed. That is, the dividing lines will encircle mountain peaks, running in rivers and over passes.

To see how it works, run pv and open the file wat_demo.mat. It is a stack of 36 images of cultured hippocampal neurons with synaptic boutons labeled with FM1-43. The first image in the stack is shown at the left. The cells were stimulated with high potassium concentration during the movie, and the synaptic brightness decreases. We want to measure the brightness of each bouton in each image.

Open the Img Process popup menu and choose WATERSHED. The function will find and display the borders between all bright areas, as shown below. An enlargement of the upper left corner is shown on the right. Your job is now to use the select/deselect tools to choose only the regions you want to use for measuring. Initially, all regions are selected (green). Deselected regions are red.

The display looks like this:


Choose the regions you want by clicking on specific regions in the image or by using the buttons and sliders. There are four ways to make selections:

* Click on a region. Left click selects, right click deselects that region only.

* Thresh(bri)=135 is a slider. Any region with at least one pixel with the value of the slider (135) or greater will be selected.

* Slct ALL or Slct none will select all regions or none of them. * Area sliders (Min 55 and Max 381) will select regions that contain at least Min and no more than Max pixels. The display near the lower right shows the number of regions selected and the total number of regions. The Brightness slider can be used to enhance the display. The image to the left shows an enlargement of the upper left hand corner after the selecton process. About 200 regions in total were selected. When you have finished selecting regions, click the

Calculate button. For each selected region in every image in the stack, calculations will be performed. The resulting data table will contain 5 columns: Image number, Region number, Region area (# pixels), Region average brightness, Region maximum brightness.

There is one final variable to set after the Calculate button is clicked. You will be asked to enter a "threshold (fraction of brightest pixel)". Enter a number from 0 to 1. For example, if you enter 0.7, then for each selected region (in every image in the stack), the brightest pixel will be found, and pixels in the region that are less than 70% as bright as the brightest pixel will be excluded. For example, if you enter 0, then every pixel in every selected region will be included in the calculations. When you click OK, the calculations begin. When they are complete, two new windows will open.

This window shows the original stack with outlines of the pixels that were ultimately selected. In the example above, it shows pixels within selected regions that are at least 70% as bright as the brightest pixel in the region. Play the movie and you will see how the outlines change from one image to the next.

This window shows the data. Which is contained in 7308 rows (=203 regions * 36 images in the stack) and 5 columns. The opening display shows 5 plots, one for each column. It isn't very useful in this form. You can click Disp Data to display the data in a table and then copy it to another application.

To make this plot, click Erase plot, click Add plot, under Y column enter 4, click OK, click Chop and enter 36, click OK (choose Skip when asked). All 203 plots can be averaged by clicking Avg on/off.

9. Imregionalmax. This function finds the brightest pixel in each ‘spot’. A spot is a region is a ‘regional maximum’, which Matlab defines as “connected components of pixels with the same intensity value, t, whose external boundary pixels all have a value less than t”. In other words, as you move out from the brightest pixels, the values decrease. This function marks the position of the brightest pixel in each ‘spot’ in an image. It also calculates nearest neighbors, that is, the distance to the nearest adjacent spot maximum, and plots the histogram of that distribution. To use this function, be sure to mask heavily and/or smooth the image, or there may be a great many ‘spots’.

10. Denoise. This is a useful routine for removing noise from images. It uses a procedure called singular value decomposition (the Matlab function ‘svd’). It opens a new window.

11. Pixel values -> table. This function will write non-zero pixel values to a table, and open a graph window for plotting. The function is not robust, in that each image must have the same number of non-zero pixels.

12. Find bleach. This is a highly individualized function for finding the bleached region in an image. It is used in FRAP studies.

13. Sort pixels. This sorts all non-zero pixels (brightest on top) in the base image (determined by the setting of the ‘first’ slider (#8)). It then makes a table with the values of pixels in the same positions as the base image for every image. In the output table, each row is a pixel position, and each column shows the values for one image. In addition, the mean, standard deviation, and coefficient of variation for each position are appended as the last 3 columns.

14. Hot spot. This routine will show how much pixels brighten by subtracting averaged background frames from test frames, and displaying the difference in a new window. A dialog box asks for 5 values: the first and last images for background (these will be averaged), the first and last images for test frames (after averaging, the average background will be subtracted. NOTE: Negative values will display as zero). The last line asks for the number of iterations. This is usually one. However, if an experiment involved stimuli at fixed intervals, then the image stack may contain more than one iteration. Each iteration generates one image in the output file.

15. RGB -> Intensity. This will break out the individual red, green, and blue layers of each image, creating a new window with 3x as many images as the input window with RGB images. This allows the three components to be examined individually. For example, if the new images are collapsed (see #10), with -3 entered as the stack size, two new windows will be created, one with 3 images (the collapsed red, green, and blue), and one deinterleaved (red1,red2, red3.... green1,green2.....blue1,blue2).

16. Scramble pixel values. This will take all of the non-zero pixel values in the image and randomize their positions among that same population of positions. A new window is opened.

17. Normalize total brightness. This routine will make images equally bright, on average. It is sometimes useful for aligning purposes, when image brightness varies a great deal. The function will find the brightest image (the base image) in the stack, and then for each of the other images calculate the factor by which its pixel values must be multiplied to make the overall average the same as the base image. A dialog box asks for 2 values. The first is the fraction of pixels to examine (starting with the brightest) in determining the brightest image. For example, if you enter 0.3, then only the brightest 30% of pixels in each image are used to determine the base image and the normalization factor for each image. The second input is whether to apply the resulting normalization factor to all pixels in the image, or just the brightest ones (30% in the example).

GRAPH WINDOW
Note: You can open the graph window by itself by typing 'pv pv' in the command window. You can then import data and plot it using the same routines as shown here.
Some routines open the Graph Window, which a graph or histogram plotting routine. For example, after clicking ROI (#18) and selecting regions of interest, the data are plotted in the graph window. This shows the rise in fluorescence when a nerve is stimulated, and the gradual decline after stimulation stops.

The Graph Window can be accessed without loading any images, by typing ‘pv pv’ in the command window. In this case, data must be loaded into the program, as described below. Red numbers refer to buttons, as shown in the image above.

BLUE BUTTONS:

1. Erase all. All data are erased. Nothing remains to plot.

2. Load: Loads a Matlab file. This is a file that ends with ‘.mat’. It was originally stored as a Matlab file. If you save a file (#4 below), it is saved in this format.

3. Load more than one file.

4. Save. The data can be saved in Matlab format. You can save either all data, or the data most recently plotted.

5. Import. Use this function to bring data in from a text file, or from the clipboard. If you paste from the clipboard, a window will be opened. Paste into the window, save the file, close the window, click ‘ok’ in the small window, and you are ready to plot the data.

6. Export. Data can be saved to a text file.

GREEN BUTTONS:

7. Erase data. This erases all plotted data and permits a fresh new plot (#9 below). The original data are not changed.

8. Transpose data. This switches rows and columns in the data set.

9. New Plot: This makes a new plot. The dialog box has 4 lines. The fist determines whether a histogram or a graph is plotted. If a histogram, the Y data (3rd line) are used. The second line is for choosing the column in the data file for the X data. If a zero is entered, the X values are simply the point number plotted. The 3rd line is for choosing the column that contains the Y data. For more than one column, just separate the numbers by a space (e.g., 1 2 5). To plot all of the columns, enter a zero. The 4th line should be ignored (leave it blank). After the data are plotted, the analysis continues with the other buttons.

If a histogram opens, PURPLE BUTTONS appear:

* Bin Width button. Click here to set the bin width manually.

* Bin Width slider. Move the slider to change the bin width.

* Bin Shift slider. This determines the location of the left edge of the first bin (which sets the edges of all bins).

* Gauss. Ignore this button.

* Integrate. This is 4 position toggle. The first (default) position shows the raw histogram. The second shows the normalized histogram. The third and fourth show the integrated histogram (raw and normalized, respectively).

10. Display Data: Displays the data currently plotted. You can copy this to the clipboard and then paste it into another program. NOTE: The first column shows x values; the remaining columns show y values.

Reset Data: Returns to the original data (any smoothing, averaging, chopping, and normalizing operations are erased).

11. New Graph: Click this green button to make a copy of your graph. A new window will open. Your data will still be there, so you can make a graph by clicking New Plot, and choosing the x values, y values, and omit condition, as described above.

12. Subtract Baseline: Click this to subtract background (or baseline). You then choose one of three ways to do the subtraction. You can subtract the smoothed plot (if you have moved the Smooth slider (below) to a higher value), or you can fit by eye an exponential function. If you choose ‘Fit exponential by eye’, three new sliders will open. You can move the sliders to fit the exponential line to the data. Click ‘Done’ and the subtraction will be performed. Finally, you can fit by eye. Just left click multiple times along the baseline that you want to subtract (be sure to move from left to right). Right click when finished, and a smoothed line that passes through your selected points will be subtracted from the data.

YELLOW BUTTONS

NOTE: None of these operations changes the original data. When you make a new plot (click ‘Erase data’ (#7) and ‘New plot’ (#9), the original data are used.

13. Normalize: The first point(s) of each curve are averaged and set to 100 percent and other values are normalized to it.

14. Smooth: This performs a moving bin average on the data.

15. Chop: This will chop the data into separate, smaller pieces. It is useful for plotting a repetitive process, and seeing each iteration superimposed.

16. Average on/off: If more than one curve is plotted, they can be averaged by clicking this button. The standard error can be shown. Clicking the button again returns to the multiple curves.

ORANGE BUTTONS:

17. Zoom: Click this expand zoom in on the plot. The button turns dark red. Rubber-band (left click, hold, and drag) the x-limits for the zoom. The y-values of the rectangle do not matter; only the x values are used to zoom around the y data values. To return to the complete view, or to zoom again, click the Zoom button again.

18. Cut: If you have zoomed the data, clicking this button will permit you to delete the values outside the zoomed region.

19. Symbol: This button toggles 3 ways: symbols+lines, symbols only, lines only.

20. Grid: Toggles a grid on and off.

RED BUTTONS: Curve fitting

21. Fit: Performs a non-linear least squares fit to the selected data. You can choose from several types of fits, as described above. The default is single decaying exponential.

22. X window: You can choose the x-range over which the fit is performed. Left-click on the graph. The cursor will change to a ‘+’. Then rubberband a rectangle. Note that the y-values of the rectangle do not matter; only the x-values are used. Click the X Window button again to return to the full scale.

23. Select the type of fit to perform. Choose from the following: a. Single exponential decaying (this is the default): This fits the data to the function y = y01*exp(-x/tau1) + constant. Data are fit from the maximum value to the last value selected, not from the first selected to the last selected (note the position of the left edge of the black rectangle in the graph above). I did this because I wanted the program to calculate also the fluorescence rise – the change between baseline (before stimulation – the first point selected) and peak fluorescence, as well as the curve fit parameters.

b. Double exponential decaying: This fits the data to the function y = y01*exp(-x/tau1) + y02*exp(-x/tau2) + constant. The procedure is the same as that for the single exponential decay (above).

c. Single exponential rising to a maximum. This fits the data to the function y=y01*(1-exp(k1*x)) + constant. Data are fit from the first value selected to the maximum value. Selected values that follow the maximum are ignored.

NOTE: If more than one plot is on the graph, you need to select with one(s) should be fitted. To select a line, left-click on it. The line will be thicker, and will turn cyan (light blue). To select ALL lines, left click on a line that is already selected. To deselect a line, rightclick on it. To deselect all lines, right click on a line that is not selected. The curve fitting will be done on all selected lines. d. Linear regression. This fits the data to the function y=y01*x + constant. All selected data are used in the fit. In the graph above, the blue line is the linear regression on the data. To see the results, click the Display Fit button (below).

24. Disp Fit: The values above are displayed in the editing window. If more than one curve fit is performed, each column shows the values from one fit. The values displayed are: column 1=y01; column 2=tau1; column 3=constant; column 4=r2; column 5=y02 (for double exponential fit only); column 6=tau2 (for double exponential fit only).

25. Erase Fit: This erases the previous fits.

GRAY BUTTONS:

26. Keyboard. This pauses the program. It is useful for debugging. To resume the program type the word ‘return’ in the Command Window and press ENTER.

27. Quit. Closes the Graph Window.

28. MISC popup has several additional functions.
1. Title
2. Subtract Linear Fit will make a linear fit of the data and subtract it.
3. Y axis scale allows you manually to set the min and max values of the Y axis.
4. Xcorr applies the Matlab xcov function to each column of data.
5. n/a
6. n/a
7. Save will save the data in a matlab file.
8. Get peaks will find peak values of superimposed traces.
9. Movie will make a movie of the graph. Each frame adds an additional data point.
10. MEPPs will find MEPPs in a data trace.
11. Interpolate will add data points using a linear interpolation.
12. Sort rows will sort ascending or descending according to data in one column.
13. Make image will take data from 3 columns (x position, y position, brightness) and make an image from the data.
14. 3d plot will separate each column to create a 3d plot.
15. Symbol size changes the size of the symbols in the plot.