@@ -56,20 +56,22 @@ def patch_cloudvolume():
56
56
57
57
# If CV not installed do nothing
58
58
if not cv :
59
- logger .info (' cloud-volume appears to not be installed?' )
59
+ logger .info (" cloud-volume appears to not be installed?" )
60
60
return
61
61
62
- for ds in [cv .datasource .graphene .mesh .sharded .GrapheneShardedMeshSource ,
63
- cv .datasource .graphene .mesh .unsharded .GrapheneUnshardedMeshSource ,
64
- cv .datasource .precomputed .mesh .unsharded .UnshardedLegacyPrecomputedMeshSource ,
65
- cv .datasource .precomputed .mesh .multilod .UnshardedMultiLevelPrecomputedMeshSource ,
66
- cv .datasource .precomputed .mesh .multilod .ShardedMultiLevelPrecomputedMeshSource ,
67
- cv .datasource .precomputed .skeleton .sharded .ShardedPrecomputedSkeletonSource ,
68
- cv .datasource .precomputed .skeleton .unsharded .UnshardedPrecomputedSkeletonSource ]:
62
+ for ds in [
63
+ cv .datasource .graphene .mesh .sharded .GrapheneShardedMeshSource ,
64
+ cv .datasource .graphene .mesh .unsharded .GrapheneUnshardedMeshSource ,
65
+ cv .datasource .precomputed .mesh .unsharded .UnshardedLegacyPrecomputedMeshSource ,
66
+ cv .datasource .precomputed .mesh .multilod .UnshardedMultiLevelPrecomputedMeshSource ,
67
+ cv .datasource .precomputed .mesh .multilod .ShardedMultiLevelPrecomputedMeshSource ,
68
+ cv .datasource .precomputed .skeleton .sharded .ShardedPrecomputedSkeletonSource ,
69
+ cv .datasource .precomputed .skeleton .unsharded .UnshardedPrecomputedSkeletonSource ,
70
+ ]:
69
71
ds .get_navis = return_navis (ds .get , only_on_kwarg = False )
70
72
ds .get = return_navis (ds .get , only_on_kwarg = True )
71
73
72
- logger .info (' cloud-volume successfully patched!' )
74
+ logger .info (" cloud-volume successfully patched!" )
73
75
74
76
75
77
def return_navis (func , only_on_kwarg = False ):
@@ -82,12 +84,15 @@ def return_navis(func, only_on_kwarg=False):
82
84
only_on_kwarg : bool
83
85
If True, will look for a `as_navis=True` (default=False)
84
86
keyword argument to determine if results should be converted
85
- to navis neurons.
87
+ to navis neurons. If 'process' is set to False, the neuron
88
+ will not be processed by TriMesh (remove nan, duplicate vertices,etc)
86
89
87
90
"""
91
+
88
92
@functools .wraps (func )
89
93
def wrapper (* args , ** kwargs ):
90
- ret_navis = kwargs .pop ('as_navis' , False )
94
+ ret_navis = kwargs .pop ("as_navis" , False )
95
+ process = kwargs .pop ("process" , False )
91
96
res = func (* args , ** kwargs )
92
97
93
98
if not only_on_kwarg or ret_navis :
@@ -99,18 +104,20 @@ def wrapper(*args, **kwargs):
99
104
100
105
for k , v in res .items ():
101
106
if isinstance (v , cv .Mesh ):
102
- n = core .MeshNeuron (v , id = k , units = 'nm' )
107
+ n = core .MeshNeuron (v , id = k , units = "nm" , process = process )
103
108
neurons .append (n )
104
109
elif isinstance (v , cv .Skeleton ):
105
110
swc_str = v .to_swc ()
106
111
n = io .read_swc (swc_str )
107
112
n .id = k
108
- n .units = 'nm'
113
+ n .units = "nm"
109
114
neurons .append (n )
110
115
else :
111
- logger .warning (f'Skipped { k } : Unable to convert { type (v )} to '
112
- 'navis Neuron.' )
116
+ logger .warning (
117
+ f"Skipped { k } : Unable to convert { type (v )} to " "navis Neuron."
118
+ )
113
119
114
120
return core .NeuronList (neurons )
115
121
return res
122
+
116
123
return wrapper
0 commit comments