sgtlib 3.3.9__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 (72) hide show
  1. StructuralGT/__init__.py +31 -0
  2. StructuralGT/apps/__init__.py +0 -0
  3. StructuralGT/apps/cli_main.py +258 -0
  4. StructuralGT/apps/gui_main.py +69 -0
  5. StructuralGT/apps/gui_mcw/__init__.py +0 -0
  6. StructuralGT/apps/gui_mcw/checkbox_model.py +91 -0
  7. StructuralGT/apps/gui_mcw/controller.py +1073 -0
  8. StructuralGT/apps/gui_mcw/image_provider.py +74 -0
  9. StructuralGT/apps/gui_mcw/imagegrid_model.py +75 -0
  10. StructuralGT/apps/gui_mcw/qthread_worker.py +102 -0
  11. StructuralGT/apps/gui_mcw/table_model.py +79 -0
  12. StructuralGT/apps/gui_mcw/tree_model.py +154 -0
  13. StructuralGT/apps/sgt_qml/CenterMainContent.qml +19 -0
  14. StructuralGT/apps/sgt_qml/LeftContent.qml +48 -0
  15. StructuralGT/apps/sgt_qml/MainWindow.qml +762 -0
  16. StructuralGT/apps/sgt_qml/RightLoggingPanel.qml +125 -0
  17. StructuralGT/apps/sgt_qml/assets/icons/.DS_Store +0 -0
  18. StructuralGT/apps/sgt_qml/assets/icons/back_icon.png +0 -0
  19. StructuralGT/apps/sgt_qml/assets/icons/brightness_icon.png +0 -0
  20. StructuralGT/apps/sgt_qml/assets/icons/cancel_icon.png +0 -0
  21. StructuralGT/apps/sgt_qml/assets/icons/crop_icon.png +0 -0
  22. StructuralGT/apps/sgt_qml/assets/icons/edit_icon.png +0 -0
  23. StructuralGT/apps/sgt_qml/assets/icons/graph_icon.png +0 -0
  24. StructuralGT/apps/sgt_qml/assets/icons/hide_panel.png +0 -0
  25. StructuralGT/apps/sgt_qml/assets/icons/next_icon.png +0 -0
  26. StructuralGT/apps/sgt_qml/assets/icons/notify_icon.png +0 -0
  27. StructuralGT/apps/sgt_qml/assets/icons/rescale_icon.png +0 -0
  28. StructuralGT/apps/sgt_qml/assets/icons/show_panel.png +0 -0
  29. StructuralGT/apps/sgt_qml/assets/icons/square_icon.png +0 -0
  30. StructuralGT/apps/sgt_qml/assets/icons/undo_icon.png +0 -0
  31. StructuralGT/apps/sgt_qml/components/ImageFilters.qml +82 -0
  32. StructuralGT/apps/sgt_qml/components/ImageProperties.qml +112 -0
  33. StructuralGT/apps/sgt_qml/components/ProjectNav.qml +127 -0
  34. StructuralGT/apps/sgt_qml/widgets/BinaryFilterWidget.qml +151 -0
  35. StructuralGT/apps/sgt_qml/widgets/BrightnessControlWidget.qml +103 -0
  36. StructuralGT/apps/sgt_qml/widgets/CreateProjectWidget.qml +112 -0
  37. StructuralGT/apps/sgt_qml/widgets/GTWidget.qml +94 -0
  38. StructuralGT/apps/sgt_qml/widgets/GraphComputeWidget.qml +77 -0
  39. StructuralGT/apps/sgt_qml/widgets/GraphExtractWidget.qml +175 -0
  40. StructuralGT/apps/sgt_qml/widgets/GraphPropertyWidget.qml +77 -0
  41. StructuralGT/apps/sgt_qml/widgets/ImageFilterWidget.qml +137 -0
  42. StructuralGT/apps/sgt_qml/widgets/ImagePropertyWidget.qml +78 -0
  43. StructuralGT/apps/sgt_qml/widgets/ImageViewWidget.qml +585 -0
  44. StructuralGT/apps/sgt_qml/widgets/MenuBarWidget.qml +137 -0
  45. StructuralGT/apps/sgt_qml/widgets/MicroscopyPropertyWidget.qml +80 -0
  46. StructuralGT/apps/sgt_qml/widgets/ProjectWidget.qml +141 -0
  47. StructuralGT/apps/sgt_qml/widgets/RescaleControlWidget.qml +83 -0
  48. StructuralGT/apps/sgt_qml/widgets/RibbonWidget.qml +406 -0
  49. StructuralGT/apps/sgt_qml/widgets/StatusBarWidget.qml +173 -0
  50. StructuralGT/compute/__init__.py +0 -0
  51. StructuralGT/compute/c_lang/include/sgt_base.h +21 -0
  52. StructuralGT/compute/graph_analyzer.py +1499 -0
  53. StructuralGT/entrypoints.py +49 -0
  54. StructuralGT/imaging/__init__.py +0 -0
  55. StructuralGT/imaging/base_image.py +403 -0
  56. StructuralGT/imaging/image_processor.py +780 -0
  57. StructuralGT/modules.py +29 -0
  58. StructuralGT/networks/__init__.py +0 -0
  59. StructuralGT/networks/fiber_network.py +490 -0
  60. StructuralGT/networks/graph_skeleton.py +425 -0
  61. StructuralGT/networks/sknw_mod.py +199 -0
  62. StructuralGT/utils/__init__.py +0 -0
  63. StructuralGT/utils/config_loader.py +244 -0
  64. StructuralGT/utils/configs.ini +97 -0
  65. StructuralGT/utils/progress_update.py +67 -0
  66. StructuralGT/utils/sgt_utils.py +291 -0
  67. sgtlib-3.3.9.dist-info/METADATA +789 -0
  68. sgtlib-3.3.9.dist-info/RECORD +72 -0
  69. sgtlib-3.3.9.dist-info/WHEEL +5 -0
  70. sgtlib-3.3.9.dist-info/entry_points.txt +3 -0
  71. sgtlib-3.3.9.dist-info/licenses/LICENSE +674 -0
  72. sgtlib-3.3.9.dist-info/top_level.txt +1 -0
