> For the complete documentation index, see [llms.txt](https://gut-analysis-toolbox.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gut-analysis-toolbox.gitbook.io/docs/8.-calcium-imaging-analysis/extracting-calcium-traces.md).

# Extracting calcium traces

Workflow to extract calcium responses from the aligned data

The analysis workflow will extract the "Mean Intensity" of each cell or object you define within the image. The script exports the normalized data by default. If you want the raw data, make sure to untick "Use F\_F0".

* Go to GAT -> Calcium imaging -> Calcium imaging analysis

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FRCBjtO8XG2DRaYLdCcWL%2F0.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Click on "Browse".

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FRWYdJYD4H6lsrDvKOsSg%2F1.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Navigate to the folder containing the file and select the image.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F5Ip7IiTMZQmx8xGWmLMe%2F2.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* You have the option of saving the data as normalized to baseline. If you leave F\_F0 ticked, it will extract the normalized traces. If you want the raw data, untick the box. Once you're done, click Ok.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FRg8QYuH0n5rO42gjutFf%2F3.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* The image will open and you will be presented with a prompt. You can use this opportunity to check your image for blank frames. "max\_stack" here means the frames which you can use as a reference for manually defining cells/ROIs.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FjeLylc4MqchH1Wbc5X5a%2F4.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* Scroll through the image by dragging the slider. In this example, the enteric glial cells show a calcium response at frame 40. As we can see the cells clearly, we'll use a range of frames that capture this response as the "max\_stack" or reference frame for ROIs.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FpE1towgsOoyX78PNnMRA%2F5.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* Click "OK "

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2Fv72KokOORgCT4Fhbjasw%2F6.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

8\* In this example, we define the reference frame window from 20 to 76 frames.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FjIc1n8hvMr4IB2Bbuoom%2F7.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Once we click Ok, we get a 2D maximum intensity projection of the range we specified.

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FSVmonNeljYgwRiXNW8e2%2F8.jpeg?alt=media)

* As we selected F\_F0, we need to define the frames that are the baseline. Usually, we use the frames before the stimuli (ex: adding a drug). In this case, the drug was added around frame 37.  Click Ok.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FSHrrHsVl2ab3h7DllRi0%2F9.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* We enter a range of 1 to 25 as baseline. There was some artefact before drug addition, so we avoid that by choosing a lower end frame.

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FirHbvbwfXCnaDs9rgtLI%2F10.jpeg?alt=media)

* Once you click Ok, you will be presented with an image that looks very different than you're original dataset. This is the image normalized to baseline. Essentially, only cells that respond above baseline will show as bright regions.

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FozXoap8sqoPkNww82Z74%2F11.jpeg?alt=media)

* If we scroll through the dataset, the first few frames have nothing and responding cells show up as bright objects from frame 40 onwards.&#x20;

The F/F0 image stack is quite good at delineating responding cells and also seeing finer details such as calcium response travelling through the processes and soma.

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FyNBB61Pz2SVromgi37FM%2F12.jpeg?alt=media)

* At this stage, you will be presented with a prompt. If you have multiple celltypes such as neuron and glia, you can enter 2. As we are only analyzing glia, we enter 1.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FR5oERT0thlgc8yLamlzq%2F13.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Click "OK "

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FB8xEaoxWQyfSUjeNo2O4%2F14.jpeg?alt=media)

* If you already have your cells segmented by other software, you can import them as ImageJ ROIs. If not, click "No, I'll draw manually".

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FNVbidAg44iu3PllpmSP3%2F15.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Enter name of the celltype.

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FfltZMZhhYXyADONxdcCd%2F16.jpeg?alt=media)

* The macro is paused so you can draw ROIs. Use the reference image, i.e., image with "MAX" at the start of the name to draw cells. You can use any image you'd like. Sometimes the F\_F0 image works well.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FWaDxsOYqG5Mi7jiXr4GZ%2F17.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* The oval tool is selected by default. If you want the freehand tool, you can select that as well.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FrZEXXGTdO2fwxrdaKLQZ%2F18.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* We use the freehand tool to draw around the cell by holding left click, dragging the cursor around the cell and releasing the left click once you're done. `Press "T"` on your keyboard to add the ROI to the ROI Manager

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F27nWJyFgcdmE7FMKuiN2%2F19.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* We can also use the Oval tool by selecting it within the drawing tools on the Fiji toolbar.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2Fq1A1Iw1cxDd2VgkPYKp6%2F20.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Left click on the outside of the cell and drag the cursor to the other end so as to define the outline.
* We can also use the Oval tool by changing to that.&#x20;

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FKS4Aen3dfY2BoOJYPdo4%2F0.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Left click on the outside of the cell and drag the cursor to the other end so as to define the outline.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FYNrsceOlcNdatlOAGedm%2F1.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Repeat this for all the glial cells of interest.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F4MdI3uY9852Ic4cNfq5x%2F2.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Click "Show All" on the ROI Manager to show your progress while you're drawing ROIs.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FV5o3sdk5Ab1wbCK5cQSv%2F3.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Once you are done, click Ok on the prompt. This will extract the values and save the Results. You've finished your data extraction!

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FARVkRXt8v2mxzR0FPzj6%2F4.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* If you go to the folder where you're data is stored, you will see a "Results folder.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FlMPe3a0vY8sVtRs1Sjcz%2F5.jpeg?alt=media" alt="" width="287"><figcaption></figcaption></figure>

* Within the Results folder is another folder with same name as the image we analyzed.

![](https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FKw2BAEMQgA9f1GqaM7qA%2F6.jpeg?alt=media)

* All the analyzed data is stored within this folder, which includes the F\_F0 image, Max intensity projection, extracted data as csv and ROI Manager file.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FqeftOZxRo8GioaUPoUhZ%2F7.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* You can open the F\_F0 stack in Fiji if you'd like to use it for displaying calcium responses in figures or presentations.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F49QlcKiW4kPiwPJ5lddi%2F8.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* The traces are saved in a 'csv' file which can be opened in Microsoft Excel or similar software.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F1xdSEYzEKs287pI0uVEY%2F9.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

* Below is an example of the traces plotted in Excel. Note that the `"Normalized Mean Intensity"` Values are being extracted. The column names are the ROI names we defined earlier with a number next to it.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FbRujFDGUSzkBDTVV8NXi%2F10.jpeg?alt=media" alt=""><figcaption></figcaption></figure>

&#x20;&#x20;
