Skip to content

Commit 07324d7

Browse files
committed
1 parent e9718c2 commit 07324d7

122 files changed

Lines changed: 815 additions & 671 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/main/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 8dcaeebed6871cfbb1fb30cc8ec519e7
3+
config: 11b386b2106af7ff3baa6d66ce2982eb
44
tags: d77d1c0d9ca2f4c8421862c7c5a0d620
Binary file not shown.

docs/main/_downloads/19abb37e5abbed9bd2dd4b38aeb4ea74/phasorpy_multidimensional.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n# Multidimensional phasor approach\n\nSimultaneous phasor analysis of lifetime and spectral data.\n\nMultidimensional phasor analysis enables the correlation and classification\nof pixels based on multiple fluorescence characteristics simultaneously.\nThis approach combines phasor coordinates from different measurement domains\nto provide enhanced discrimination and identification of molecular species\nor cellular components that may appear similar in single-domain analysis.\n\nPhasor coordinates in one dimension can be mapped to other dimensions by masks\n(or cursors) that define regions of interest in the phasor space. The dimension\nwhere cursors are defined serves as the \"main\" dimension, controlling the\nclassification that is then applied to correlate with other dimensions.\n\nThis analysis method is demonstrated using a dataset combining fluorescence\nlifetime imaging microscopy (FLIM) and hyperspectral imaging (HSI) of LAURDAN\nfluorescence as presented in:\n\n Malacrida L, Jameson D, and Gratton E.\n A multidimensional phasor approach reveals LAURDAN photophysics in NIH-3T3\n cell membranes.\n *Sci Rep*, 7: 9215 (2017). https://doi.org/10.1038/s41598-017-08564-z\n\nThe dataset is available at https://zenodo.org/records/16894639.\n\nThe multidimensional analysis correlates FLIM phasor coordinates from two\ndetection channels with spectral phasor coordinates, enabling enhanced\nclassification of cellular regions based on both lifetime and spectral\nproperties of LAURDAN fluorescence.\n"
7+
"\n# Multidimensional phasor approach\n\nSimultaneous phasor analysis of lifetime and spectral data.\n\nMultidimensional phasor analysis enables the correlation and classification\nof pixels based on multiple fluorescence characteristics simultaneously.\nThis approach combines phasor coordinates from different measurement domains\nto provide enhanced discrimination and identification of molecular species\nor cellular components that may appear similar in single-domain analysis.\n\nPhasor coordinates in one dimension can be mapped to other dimensions by masks\n(or cursors) that define regions of interest in the phasor space. The dimension\nwhere cursors are defined serves as the \"main\" dimension, controlling the\nclassification that is then applied to correlate with other dimensions.\n\nThis analysis method is demonstrated using a dataset combining fluorescence\nlifetime imaging microscopy (FLIM) and hyperspectral imaging (HSI) of LAURDAN\nfluorescence as presented in:\n\n Malacrida L, Jameson D, and Gratton E.\n [A multidimensional phasor approach reveals LAURDAN photophysics in NIH-3T3\n cell membranes](https://doi.org/10.1038/s41598-017-08564-z).\n *Sci Rep*, 7: 9215 (2017).\n\nThe dataset is available at https://zenodo.org/records/16894639.\n\nThe multidimensional analysis correlates FLIM phasor coordinates from two\ndetection channels with spectral phasor coordinates, enabling enhanced\nclassification of cellular regions based on both lifetime and spectral\nproperties of LAURDAN fluorescence.\n"
88
]
99
},
1010
{
@@ -40,7 +40,7 @@
4040
},
4141
"outputs": [],
4242
"source": [
43-
"spectral_signal = signal_from_lsm(fetch('04 NIH3T3LAURDAN8meanspectra.lsm'))\n\nflim_signal = signal_from_fbd(\n fetch('04NIH3T3_LAURDAN_000$CC0Z.fbd'),\n frame=-1, # integrate all frames\n channel=None, # load all channels\n laser_factor=0.99168, # override incorrect metadata in FBD file\n)\n\nreference_signal = numpy.stack(\n [\n signal_from_fbd(\n fetch(f'cumarinech{ch}_780LAURDAN_000$CC0Z.fbd'),\n frame=-1,\n channel=ch - 1,\n laser_factor=0.99168,\n )\n for ch in (1, 2)\n ],\n)\n\nfrequency = flim_signal.attrs['frequency'] * flim_signal.attrs['harmonic']"
43+
"spectral_signal = signal_from_lsm(fetch('04 NIH3T3LAURDAN8meanspectra.lsm'))\n\nflim_signal = signal_from_fbd(\n fetch('04NIH3T3_LAURDAN_000$CC0Z.fbd'),\n frame=-1, # integrate all frames\n channel=None, # load all channels\n laser_factor=0.99168, # override incorrect metadata in FBD file\n)\n\nreference_signal = numpy.stack(\n [\n signal_from_fbd(\n fetch(f'cumarinech{ch + 1}_780LAURDAN_000$CC0Z.fbd'),\n frame=-1,\n channel=ch,\n laser_factor=0.99168,\n )\n for ch in (0, 1)\n ],\n)\n\nfrequency = flim_signal.attrs['frequency'] * flim_signal.attrs['harmonic']"
4444
]
4545
},
4646
{
@@ -94,7 +94,7 @@
9494
},
9595
"outputs": [],
9696
"source": [
97-
"plot_phasor(\n spectral_real,\n spectral_imag,\n xlim=(-0.5, 1.05),\n ylim=(-0.1, 1.05),\n allquadrants=True,\n title='Spectral phasor coordinates',\n)"
97+
"plot_phasor(\n spectral_real,\n spectral_imag,\n xlim=(-0.5, 1.05),\n ylim=(-0.1, 1.05),\n allquadrants=True,\n title='Spectral phasor',\n)"
9898
]
9999
},
100100
{
@@ -112,7 +112,7 @@
112112
},
113113
"outputs": [],
114114
"source": [
115-
"plot = PhasorPlot(frequency=frequency, title='FLIM phasor coordinates')\nplot.hist2d(flim_real[0], flim_imag[0], cmap='Blues')\nplot.hist2d(flim_real[1], flim_imag[1], cmap='Oranges', alpha=0.5)\nplot.show()"
115+
"fig, axs = pyplot.subplots(2, 1, figsize=(6.4, 9))\nfig.suptitle('FLIM phasor')\nfor ch in (0, 1):\n plot = PhasorPlot(\n ax=axs[ch], frequency=frequency, title=f'Channel {ch + 1}'\n )\n plot.hist2d(flim_real[ch], flim_imag[ch])\nfig.tight_layout()\nplot.show()"
116116
]
117117
},
118118
{
@@ -130,7 +130,7 @@
130130
},
131131
"outputs": [],
132132
"source": [
133-
"spectral_cursor_real = [0.04, 0.24, 0.14]\nspectral_cursor_imag = [0.74, 0.70, 0.72]\nspectral_cursor_radius = 0.05\n\nspectral_masks = mask_from_circular_cursor(\n spectral_real,\n spectral_imag,\n spectral_cursor_real,\n spectral_cursor_imag,\n radius=spectral_cursor_radius,\n)"
133+
"spectral_cursor_real = [0.04, 0.24, 0.14]\nspectral_cursor_imag = [0.74, 0.70, 0.72]\nspectral_cursor_radius = 0.05\n\nspectral_mask = mask_from_circular_cursor(\n spectral_real,\n spectral_imag,\n spectral_cursor_real,\n spectral_cursor_imag,\n radius=spectral_cursor_radius,\n)"
134134
]
135135
},
136136
{
@@ -148,7 +148,7 @@
148148
},
149149
"outputs": [],
150150
"source": [
151-
"plot = PhasorPlot(\n xlim=(-0.5, 1.05),\n ylim=(-0.1, 1.05),\n xticks=None,\n yticks=None,\n allquadrants=True,\n title='Spectral phasor and cursors',\n)\nplot.hist2d(\n spectral_real,\n spectral_imag,\n cmap='Grays',\n bins=200,\n)\nplot.cursor(\n spectral_cursor_real,\n spectral_cursor_imag,\n radius=spectral_cursor_radius,\n color=CATEGORICAL[:3],\n linestyle='-',\n linewidth=2,\n)\nplot.show()"
151+
"plot = PhasorPlot(\n xlim=(-0.5, 1.05),\n ylim=(-0.1, 1.05),\n xticks=None,\n yticks=None,\n allquadrants=True,\n title='Spectral phasor and cursors',\n)\nplot.hist2d(\n spectral_real,\n spectral_imag,\n cmap='Grays',\n bins=200,\n)\nplot.cursor(\n spectral_cursor_real,\n spectral_cursor_imag,\n radius=spectral_cursor_radius,\n color=CATEGORICAL[:3],\n linewidth=2,\n)\nplot.show()"
152152
]
153153
},
154154
{
@@ -166,7 +166,7 @@
166166
},
167167
"outputs": [],
168168
"source": [
169-
"spectral_pseudo_color = pseudo_color(*spectral_masks)\nplot_image(spectral_pseudo_color, title='Spectral pseudo-color image')"
169+
"spectral_pseudo_color = pseudo_color(*spectral_mask)\nplot_image(spectral_pseudo_color, title='Spectral pseudo-color image')"
170170
]
171171
},
172172
{
@@ -184,7 +184,7 @@
184184
},
185185
"outputs": [],
186186
"source": [
187-
"fig, axs = pyplot.subplots(2, 1, figsize=(6.4, 8))\nfig.suptitle('Spectral classified FLIM phasor')\n\nfor ch in range(2):\n plot = PhasorPlot(\n ax=axs[ch], frequency=frequency, title=f'Channel {ch + 1}'\n )\n for i in range(spectral_masks.shape[0]):\n plot.plot(\n flim_real[ch][spectral_masks[i]],\n flim_imag[ch][spectral_masks[i]],\n color=CATEGORICAL[i],\n alpha=0.05,\n markersize=0.5,\n )\nfig.tight_layout()\nplot.show()"
187+
"fig, axs = pyplot.subplots(2, 1, figsize=(6.4, 9))\nfig.suptitle('Spectral classified FLIM phasor')\n\nfor ch in (0, 1):\n plot = PhasorPlot(\n ax=axs[ch], frequency=frequency, title=f'Channel {ch + 1}'\n )\n for i in range(spectral_mask.shape[0]):\n plot.plot(\n flim_real[ch][spectral_mask[i]],\n flim_imag[ch][spectral_mask[i]],\n color=CATEGORICAL[i],\n alpha=0.05,\n markersize=0.5,\n )\nfig.tight_layout()\nplot.show()"
188188
]
189189
},
190190
{
@@ -202,7 +202,7 @@
202202
},
203203
"outputs": [],
204204
"source": [
205-
"flim_cursor_real = [0.35, 0.19, 0.27]\nflim_cursor_imag = [0.44, 0.38, 0.41]\nflim_cursor_radius = 0.05\n\nflim_ch1_masks = mask_from_circular_cursor(\n flim_real[0],\n flim_imag[0],\n flim_cursor_real,\n flim_cursor_imag,\n radius=flim_cursor_radius,\n)"
205+
"flim_cursor_real = [0.35, 0.19, 0.27]\nflim_cursor_imag = [0.44, 0.38, 0.41]\nflim_cursor_radius = 0.05\n\nflim_mask = mask_from_circular_cursor(\n flim_real[0],\n flim_imag[0],\n flim_cursor_real,\n flim_cursor_imag,\n radius=flim_cursor_radius,\n)"
206206
]
207207
},
208208
{
@@ -220,7 +220,7 @@
220220
},
221221
"outputs": [],
222222
"source": [
223-
"plot = PhasorPlot(\n frequency=frequency,\n title='FLIM phasor and cursors (first channel)',\n)\nplot.hist2d(flim_real[0], flim_imag[0], cmap='Grays', bins=200)\nplot.cursor(\n flim_cursor_real,\n flim_cursor_imag,\n radius=flim_cursor_radius,\n color=CATEGORICAL[:3],\n linestyle='-',\n linewidth=2,\n)\nplot.show()"
223+
"plot = PhasorPlot(\n frequency=frequency,\n title='FLIM phasor and cursors (first channel)',\n)\nplot.hist2d(flim_real[0], flim_imag[0], cmap='Grays', bins=200)\nplot.cursor(\n flim_cursor_real,\n flim_cursor_imag,\n radius=flim_cursor_radius,\n color=CATEGORICAL[:3],\n linewidth=2,\n)\nplot.show()"
224224
]
225225
},
226226
{
@@ -238,7 +238,7 @@
238238
},
239239
"outputs": [],
240240
"source": [
241-
"plot_image(\n pseudo_color(*flim_ch1_masks),\n title='FLIM pseudo-color image (first channel)',\n)"
241+
"plot_image(\n pseudo_color(*flim_mask), title='FLIM pseudo-color image (first channel)'\n)"
242242
]
243243
},
244244
{
@@ -256,7 +256,7 @@
256256
},
257257
"outputs": [],
258258
"source": [
259-
"plot = PhasorPlot(\n xlim=(-0.5, 1.05),\n ylim=(-0.1, 1.05),\n allquadrants=True,\n title='FLIM classified spectral phasor',\n)\n\nfor i in range(flim_ch1_masks.shape[0]):\n plot.plot(\n spectral_real[flim_ch1_masks[i]],\n spectral_imag[flim_ch1_masks[i]],\n color=CATEGORICAL[i],\n alpha=0.05,\n markersize=1,\n )\n\nplot.show()"
259+
"plot = PhasorPlot(\n xlim=(-0.5, 1.05),\n ylim=(-0.1, 1.05),\n allquadrants=True,\n title='FLIM classified spectral phasor',\n)\n\nfor i in range(flim_mask.shape[0]):\n plot.plot(\n spectral_real[flim_mask[i]],\n spectral_imag[flim_mask[i]],\n color=CATEGORICAL[i],\n alpha=0.05,\n markersize=1,\n )\n\nplot.show()"
260260
]
261261
},
262262
{
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/main/_downloads/3d4848bddcffa720ad46868dfbf9ab33/phasorpy_multidimensional.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
fluorescence as presented in:
2121
2222
Malacrida L, Jameson D, and Gratton E.
23-
A multidimensional phasor approach reveals LAURDAN photophysics in NIH-3T3
24-
cell membranes.
25-
*Sci Rep*, 7: 9215 (2017). https://doi.org/10.1038/s41598-017-08564-z
23+
`A multidimensional phasor approach reveals LAURDAN photophysics in NIH-3T3
24+
cell membranes <https://doi.org/10.1038/s41598-017-08564-z>`_.
25+
*Sci Rep*, 7: 9215 (2017).
2626
2727
The dataset is available at https://zenodo.org/records/16894639.
2828
@@ -73,12 +73,12 @@
7373
reference_signal = numpy.stack(
7474
[
7575
signal_from_fbd(
76-
fetch(f'cumarinech{ch}_780LAURDAN_000$CC0Z.fbd'),
76+
fetch(f'cumarinech{ch + 1}_780LAURDAN_000$CC0Z.fbd'),
7777
frame=-1,
78-
channel=ch - 1,
78+
channel=ch,
7979
laser_factor=0.99168,
8080
)
81-
for ch in (1, 2)
81+
for ch in (0, 1)
8282
],
8383
)
8484

@@ -141,15 +141,20 @@
141141
xlim=(-0.5, 1.05),
142142
ylim=(-0.1, 1.05),
143143
allquadrants=True,
144-
title='Spectral phasor coordinates',
144+
title='Spectral phasor',
145145
)
146146

