jimg-int 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jimg_int-0.1.0/PKG-INFO +361 -0
- jimg_int-0.1.0/README.md +336 -0
- jimg_int-0.1.0/jimg_int/__init__.py +2 -0
- jimg_int-0.1.0/jimg_int/config.py +2 -0
- jimg_int-0.1.0/jimg_int/intensity.py +1913 -0
- jimg_int-0.1.0/jimg_int/utils.py +1569 -0
- jimg_int-0.1.0/license.txt +165 -0
- jimg_int-0.1.0/pyproject.toml +36 -0
jimg_int-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jimg_int
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
License-File: license.txt
|
|
6
|
+
Author: Jakub Kubis - JBS
|
|
7
|
+
Author-email: jbiosystem@gmail.com
|
|
8
|
+
Requires-Python: >=3.12,<3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Requires-Dist: gdown (>=5.2.0,<6.0.0)
|
|
12
|
+
Requires-Dist: matplotlib (<3.10.0)
|
|
13
|
+
Requires-Dist: numpy (==1.26.0)
|
|
14
|
+
Requires-Dist: opencv-python
|
|
15
|
+
Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
|
|
16
|
+
Requires-Dist: pandas
|
|
17
|
+
Requires-Dist: pingouin
|
|
18
|
+
Requires-Dist: plotly
|
|
19
|
+
Requires-Dist: scikit-image
|
|
20
|
+
Requires-Dist: scipy
|
|
21
|
+
Requires-Dist: tensorflow (>=2.20.0,<3.0.0)
|
|
22
|
+
Requires-Dist: tqdm
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
### JIMG_int – Python library for marker intensity and distribution analysis
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+
</br>
|
|
31
|
+
|
|
32
|
+
<p align="right">
|
|
33
|
+
<img src="https://github.com/jkubis96/Logos/blob/main/logos/jbs_current.png?raw=true" alt="drawing" width="250" />
|
|
34
|
+
<img src="https://github.com/jkubis96/Logos/blob/main/logos/jbi_current.png?raw=true" alt="drawing" width="250" />
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
</br>
|
|
38
|
+
|
|
39
|
+
### Author: Jakub KubiÅ›
|
|
40
|
+
|
|
41
|
+
<div align="left">
|
|
42
|
+
Institute of Bioorganic Chemistry<br />
|
|
43
|
+
Polish Academy of Sciences<br />
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Description
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
<div align="justify">
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
***JIMG_int*** is a Python library designed to quantify and analyze marker intensity and spatial distribution in images. It is particularly useful for biological imaging, immunofluorescence, or any field requiring analysis of labeled markers in microscopy or medical images.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
The library support the [JIMG](https://github.com/jkubis96/JIMG) image processing tool, specifically tailored for analyzing high-resolution confocal microscope images [Opera-Phoenix](https://www.revvity.com/product/opera-phenix-plus-system-hh14001000?srsltid=AfmBOoohz1LiEemNbG4SJnaEtScwr16MyFL8Ulf9NyDDEAffV2NLJXoe) and other technologies.
|
|
57
|
+
|
|
58
|
+
It provides algorithms for measuring the intensity of specific protein markers using customizable image masks on high-resolution microscope images. These measurements are normalized using a background mask for consistent data comparison. The collected intensity data can be statistically analyzed to detect differences in marker localization, occurrence, and intensity.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
</br>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
<br />
|
|
69
|
+
|
|
70
|
+
## 📚 Table of Contents
|
|
71
|
+
- 1.[Installation](#installation)
|
|
72
|
+
- 2.[Documentation](#doc)
|
|
73
|
+
- 3.[Example pipelines](#epip)
|
|
74
|
+
- 3.1. [Marker intensity features extraction](#nacm)
|
|
75
|
+
- 3.1.1 [Adjusting parameters and image loading](#nacm1)
|
|
76
|
+
- 3.1.2 [ROI mask loading](#nacm2)
|
|
77
|
+
- 3.1.3 [Normalization mask loading](#nacm3)
|
|
78
|
+
- 3.1.4 [Extracting intensity values](#nacm4)
|
|
79
|
+
- 3.1.5 [Saving intensity data](#nacm5)
|
|
80
|
+
- 3.1.6 [APerforming analysis pipeline for the subsequent image](#nacm6)
|
|
81
|
+
- 3.1.7 [Combining the experimental data](#nacm7)
|
|
82
|
+
- 3.2. [Analyzing the intensity and spatial distribution of the marker](#miacmda)
|
|
83
|
+
- 3.2.1 [Loading experimental data](#miacmda1)
|
|
84
|
+
- 3.2.2 [Quantitative analysis of marker intensity and spatial distribution](#miacmda2)
|
|
85
|
+
- 3.2.3 [Visualizing the data using a histogram distribution](#miacmda3)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
<br />
|
|
90
|
+
|
|
91
|
+
<br />
|
|
92
|
+
|
|
93
|
+
# 1. Installation <a id="installation"></a>
|
|
94
|
+
|
|
95
|
+
#### In command line write:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
pip install jimg_int
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
# 2. Documenation <a id="doc"></a>
|
|
102
|
+
|
|
103
|
+
Documentation for classes and functions is available here 👉 [Documentation 📄](https://jkubis96.github.io/JIMG_int/jimg_int.html)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# 3. Example pipelines <a id="epip"></a>
|
|
107
|
+
|
|
108
|
+
If you want to run the examples, you must download the test data. To do this, use:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
from jimg_ncd.nuclei import test_data
|
|
112
|
+
|
|
113
|
+
test_data()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
<br />
|
|
118
|
+
|
|
119
|
+
#### 3.1 Marker intensity features extraction <a id="nacm"></a>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
##### 3.1.1 Adjusting parameters and image loading <a id="nacm1"></a>
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
from jimg_int.intensity import FeatureIntensity
|
|
127
|
+
|
|
128
|
+
# Select intenity are data for 1st Image - healthy
|
|
129
|
+
|
|
130
|
+
# initiate class
|
|
131
|
+
fi = FeatureIntensity()
|
|
132
|
+
|
|
133
|
+
# check current metadata
|
|
134
|
+
fi.current_metadata
|
|
135
|
+
|
|
136
|
+
# if required, change parameters
|
|
137
|
+
fi.set_projection(projection="avg")
|
|
138
|
+
|
|
139
|
+
fi.set_correction_factorn(factor=0.2)
|
|
140
|
+
|
|
141
|
+
# fi.set_scale(scale = 0.5)
|
|
142
|
+
# fi.set_selection_list(rm_list = [2,5,6,7])
|
|
143
|
+
# OR
|
|
144
|
+
# load JIMG project where scale and rm_lis is set in project metadata
|
|
145
|
+
# fi.load_JIMG_project_(path = '')
|
|
146
|
+
# for more information go to: https://github.com/jkubis96/JIMG
|
|
147
|
+
# rm_list and scale can be omitted
|
|
148
|
+
|
|
149
|
+
# load image
|
|
150
|
+
fi.load_image_3D(path="test_data/intensity/ctrl/image.tiff")
|
|
151
|
+
|
|
152
|
+
# or 1D image after projection, be sure that image was not adjusted, for analysis should be use !RAW! image
|
|
153
|
+
# fi.load_image_(path)
|
|
154
|
+
```
|
|
155
|
+
<br/>
|
|
156
|
+
|
|
157
|
+
***Analysed image projection (after projection with JIMG)***
|
|
158
|
+
|
|
159
|
+
* input image in this case is raw 3D-image in *.tiff format
|
|
160
|
+
|
|
161
|
+
<p align="center">
|
|
162
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/ctrl.bmp" alt="drawing" width="600" />
|
|
163
|
+
</p>
|
|
164
|
+
|
|
165
|
+
<br/>
|
|
166
|
+
|
|
167
|
+
##### 3.1.2 ROI mask loading<a id="nacm2"></a>
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
fi.load_mask_(path = 'test_data/intensity/ctrl/mask_1.png')
|
|
171
|
+
```
|
|
172
|
+
<br/>
|
|
173
|
+
|
|
174
|
+
***Analysed image region mask***
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
<p align="center">
|
|
178
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/ctrl_mask.bmp" alt="drawing" width="600" />
|
|
179
|
+
</p>
|
|
180
|
+
|
|
181
|
+
<br/>
|
|
182
|
+
|
|
183
|
+
##### 3.1.3 Normalization mask loading<a id="nacm3"></a>
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
fi.load_normalization_mask_(path = 'test_data/intensity/ctrl/background_1.png')
|
|
187
|
+
```
|
|
188
|
+
<br/>
|
|
189
|
+
|
|
190
|
+
***Normalization region mask (reversed)***
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
<p align="center">
|
|
194
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/ctrl_back.bmp" alt="drawing" width="600" />
|
|
195
|
+
</p>
|
|
196
|
+
|
|
197
|
+
<br/>
|
|
198
|
+
|
|
199
|
+
##### 3.1.4 Extracting intensity values <a id="nacm4"></a>
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
# strat calculations
|
|
203
|
+
fi.run_calculations()
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
# get results
|
|
207
|
+
results = fi.get_results()
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
##### 3.1.5 Saving intensity data <a id="nacm5"></a>
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
# save results for further analysis, ensuring each feature
|
|
214
|
+
# is stored in a separate directory (single directory
|
|
215
|
+
# should contain data with the same 'feature_name'),
|
|
216
|
+
# this setup allows running fi.concatenate_intensity_data()
|
|
217
|
+
# in the specific directory of each feature
|
|
218
|
+
# while preventing errors from incorrect feature concatenation
|
|
219
|
+
|
|
220
|
+
fi.save_results(path = os.getcwd(),
|
|
221
|
+
mask_region = 'brain',
|
|
222
|
+
feature_name = 'Feature1',
|
|
223
|
+
individual_number = 1,
|
|
224
|
+
individual_name = 'CTRL')
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
##### 3.1.6 Performing analysis pipeline for the subsequent image <a id="nacm6"></a>
|
|
228
|
+
|
|
229
|
+
* Apply steps 3.1.1–3.1.5 to the subsequent image to support comparison analysis.
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
# Select intenity are data for 2st Image - disease
|
|
233
|
+
|
|
234
|
+
# initiate class
|
|
235
|
+
fi = FeatureIntensity()
|
|
236
|
+
|
|
237
|
+
fi.set_projection(projection="avg")
|
|
238
|
+
|
|
239
|
+
fi.set_correction_factorn(factor=0.2)
|
|
240
|
+
|
|
241
|
+
fi.load_image_3D(path="test_data/intensity/dise/image.tiff")
|
|
242
|
+
|
|
243
|
+
###############################################################################
|
|
244
|
+
|
|
245
|
+
fi.load_mask_(path="test_data/intensity/dise/mask_1.png")
|
|
246
|
+
|
|
247
|
+
###############################################################################
|
|
248
|
+
|
|
249
|
+
fi.load_normalization_mask_(path="test_data/intensity/dise/background_1.png")
|
|
250
|
+
|
|
251
|
+
###############################################################################
|
|
252
|
+
|
|
253
|
+
fi.run_calculations()
|
|
254
|
+
|
|
255
|
+
results = fi.get_results()
|
|
256
|
+
|
|
257
|
+
fi.save_results(
|
|
258
|
+
path="",
|
|
259
|
+
mask_region="brain",
|
|
260
|
+
feature_name="Feature1",
|
|
261
|
+
individual_number=1,
|
|
262
|
+
individual_name="DISEASE",
|
|
263
|
+
)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
***Analysed image projection (after projection with JIMG)***
|
|
267
|
+
|
|
268
|
+
* input image in this case is raw 3D-image in *.tiff format
|
|
269
|
+
|
|
270
|
+
<p align="center">
|
|
271
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/dis.bmp" alt="drawing" width="600" />
|
|
272
|
+
</p>
|
|
273
|
+
|
|
274
|
+
<br/>
|
|
275
|
+
|
|
276
|
+
***Normalization region mask (reversed)***
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
<p align="center">
|
|
280
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/dis_back.bmp" alt="drawing" width="600" />
|
|
281
|
+
</p>
|
|
282
|
+
|
|
283
|
+
<br/>
|
|
284
|
+
|
|
285
|
+
***Analysed image region mask***
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
<p align="center">
|
|
289
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/dis_mask.bmp" alt="drawing" width="600" />
|
|
290
|
+
</p>
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
##### 3.1.7 Combining the experimental data <a id="nacm7"></a>
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
# concatenate data of experiment 1 & 2
|
|
299
|
+
fi.concatenate_intensity_data(directory="", name="example_data")
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
<br/>
|
|
303
|
+
|
|
304
|
+
#### 3.2 Analyzing the intensity and spatial distribution of the marker <a id="miacmda"></a>
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
#### 3.2.1 Loading experimental data <a id="miacmda1"></a>
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
import pandas as pd
|
|
312
|
+
from jimg_int.intensity import IntensityAnalysis
|
|
313
|
+
|
|
314
|
+
# initiate class
|
|
315
|
+
ia = IntensityAnalysis()
|
|
316
|
+
|
|
317
|
+
input_data = pd.read_csv("example_data_Feature1_brain.csv")
|
|
318
|
+
|
|
319
|
+
# check columns
|
|
320
|
+
input_data.head()
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### 3.2.2 Quantitative analysis of marker intensity and spatial distribution <a id="miacmda2"></a>
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
data = ia.df_to_percentiles(
|
|
327
|
+
data=input_data,
|
|
328
|
+
group_col="individual_name",
|
|
329
|
+
values_col="norm_intensity",
|
|
330
|
+
sep_perc=1,
|
|
331
|
+
)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
#### 3.2.3 Visualizing the data using a histogram distribution <a id="miacmda3"></a>
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
results = ia.hist_compare_plot(
|
|
338
|
+
data=data, queue=["CTRL", "DISEASE"], tested_value="avg", p_adj=True, txt_size=20
|
|
339
|
+
)
|
|
340
|
+
```
|
|
341
|
+
<br/>
|
|
342
|
+
|
|
343
|
+
***Results of intensity comparison analysis (region under the mask)***
|
|
344
|
+
|
|
345
|
+
<p align="center">
|
|
346
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/compare_result.bmp" alt="drawing" width="600" />
|
|
347
|
+
</p>
|
|
348
|
+
|
|
349
|
+
<br/>
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
results.savefig('example_results.svg', format = 'svg', dpi = 300, bbox_inches = 'tight')
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
<br />
|
|
356
|
+
<br />
|
|
357
|
+
|
|
358
|
+
### Have fun JBS
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
jimg_int-0.1.0/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
### JIMG_int – Python library for marker intensity and distribution analysis
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
</br>
|
|
7
|
+
|
|
8
|
+
<p align="right">
|
|
9
|
+
<img src="https://github.com/jkubis96/Logos/blob/main/logos/jbs_current.png?raw=true" alt="drawing" width="250" />
|
|
10
|
+
<img src="https://github.com/jkubis96/Logos/blob/main/logos/jbi_current.png?raw=true" alt="drawing" width="250" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
</br>
|
|
14
|
+
|
|
15
|
+
### Author: Jakub KubiÅ›
|
|
16
|
+
|
|
17
|
+
<div align="left">
|
|
18
|
+
Institute of Bioorganic Chemistry<br />
|
|
19
|
+
Polish Academy of Sciences<br />
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
<div align="justify">
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
***JIMG_int*** is a Python library designed to quantify and analyze marker intensity and spatial distribution in images. It is particularly useful for biological imaging, immunofluorescence, or any field requiring analysis of labeled markers in microscopy or medical images.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
The library support the [JIMG](https://github.com/jkubis96/JIMG) image processing tool, specifically tailored for analyzing high-resolution confocal microscope images [Opera-Phoenix](https://www.revvity.com/product/opera-phenix-plus-system-hh14001000?srsltid=AfmBOoohz1LiEemNbG4SJnaEtScwr16MyFL8Ulf9NyDDEAffV2NLJXoe) and other technologies.
|
|
33
|
+
|
|
34
|
+
It provides algorithms for measuring the intensity of specific protein markers using customizable image masks on high-resolution microscope images. These measurements are normalized using a background mask for consistent data comparison. The collected intensity data can be statistically analyzed to detect differences in marker localization, occurrence, and intensity.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
</br>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<br />
|
|
45
|
+
|
|
46
|
+
## 📚 Table of Contents
|
|
47
|
+
- 1.[Installation](#installation)
|
|
48
|
+
- 2.[Documentation](#doc)
|
|
49
|
+
- 3.[Example pipelines](#epip)
|
|
50
|
+
- 3.1. [Marker intensity features extraction](#nacm)
|
|
51
|
+
- 3.1.1 [Adjusting parameters and image loading](#nacm1)
|
|
52
|
+
- 3.1.2 [ROI mask loading](#nacm2)
|
|
53
|
+
- 3.1.3 [Normalization mask loading](#nacm3)
|
|
54
|
+
- 3.1.4 [Extracting intensity values](#nacm4)
|
|
55
|
+
- 3.1.5 [Saving intensity data](#nacm5)
|
|
56
|
+
- 3.1.6 [APerforming analysis pipeline for the subsequent image](#nacm6)
|
|
57
|
+
- 3.1.7 [Combining the experimental data](#nacm7)
|
|
58
|
+
- 3.2. [Analyzing the intensity and spatial distribution of the marker](#miacmda)
|
|
59
|
+
- 3.2.1 [Loading experimental data](#miacmda1)
|
|
60
|
+
- 3.2.2 [Quantitative analysis of marker intensity and spatial distribution](#miacmda2)
|
|
61
|
+
- 3.2.3 [Visualizing the data using a histogram distribution](#miacmda3)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
<br />
|
|
66
|
+
|
|
67
|
+
<br />
|
|
68
|
+
|
|
69
|
+
# 1. Installation <a id="installation"></a>
|
|
70
|
+
|
|
71
|
+
#### In command line write:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
pip install jimg_int
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
# 2. Documenation <a id="doc"></a>
|
|
78
|
+
|
|
79
|
+
Documentation for classes and functions is available here 👉 [Documentation 📄](https://jkubis96.github.io/JIMG_int/jimg_int.html)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# 3. Example pipelines <a id="epip"></a>
|
|
83
|
+
|
|
84
|
+
If you want to run the examples, you must download the test data. To do this, use:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
from jimg_ncd.nuclei import test_data
|
|
88
|
+
|
|
89
|
+
test_data()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
<br />
|
|
94
|
+
|
|
95
|
+
#### 3.1 Marker intensity features extraction <a id="nacm"></a>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
##### 3.1.1 Adjusting parameters and image loading <a id="nacm1"></a>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
from jimg_int.intensity import FeatureIntensity
|
|
103
|
+
|
|
104
|
+
# Select intenity are data for 1st Image - healthy
|
|
105
|
+
|
|
106
|
+
# initiate class
|
|
107
|
+
fi = FeatureIntensity()
|
|
108
|
+
|
|
109
|
+
# check current metadata
|
|
110
|
+
fi.current_metadata
|
|
111
|
+
|
|
112
|
+
# if required, change parameters
|
|
113
|
+
fi.set_projection(projection="avg")
|
|
114
|
+
|
|
115
|
+
fi.set_correction_factorn(factor=0.2)
|
|
116
|
+
|
|
117
|
+
# fi.set_scale(scale = 0.5)
|
|
118
|
+
# fi.set_selection_list(rm_list = [2,5,6,7])
|
|
119
|
+
# OR
|
|
120
|
+
# load JIMG project where scale and rm_lis is set in project metadata
|
|
121
|
+
# fi.load_JIMG_project_(path = '')
|
|
122
|
+
# for more information go to: https://github.com/jkubis96/JIMG
|
|
123
|
+
# rm_list and scale can be omitted
|
|
124
|
+
|
|
125
|
+
# load image
|
|
126
|
+
fi.load_image_3D(path="test_data/intensity/ctrl/image.tiff")
|
|
127
|
+
|
|
128
|
+
# or 1D image after projection, be sure that image was not adjusted, for analysis should be use !RAW! image
|
|
129
|
+
# fi.load_image_(path)
|
|
130
|
+
```
|
|
131
|
+
<br/>
|
|
132
|
+
|
|
133
|
+
***Analysed image projection (after projection with JIMG)***
|
|
134
|
+
|
|
135
|
+
* input image in this case is raw 3D-image in *.tiff format
|
|
136
|
+
|
|
137
|
+
<p align="center">
|
|
138
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/ctrl.bmp" alt="drawing" width="600" />
|
|
139
|
+
</p>
|
|
140
|
+
|
|
141
|
+
<br/>
|
|
142
|
+
|
|
143
|
+
##### 3.1.2 ROI mask loading<a id="nacm2"></a>
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
fi.load_mask_(path = 'test_data/intensity/ctrl/mask_1.png')
|
|
147
|
+
```
|
|
148
|
+
<br/>
|
|
149
|
+
|
|
150
|
+
***Analysed image region mask***
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
<p align="center">
|
|
154
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/ctrl_mask.bmp" alt="drawing" width="600" />
|
|
155
|
+
</p>
|
|
156
|
+
|
|
157
|
+
<br/>
|
|
158
|
+
|
|
159
|
+
##### 3.1.3 Normalization mask loading<a id="nacm3"></a>
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
fi.load_normalization_mask_(path = 'test_data/intensity/ctrl/background_1.png')
|
|
163
|
+
```
|
|
164
|
+
<br/>
|
|
165
|
+
|
|
166
|
+
***Normalization region mask (reversed)***
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<p align="center">
|
|
170
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/ctrl_back.bmp" alt="drawing" width="600" />
|
|
171
|
+
</p>
|
|
172
|
+
|
|
173
|
+
<br/>
|
|
174
|
+
|
|
175
|
+
##### 3.1.4 Extracting intensity values <a id="nacm4"></a>
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
# strat calculations
|
|
179
|
+
fi.run_calculations()
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# get results
|
|
183
|
+
results = fi.get_results()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
##### 3.1.5 Saving intensity data <a id="nacm5"></a>
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
# save results for further analysis, ensuring each feature
|
|
190
|
+
# is stored in a separate directory (single directory
|
|
191
|
+
# should contain data with the same 'feature_name'),
|
|
192
|
+
# this setup allows running fi.concatenate_intensity_data()
|
|
193
|
+
# in the specific directory of each feature
|
|
194
|
+
# while preventing errors from incorrect feature concatenation
|
|
195
|
+
|
|
196
|
+
fi.save_results(path = os.getcwd(),
|
|
197
|
+
mask_region = 'brain',
|
|
198
|
+
feature_name = 'Feature1',
|
|
199
|
+
individual_number = 1,
|
|
200
|
+
individual_name = 'CTRL')
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
##### 3.1.6 Performing analysis pipeline for the subsequent image <a id="nacm6"></a>
|
|
204
|
+
|
|
205
|
+
* Apply steps 3.1.1–3.1.5 to the subsequent image to support comparison analysis.
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
# Select intenity are data for 2st Image - disease
|
|
209
|
+
|
|
210
|
+
# initiate class
|
|
211
|
+
fi = FeatureIntensity()
|
|
212
|
+
|
|
213
|
+
fi.set_projection(projection="avg")
|
|
214
|
+
|
|
215
|
+
fi.set_correction_factorn(factor=0.2)
|
|
216
|
+
|
|
217
|
+
fi.load_image_3D(path="test_data/intensity/dise/image.tiff")
|
|
218
|
+
|
|
219
|
+
###############################################################################
|
|
220
|
+
|
|
221
|
+
fi.load_mask_(path="test_data/intensity/dise/mask_1.png")
|
|
222
|
+
|
|
223
|
+
###############################################################################
|
|
224
|
+
|
|
225
|
+
fi.load_normalization_mask_(path="test_data/intensity/dise/background_1.png")
|
|
226
|
+
|
|
227
|
+
###############################################################################
|
|
228
|
+
|
|
229
|
+
fi.run_calculations()
|
|
230
|
+
|
|
231
|
+
results = fi.get_results()
|
|
232
|
+
|
|
233
|
+
fi.save_results(
|
|
234
|
+
path="",
|
|
235
|
+
mask_region="brain",
|
|
236
|
+
feature_name="Feature1",
|
|
237
|
+
individual_number=1,
|
|
238
|
+
individual_name="DISEASE",
|
|
239
|
+
)
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
***Analysed image projection (after projection with JIMG)***
|
|
243
|
+
|
|
244
|
+
* input image in this case is raw 3D-image in *.tiff format
|
|
245
|
+
|
|
246
|
+
<p align="center">
|
|
247
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/dis.bmp" alt="drawing" width="600" />
|
|
248
|
+
</p>
|
|
249
|
+
|
|
250
|
+
<br/>
|
|
251
|
+
|
|
252
|
+
***Normalization region mask (reversed)***
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
<p align="center">
|
|
256
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/dis_back.bmp" alt="drawing" width="600" />
|
|
257
|
+
</p>
|
|
258
|
+
|
|
259
|
+
<br/>
|
|
260
|
+
|
|
261
|
+
***Analysed image region mask***
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
<p align="center">
|
|
265
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/dis_mask.bmp" alt="drawing" width="600" />
|
|
266
|
+
</p>
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
##### 3.1.7 Combining the experimental data <a id="nacm7"></a>
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
# concatenate data of experiment 1 & 2
|
|
275
|
+
fi.concatenate_intensity_data(directory="", name="example_data")
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
<br/>
|
|
279
|
+
|
|
280
|
+
#### 3.2 Analyzing the intensity and spatial distribution of the marker <a id="miacmda"></a>
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
#### 3.2.1 Loading experimental data <a id="miacmda1"></a>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
import pandas as pd
|
|
288
|
+
from jimg_int.intensity import IntensityAnalysis
|
|
289
|
+
|
|
290
|
+
# initiate class
|
|
291
|
+
ia = IntensityAnalysis()
|
|
292
|
+
|
|
293
|
+
input_data = pd.read_csv("example_data_Feature1_brain.csv")
|
|
294
|
+
|
|
295
|
+
# check columns
|
|
296
|
+
input_data.head()
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
#### 3.2.2 Quantitative analysis of marker intensity and spatial distribution <a id="miacmda2"></a>
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
data = ia.df_to_percentiles(
|
|
303
|
+
data=input_data,
|
|
304
|
+
group_col="individual_name",
|
|
305
|
+
values_col="norm_intensity",
|
|
306
|
+
sep_perc=1,
|
|
307
|
+
)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
#### 3.2.3 Visualizing the data using a histogram distribution <a id="miacmda3"></a>
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
results = ia.hist_compare_plot(
|
|
314
|
+
data=data, queue=["CTRL", "DISEASE"], tested_value="avg", p_adj=True, txt_size=20
|
|
315
|
+
)
|
|
316
|
+
```
|
|
317
|
+
<br/>
|
|
318
|
+
|
|
319
|
+
***Results of intensity comparison analysis (region under the mask)***
|
|
320
|
+
|
|
321
|
+
<p align="center">
|
|
322
|
+
<img src="https://raw.githubusercontent.com/jkubis96/JIMG_int/refs/heads/documentation/fig/Intensity/compare_result.bmp" alt="drawing" width="600" />
|
|
323
|
+
</p>
|
|
324
|
+
|
|
325
|
+
<br/>
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
results.savefig('example_results.svg', format = 'svg', dpi = 300, bbox_inches = 'tight')
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
<br />
|
|
332
|
+
<br />
|
|
333
|
+
|
|
334
|
+
### Have fun JBS
|
|
335
|
+
|
|
336
|
+
|