@@ -121,7 +121,7 @@ class GfxPlotter(Plotter):
121
121
"volume_legend" ,
122
122
}
123
123
BACKEND = "pygfx"
124
-
124
+
125
125
def plot (self ):
126
126
"""Generate the plot."""
127
127
colors = self .kwargs .get ('color' , None )
@@ -138,18 +138,18 @@ def plot(self):
138
138
)
139
139
140
140
141
- # Generate scene
141
+ # Generate scene
142
142
scene = gfx .Group ()
143
143
scene .add (* neuron2gfx (core .NeuronList (self .neurons ), ** self .kwargs ))
144
144
scene .add (* volume2gfx (self .volumes , ** self .kwargs ))
145
145
scene .add (* points2gfx (self .points , ** self .kwargs ))
146
146
147
- # Add background
147
+ # Add background
148
148
scene .add (
149
149
gfx .Background (material = gfx .BackgroundMaterial ([0 , 0 , 0 ]))
150
150
)
151
151
152
- # Add light
152
+ # Add light
153
153
scene .add (gfx .AmbientLight ())
154
154
scene .add (gfx .DirectionalLight ())
155
155
@@ -167,15 +167,13 @@ def plot(self):
167
167
controller = controller ,
168
168
camera = camera ,
169
169
renderer = renderer )
170
- #draw_function=lambda : poll_for_input(renderer, scene, camera))
170
+ #draw_function=lambda : poll_for_input(renderer, scene, camera))
171
171
#disp = gfx.Display() # (camera=camera)
172
172
#disp.show(scene)
173
173
174
174
175
175
#def poll_for_input(renderer, scene, camera):
176
176
# renderer.render(scene, camera)
177
-
178
-
179
177
180
178
181
179
def volume2gfx (x , ** kwargs ):
@@ -235,7 +233,7 @@ def volume2gfx(x, **kwargs):
235
233
return visuals
236
234
237
235
238
- def neuron2gfx (x , ** kwargs ):
236
+ def neuron2gfx (x , color = None , ** kwargs ):
239
237
"""Convert a Neuron/List to pygfx visuals.
240
238
241
239
Parameters
@@ -291,7 +289,7 @@ def neuron2gfx(x, **kwargs):
291
289
else :
292
290
raise TypeError (f'Unable to process data of type "{ type (x )} "' )
293
291
294
- colors = kwargs . get ( " color" , kwargs .get ("c" , kwargs .get ("colors" , None ) ))
292
+ colors = color if color is not None else kwargs .get ("c" , kwargs .get ("colors" , None ))
295
293
palette = kwargs .get ("palette" , None )
296
294
color_by = kwargs .get ("color_by" , None )
297
295
shade_by = kwargs .get ("shade_by" , None )
@@ -577,9 +575,9 @@ def skeleton2gfx(neuron, neuron_color, object_id, **kwargs):
577
575
if neuron_color .ndim == 1 :
578
576
coords = segments_to_coords (neuron , neuron .segments )
579
577
else :
580
- coords , vertex_colors = segments_to_coords (neuron , neuron .segments , node_colors = neuron_color )
581
- # `neuron_color` is now a list of colors for each segment; we have to flatten it
582
- # and add `None` to match the breaks
578
+ coords , vertex_colors = segments_to_coords (neuron , neuron .segments , node_colors = neuron_color )
579
+ # `neuron_color` is now a list of colors for each segment; we have to flatten it
580
+ # and add `None` to match the breaks
583
581
vertex_colors = np .vstack ([np .append (t , [[None ] * t .shape [1 ]], axis = 0 ) for t in vertex_colors ]).astype (np .float32 , copy = False )
584
582
585
583
coords = np .vstack ([np .append (t , [[None ] * 3 ], axis = 0 ) for t in coords ])
0 commit comments