@@ -0,0 +1,137 @@
1
+ import QtQuick
2
+ import QtQuick.Controls
3
+ //import Qt.labs.platform
4
+
5
+
6
+ MenuBar {
7
+ property int valueRole: Qt.UserRole + 4
8
+
9
+ Menu {
10
+ title: "Structural GT"
11
+ MenuItem { text: "&About"; onTriggered: dialogAbout.open(); }
12
+ MenuSeparator{}
13
+ MenuItem { text: "&Quit"; onTriggered: Qt.quit(); }
14
+ }
15
+ Menu {
16
+ title: "File"
17
+ MenuItem { text: "Add image"; onTriggered: imageFileDialog.open() }
18
+ //MenuItem { text: "Add image folder"; onTriggered: console.log("add image folder clicked") }
19
+
20
+ Menu { title: "Project..."
21
+ MenuItem { text: "Create project"; onTriggered: createProjectDialog.open() }
22
+ MenuItem { text: "Open project"; onTriggered: projectFileDialog.open() }
23
+ }
24
+ MenuSeparator{}
25
+
26
+ MenuItem {id: mnuSaveProjAs; text: "Save"; enabled: mainController.display_image(); onTriggered: save_project() }
27
+ MenuSeparator{}
28
+
29
+ Menu {
30
+ id: mnuExportGraphAs
31
+ title: "Export GT graph as..."
32
+ enabled: true
33
+ MenuItem {id:mnuExportEdge; text: "Edge list"; enabled: false; onTriggered: export_graph_data(0) }
34
+ MenuItem {id:mnuExportAdj; text: "Adjacency matix"; enabled: false; onTriggered: export_graph_data(2) }
35
+ MenuItem {id:mnuExportGexf; text: "As gexf"; enabled: false; onTriggered: export_graph_data(1) }
36
+ MenuItem {id:mnuExportGSD; text: "As GSD/HOOMD"; enabled: false; onTriggered: export_graph_data(3) }
37
+
38
+ }
39
+ MenuSeparator{}
40
+
41
+ MenuItem {id:mnuExportAll; text: "Save processed images"; enabled: false; onTriggered: save_processed_images(0) }
42
+
43
+ }
44
+ Menu {
45
+ id: mnuImgCtrls
46
+ title: "Tools"
47
+ enabled: true
48
+ //MenuItem {id:mnuRescaleImgCtrl; text: "Rescale Image"; enabled: false; onTriggered: dialogRescaleCtrl.open() }
49
+ MenuItem {id:mnuBrightnessImgCtrl; text: "Brightness/Contrast"; enabled: false; onTriggered: dialogBrightnessCtrl.open() }
50
+ MenuItem {id:mnuContrastImgCtrl; text: "Show Graph"; enabled: false; onTriggered: dialogExtractGraph.open() }
51
+ }
52
+ Menu {
53
+ id: mnuImgFilters
54
+ title: "Filters"
55
+ enabled: true
56
+ MenuItem {id:mnuBinImgFilter; text: "Binary Filters"; enabled: false; onTriggered: dialogBinFilters.open() }
57
+
58
+ MenuSeparator{}
59
+
60
+ MenuItem {id:mnuImgFilter; text: "Image Filters"; enabled: false; onTriggered: dialogImgFilters.open() }
61
+ }
62
+ Menu {
63
+ id: mnuAnalyze
64
+ title: "Analyze"
65
+ enabled: true
66
+ Menu { title: "GT Parameters"
67
+ MenuItem {id:mnuSoloAnalze; text: "Current Image"; enabled: false; onTriggered: dialogRunAnalyzer.open() }
68
+ MenuItem {id:mnuMultiAnalyze; text: "All Images"; enabled: false; onTriggered: dialogRunMultiAnalyzer.open() }
69
+ }
70
+ }
71
+ Menu {
72
+ title: "Help"
73
+ MenuItem { id:mnuHelp; text: "Structural GT Help"; enabled: true; onTriggered: dialogAbout.open() }
74
+ MenuItem { id:mnuLogs; text: "View Logs"; enabled: true; onTriggered: loggingWindowPanel.visible = true }
75
+ }
76
+
77
+ function export_graph_data (row) {
78
+
79
+ for (let i = 0; i < exportGraphModel.rowCount(); i++) {
80
+ let val = i === row ? 1 : 0;
81
+ var index = exportGraphModel.index(i, 0);
82
+ exportGraphModel.setData(index, val, valueRole);
83
+ }
84
+ mainController.export_graph_to_file();
85
+ }
86
+
87
+
88
+ function save_processed_images (row) {
89
+
90
+ for (let i = 0; i < saveImgModel.rowCount(); i++) {
91
+ let val = i === row ? 1 : 0;
92
+ var index = saveImgModel.index(i, 0);
93
+ saveImgModel.setData(index, val, valueRole);
94
+ }
95
+ mainController.save_img_files();
96
+ }
97
+
98
+
99
+ function save_project () {
100
+
101
+ let is_open = mainController.is_project_open();
102
+ if (is_open === false) {
103
+ dialogAlert.title = "Save Error";
104
+ lblAlertMsg.text = "Please create/open the SGT project first, then try again.";
105
+ lblAlertMsg.color = "#2255bc";
106
+ dialogAlert.open();
107
+ } else {
108
+ let success_val = mainController.run_save_project();
109
+ }
110
+
111
+ }
112
+
113
+
114
+ Connections {
115
+ target: mainController
116
+
117
+ function onImageChangedSignal() {
118
+ // Force refresh
119
+ mnuSaveProjAs.enabled = mainController.display_image();
120
+
121
+ mnuExportEdge.enabled = graphPropsModel.rowCount() > 0 ? true : false;
122
+ mnuExportAdj.enabled = graphPropsModel.rowCount() > 0 ? true : false;
123
+ mnuExportGexf.enabled = graphPropsModel.rowCount() > 0 ? true : false;
124
+ mnuExportGSD.enabled = graphPropsModel.rowCount() > 0 ? true : false;
125
+ mnuExportAll.enabled = graphPropsModel.rowCount() > 0 ? true : false;
126
+
127
+ //mnuRescaleImgCtrl.enabled = mainController.display_image(); HAS ERRORS
128
+ mnuBrightnessImgCtrl.enabled = mainController.display_image();
129
+ mnuContrastImgCtrl.enabled = mainController.display_image();
130
+ mnuBinImgFilter.enabled = mainController.display_image();
131
+ mnuImgFilter.enabled = mainController.display_image();
132
+ mnuSoloAnalze.enabled = mainController.display_image();
133
+ mnuMultiAnalyze.enabled = mainController.display_image();
134
+ }
135
+ }
136
+ }
137
+
@@ -0,0 +1,80 @@
1
+ import QtQuick
2
+ import QtQuick.Controls
3
+ import QtQuick.Layouts
4
+
5
+ Item {
6
+ id: microscopyProps
7
+ Layout.preferredHeight: 100
8
+ Layout.preferredWidth: parent.width - 75
9
+ enabled: mainController.display_image();
10
+
11
+ property int txtWidthSize: 70
12
+ property int lblWidthSize: 80
13
+ property int valueRole: Qt.UserRole + 4
14
+
15
+ ColumnLayout {
16
+ id: microscopyPropsLayout
17
+
18
+ Repeater {
19
+ model: microscopyPropsModel
20
+ delegate: RowLayout {
21
+ visible: model.visible === 1
22
+
23
+ Label {
24
+ id: label
25
+ wrapMode: Text.Wrap
26
+ color: "#2222bc"
27
+ font.pixelSize: 10
28
+ Layout.preferredWidth: lblWidthSize
29
+ Layout.leftMargin: 10
30
+ text: model.text
31
+ }
32
+
33
+ TextField {
34
+ id: txtField
35
+ objectName: model.id
36
+ color: "#2222bc"
37
+ font.pixelSize: 10
38
+ Layout.preferredWidth: txtWidthSize
39
+ text: model.value
40
+ onActiveFocusChanged: {
41
+ if (focus) {
42
+ btnOK.visible = true;
43
+ }
44
+ }
45
+ }
46
+
47
+ Button {
48
+ id: btnOK
49
+ text: ""
50
+ Layout.preferredWidth: 40
51
+ Layout.preferredHeight: 30
52
+ Layout.rightMargin: 10
53
+ visible: false
54
+ onClicked: {
55
+ btnOK.visible = false;
56
+
57
+ var index = microscopyPropsModel.index(model.index, 0);
58
+ microscopyPropsModel.setData(index, txtField.text, valueRole);
59
+ mainController.apply_microscopy_props_changes();
60
+ //console.log(txtField.text);
61
+ }
62
+
63
+ Rectangle {
64
+ anchors.fill: parent
65
+ radius: 5
66
+ color: "#22bc55"
67
+
68
+ Label {
69
+ text: "OK"
70
+ color: "#ffffff"
71
+ //font.bold: true
72
+ //font.pixelSize: 10
73
+ anchors.centerIn: parent
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,141 @@
1
+ import QtQuick
2
+ import QtQuick.Controls
3
+ import QtQuick.Layouts
4
+
5
+ Item {
6
+ id: projectControls // used for external access
7
+ Layout.preferredHeight: 200
8
+ Layout.preferredWidth: parent.width
9
+
10
+ property int numRows: 10 // imgThumbnailModel.rowCount()
11
+ property int tblRowHeight: 50
12
+
13
+
14
+ ColumnLayout {
15
+ id: projectCtrlLayout
16
+ anchors.fill: parent
17
+ spacing: 10
18
+
19
+ Label {
20
+ id: lblNoImages
21
+ Layout.alignment: Qt.AlignHCenter
22
+ Layout.topMargin: 20
23
+ text: "No images to show!\nPlease add image/folder."
24
+ color: "#808080"
25
+ visible: imgThumbnailModel.rowCount() > 0 ? false : true
26
+ //visible: false
27
+ }
28
+
29
+ TableView {
30
+ id: tableView
31
+ height: numRows * tblRowHeight
32
+ Layout.fillWidth: true
33
+ Layout.topMargin: 5
34
+ Layout.leftMargin: 2
35
+ Layout.rightMargin: 2
36
+ rowSpacing: 2
37
+ //columnSpacing: 2
38
+ model: imgThumbnailModel
39
+ visible: imgThumbnailModel.rowCount() > 0 ? true : false
40
+
41
+ delegate: Rectangle {
42
+ implicitWidth: tableView.width
43
+ implicitHeight: tblRowHeight
44
+ //color: row % 2 === 0 ? "#f5f5f5" : "#ffffff" // Alternating colors
45
+ color: model.selected ? "#d0d0d0" : "transparent"
46
+
47
+ MouseArea {
48
+ anchors.fill: parent // Make the MouseArea cover the entire Rectangle
49
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
50
+
51
+ // Left-click to select item
52
+ onClicked: {
53
+ mainController.load_image(row);
54
+ }
55
+
56
+ // Right-click to show context menu
57
+ onPressed: (mouse) => {
58
+ if (mouse.button === Qt.RightButton) {
59
+ contextMenu.x = mouse.x;
60
+ contextMenu.y = mouse.y;
61
+ contextMenu.itemRow = row; // index to delete
62
+ contextMenu.open();
63
+ }
64
+ }
65
+ }
66
+
67
+ RowLayout {
68
+
69
+ Rectangle {
70
+ width: tblRowHeight
71
+ height: tblRowHeight
72
+ radius: 4
73
+ color: "transparent"
74
+ border.width: 1
75
+ border.color: "black"
76
+
77
+ Image {
78
+ id: imgThumbnail
79
+ anchors.fill: parent
80
+ source: "data:image/png;base64," + model.thumbnail // Base64 encoded image
81
+ }
82
+
83
+ }
84
+
85
+ Label {
86
+ id: lblImgItem
87
+ text: model.text
88
+ color: model.selected ? "#303030" : "#808080"
89
+ }
90
+ }
91
+
92
+ }
93
+
94
+ }
95
+
96
+ }
97
+
98
+ // Context Menu for deleting an item
99
+ Menu {
100
+ id: contextMenu
101
+ property int itemRow: -1 // Stores the selected item's index
102
+
103
+ MenuItem {
104
+ text: "Delete"
105
+ onTriggered: {
106
+ if (contextMenu.itemIndex !== -1) {
107
+ mainController.delete_selected_thumbnail(contextMenu.itemRow);
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ Connections {
114
+ target: mainController
115
+
116
+ function onImageChangedSignal() {
117
+ // Force refresh
118
+ lblNoImages.visible = imgThumbnailModel.rowCount() > 0 ? false : true
119
+ tableView.visible = imgThumbnailModel.rowCount() > 0 ? true : false
120
+ tableView.enabled = !mainController.is_task_running();
121
+
122
+ let rowCount = imgThumbnailModel.rowCount() > numRows ? imgThumbnailModel.rowCount() : numRows;
123
+ tableView.height = rowCount * tblRowHeight;
124
+ }
125
+
126
+ function onProjectOpenedSignal(name) {
127
+ lblNoImages.text = "No images to show!\nPlease import image(s).";
128
+ tableView.visible = imgThumbnailModel.rowCount() > 0 ? true : false
129
+ }
130
+
131
+ function onUpdateProgressSignal(val, msg) {
132
+ tableView.enabled = !mainController.is_task_running();
133
+ }
134
+
135
+ function onTaskTerminatedSignal(success_val, msg_data){
136
+ tableView.enabled = !mainController.is_task_running();
137
+ }
138
+
139
+ }
140
+
141
+ }
@@ -0,0 +1,83 @@
1
+ import QtQuick
2
+ import QtQuick.Controls
3
+ import QtQuick.Layouts
4
+
5
+
6
+ Item {
7
+ id: rescaleControl
8
+ height: 180
9
+ width: parent.width
10
+
11
+ // Expose TextFields as properties to make them accessible
12
+ property alias lblScale: lblScaling
13
+ property int valueRole: Qt.UserRole + 4
14
+
15
+
16
+ ColumnLayout {
17
+ id: scalingContainer
18
+ spacing: 5
19
+ //Layout.alignment: Qt.AlignHCenter
20
+ visible: mainController.display_image()
21
+
22
+ Label {
23
+ id: lblScaling
24
+ text: "Re-scale to:"
25
+ font.bold: true
26
+ }
27
+
28
+ ListView {
29
+ id: listViewScalingOptions
30
+ width: 180
31
+ height: 150
32
+ model: imgScaleOptionModel
33
+
34
+ ButtonGroup {
35
+ id: btnGrpScales
36
+ exclusive: true
37
+ }
38
+
39
+ delegate: Item {
40
+ width: listViewScalingOptions.width
41
+ height: 24
42
+
43
+ RowLayout {
44
+ anchors.fill: parent
45
+
46
+ RadioButton {
47
+ text: model.text
48
+ ButtonGroup.group: btnGrpScales
49
+ property bool isChecked: model.value
50
+ checked: isChecked
51
+ onClicked: btnGrpScales.checkedButton = this
52
+ onCheckedChanged: {
53
+ if (isChecked !== checked) { // Only update if there is a change
54
+ isChecked = checked
55
+ var val = checked ? 1 : 0;
56
+ var index = imgFilterModel.index(model.index, 0);
57
+ imgScaleOptionModel.setData(index, val, valueRole);
58
+ mainController.apply_img_scaling();
59
+
60
+ //if (dialogRescaleCtrl) { dialogRescaleCtrl.close(); }
61
+ drpDownRescale.close();
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+
70
+
71
+ }
72
+
73
+
74
+ Connections {
75
+ target: mainController
76
+
77
+ function onImageChangedSignal() {
78
+ // Force refresh
79
+ scalingContainer.visible = mainController.display_image();
80
+ }
81
+ }
82
+
83
+ }