_Our standard rig plan‎ > ‎Modules‎ > ‎Two-Photon‎ > ‎

Line scan analysis


1) Open Matlab, make sure the vhtools are installed and are initialized correctly

2) Type twophotonbulkload.  A figure window will pop up.

3) Select your experiment data using the [choose] button or enter the path manually and click [Update].

(this is a slightly old version picture, lacks the new [choose] button.)

4) Under Stacks, either 4a) hit the [new] button and type 'Site1' or give your site some other name; or, 4b) if you've already made a site previously and you are continuing your work, click on the stackname and click [Edit]

5) A blank 2-photon analysis window should pop up.

(this is a slightly old version picture; preview image is bigger now and off to the left) 

6) To add slices hit [Add new slice] button; choose a directory and hit okay.


Slices will be added to the session in order of the file name t00001t00002

If the reference number is the same for several directories, then the rest of the files will be indented and refer back to the first recording with that reference number (be aligned and compared to it).

To change the reference number, remove the slice, go to the reference.txt file in that directory, change the reference number, and add the slice again.


7) [Optional] Correct drift by clicking [Correct drift].

Drift for the first slice is compared to itself. 

Drift for all indented files are compared first to themselves and then to the reference file.

Important: Highlighting each slice will only show you that slice in the window.  To make any change to a slice, like correct drift or analyze you must type the slice name into the “Dir” box.


8) Draw circles in the first recorded directory

Type an appropriate diameter (ex ~12 for a 40x objective, ~8 for a 16) circle that will most closely match the size of cell bodies into the “Dia” box.

Hit the “[draw circles until...]” button.  Draw circles until means that you will only be able to draw circles until you hit the enter button on your keyboard.  After hitting this button you must draw at least one circle before you are allowed to hit enter and use another tool. 

Center the cross hairs and click.


9) More about drawing cells

Circles drawn while viewing more-recently-recorded slices will appear in newer slices but not older slices.  To indicate that a cell is not found in a newer slice (if it died or recording window moved in Z), highlight the slice number in the slice window so that that slice is displayed and then highlight the circle number in the Cell id# window.  The circle will turn from blue to yellow then uncheck the [Present] check box.  The cell will be marked as not present in the displayed slice and all subsequent slices but not previous (higher) slices.  To remove the cell completely hit the [delete cell] button.  The cell will completely disappear in all slices.

To move a circle follow these steps but press the [move cell] button.  Move cross hairs to where you want the cell moved and click.  Hierarchy rules are the same.  You can also add cells to lower slices and have them not appear in higher slices by highlighting the desired slice in the slice window and drawing cells there.

If you move a circle in a lower slice and then move it in a higher slice the circle will not move again in the lower slice it will stay where you originally put it.

10) It is a good idea to occasionally hit save and save your work.  

11) Analysis

If you are not using our visual stimulation system, then you can simply enter the slice directory you want to analyze in the Dir field in the analysis section, and press the [Raw] button under the analysis section, and F values for the cells that were recorded will pop up.  They will also be written to a file in the same directory as the slice data; for example, if your directory was t00001 (if you are using a Prairie 2-photon, the 2-photon data is probably in t00001-001), then the analysis file would be written to t00001/Site1_t00001_raw.mat.  You can go and load this file from the command line.  If you type g = load ('Site1_t00001_raw'), and if you drew 13 cells, for example, you might see:

g =

        listofcells: {1x13 cell}

    listofcellnames: {1x13 cell}

               data: {1x13 cell}

                  t: {1x13 cell}

Plotting plot(g.t{1},g.data{1},'b') will plot the raw F values for cell 1, which has the name and id g.listofcellnames{1} (which has the value 'cell 1 ref t00001' in this case).  

 12) Optionally, exporting the data for a given cell to a text file.

To export the data for a given cell to a text file, you could use 

mynewvar = [g.t{1}(:)' g.data{1}(:)'];