Skip to content

Commit

Permalink
bits and pieces for masking:
Browse files Browse the repository at this point in the history
- add .view() methods to neuron objects
- by default, do not copy data
- bits and pieces
  • Loading branch information
schlegelp committed Dec 4, 2024
1 parent fe2d716 commit fcc2d44
Show file tree
Hide file tree
Showing 6 changed files with 328 additions and 206 deletions.
26 changes: 24 additions & 2 deletions navis/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@


def Neuron(
x: Union[nx.DiGraph, str, pd.DataFrame, "TreeNeuron", "MeshNeuron"],
x: Union[nx.DiGraph, str, pd.DataFrame, "TreeNeuron", "MeshNeuron"], # noqa: F821
**metadata, # noqa: F821
):
"""Constructor for Neuron objects. Depending on the input, either a
Expand Down Expand Up @@ -664,6 +664,10 @@ def copy(self, deepcopy=False) -> "BaseNeuron":

return x

def view(self) -> "BaseNeuron":
"""Create a view of the neuron without copying data."""
raise NotImplementedError(f"View not implemented for neuron of type {type(self)}.")

def summary(self, add_props=None) -> pd.Series:
"""Get a summary of this neuron."""

Expand All @@ -687,6 +691,11 @@ def summary(self, add_props=None) -> pd.Series:
warnings.simplefilter("ignore")
s = pd.Series([getattr(self, at, "NA") for at in props], index=props)

# Show mask status
if self.is_masked:
if "masked" not in s.index:
s["masked"] = True

return s

def plot2d(self, **kwargs):
Expand Down Expand Up @@ -750,7 +759,20 @@ def is_masked(self):
return hasattr(self, "_masked_data")

def mask(self, mask):
"""Mask neuron."""
"""Mask neuron.
Implementation details depend on the neuron type (see below).
See Also
--------
[`navis.TreeNeuron.mask`][]
Mask skeleton.
[`navis.MeshNeuron.mask`][]
Mask mesh.
[`navis.Dotprops.mask`][]
Mask dotprops.
"""
raise NotImplementedError(
f"Masking not implemented for neuron of type {type(self)}."
)
Expand Down
Loading

0 comments on commit fcc2d44

Please sign in to comment.