147147
# %%
148148
# Plot the FLIM phasor coordinates of channel 1 (blue) and 2 (orange):
149149

150-
plot = PhasorPlot(frequency=frequency, title='FLIM phasor coordinates')
151-
plot.hist2d(flim_real[0], flim_imag[0], cmap='Blues')
152-
plot.hist2d(flim_real[1], flim_imag[1], cmap='Oranges', alpha=0.5)
150+
fig, axs = pyplot.subplots(2, 1, figsize=(6.4, 9))
151+
fig.suptitle('FLIM phasor')
152+
for ch in (0, 1):
153+
plot = PhasorPlot(
154+
ax=axs[ch], frequency=frequency, title=f'Channel {ch + 1}'
155+
)
156+
plot.hist2d(flim_real[ch], flim_imag[ch])
157+
fig.tight_layout()
153158
plot.show()
154159

155160
# %%
@@ -166,7 +171,7 @@
166171
spectral_cursor_imag = [0.74, 0.70, 0.72]
167172
spectral_cursor_radius = 0.05
168173

169-
spectral_masks = mask_from_circular_cursor(
174+
spectral_mask = mask_from_circular_cursor(
170175
spectral_real,
171176
spectral_imag,
172177
spectral_cursor_real,
@@ -196,7 +201,6 @@
196201
spectral_cursor_imag,
197202
radius=spectral_cursor_radius,
198203
color=CATEGORICAL[:3],
199-
linestyle='-',
200204
linewidth=2,
201205
)
202206
plot.show()
@@ -208,7 +212,7 @@
208212
# Create a pseudo-colored image where each pixel is colored according to
209213
# its spectral classification based on the main cursors:
210214

211-
spectral_pseudo_color = pseudo_color(*spectral_masks)
215+
spectral_pseudo_color = pseudo_color(*spectral_mask)
212216
plot_image(spectral_pseudo_color, title='Spectral pseudo-color image')
213217

214218
# %%
@@ -221,17 +225,17 @@
221225
# the FLIM phasor space and reveals the correlation between spectral and
222226
# lifetime characteristics:
223227

224-
fig, axs = pyplot.subplots(2, 1, figsize=(6.4, 8))
228+
fig, axs = pyplot.subplots(2, 1, figsize=(6.4, 9))
225229
fig.suptitle('Spectral classified FLIM phasor')
226230

227-
for ch in range(2):
231+
for ch in (0, 1):
228232
plot = PhasorPlot(
229233
ax=axs[ch], frequency=frequency, title=f'Channel {ch + 1}'
230234
)
231-
for i in range(spectral_masks.shape[0]):
235+
for i in range(spectral_mask.shape[0]):
232236
plot.plot(
233-
flim_real[ch][spectral_masks[i]],
234-
flim_imag[ch][spectral_masks[i]],
237+
flim_real[ch][spectral_mask[i]],
238+
flim_imag[ch][spectral_mask[i]],
235239
color=CATEGORICAL[i],
236240
alpha=0.05,
237241
markersize=0.5,
@@ -253,7 +257,7 @@
253257
flim_cursor_imag = [0.44, 0.38, 0.41]
254258
flim_cursor_radius = 0.05
255259

256-
flim_ch1_masks = mask_from_circular_cursor(
260+
flim_mask = mask_from_circular_cursor(
257261
flim_real[0],
258262
flim_imag[0],
259263
flim_cursor_real,
@@ -274,7 +278,6 @@
274278
flim_cursor_imag,
275279
radius=flim_cursor_radius,
276280
color=CATEGORICAL[:3],
277-
linestyle='-',
278281
linewidth=2,
279282
)
280283
plot.show()
@@ -283,8 +286,7 @@
283286
# Display the FLIM pseudo-color image:
284287

285288
plot_image(
286-
pseudo_color(*flim_ch1_masks),
287-
title='FLIM pseudo-color image (first channel)',
289+
pseudo_color(*flim_mask), title='FLIM pseudo-color image (first channel)'
288290
)
289291

290292
# %%
@@ -297,10 +299,10 @@
297299
title='FLIM classified spectral phasor',
298300
)
299301

300-
for i in range(flim_ch1_masks.shape[0]):
302+
for i in range(flim_mask.shape[0]):
301303
plot.plot(
302-
spectral_real[flim_ch1_masks[i]],
303-
spectral_imag[flim_ch1_masks[i]],
304+
spectral_real[flim_mask[i]],
305+
spectral_imag[flim_mask[i]],
304306
color=CATEGORICAL[i],
305307
alpha=0.05,
306308
markersize=1,

docs/main/_downloads/41595418bc794ed8aa60b368b9005d1e/phasorpy_component_fit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
containing five fluorescent markers as presented in:
1717
1818
Vallmitjana A, Lepanto P, Irigoin F, and Malacrida L.
19-
Phasor-based multi-harmonic unmixing for in-vivo hyperspectral imaging.
19+
`Phasor-based multi-harmonic unmixing for in-vivo hyperspectral imaging
20+
<https://doi.org/10.1088/2050-6120/ac9ae9>`_.
2021
*Methods Appl Fluoresc*, 11(1): 014001 (2022).
2122
2223
The dataset is available at https://zenodo.org/records/13625087.

docs/main/_downloads/48468d09fb73a61a0aaeafe78be9fd74/phasorpy_component_fit.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n# Multi-component fit\n\nSpectral unmixing using multi-component analysis in phasor space.\n\nFluorescent components in a fluorescence spectrum can be unmixed\nif the spectra of the individual components are known.\nThis can be achieved by solving a system of linear equations that fits\nthe fractional contributions of the phasor coordinates of the component\nspectra to the phasor coordinates of the mixture spectrum.\nPhasor coordinates at multiple harmonics may be used to ensure the\nlinear system is not underdetermined.\n\nThis analysis method is demonstrated using a hyperspectral imaging dataset\ncontaining five fluorescent markers as presented in:\n\n Vallmitjana A, Lepanto P, Irigoin F, and Malacrida L.\n Phasor-based multi-harmonic unmixing for in-vivo hyperspectral imaging.\n *Methods Appl Fluoresc*, 11(1): 014001 (2022).\n\nThe dataset is available at https://zenodo.org/records/13625087.\n\nThe spectral unmixing of the five components is performed using phasor\ncoordinates at two harmonics.\n"
7+
"\n# Multi-component fit\n\nSpectral unmixing using multi-component analysis in phasor space.\n\nFluorescent components in a fluorescence spectrum can be unmixed\nif the spectra of the individual components are known.\nThis can be achieved by solving a system of linear equations that fits\nthe fractional contributions of the phasor coordinates of the component\nspectra to the phasor coordinates of the mixture spectrum.\nPhasor coordinates at multiple harmonics may be used to ensure the\nlinear system is not underdetermined.\n\nThis analysis method is demonstrated using a hyperspectral imaging dataset\ncontaining five fluorescent markers as presented in:\n\n Vallmitjana A, Lepanto P, Irigoin F, and Malacrida L.\n [Phasor-based multi-harmonic unmixing for in-vivo hyperspectral imaging](https://doi.org/10.1088/2050-6120/ac9ae9).\n *Methods Appl Fluoresc*, 11(1): 014001 (2022).\n\nThe dataset is available at https://zenodo.org/records/13625087.\n\nThe spectral unmixing of the five components is performed using phasor\ncoordinates at two harmonics.\n"
88
]
99
},
1010
{

0 commit comments

Comments
 (0)