You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Tutorials/Find ROI average in Stack.md
+42-21Lines changed: 42 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -2,91 +2,112 @@ The point of this tutorial is to show how to decode a stack of images and how to
2
2
3
3
## Synopsis
4
4
5
-
This tutorial demonstrates how to use ImageJS to decode a TIFF stack of images and analyze frame-by-frame changes, particularly focusing on regions of interest (ROIs) in pulsar images. The process involves:
6
-
Using the fs library we read and decode the TIFF stack.
7
-
Then,utilizing the `maxImage()` function to get the image with the maximum pixel values across the stack.
8
-
We identify regions of interest from the maximum value image using a threshold mask and obtaining their coordinates.
9
-
Finally we compute the average pixel value for each ROI across all images in the stack, storing the results in a map.
10
-
We can use this data to analyze changes in intensity over time.
5
+
This tutorial demonstrates how to use ImageJS to decode a TIFF stack of images and analyze frame-by-frame changes, particularly focusing on regions of interest (ROIs) in pulsar images.
6
+
7
+
- Using the `fs` library we read and decode the TIFF stack.
8
+
- Then,utilizing the `maxImage()` function, we get the image with the maximum pixel values across the stack. Since we need to use `threshold()`to find ROI, we must check if its `colorModel` is `"GREY"`. If not, image must be grayscaled.
9
+
- We identify regions of interest from the maximum value image using a threshold algorithm and obtain their coordinates.
10
+
- Finally we compute the average pixel value for each ROI across all images in the stack, storing the results in a map.
11
+
We can use this data to analyze changes in intensity over time or compare changes in its position.
//Gets value from one channel since it is grayscaled.
27
-
stackAvgs.push(avgValue[0]);
33
+
stackAvgs.push(avgValue);
28
34
}
29
35
stackGrays.set(roi.id, stackAvgs);
30
36
}
31
37
```
32
38
39
+
Here is a more detailed review of these steps.
40
+
33
41
## Decode the Stack
34
42
35
-
ImageJS has the ability to decode a `tiff` stack of images. Images in stack can represent frame-by-frame successive changes. This way we can take a look dynamically at changes that happen to regions of interest.
43
+
ImageJS has the ability to decode a TIFF stack of images. Images in stack can represent frame-by-frame successive changes. This way we can take a look at dynamic changes that happen to regions of interest.
36
44
In our specific case here, we have a stack of pulsar kind of images. We can use ImageJS to figure out when the region is shown in the image and when it isn't by looking at the average value of said region.
37
45
38
-
Just like any image, after getting our stack needs to be parsed fo us to work with data. ImageJS doesn't have a built-in function to parse tiff stack, so you will have to use
39
-
`fs` library.
46
+
Just like any image, after getting our stack needs to be parsed fo us to work with data.
40
47
41
48
```ts
49
+
//ImageJS doesn't have a built-in function to parse TIFF stack,
Stack class has a function called `maxImage()`. It will give us the maximum value of each pixel throughout the stack. We will use this image as a reference for all other images, to locate all possible regions of interest.
57
+
Stack class has a function called `maxImage()`. It will give us the maximum value of each pixel throughout the stack. We will use this image as a reference for all other images to locate their ROIs.
49
58
50
59
```ts
51
60
const maxValueImage =stack.maxImage();
61
+
//We will use `threshold()` to find ROIs
62
+
//therefore color model has to be "GREY".
63
+
if (maxValueImage.colorModel!=='GREY') {
64
+
maxValueImage=maxValueImage.grey();
65
+
}
52
66
```
53
67
54
68
;
55
69
56
70
## Locate ROIs
57
71
58
-
From our "maxValues" image we can find all the regions of interest. To be precise we need their coordinates to apply them to other images.
72
+
From our `maxValueImage` image we can find all the regions of interest. To be precise we need their coordinates to apply them to other images.
//Gets value from one channel since it is grayscaled.
82
-
stackAvgs.push(avgValue[0]);
101
+
stackAvgs.push(avgValue);
83
102
}
84
103
stackGrays.set(roi.id, stackAvgs);
85
104
}
86
105
```
87
106
88
-
This will create a map where the key is the ID of each ROI, and the values are an array of average values of ROI coordinates across all the images in the stack.
107
+
This will create a map where keys are IDs of each ROI, and values are an array of pixels with average intensity across all the images in the stack.
89
108
This way we can take a look at the changes in intensity of ROI from one image to another.
90
109
This will give us the graph of intensities across all the images in the stack for each ROI.
110
+
For instance here we have a graph of intensity of region with ID of 9. We can see that there is a rising pulse between images 1 and 4, but then it disappears.
0 commit comments