miblab-plot 0.0.6__tar.gz → 0.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: miblab-plot
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Plotting utilities for medical images
5
5
  Author-email: Steven Sourbron <s.sourbron@sheffield.ac.uk>
6
6
  License-Expression: Apache-2.0
@@ -6,7 +6,7 @@ requires = ['setuptools>=61.2']
6
6
 
7
7
  [project]
8
8
  name = "miblab-plot"
9
- version = "0.0.6"
9
+ version = "0.0.8"
10
10
  dependencies = [
11
11
  'pillow',
12
12
  'numpy',
@@ -18,11 +18,7 @@ def setup_rendering_env():
18
18
 
19
19
  current_os = platform.system().lower()
20
20
  if current_os == "linux":
21
-
22
- # 1. Prefer OSMesa for headless Linux (avoids the Xvfb requirement)
23
- # This tells PyVista to use the software-based buffer provided by the Mesa module
24
- if hasattr(pv, 'set_jupyter_backend'):
25
- pv.set_jupyter_backend('static')
21
+
26
22
 
27
23
  # 2. Environment variables to bypass X11 requirements
28
24
  os.environ['QT_QPA_PLATFORM'] = 'offscreen'
@@ -139,10 +135,20 @@ def rotating_masks_grid(
139
135
  plotter.subplot(row, col)
140
136
  if labels is not None:
141
137
  plotter.add_text(str(labels[col, row]), font_size=6, color='black')
142
-
143
- plotter.add_mesh(surf, color='lightblue', smooth_shading=True)
144
- plotter.camera_position = [pos, center, (0, 0, 1)] # Simple Up-vector
145
138
 
139
+ # Catch empty masks
140
+ if surf.n_points > 0:
141
+ # Only calculate camera and add mesh if points exist
142
+ distance = surf.length * 2.5
143
+ center = list(surf.center)
144
+ pos = center + distance * np.array(vec)
145
+
146
+ plotter.add_mesh(surf, color='lightblue', smooth_shading=True)
147
+ plotter.camera_position = [pos, center, (0, 0, 1)]
148
+ else:
149
+ # Optional: Add placeholder text so you know it was empty
150
+ plotter.add_text("Empty Mask", font_size=5, color='gray')
151
+
146
152
  # 4. Save and Destroy
147
153
  # This is where the RAM resets to zero for the next angle
148
154
  file = os.path.join(dir_output, f"mosaic_{i:03d}.png")
@@ -232,10 +238,20 @@ def multiple_mosaic_masks_da(masks: list, directions: dict, labels, columns=None
232
238
  plotter.subplot(row, col)
233
239
  if labels is not None:
234
240
  plotter.add_text(labels[i], font_size=6, color='black')
235
-
236
- plotter.add_mesh(surf, color='lightblue', smooth_shading=True)
237
- plotter.camera_position = [pos, center, up]
238
241
 
242
+ # Catch empty masks
243
+ if surf.n_points > 0:
244
+ # Only calculate camera and add mesh if points exist
245
+ distance = surf.length * 2.5
246
+ center = list(surf.center)
247
+ pos = center + distance * np.array(vec)
248
+
249
+ plotter.add_mesh(surf, color='lightblue', smooth_shading=True)
250
+ plotter.camera_position = [pos, center, up]
251
+ else:
252
+ # Optional: Add placeholder text so you know it was empty
253
+ plotter.add_text("Empty Mask", font_size=5, color='gray')
254
+
239
255
  # 1. Initialize the window in the background
240
256
  plotter.show(auto_close=False, interactive=False, interactive_update=True)
241
257
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: miblab-plot
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Plotting utilities for medical images
5
5
  Author-email: Steven Sourbron <s.sourbron@sheffield.ac.uk>
6
6
  License-Expression: Apache-2.0
File without changes
File without changes
File without changes