scitex 2.7.0__py3-none-any.whl → 2.7.3__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.
- scitex/__init__.py +6 -2
- scitex/__version__.py +1 -1
- scitex/audio/README.md +52 -0
- scitex/audio/__init__.py +384 -0
- scitex/audio/__main__.py +129 -0
- scitex/audio/_tts.py +334 -0
- scitex/audio/engines/__init__.py +44 -0
- scitex/audio/engines/base.py +275 -0
- scitex/audio/engines/elevenlabs_engine.py +143 -0
- scitex/audio/engines/gtts_engine.py +162 -0
- scitex/audio/engines/pyttsx3_engine.py +131 -0
- scitex/audio/mcp_server.py +757 -0
- scitex/bridge/_helpers.py +1 -1
- scitex/bridge/_plt_vis.py +1 -1
- scitex/bridge/_stats_vis.py +1 -1
- scitex/dev/plt/__init__.py +272 -0
- scitex/dev/plt/plot_mpl_axhline.py +28 -0
- scitex/dev/plt/plot_mpl_axhspan.py +28 -0
- scitex/dev/plt/plot_mpl_axvline.py +28 -0
- scitex/dev/plt/plot_mpl_axvspan.py +28 -0
- scitex/dev/plt/plot_mpl_bar.py +29 -0
- scitex/dev/plt/plot_mpl_barh.py +29 -0
- scitex/dev/plt/plot_mpl_boxplot.py +28 -0
- scitex/dev/plt/plot_mpl_contour.py +31 -0
- scitex/dev/plt/plot_mpl_contourf.py +31 -0
- scitex/dev/plt/plot_mpl_errorbar.py +30 -0
- scitex/dev/plt/plot_mpl_eventplot.py +28 -0
- scitex/dev/plt/plot_mpl_fill.py +30 -0
- scitex/dev/plt/plot_mpl_fill_between.py +31 -0
- scitex/dev/plt/plot_mpl_hexbin.py +28 -0
- scitex/dev/plt/plot_mpl_hist.py +28 -0
- scitex/dev/plt/plot_mpl_hist2d.py +28 -0
- scitex/dev/plt/plot_mpl_imshow.py +29 -0
- scitex/dev/plt/plot_mpl_pcolormesh.py +31 -0
- scitex/dev/plt/plot_mpl_pie.py +29 -0
- scitex/dev/plt/plot_mpl_plot.py +29 -0
- scitex/dev/plt/plot_mpl_quiver.py +31 -0
- scitex/dev/plt/plot_mpl_scatter.py +28 -0
- scitex/dev/plt/plot_mpl_stackplot.py +31 -0
- scitex/dev/plt/plot_mpl_stem.py +29 -0
- scitex/dev/plt/plot_mpl_step.py +29 -0
- scitex/dev/plt/plot_mpl_violinplot.py +28 -0
- scitex/dev/plt/plot_sns_barplot.py +29 -0
- scitex/dev/plt/plot_sns_boxplot.py +29 -0
- scitex/dev/plt/plot_sns_heatmap.py +28 -0
- scitex/dev/plt/plot_sns_histplot.py +29 -0
- scitex/dev/plt/plot_sns_kdeplot.py +29 -0
- scitex/dev/plt/plot_sns_lineplot.py +31 -0
- scitex/dev/plt/plot_sns_scatterplot.py +29 -0
- scitex/dev/plt/plot_sns_stripplot.py +29 -0
- scitex/dev/plt/plot_sns_swarmplot.py +29 -0
- scitex/dev/plt/plot_sns_violinplot.py +29 -0
- scitex/dev/plt/plot_stx_bar.py +29 -0
- scitex/dev/plt/plot_stx_barh.py +29 -0
- scitex/dev/plt/plot_stx_box.py +28 -0
- scitex/dev/plt/plot_stx_boxplot.py +28 -0
- scitex/dev/plt/plot_stx_conf_mat.py +28 -0
- scitex/dev/plt/plot_stx_contour.py +31 -0
- scitex/dev/plt/plot_stx_ecdf.py +28 -0
- scitex/dev/plt/plot_stx_errorbar.py +30 -0
- scitex/dev/plt/plot_stx_fill_between.py +31 -0
- scitex/dev/plt/plot_stx_fillv.py +28 -0
- scitex/dev/plt/plot_stx_heatmap.py +28 -0
- scitex/dev/plt/plot_stx_image.py +28 -0
- scitex/dev/plt/plot_stx_imshow.py +28 -0
- scitex/dev/plt/plot_stx_joyplot.py +28 -0
- scitex/dev/plt/plot_stx_kde.py +28 -0
- scitex/dev/plt/plot_stx_line.py +28 -0
- scitex/dev/plt/plot_stx_mean_ci.py +28 -0
- scitex/dev/plt/plot_stx_mean_std.py +28 -0
- scitex/dev/plt/plot_stx_median_iqr.py +28 -0
- scitex/dev/plt/plot_stx_raster.py +28 -0
- scitex/dev/plt/plot_stx_rectangle.py +28 -0
- scitex/dev/plt/plot_stx_scatter.py +29 -0
- scitex/dev/plt/plot_stx_shaded_line.py +29 -0
- scitex/dev/plt/plot_stx_violin.py +28 -0
- scitex/dev/plt/plot_stx_violinplot.py +28 -0
- scitex/fig/__init__.py +352 -0
- scitex/{vis → fig}/backend/_parser.py +1 -1
- scitex/{vis → fig}/canvas.py +1 -1
- scitex/{vis → fig}/editor/_defaults.py +70 -5
- scitex/fig/editor/_edit.py +751 -0
- scitex/{vis → fig}/editor/_qt_editor.py +181 -1
- scitex/fig/editor/flask_editor/_bbox.py +1276 -0
- scitex/fig/editor/flask_editor/_core.py +624 -0
- scitex/{vis → fig}/editor/flask_editor/_plotter.py +38 -4
- scitex/fig/editor/flask_editor/_renderer.py +739 -0
- scitex/{vis → fig}/editor/flask_editor/templates/__init__.py +1 -1
- scitex/fig/editor/flask_editor/templates/_html.py +834 -0
- scitex/fig/editor/flask_editor/templates/_scripts.py +3136 -0
- scitex/{vis → fig}/editor/flask_editor/templates/_styles.py +625 -18
- scitex/{vis → fig}/io/__init__.py +13 -1
- scitex/fig/io/_bundle.py +973 -0
- scitex/{vis → fig}/io/_canvas.py +1 -1
- scitex/{vis → fig}/io/_data.py +1 -1
- scitex/{vis → fig}/io/_export.py +1 -1
- scitex/{vis → fig}/io/_load.py +1 -1
- scitex/{vis → fig}/io/_panel.py +1 -1
- scitex/{vis → fig}/io/_save.py +1 -1
- scitex/{vis → fig}/model/__init__.py +1 -1
- scitex/{vis → fig}/model/_annotations.py +1 -1
- scitex/{vis → fig}/model/_axes.py +1 -1
- scitex/{vis → fig}/model/_figure.py +1 -1
- scitex/{vis → fig}/model/_guides.py +1 -1
- scitex/{vis → fig}/model/_plot.py +1 -1
- scitex/{vis → fig}/model/_styles.py +1 -1
- scitex/{vis → fig}/utils/__init__.py +1 -1
- scitex/io/__init__.py +10 -26
- scitex/io/_bundle.py +434 -0
- scitex/io/_flush.py +5 -2
- scitex/io/_load.py +98 -0
- scitex/io/_load_modules/_H5Explorer.py +5 -2
- scitex/io/_load_modules/_canvas.py +2 -2
- scitex/io/_load_modules/_image.py +3 -4
- scitex/io/_load_modules/_txt.py +4 -2
- scitex/io/_metadata.py +34 -324
- scitex/io/_metadata_modules/__init__.py +46 -0
- scitex/io/_metadata_modules/_embed.py +70 -0
- scitex/io/_metadata_modules/_read.py +64 -0
- scitex/io/_metadata_modules/_utils.py +79 -0
- scitex/io/_metadata_modules/embed_metadata_jpeg.py +74 -0
- scitex/io/_metadata_modules/embed_metadata_pdf.py +53 -0
- scitex/io/_metadata_modules/embed_metadata_png.py +26 -0
- scitex/io/_metadata_modules/embed_metadata_svg.py +62 -0
- scitex/io/_metadata_modules/read_metadata_jpeg.py +57 -0
- scitex/io/_metadata_modules/read_metadata_pdf.py +51 -0
- scitex/io/_metadata_modules/read_metadata_png.py +39 -0
- scitex/io/_metadata_modules/read_metadata_svg.py +44 -0
- scitex/io/_qr_utils.py +5 -3
- scitex/io/_save.py +548 -30
- scitex/io/_save_modules/_canvas.py +3 -3
- scitex/io/_save_modules/_image.py +5 -9
- scitex/io/_save_modules/_tex.py +7 -4
- scitex/io/utils/h5_to_zarr.py +11 -9
- scitex/msword/__init__.py +255 -0
- scitex/msword/profiles.py +357 -0
- scitex/msword/reader.py +753 -0
- scitex/msword/utils.py +289 -0
- scitex/msword/writer.py +362 -0
- scitex/plt/__init__.py +5 -2
- scitex/plt/_subplots/_AxesWrapper.py +6 -6
- scitex/plt/_subplots/_AxisWrapper.py +15 -9
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/__init__.py +36 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/_labels.py +264 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/_metadata.py +213 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/_visual.py +128 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/__init__.py +59 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_base.py +34 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_scientific.py +593 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_statistical.py +654 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_stx_aliases.py +527 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_RawMatplotlibMixin.py +321 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/__init__.py +33 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/_base.py +152 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/_wrappers.py +600 -0
- scitex/plt/_subplots/_AxisWrapperMixins/__init__.py +79 -5
- scitex/plt/_subplots/_FigWrapper.py +6 -6
- scitex/plt/_subplots/_SubplotsWrapper.py +28 -18
- scitex/plt/_subplots/_export_as_csv.py +35 -5
- scitex/plt/_subplots/_export_as_csv_formatters/__init__.py +8 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_annotate.py +10 -21
- scitex/plt/_subplots/_export_as_csv_formatters/_format_eventplot.py +18 -7
- scitex/plt/_subplots/_export_as_csv_formatters/_format_imshow2d.py +28 -12
- scitex/plt/_subplots/_export_as_csv_formatters/_format_matshow.py +10 -4
- scitex/plt/_subplots/_export_as_csv_formatters/_format_plot_imshow.py +13 -1
- scitex/plt/_subplots/_export_as_csv_formatters/_format_plot_kde.py +12 -2
- scitex/plt/_subplots/_export_as_csv_formatters/_format_plot_scatter.py +10 -3
- scitex/plt/_subplots/_export_as_csv_formatters/_format_quiver.py +10 -4
- scitex/plt/_subplots/_export_as_csv_formatters/_format_sns_jointplot.py +18 -3
- scitex/plt/_subplots/_export_as_csv_formatters/_format_sns_lineplot.py +44 -36
- scitex/plt/_subplots/_export_as_csv_formatters/_format_sns_pairplot.py +14 -2
- scitex/plt/_subplots/_export_as_csv_formatters/_format_streamplot.py +11 -5
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_bar.py +84 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_barh.py +85 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_conf_mat.py +14 -3
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_contour.py +54 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_ecdf.py +14 -2
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_errorbar.py +120 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_heatmap.py +16 -6
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_image.py +29 -19
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_imshow.py +63 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_joyplot.py +22 -5
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_mean_ci.py +18 -14
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_mean_std.py +18 -14
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_median_iqr.py +18 -14
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_raster.py +10 -2
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_scatter.py +51 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_scatter_hist.py +18 -9
- scitex/plt/ax/_plot/_stx_ecdf.py +4 -2
- scitex/plt/gallery/_generate.py +421 -14
- scitex/plt/io/__init__.py +53 -0
- scitex/plt/io/_bundle.py +490 -0
- scitex/plt/io/_layered_bundle.py +1343 -0
- scitex/plt/styles/SCITEX_STYLE.yaml +26 -0
- scitex/plt/styles/__init__.py +14 -0
- scitex/plt/styles/presets.py +78 -0
- scitex/plt/utils/__init__.py +13 -1
- scitex/plt/utils/_collect_figure_metadata.py +10 -14
- scitex/plt/utils/_configure_mpl.py +6 -18
- scitex/plt/utils/_crop.py +32 -14
- scitex/plt/utils/_csv_column_naming.py +54 -0
- scitex/plt/utils/_figure_mm.py +116 -1
- scitex/plt/utils/_hitmap.py +1643 -0
- scitex/plt/utils/metadata/__init__.py +25 -0
- scitex/plt/utils/metadata/_core.py +9 -10
- scitex/plt/utils/metadata/_dimensions.py +6 -3
- scitex/plt/utils/metadata/_editable_export.py +405 -0
- scitex/plt/utils/metadata/_geometry_extraction.py +570 -0
- scitex/schema/__init__.py +109 -16
- scitex/schema/_canvas.py +1 -1
- scitex/schema/_plot.py +1015 -0
- scitex/schema/_stats.py +2 -2
- scitex/stats/__init__.py +117 -0
- scitex/stats/io/__init__.py +29 -0
- scitex/stats/io/_bundle.py +156 -0
- scitex/tex/__init__.py +4 -0
- scitex/tex/_export.py +890 -0
- {scitex-2.7.0.dist-info → scitex-2.7.3.dist-info}/METADATA +11 -1
- {scitex-2.7.0.dist-info → scitex-2.7.3.dist-info}/RECORD +238 -170
- scitex/io/memo.md +0 -2827
- scitex/plt/REQUESTS.md +0 -191
- scitex/plt/_subplots/TODO.md +0 -53
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin.py +0 -559
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin.py +0 -1609
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin.py +0 -447
- scitex/plt/templates/research-master/scitex/vis/gallery/area/fill_between.json +0 -110
- scitex/plt/templates/research-master/scitex/vis/gallery/area/fill_betweenx.json +0 -88
- scitex/plt/templates/research-master/scitex/vis/gallery/area/stx_fill_between.json +0 -103
- scitex/plt/templates/research-master/scitex/vis/gallery/area/stx_fillv.json +0 -106
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/bar.json +0 -92
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/barh.json +0 -92
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/boxplot.json +0 -92
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/stx_bar.json +0 -84
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/stx_barh.json +0 -84
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/stx_box.json +0 -83
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/stx_boxplot.json +0 -93
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/stx_violin.json +0 -91
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/stx_violinplot.json +0 -91
- scitex/plt/templates/research-master/scitex/vis/gallery/categorical/violinplot.json +0 -91
- scitex/plt/templates/research-master/scitex/vis/gallery/contour/contour.json +0 -97
- scitex/plt/templates/research-master/scitex/vis/gallery/contour/contourf.json +0 -98
- scitex/plt/templates/research-master/scitex/vis/gallery/contour/stx_contour.json +0 -84
- scitex/plt/templates/research-master/scitex/vis/gallery/distribution/hist.json +0 -101
- scitex/plt/templates/research-master/scitex/vis/gallery/distribution/hist2d.json +0 -96
- scitex/plt/templates/research-master/scitex/vis/gallery/distribution/stx_ecdf.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/distribution/stx_joyplot.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/distribution/stx_kde.json +0 -93
- scitex/plt/templates/research-master/scitex/vis/gallery/grid/imshow.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/grid/matshow.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/grid/stx_conf_mat.json +0 -83
- scitex/plt/templates/research-master/scitex/vis/gallery/grid/stx_heatmap.json +0 -92
- scitex/plt/templates/research-master/scitex/vis/gallery/grid/stx_image.json +0 -121
- scitex/plt/templates/research-master/scitex/vis/gallery/grid/stx_imshow.json +0 -84
- scitex/plt/templates/research-master/scitex/vis/gallery/line/plot.json +0 -110
- scitex/plt/templates/research-master/scitex/vis/gallery/line/step.json +0 -92
- scitex/plt/templates/research-master/scitex/vis/gallery/line/stx_line.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/line/stx_shaded_line.json +0 -96
- scitex/plt/templates/research-master/scitex/vis/gallery/scatter/hexbin.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/scatter/scatter.json +0 -95
- scitex/plt/templates/research-master/scitex/vis/gallery/scatter/stem.json +0 -92
- scitex/plt/templates/research-master/scitex/vis/gallery/scatter/stx_scatter.json +0 -84
- scitex/plt/templates/research-master/scitex/vis/gallery/special/pie.json +0 -94
- scitex/plt/templates/research-master/scitex/vis/gallery/special/stx_raster.json +0 -109
- scitex/plt/templates/research-master/scitex/vis/gallery/special/stx_rectangle.json +0 -108
- scitex/plt/templates/research-master/scitex/vis/gallery/statistical/errorbar.json +0 -93
- scitex/plt/templates/research-master/scitex/vis/gallery/statistical/stx_errorbar.json +0 -84
- scitex/plt/templates/research-master/scitex/vis/gallery/statistical/stx_mean_ci.json +0 -96
- scitex/plt/templates/research-master/scitex/vis/gallery/statistical/stx_mean_std.json +0 -96
- scitex/plt/templates/research-master/scitex/vis/gallery/statistical/stx_median_iqr.json +0 -96
- scitex/plt/templates/research-master/scitex/vis/gallery/vector/quiver.json +0 -99
- scitex/plt/templates/research-master/scitex/vis/gallery/vector/streamplot.json +0 -100
- scitex/vis/__init__.py +0 -177
- scitex/vis/editor/_edit.py +0 -390
- scitex/vis/editor/flask_editor/_bbox.py +0 -529
- scitex/vis/editor/flask_editor/_core.py +0 -168
- scitex/vis/editor/flask_editor/_renderer.py +0 -393
- scitex/vis/editor/flask_editor/templates/_html.py +0 -513
- scitex/vis/editor/flask_editor/templates/_scripts.py +0 -1261
- /scitex/{vis → fig}/README.md +0 -0
- /scitex/{vis → fig}/backend/__init__.py +0 -0
- /scitex/{vis → fig}/backend/_export.py +0 -0
- /scitex/{vis → fig}/backend/_render.py +0 -0
- /scitex/{vis → fig}/docs/CANVAS_ARCHITECTURE.md +0 -0
- /scitex/{vis → fig}/editor/__init__.py +0 -0
- /scitex/{vis → fig}/editor/_dearpygui_editor.py +0 -0
- /scitex/{vis → fig}/editor/_flask_editor.py +0 -0
- /scitex/{vis → fig}/editor/_mpl_editor.py +0 -0
- /scitex/{vis → fig}/editor/_tkinter_editor.py +0 -0
- /scitex/{vis → fig}/editor/flask_editor/__init__.py +0 -0
- /scitex/{vis → fig}/editor/flask_editor/_utils.py +0 -0
- /scitex/{vis → fig}/io/_directory.py +0 -0
- /scitex/{vis → fig}/model/_plot_types.py +0 -0
- /scitex/{vis → fig}/utils/_defaults.py +0 -0
- /scitex/{vis → fig}/utils/_validate.py +0 -0
- {scitex-2.7.0.dist-info → scitex-2.7.3.dist-info}/WHEEL +0 -0
- {scitex-2.7.0.dist-info → scitex-2.7.3.dist-info}/entry_points.txt +0 -0
- {scitex-2.7.0.dist-info → scitex-2.7.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,6 +12,9 @@ __DIR__ = os.path.dirname(__FILE__)
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pandas as pd
|
|
14
14
|
|
|
15
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
16
|
+
from ._format_plot import _parse_tracking_id
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
def _format_plot_heatmap(id, tracked_dict, kwargs):
|
|
17
20
|
"""Format data from a stx_heatmap call.
|
|
@@ -39,12 +42,15 @@ def _format_plot_heatmap(id, tracked_dict, kwargs):
|
|
|
39
42
|
rows, cols = data.shape
|
|
40
43
|
row_indices, col_indices = np.meshgrid(range(rows), range(cols), indexing="ij")
|
|
41
44
|
|
|
42
|
-
#
|
|
45
|
+
# Parse the tracking ID to get axes position and trace ID
|
|
46
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
47
|
+
|
|
48
|
+
# Format data in xyz format (x, y, value) using single source of truth
|
|
43
49
|
df = pd.DataFrame(
|
|
44
50
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
get_csv_column_name("x", ax_row, ax_col, trace_id=trace_id): col_indices.flatten(), # x is column
|
|
52
|
+
get_csv_column_name("y", ax_row, ax_col, trace_id=trace_id): row_indices.flatten(), # y is row
|
|
53
|
+
get_csv_column_name("value", ax_row, ax_col, trace_id=trace_id): data.flatten(), # z is intensity/value
|
|
48
54
|
}
|
|
49
55
|
)
|
|
50
56
|
|
|
@@ -52,12 +58,16 @@ def _format_plot_heatmap(id, tracked_dict, kwargs):
|
|
|
52
58
|
if x_labels is not None and len(x_labels) == cols:
|
|
53
59
|
# Map column indices to x labels (columns are x)
|
|
54
60
|
x_label_map = {i: label for i, label in enumerate(x_labels)}
|
|
55
|
-
|
|
61
|
+
x_col_name = get_csv_column_name("x", ax_row, ax_col, trace_id=trace_id)
|
|
62
|
+
x_label_col_name = get_csv_column_name("x_label", ax_row, ax_col, trace_id=trace_id)
|
|
63
|
+
df[x_label_col_name] = df[x_col_name].map(x_label_map)
|
|
56
64
|
|
|
57
65
|
if y_labels is not None and len(y_labels) == rows:
|
|
58
66
|
# Map row indices to y labels (rows are y)
|
|
59
67
|
y_label_map = {i: label for i, label in enumerate(y_labels)}
|
|
60
|
-
|
|
68
|
+
y_col_name = get_csv_column_name("y", ax_row, ax_col, trace_id=trace_id)
|
|
69
|
+
y_label_col_name = get_csv_column_name("y_label", ax_row, ax_col, trace_id=trace_id)
|
|
70
|
+
df[y_label_col_name] = df[y_col_name].map(y_label_map)
|
|
61
71
|
|
|
62
72
|
return df
|
|
63
73
|
|
|
@@ -7,6 +7,9 @@ import os
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import pandas as pd
|
|
9
9
|
|
|
10
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
11
|
+
from ._format_plot import _parse_tracking_id
|
|
12
|
+
|
|
10
13
|
__FILE__ = __file__
|
|
11
14
|
__DIR__ = os.path.dirname(__FILE__)
|
|
12
15
|
# ----------------------------------------
|
|
@@ -30,6 +33,9 @@ def _format_plot_image(id, tracked_dict, kwargs):
|
|
|
30
33
|
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
31
34
|
return pd.DataFrame()
|
|
32
35
|
|
|
36
|
+
# Parse the tracking ID to get axes position and trace ID
|
|
37
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
38
|
+
|
|
33
39
|
# Check if image_df is available and use it if present
|
|
34
40
|
if "image_df" in tracked_dict:
|
|
35
41
|
image_df = tracked_dict.get("image_df")
|
|
@@ -37,19 +43,20 @@ def _format_plot_image(id, tracked_dict, kwargs):
|
|
|
37
43
|
# Add prefix if ID is provided
|
|
38
44
|
if id is not None:
|
|
39
45
|
image_df = image_df.copy()
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
# Rename columns using single source of truth
|
|
47
|
+
renamed = {}
|
|
48
|
+
for col in image_df.columns:
|
|
49
|
+
# Convert to string to handle integer column names
|
|
50
|
+
col_str = str(col)
|
|
51
|
+
renamed[col] = get_csv_column_name(
|
|
52
|
+
col_str, ax_row, ax_col, trace_id=trace_id
|
|
53
|
+
)
|
|
54
|
+
image_df = image_df.rename(columns=renamed)
|
|
47
55
|
return image_df
|
|
48
56
|
|
|
49
57
|
# If we have image data
|
|
50
58
|
if "image" in tracked_dict:
|
|
51
59
|
img = tracked_dict["image"]
|
|
52
|
-
id_str = str(id) if id is not None else "image"
|
|
53
60
|
|
|
54
61
|
# Handle 2D grayscale images - create xyz format (x, y, value)
|
|
55
62
|
if isinstance(img, np.ndarray) and img.ndim == 2:
|
|
@@ -58,12 +65,12 @@ def _format_plot_image(id, tracked_dict, kwargs):
|
|
|
58
65
|
range(rows), range(cols), indexing="ij"
|
|
59
66
|
)
|
|
60
67
|
|
|
61
|
-
# Create xyz format
|
|
68
|
+
# Create xyz format using single source of truth
|
|
62
69
|
df = pd.DataFrame(
|
|
63
70
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
get_csv_column_name("x", ax_row, ax_col, trace_id=trace_id): col_indices.flatten(), # x is column
|
|
72
|
+
get_csv_column_name("y", ax_row, ax_col, trace_id=trace_id): row_indices.flatten(), # y is row
|
|
73
|
+
get_csv_column_name("value", ax_row, ax_col, trace_id=trace_id): img.flatten(), # z is intensity
|
|
67
74
|
}
|
|
68
75
|
)
|
|
69
76
|
return df
|
|
@@ -71,24 +78,27 @@ def _format_plot_image(id, tracked_dict, kwargs):
|
|
|
71
78
|
# Handle RGB/RGBA images - create xyz format with additional channel information
|
|
72
79
|
elif isinstance(img, np.ndarray) and img.ndim == 3:
|
|
73
80
|
rows, cols, channels = img.shape
|
|
74
|
-
row_indices, col_indices = np.meshgrid(
|
|
75
|
-
range(rows), range(cols), indexing="ij"
|
|
76
|
-
)
|
|
77
81
|
|
|
78
82
|
# Create a list to hold rows for a long-format DataFrame
|
|
79
83
|
data_rows = []
|
|
80
84
|
channel_names = ["r", "g", "b", "a"]
|
|
81
85
|
|
|
86
|
+
# Get column names using single source of truth
|
|
87
|
+
x_col = get_csv_column_name("x", ax_row, ax_col, trace_id=trace_id)
|
|
88
|
+
y_col = get_csv_column_name("y", ax_row, ax_col, trace_id=trace_id)
|
|
89
|
+
channel_col = get_csv_column_name("channel", ax_row, ax_col, trace_id=trace_id)
|
|
90
|
+
value_col = get_csv_column_name("value", ax_row, ax_col, trace_id=trace_id)
|
|
91
|
+
|
|
82
92
|
# Create long-format data (x, y, channel, value)
|
|
83
93
|
for r in range(rows):
|
|
84
94
|
for c in range(cols):
|
|
85
95
|
for ch in range(min(channels, len(channel_names))):
|
|
86
96
|
data_rows.append(
|
|
87
97
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
x_col: c, # x is column
|
|
99
|
+
y_col: r, # y is row
|
|
100
|
+
channel_col: channel_names[ch], # channel name
|
|
101
|
+
value_col: img[r, c, ch], # channel value
|
|
92
102
|
}
|
|
93
103
|
)
|
|
94
104
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""CSV formatter for stx_imshow() calls."""
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import pandas as pd
|
|
7
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
8
|
+
from ._format_plot import _parse_tracking_id
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _format_stx_imshow(id, tracked_dict, kwargs):
|
|
12
|
+
"""Format data from stx_imshow call for CSV export.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
id : str
|
|
17
|
+
Identifier for the plot
|
|
18
|
+
tracked_dict : dict
|
|
19
|
+
Dictionary containing tracked data with 'imshow_df'
|
|
20
|
+
kwargs : dict
|
|
21
|
+
Keyword arguments passed to stx_imshow
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
pd.DataFrame
|
|
26
|
+
Formatted imshow data in row, col, value format (or row, col, R, G, B for RGB)
|
|
27
|
+
"""
|
|
28
|
+
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
29
|
+
return pd.DataFrame()
|
|
30
|
+
|
|
31
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
32
|
+
|
|
33
|
+
# Get imshow_df from tracked_dict
|
|
34
|
+
imshow_df = tracked_dict.get("imshow_df")
|
|
35
|
+
if imshow_df is not None and isinstance(imshow_df, pd.DataFrame):
|
|
36
|
+
# Convert from 2D DataFrame format (with col_0, col_1, ... columns)
|
|
37
|
+
# to row, col, value format for easier analysis
|
|
38
|
+
n_rows, n_cols = imshow_df.shape
|
|
39
|
+
|
|
40
|
+
# Create row and column indices
|
|
41
|
+
row_indices = np.repeat(np.arange(n_rows), n_cols)
|
|
42
|
+
col_indices = np.tile(np.arange(n_cols), n_rows)
|
|
43
|
+
|
|
44
|
+
# Get column names from single source of truth
|
|
45
|
+
col_row = get_csv_column_name("row", ax_row, ax_col, trace_id=trace_id)
|
|
46
|
+
col_col = get_csv_column_name("col", ax_row, ax_col, trace_id=trace_id)
|
|
47
|
+
col_value = get_csv_column_name("value", ax_row, ax_col, trace_id=trace_id)
|
|
48
|
+
|
|
49
|
+
# Flatten the DataFrame values
|
|
50
|
+
values = imshow_df.values.flatten()
|
|
51
|
+
|
|
52
|
+
result = pd.DataFrame({
|
|
53
|
+
col_row: row_indices,
|
|
54
|
+
col_col: col_indices,
|
|
55
|
+
col_value: values
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
return result
|
|
59
|
+
|
|
60
|
+
return pd.DataFrame()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# EOF
|
|
@@ -12,6 +12,8 @@ __DIR__ = os.path.dirname(__FILE__)
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pandas as pd
|
|
14
14
|
from scitex.pd import force_df
|
|
15
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
16
|
+
from ._format_plot import _parse_tracking_id
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
def _format_plot_joyplot(id, tracked_dict, kwargs):
|
|
@@ -29,6 +31,9 @@ def _format_plot_joyplot(id, tracked_dict, kwargs):
|
|
|
29
31
|
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
30
32
|
return pd.DataFrame()
|
|
31
33
|
|
|
34
|
+
# Parse tracking ID to get axes position and trace ID
|
|
35
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
36
|
+
|
|
32
37
|
# Get joyplot_data from tracked_dict
|
|
33
38
|
data = tracked_dict.get("joyplot_data")
|
|
34
39
|
|
|
@@ -39,16 +44,22 @@ def _format_plot_joyplot(id, tracked_dict, kwargs):
|
|
|
39
44
|
if isinstance(data, pd.DataFrame):
|
|
40
45
|
# Make a copy to avoid modifying original
|
|
41
46
|
result = data.copy()
|
|
42
|
-
# Add prefix to column names
|
|
47
|
+
# Add prefix to column names using single source of truth
|
|
43
48
|
if id is not None:
|
|
44
|
-
result.columns = [
|
|
49
|
+
result.columns = [
|
|
50
|
+
get_csv_column_name(f"joyplot-{col}", ax_row, ax_col, trace_id=trace_id)
|
|
51
|
+
for col in result.columns
|
|
52
|
+
]
|
|
45
53
|
return result
|
|
46
54
|
|
|
47
55
|
elif isinstance(data, dict):
|
|
48
56
|
# Convert dictionary to DataFrame
|
|
49
57
|
result = pd.DataFrame()
|
|
50
58
|
for group, values in data.items():
|
|
51
|
-
|
|
59
|
+
col_name = get_csv_column_name(
|
|
60
|
+
f"joyplot-{group}", ax_row, ax_col, trace_id=trace_id
|
|
61
|
+
)
|
|
62
|
+
result[col_name] = pd.Series(values)
|
|
52
63
|
return result
|
|
53
64
|
|
|
54
65
|
elif isinstance(data, (list, tuple)) and all(
|
|
@@ -57,11 +68,17 @@ def _format_plot_joyplot(id, tracked_dict, kwargs):
|
|
|
57
68
|
# Convert list of arrays to DataFrame
|
|
58
69
|
result = pd.DataFrame()
|
|
59
70
|
for i, values in enumerate(data):
|
|
60
|
-
|
|
71
|
+
col_name = get_csv_column_name(
|
|
72
|
+
f"joyplot-group{i:02d}", ax_row, ax_col, trace_id=trace_id
|
|
73
|
+
)
|
|
74
|
+
result[col_name] = pd.Series(values)
|
|
61
75
|
return result
|
|
62
76
|
|
|
63
77
|
# Try to force to DataFrame as a last resort
|
|
64
78
|
try:
|
|
65
|
-
|
|
79
|
+
col_name = get_csv_column_name(
|
|
80
|
+
"joyplot-data", ax_row, ax_col, trace_id=trace_id
|
|
81
|
+
)
|
|
82
|
+
return force_df({col_name: data})
|
|
66
83
|
except:
|
|
67
84
|
return pd.DataFrame()
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
|
-
# Timestamp: "2025-
|
|
4
|
-
# File:
|
|
5
|
-
# ----------------------------------------
|
|
6
|
-
import os
|
|
3
|
+
# Timestamp: "2025-12-13 02:00:00 (ywatanabe)"
|
|
4
|
+
# File: ./src/scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_mean_ci.py
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
__DIR__ = os.path.dirname(__FILE__)
|
|
10
|
-
# ----------------------------------------
|
|
6
|
+
"""CSV formatter for stx_mean_ci() calls - uses standard column naming."""
|
|
11
7
|
|
|
12
8
|
import pandas as pd
|
|
13
9
|
|
|
10
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
11
|
+
|
|
12
|
+
from ._format_plot import _parse_tracking_id
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
def _format_plot_mean_ci(id, tracked_dict, kwargs):
|
|
16
16
|
"""Format data from a stx_mean_ci call.
|
|
17
17
|
|
|
18
|
-
Processes mean with confidence interval band plot data for CSV export
|
|
18
|
+
Processes mean with confidence interval band plot data for CSV export using
|
|
19
|
+
standard column naming (ax-row-{r}-col-{c}_trace-id-{id}_variable-{var}).
|
|
19
20
|
|
|
20
21
|
Args:
|
|
21
22
|
id (str): Identifier for the plot
|
|
@@ -23,7 +24,7 @@ def _format_plot_mean_ci(id, tracked_dict, kwargs):
|
|
|
23
24
|
kwargs (dict): Keyword arguments passed to stx_mean_ci
|
|
24
25
|
|
|
25
26
|
Returns:
|
|
26
|
-
pd.DataFrame: Formatted mean and CI data
|
|
27
|
+
pd.DataFrame: Formatted mean and CI data with standard column names
|
|
27
28
|
"""
|
|
28
29
|
# Mean-CI plot data is passed in the tracked_dict
|
|
29
30
|
if not tracked_dict:
|
|
@@ -35,12 +36,15 @@ def _format_plot_mean_ci(id, tracked_dict, kwargs):
|
|
|
35
36
|
if plot_df is None or not isinstance(plot_df, pd.DataFrame):
|
|
36
37
|
return pd.DataFrame()
|
|
37
38
|
|
|
39
|
+
# Parse tracking ID to get axes position
|
|
40
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
41
|
+
|
|
38
42
|
# Create a copy to avoid modifying the original
|
|
39
43
|
result = plot_df.copy()
|
|
40
44
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
# Rename columns using standard naming convention
|
|
46
|
+
renamed = {}
|
|
47
|
+
for col in result.columns:
|
|
48
|
+
renamed[col] = get_csv_column_name(col, ax_row, ax_col, trace_id=trace_id)
|
|
45
49
|
|
|
46
|
-
return result
|
|
50
|
+
return result.rename(columns=renamed)
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
|
-
# Timestamp: "2025-
|
|
4
|
-
# File:
|
|
5
|
-
# ----------------------------------------
|
|
6
|
-
import os
|
|
3
|
+
# Timestamp: "2025-12-13 02:00:00 (ywatanabe)"
|
|
4
|
+
# File: ./src/scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_mean_std.py
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
__DIR__ = os.path.dirname(__FILE__)
|
|
10
|
-
# ----------------------------------------
|
|
6
|
+
"""CSV formatter for stx_mean_std() calls - uses standard column naming."""
|
|
11
7
|
|
|
12
8
|
import pandas as pd
|
|
13
9
|
|
|
10
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
11
|
+
|
|
12
|
+
from ._format_plot import _parse_tracking_id
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
def _format_plot_mean_std(id, tracked_dict, kwargs):
|
|
16
16
|
"""Format data from a stx_mean_std call.
|
|
17
17
|
|
|
18
|
-
Processes mean with standard deviation band plot data for CSV export
|
|
18
|
+
Processes mean with standard deviation band plot data for CSV export using
|
|
19
|
+
standard column naming (ax-row-{r}-col-{c}_trace-id-{id}_variable-{var}).
|
|
19
20
|
|
|
20
21
|
Args:
|
|
21
22
|
id (str): Identifier for the plot
|
|
@@ -23,7 +24,7 @@ def _format_plot_mean_std(id, tracked_dict, kwargs):
|
|
|
23
24
|
kwargs (dict): Keyword arguments passed to stx_mean_std
|
|
24
25
|
|
|
25
26
|
Returns:
|
|
26
|
-
pd.DataFrame: Formatted mean and std data
|
|
27
|
+
pd.DataFrame: Formatted mean and std data with standard column names
|
|
27
28
|
"""
|
|
28
29
|
# Check if tracked_dict is empty or not a dictionary
|
|
29
30
|
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
@@ -35,12 +36,15 @@ def _format_plot_mean_std(id, tracked_dict, kwargs):
|
|
|
35
36
|
if plot_df is None or not isinstance(plot_df, pd.DataFrame):
|
|
36
37
|
return pd.DataFrame()
|
|
37
38
|
|
|
39
|
+
# Parse tracking ID to get axes position
|
|
40
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
41
|
+
|
|
38
42
|
# Create a copy to avoid modifying the original
|
|
39
43
|
result = plot_df.copy()
|
|
40
44
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
# Rename columns using standard naming convention
|
|
46
|
+
renamed = {}
|
|
47
|
+
for col in result.columns:
|
|
48
|
+
renamed[col] = get_csv_column_name(col, ax_row, ax_col, trace_id=trace_id)
|
|
45
49
|
|
|
46
|
-
return result
|
|
50
|
+
return result.rename(columns=renamed)
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
|
-
# Timestamp: "2025-
|
|
4
|
-
# File:
|
|
5
|
-
# ----------------------------------------
|
|
6
|
-
import os
|
|
3
|
+
# Timestamp: "2025-12-13 02:00:00 (ywatanabe)"
|
|
4
|
+
# File: ./src/scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_median_iqr.py
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
__DIR__ = os.path.dirname(__FILE__)
|
|
10
|
-
# ----------------------------------------
|
|
6
|
+
"""CSV formatter for stx_median_iqr() calls - uses standard column naming."""
|
|
11
7
|
|
|
12
8
|
import pandas as pd
|
|
13
9
|
|
|
10
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
11
|
+
|
|
12
|
+
from ._format_plot import _parse_tracking_id
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
def _format_plot_median_iqr(id, tracked_dict, kwargs):
|
|
16
16
|
"""Format data from a stx_median_iqr call.
|
|
17
17
|
|
|
18
|
-
Processes median with interquartile range band plot data for CSV export
|
|
18
|
+
Processes median with interquartile range band plot data for CSV export using
|
|
19
|
+
standard column naming (ax-row-{r}-col-{c}_trace-id-{id}_variable-{var}).
|
|
19
20
|
|
|
20
21
|
Args:
|
|
21
22
|
id (str): Identifier for the plot
|
|
@@ -23,7 +24,7 @@ def _format_plot_median_iqr(id, tracked_dict, kwargs):
|
|
|
23
24
|
kwargs (dict): Keyword arguments passed to stx_median_iqr
|
|
24
25
|
|
|
25
26
|
Returns:
|
|
26
|
-
pd.DataFrame: Formatted median and IQR data
|
|
27
|
+
pd.DataFrame: Formatted median and IQR data with standard column names
|
|
27
28
|
"""
|
|
28
29
|
# Median-IQR plot data is passed in the tracked_dict
|
|
29
30
|
if not tracked_dict:
|
|
@@ -35,12 +36,15 @@ def _format_plot_median_iqr(id, tracked_dict, kwargs):
|
|
|
35
36
|
if plot_df is None or not isinstance(plot_df, pd.DataFrame):
|
|
36
37
|
return pd.DataFrame()
|
|
37
38
|
|
|
39
|
+
# Parse tracking ID to get axes position
|
|
40
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
41
|
+
|
|
38
42
|
# Create a copy to avoid modifying the original
|
|
39
43
|
result = plot_df.copy()
|
|
40
44
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
# Rename columns using standard naming convention
|
|
46
|
+
renamed = {}
|
|
47
|
+
for col in result.columns:
|
|
48
|
+
renamed[col] = get_csv_column_name(col, ax_row, ax_col, trace_id=trace_id)
|
|
45
49
|
|
|
46
|
-
return result
|
|
50
|
+
return result.rename(columns=renamed)
|
|
@@ -10,6 +10,8 @@ __DIR__ = os.path.dirname(__FILE__)
|
|
|
10
10
|
# ----------------------------------------
|
|
11
11
|
|
|
12
12
|
import pandas as pd
|
|
13
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
14
|
+
from ._format_plot import _parse_tracking_id
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
def _format_plot_raster(id, tracked_dict, kwargs):
|
|
@@ -27,6 +29,9 @@ def _format_plot_raster(id, tracked_dict, kwargs):
|
|
|
27
29
|
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
28
30
|
return pd.DataFrame()
|
|
29
31
|
|
|
32
|
+
# Parse tracking ID to get axes position and trace ID
|
|
33
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
34
|
+
|
|
30
35
|
# Get the raster_digit_df from args
|
|
31
36
|
raster_df = tracked_dict.get("raster_digit_df")
|
|
32
37
|
|
|
@@ -36,9 +41,12 @@ def _format_plot_raster(id, tracked_dict, kwargs):
|
|
|
36
41
|
# Create a copy to avoid modifying the original
|
|
37
42
|
result = raster_df.copy()
|
|
38
43
|
|
|
39
|
-
# Add prefix to column names
|
|
44
|
+
# Add prefix to column names using single source of truth
|
|
40
45
|
if id is not None:
|
|
41
46
|
# Rename columns with ID prefix
|
|
42
|
-
result.columns = [
|
|
47
|
+
result.columns = [
|
|
48
|
+
get_csv_column_name(f"raster-{col}", ax_row, ax_col, trace_id=trace_id)
|
|
49
|
+
for col in result.columns
|
|
50
|
+
]
|
|
43
51
|
|
|
44
52
|
return result
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""CSV formatter for stx_scatter() calls."""
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
7
|
+
from ._format_plot import _parse_tracking_id
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _format_stx_scatter(id, tracked_dict, kwargs):
|
|
11
|
+
"""Format data from stx_scatter call for CSV export.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
id : str
|
|
16
|
+
Tracking identifier
|
|
17
|
+
tracked_dict : dict
|
|
18
|
+
Dictionary containing tracked data with 'scatter_df' key
|
|
19
|
+
kwargs : dict
|
|
20
|
+
Additional keyword arguments (unused)
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
pd.DataFrame
|
|
25
|
+
Formatted scatter data with standardized column names
|
|
26
|
+
"""
|
|
27
|
+
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
28
|
+
return pd.DataFrame()
|
|
29
|
+
|
|
30
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
31
|
+
|
|
32
|
+
# Get scatter_df from tracked data
|
|
33
|
+
scatter_df = tracked_dict.get("scatter_df")
|
|
34
|
+
if scatter_df is not None and isinstance(scatter_df, pd.DataFrame):
|
|
35
|
+
result = scatter_df.copy()
|
|
36
|
+
renamed = {}
|
|
37
|
+
for col in result.columns:
|
|
38
|
+
renamed[col] = get_csv_column_name(col, ax_row, ax_col, trace_id=trace_id)
|
|
39
|
+
return result.rename(columns=renamed)
|
|
40
|
+
|
|
41
|
+
# Fallback to args if scatter_df not found
|
|
42
|
+
args = tracked_dict.get("args", [])
|
|
43
|
+
if len(args) >= 2:
|
|
44
|
+
col_x = get_csv_column_name("x", ax_row, ax_col, trace_id=trace_id)
|
|
45
|
+
col_y = get_csv_column_name("y", ax_row, ax_col, trace_id=trace_id)
|
|
46
|
+
return pd.DataFrame({col_x: args[0], col_y: args[1]})
|
|
47
|
+
|
|
48
|
+
return pd.DataFrame()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# EOF
|
|
@@ -12,6 +12,9 @@ __DIR__ = os.path.dirname(__FILE__)
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pandas as pd
|
|
14
14
|
|
|
15
|
+
from scitex.plt.utils._csv_column_naming import get_csv_column_name
|
|
16
|
+
from ._format_plot import _parse_tracking_id
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
def _format_plot_scatter_hist(id, tracked_dict, kwargs):
|
|
17
20
|
"""Format data from a stx_scatter_hist call.
|
|
@@ -28,13 +31,19 @@ def _format_plot_scatter_hist(id, tracked_dict, kwargs):
|
|
|
28
31
|
if not tracked_dict or not isinstance(tracked_dict, dict):
|
|
29
32
|
return pd.DataFrame()
|
|
30
33
|
|
|
34
|
+
# Parse tracking ID to extract axes position and trace ID
|
|
35
|
+
ax_row, ax_col, trace_id = _parse_tracking_id(id)
|
|
36
|
+
|
|
31
37
|
# Extract data from tracked_dict
|
|
32
38
|
x = tracked_dict.get("x")
|
|
33
39
|
y = tracked_dict.get("y")
|
|
34
40
|
|
|
35
41
|
if x is not None and y is not None:
|
|
36
42
|
# Create base DataFrame with x and y values
|
|
37
|
-
df = pd.DataFrame({
|
|
43
|
+
df = pd.DataFrame({
|
|
44
|
+
get_csv_column_name("scatter_hist_x", ax_row, ax_col, trace_id=trace_id): x,
|
|
45
|
+
get_csv_column_name("scatter_hist_y", ax_row, ax_col, trace_id=trace_id): y,
|
|
46
|
+
})
|
|
38
47
|
|
|
39
48
|
# Add histogram data if available
|
|
40
49
|
hist_x = tracked_dict.get("hist_x")
|
|
@@ -50,15 +59,15 @@ def _format_plot_scatter_hist(id, tracked_dict, kwargs):
|
|
|
50
59
|
# Create a DataFrame for x histogram data
|
|
51
60
|
hist_x_df = pd.DataFrame(
|
|
52
61
|
{
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
get_csv_column_name("hist_x_bin_centers", ax_row, ax_col, trace_id=trace_id): bin_centers_x,
|
|
63
|
+
get_csv_column_name("hist_x_counts", ax_row, ax_col, trace_id=trace_id): hist_x,
|
|
55
64
|
}
|
|
56
65
|
)
|
|
57
66
|
|
|
58
67
|
# Add it to the main DataFrame using a MultiIndex
|
|
59
68
|
for i, (center, count) in enumerate(zip(bin_centers_x, hist_x)):
|
|
60
|
-
df.loc[f"hist_x_{i}",
|
|
61
|
-
df.loc[f"hist_x_{i}",
|
|
69
|
+
df.loc[f"hist_x_{i}", get_csv_column_name("hist_x_bin", ax_row, ax_col, trace_id=trace_id)] = center
|
|
70
|
+
df.loc[f"hist_x_{i}", get_csv_column_name("hist_x_count", ax_row, ax_col, trace_id=trace_id)] = count
|
|
62
71
|
|
|
63
72
|
# If we have y histogram data
|
|
64
73
|
if hist_y is not None and bin_edges_y is not None:
|
|
@@ -68,15 +77,15 @@ def _format_plot_scatter_hist(id, tracked_dict, kwargs):
|
|
|
68
77
|
# Create a DataFrame for y histogram data
|
|
69
78
|
hist_y_df = pd.DataFrame(
|
|
70
79
|
{
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
get_csv_column_name("hist_y_bin_centers", ax_row, ax_col, trace_id=trace_id): bin_centers_y,
|
|
81
|
+
get_csv_column_name("hist_y_counts", ax_row, ax_col, trace_id=trace_id): hist_y,
|
|
73
82
|
}
|
|
74
83
|
)
|
|
75
84
|
|
|
76
85
|
# Add it to the main DataFrame using a MultiIndex
|
|
77
86
|
for i, (center, count) in enumerate(zip(bin_centers_y, hist_y)):
|
|
78
|
-
df.loc[f"hist_y_{i}",
|
|
79
|
-
df.loc[f"hist_y_{i}",
|
|
87
|
+
df.loc[f"hist_y_{i}", get_csv_column_name("hist_y_bin", ax_row, ax_col, trace_id=trace_id)] = center
|
|
88
|
+
df.loc[f"hist_y_{i}", get_csv_column_name("hist_y_count", ax_row, ax_col, trace_id=trace_id)] = count
|
|
80
89
|
|
|
81
90
|
return df
|
|
82
91
|
|
scitex/plt/ax/_plot/_stx_ecdf.py
CHANGED
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
"""Empirical Cumulative Distribution Function (ECDF) plotting."""
|
|
7
7
|
|
|
8
|
-
import warnings
|
|
9
8
|
from typing import Any, Tuple, Union
|
|
10
9
|
|
|
11
10
|
import numpy as np
|
|
12
11
|
import pandas as pd
|
|
13
12
|
from matplotlib.axes import Axes
|
|
14
13
|
|
|
14
|
+
from scitex import logging
|
|
15
15
|
from scitex.pd._force_df import force_df as scitex_pd_force_df
|
|
16
16
|
from ....plt.utils import assert_valid_axis, mm_to_pt
|
|
17
17
|
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
18
20
|
|
|
19
21
|
# Default line width (0.2mm for publication)
|
|
20
22
|
DEFAULT_LINE_WIDTH_MM = 0.2
|
|
@@ -68,7 +70,7 @@ def stx_ecdf(
|
|
|
68
70
|
|
|
69
71
|
# Warnings
|
|
70
72
|
if np.isnan(values_1d).any():
|
|
71
|
-
|
|
73
|
+
logger.warning("NaN values are ignored for ECDF plot.")
|
|
72
74
|
values_1d = values_1d[~np.isnan(values_1d)]
|
|
73
75
|
nn = len(values_1d)
|
|
74
76
|
|