skinoptics 0.0.1__py3-none-any.whl

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.
Files changed (44) hide show
  1. skinoptics/__init__.py +47 -0
  2. skinoptics/absorption_coefficient.py +893 -0
  3. skinoptics/anisotropy_factor.py +955 -0
  4. skinoptics/colors.py +1403 -0
  5. skinoptics/dataframes.py +98 -0
  6. skinoptics/datasets/colors/Lab_Alaluf2002.txt +11 -0
  7. skinoptics/datasets/colors/Lab_Xiao2017.txt +25 -0
  8. skinoptics/datasets/colors/cmfs.txt +472 -0
  9. skinoptics/datasets/colors/rspds_A_D50_D65.txt +532 -0
  10. skinoptics/datasets/colors/rspds_D55_D75.txt +98 -0
  11. skinoptics/datasets/optical_properties/DE_Salomatina.txt +279 -0
  12. skinoptics/datasets/optical_properties/DE_Shimojo.txt +10 -0
  13. skinoptics/datasets/optical_properties/EP_Salomatina.txt +279 -0
  14. skinoptics/datasets/optical_properties/EP_Shimojo.txt +10 -0
  15. skinoptics/datasets/optical_properties/HY_Salomatina.txt +278 -0
  16. skinoptics/datasets/optical_properties/HY_Shimojo.txt +10 -0
  17. skinoptics/datasets/optical_properties/SCC_Salomatina.txt +279 -0
  18. skinoptics/datasets/optical_properties/beta_oxy_Friebel.txt +85 -0
  19. skinoptics/datasets/optical_properties/ext_and_molarext_eum_Sarna.txt +32 -0
  20. skinoptics/datasets/optical_properties/ext_and_molarext_oxy_and_deo_Prahl.txt +377 -0
  21. skinoptics/datasets/optical_properties/ext_and_molarext_phe_Sarna.txt +50 -0
  22. skinoptics/datasets/optical_properties/iBCC_Salomatina.txt +279 -0
  23. skinoptics/datasets/optical_properties/molarext_bil_Li.txt +1843 -0
  24. skinoptics/datasets/optical_properties/mua_fat_vanVeen.txt +671 -0
  25. skinoptics/datasets/optical_properties/mua_wat_Hale.txt +232 -0
  26. skinoptics/datasets/optical_properties/mua_wat_Segelstein.txt +1262 -0
  27. skinoptics/datasets/optical_properties/nBCC_Salomatina.txt +279 -0
  28. skinoptics/datasets/optical_properties/n_AT_Matiatou.txt +6 -0
  29. skinoptics/datasets/optical_properties/n_HY_Matiatou.txt +6 -0
  30. skinoptics/datasets/optical_properties/n_and_k_DE_Ding.txt +9 -0
  31. skinoptics/datasets/optical_properties/n_and_k_EP_Ding.txt +9 -0
  32. skinoptics/datasets/optical_properties/n_and_k_wat_Hale.txt +170 -0
  33. skinoptics/datasets/optical_properties/n_and_k_wat_Segelstein.txt +1262 -0
  34. skinoptics/datasets/optical_properties/oxy_and_deo_Bosschaart.txt +456 -0
  35. skinoptics/datasets/spectra/Xiao2016/skindatabaseSpectra/readmeSpectra.docx +0 -0
  36. skinoptics/datasets/spectra/Xiao2016/skindatabaseSpectra/skin spectra data.xlsx +0 -0
  37. skinoptics/refractive_index.py +414 -0
  38. skinoptics/scattering_coefficient.py +403 -0
  39. skinoptics/utils.py +420 -0
  40. skinoptics-0.0.1.dist-info/METADATA +31 -0
  41. skinoptics-0.0.1.dist-info/RECORD +44 -0
  42. skinoptics-0.0.1.dist-info/WHEEL +5 -0
  43. skinoptics-0.0.1.dist-info/licenses/LICENSE.txt +674 -0
  44. skinoptics-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,403 @@
1
+ '''
2
+ | SkinOptics
3
+ | Copyright (C) 2024-2025 Victor Lima
4
+
5
+ | This program is free software: you can redistribute it and/or modify
6
+ | it under the terms of the GNU General Public License as published by
7
+ | the Free Software Foundation, either version 3 of the License, or
8
+ | (at your option) any later version.
9
+
10
+ | This program is distributed in the hope that it will be useful,
11
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ | GNU General Public License for more details.
14
+
15
+ | You should have received a copy of the GNU General Public License
16
+ | along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ | Victor Lima
19
+ | victorporto\@ifsc.usp.br
20
+ | victor.lima\@ufscar.br
21
+ | victorportog.github.io
22
+
23
+ | Release date:
24
+ | October 2024
25
+ | Last modification:
26
+ | October 2024
27
+
28
+ | References:
29
+
30
+ | [SJT95] Saidi, Jacques & Tittel 1995.
31
+ | Mie and Rayleigh modeling of visible-light scattering in neonatal skin.
32
+ | https://doi.org/10.1364/AO.34.007410
33
+
34
+ | [S*06] Salomatina, Jiang, Novak & Yaroslavsky 2006.
35
+ | Optical properties of normal and cancerous human skin in the visible and near-infrared spectral range.
36
+ | https://doi.org/10.1117/1.2398928
37
+
38
+ | [J13] Jacques 2013.
39
+ | Optical properties of biological tissues: a review.
40
+ | https://doi.org/10.1088/0031-9155/58/14/5007
41
+
42
+ | [N19] Niemz 2019.
43
+ | Laser-Tissue Interactions: Fundamentals and Applications (4th edition).
44
+ | https://doi.org/10.1007/978-3-030-11917-1
45
+ '''
46
+
47
+ import numpy as np
48
+ from scipy.interpolate import interp1d
49
+
50
+ from skinoptics.utils import *
51
+ from skinoptics.dataframes import *
52
+
53
+ def albedo(mua, mus):
54
+ r'''
55
+ | Calculate the optical albedo from the absorption coefficient and the scattering coefficient.
56
+ | For details please check section 2.4 from Niemz 2019 [N19].
57
+
58
+ :math:`a = \frac{\mu_s}{\mu_a + \mu_s}`
59
+
60
+ :param mua: absorption coefficient [mm^-1]
61
+ :type mua: float or np.ndarray
62
+
63
+ :param mus: scattering coefficient [mm^-1]
64
+ :type mus: float or np.ndarray
65
+
66
+ :return: - **albedo** (*float or np.ndarray*) – optical albedo [-]
67
+ '''
68
+
69
+ return mus/(mua + mus)
70
+
71
+ def mus_from_rmus(rmus, g):
72
+ r'''
73
+ | Calculate the scattering coefficient from the reduced scattering coefficient and the
74
+ | anisotropy factor.
75
+
76
+ :math:`\mu_s(\lambda) = \frac{\mu_s'(\lambda)}{1-g}`
77
+
78
+ :param rmus: reduced scattering coefficient [mm^-1]
79
+ :type rmus: float or np.ndarray
80
+
81
+ :param g: anisotropy factor [-] (must be in the range [-1, 1])
82
+ :type g: float
83
+
84
+ :return: - **mus** (*float or np.ndarray*) – scattering coefficient [mm^-1]
85
+ '''
86
+
87
+ return rmus/(1 - g)
88
+
89
+ def rmus_from_mus(mus, g):
90
+ r'''
91
+ | Calculate the reduced scattering coefficient from the scattering coefficient and the
92
+ | anisotropy factor.
93
+
94
+ :math:`\mu_s'(\lambda) = (1-g) \mbox{ } \mu_s(\lambda)`
95
+
96
+ :param mus: scattering coefficient [mm^-1]
97
+ :type mus: float or np.ndarray
98
+
99
+ :param g: anisotropy factor [-] (must be in the range [-1, 1])
100
+ :type g: float
101
+
102
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
103
+ '''
104
+
105
+ return mus*(1 - g)
106
+
107
+ def rmus_EP_Salomatina(lambda0):
108
+ r'''
109
+ | The reduced scattering coefficient of human EPIDERMIS as a function of wavelength.
110
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
111
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
112
+
113
+ | wavelength range: [370 nm, 1600 nm]
114
+
115
+ :param lambda0: wavelength [nm]
116
+ :type lambda0: float or np.ndarray
117
+
118
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
119
+ '''
120
+
121
+ return interp1d(np.array(EP_Salomatina_dataframe)[:,0],
122
+ np.array(EP_Salomatina_dataframe)[:,3],
123
+ bounds_error = False,
124
+ fill_value = (np.array(EP_Salomatina_dataframe)[0,3],
125
+ np.array(EP_Salomatina_dataframe)[-1,3]))(lambda0)
126
+
127
+ def rmus_DE_Salomatina(lambda0):
128
+ r'''
129
+ | The reduced scattering coefficient of human DERMIS as a function of wavelength.
130
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
131
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2/>.
132
+
133
+ | wavelength range: [370 nm, 1600 nm]
134
+
135
+ :param lambda0: wavelength [nm]
136
+ :type lambda0: float or np.ndarray
137
+
138
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
139
+ '''
140
+
141
+ return interp1d(np.array(DE_Salomatina_dataframe)[:,0],
142
+ np.array(DE_Salomatina_dataframe)[:,3],
143
+ bounds_error = False,
144
+ fill_value = (np.array(DE_Salomatina_dataframe)[0,3],
145
+ np.array(DE_Salomatina_dataframe)[-1,3]))(lambda0)
146
+
147
+ def rmus_HY_Salomatina(lambda0):
148
+ r'''
149
+ | The reduced scattering coefficient of human HYPODERMIS as a function of wavelength.
150
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
151
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2/>.
152
+
153
+ | wavelength range: [370 nm, 1600 nm]
154
+
155
+ :param lambda0: wavelength [nm]
156
+ :type lambda0: float or np.ndarray
157
+
158
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
159
+ '''
160
+
161
+ return interp1d(np.array(HY_Salomatina_dataframe)[:,0],
162
+ np.array(HY_Salomatina_dataframe)[:,3],
163
+ bounds_error = False,
164
+ fill_value = (np.array(HY_Salomatina_dataframe)[0,3],
165
+ np.array(HY_Salomatina_dataframe)[-1,3]))(lambda0)
166
+
167
+ def rmus_iBCC_Salomatina(lambda0):
168
+ r'''
169
+ | The reduced scattering coefficient of INFILTRATIVE BASAL CELL CARCINOMA (iBCC)
170
+ | as a function of wavelength.
171
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
172
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
173
+
174
+ | wavelength range: [370 nm, 1600 nm]
175
+
176
+ :param lambda0: wavelength [nm]
177
+ :type lambda0: float or np.ndarray
178
+
179
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
180
+ '''
181
+
182
+ return interp1d(np.array(iBCC_Salomatina_dataframe)[:,0],
183
+ np.array(iBCC_Salomatina_dataframe)[:,3],
184
+ bounds_error = False,
185
+ fill_value = (np.array(iBCC_Salomatina_dataframe)[0,3],
186
+ np.array(iBCC_Salomatina_dataframe)[-1,3]))(lambda0)
187
+
188
+ def rmus_nBCC_Salomatina(lambda0):
189
+ r'''
190
+ | The reduced scattering coefficient of NODULAR BASAL CELL CARCINOMA (nBCC)
191
+ | as a function of wavelength.
192
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
193
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
194
+
195
+ | wavelength range: [370 nm, 1600 nm]
196
+
197
+ :param lambda0: wavelength [nm]
198
+ :type lambda0: float or np.ndarray
199
+
200
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
201
+ '''
202
+
203
+ return interp1d(np.array(nBCC_Salomatina_dataframe)[:,0],
204
+ np.array(nBCC_Salomatina_dataframe)[:,3],
205
+ bounds_error = False,
206
+ fill_value = (np.array(nBCC_Salomatina_dataframe)[0,3],
207
+ np.array(nBCC_Salomatina_dataframe)[-1,3]))(lambda0)
208
+
209
+ def rmus_SCC_Salomatina(lambda0):
210
+ r'''
211
+ | The reduced scattering coefficient of SQUAMOUS CELL CARCINOMA (SCC)
212
+ | as a function of wavelength.
213
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
214
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
215
+
216
+ | wavelength range: [370 nm, 1600 nm]
217
+
218
+ :param lambda0: wavelength [nm]
219
+ :type lambda0: float or np.ndarray
220
+
221
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
222
+ '''
223
+
224
+ return interp1d(np.array(SCC_Salomatina_dataframe)[:,0],
225
+ np.array(SCC_Salomatina_dataframe)[:,3],
226
+ bounds_error = False,
227
+ fill_value = (np.array(SCC_Salomatina_dataframe)[0,3],
228
+ np.array(SCC_Salomatina_dataframe)[-1,3]))(lambda0)
229
+
230
+ def std_rmus_EP_Salomatina(lambda0):
231
+ r'''
232
+ | The standard deviation respective to :meth:`skinoptics.scattering_coefficient.rmus_EP_Salomatina`.
233
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
234
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
235
+
236
+ | wavelength range: [370 nm, 1600 nm]
237
+
238
+ :param lambda0: wavelength [nm]
239
+ :type lambda0: float or np.ndarray
240
+
241
+ :return: - **std_rmus** (*float or np.ndarray*) – standard deviation of the reduced scattering coefficient [mm^-1]
242
+ '''
243
+
244
+ return interp1d(np.array(EP_Salomatina_dataframe)[:,0],
245
+ np.array(EP_Salomatina_dataframe)[:,4],
246
+ bounds_error = False,
247
+ fill_value = (np.array(EP_Salomatina_dataframe)[0,4],
248
+ np.array(EP_Salomatina_dataframe)[-1,4]))(lambda0)
249
+
250
+ def std_rmus_DE_Salomatina(lambda0):
251
+ r'''
252
+ | The standard deviation respective to :meth:`skinoptics.scattering_coefficient.rmus_DE_Salomatina`.
253
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
254
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
255
+
256
+ | wavelength range: [370 nm, 1600 nm]
257
+
258
+ :param lambda0: wavelength [nm]
259
+ :type lambda0: float or np.ndarray
260
+
261
+ :return: - **std_rmus** (*float or np.ndarray*) – standard deviation of the reduced scattering coefficient [mm^-1]
262
+ '''
263
+
264
+ return interp1d(np.array(DE_Salomatina_dataframe)[:,0],
265
+ np.array(DE_Salomatina_dataframe)[:,4],
266
+ bounds_error = False,
267
+ fill_value = (np.array(DE_Salomatina_dataframe)[0,4],
268
+ np.array(DE_Salomatina_dataframe)[-1,4]))(lambda0)
269
+
270
+ def std_rmus_HY_Salomatina(lambda0):
271
+ r'''
272
+ | The standard deviation respective to :meth:`skinoptics.scattering_coefficient.rmus_HY_Salomatina`.
273
+ | Linear interpolation of experimental data from Salomatina et al. 2006 [S*06],
274
+ | publicly available at <https://sites.uml.edu/abl/optical-properties-2>.
275
+
276
+ | wavelength range: [370 nm, 1600 nm]
277
+
278
+ :param lambda0: wavelength [nm]
279
+ :type lambda0: float or np.ndarray
280
+
281
+ :return: - **std_rmus** (*float or np.ndarray*) – standard deviation of the reduced scattering coefficient [mm^-1]
282
+ '''
283
+
284
+ return interp1d(np.array(HY_Salomatina_dataframe)[:,0],
285
+ np.array(HY_Salomatina_dataframe)[:,4],
286
+ bounds_error = False,
287
+ fill_value = (np.array(HY_Salomatina_dataframe)[0,4],
288
+ np.array(HY_Salomatina_dataframe)[-1,4]))(lambda0)
289
+
290
+ def rmus_Ray(lambda0, A):
291
+ r'''
292
+ | The reduced scattering coefficient as a function of wavelength, Rayleigh scattering only.
293
+ | For details please check Jacques 2013 [J13].
294
+
295
+ :math:`\mu_s'(\lambda) = A \mbox{ } \lambda^{-4}`
296
+
297
+ :param lambda0: wavelength [nm]
298
+ :type lambda0: float or np.ndarray
299
+
300
+ :param A: parameter :math:`A` [mm^-1 nm^4] (must be nonnegative)
301
+ :type A: float
302
+
303
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
304
+ '''
305
+
306
+ if A < 0:
307
+ msg = 'The input A = {} is not valid.'.format(A)
308
+ raise Exception(msg)
309
+
310
+ return A*np.power(lambda0, -4, dtype = 'float64')
311
+
312
+ def rmus_Mie(lambda0, B, b):
313
+ r'''
314
+ | The reduced scattering coefficient as a function of wavelength, Mie scattering only.
315
+ | For details please check Jacques 2013 [J13].
316
+
317
+ :math:`\mu_s'(\lambda) = B \mbox{ } \lambda^{-b}`
318
+
319
+ :param lambda0: wavelength [nm]
320
+ :type lambda0: float or np.ndarray
321
+
322
+ :param B: parameter :math:`B` [mm^-1 nm^b] (must be nonnegative)
323
+ :type B: float
324
+
325
+ :param b: Mie scattering power [-] (must be nonnegative)
326
+ :type b: float
327
+
328
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
329
+ '''
330
+
331
+ if B < 0:
332
+ msg = 'The input B = {} is not valid.'.format(B)
333
+ raise Exception(msg)
334
+ if b < 0:
335
+ msg = 'The input b = {} is not valid.'.format(b)
336
+ raise Exception(msg)
337
+
338
+ return B*np.power(lambda0, -b, dtype = 'float64')
339
+
340
+ def rmus_Jacques(lambda0, a, f_Ray, b_Mie):
341
+ r'''
342
+ | The reduced scattering coefficient as a function of wavelength, assuming contributions from
343
+ | both Rayleigh and Mie scattering.
344
+ | For details please check Jacques 2013 [J13].
345
+
346
+ :math:`\mu_s'(\lambda) = a\left[f_{Ray} \mbox{ } \left(\frac{\lambda}{500}\right)^{-4} + (1-f_{Ray})\left(\frac{\lambda}{500}\right)^{-b_{Mie}} \right]`
347
+
348
+ :param lambda0: wavelength [nm]
349
+ :type lambda0: float or np.ndarray
350
+
351
+ :param a: parameter :math:`a` [mm^-1]
352
+ :type a: float
353
+
354
+ :param f_Ray: fraction of Rayleigh scattering contribution [-] (must be in the range [0, 1])
355
+ :type f_Ray: float
356
+
357
+ :param b_Mie: Mie scattering power [-] (must be nonnegative)
358
+ :type b_Mie: float
359
+
360
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
361
+ '''
362
+
363
+ if f_Ray < 0 or f_Ray > 1:
364
+ msg = 'The input f_Ray = {} is not valid.'.format(f_Ray)
365
+ raise Exception(msg)
366
+ if b_Mie < 0:
367
+ msg = 'The input b_Mie = {} is not valid.'.format(b_Mie)
368
+ raise Exception(msg)
369
+
370
+ return a*(rmus_Ray(lambda0 = lambda0/500., A = f_Ray) +
371
+ rmus_Mie(lambda0 = lambda0/500., B = (1 - f_Ray), b = b_Mie))
372
+
373
+ def rmus_Saidi(lambda0, A_Mie, B_Ray):
374
+ r'''
375
+ | The reduced scattering coefficient of NEONATAL SKIN as a function of wavelength.
376
+ | Saidi, Jacques & Tittel 1995 [SJT95] fit to their own experimental data.
377
+
378
+ :math:`\mu_s'(\lambda) = A_{Mie} \mbox{ (} 9.843 \times 10^{-7} \times \lambda^2 - 1.745 \times 10^{-3} \times \lambda + 1) + B_{Ray} \mbox{ } \lambda^{-4}`
379
+
380
+ | wavelength range: [450 nm, 750 nm]
381
+ | gestational ages between 19 and 52 weeks
382
+
383
+ :param lambda0: wavelength [nm]
384
+ :type lambda0: float or np.ndarray
385
+
386
+ :param A_Mie: parameter :math:`A_{Mie}` [mm^-1] (must be nonnegative)
387
+ :type A_Mie: float
388
+
389
+ :param B_Ray: parameter :math:`B_{Ray}` [mm^-1 nm^4] (must be nonnegative)
390
+ :type B_Ray: float
391
+
392
+ :return: - **rmus** (*float or np.ndarray*) – reduced scattering coefficient [mm^-1]
393
+ '''
394
+
395
+ if A_Mie < 0:
396
+ msg = 'The input A_Mie = {} is not valid.'.format(A_Mie)
397
+ raise Exception(msg)
398
+ if B_Ray < 0:
399
+ msg = 'The input B_Ray = {} is not valid.'.format(B_Ray)
400
+ raise Exception(msg)
401
+
402
+ return A_Mie*quadratic(x = lambda0, a = 9.843E-7, b = -1.745E-3, c = 1) + \
403
+ rmus_Ray(lambda0 = lambda0, A = B_Ray)