"""Module for the CellType configuration node and its dependencies."""importtypingfrom.importconfigfrom._utilimportobj_str_insertfrom.configimporttypesfrom.placement.indicatorimportPlacementIndicationsiftyping.TYPE_CHECKING:from.coreimportScaffold
[docs]@config.nodeclassPlotting:scaffold:"Scaffold"display_name=config.attr()""" Label used to display this cell type in plots. """color=config.attr()""" Color used to display this cell type in plots. """opacity=config.attr(type=types.fraction(),default=1.0)""" Opacity used to display this cell type in plots. """
[docs]@config.nodeclassCellType:""" Information on a population of cells. """scaffold:"Scaffold"name=config.attr(key=True)""" Name of the cell type, equivalent to the key it occurs under in the configuration. """spatial=config.attr(type=PlacementIndications,required=_not_an_entity,default={"radius":None})""" Spatial information about the cell type such as radius and density, and geometric or morphological information. """plotting=config.attr(type=Plotting)""" Plotting information about the cell type, such as color and labels. """entity=config.attr(type=bool,default=False)""" Whether this cell type is an entity type. Entity types don't have representations in space, but can still be connected and simulated. """def__boot__(self):storage=self.scaffold.storageifstorage.supports("PlacementSet"):storage.require_placement_set(self)def__lt__(self,other):try:returnself.name<other.nameexceptException:returnTrue@obj_str_insertdef__repr__(self):try:placements=len(self.get_placement())exceptException:placements="?"try:cells_placed=len(self.get_placement_set())exceptException:cells_placed=0returnf"'{self.name}', {cells_placed} cells, {placements} placement strategies"
[docs]defget_placement(self):""" Get the placement components this cell type is a part of. """returnself.scaffold.get_placement_of(self)
[docs]defget_placement_set(self,*args,**kwargs):""" Retrieve this cell type's placement data :param chunks: When given, restricts the placement data to these chunks. :type chunks: List[bsb.storage._chunks.Chunk] """returnself.scaffold.get_placement_set(self,*args,**kwargs)
[docs]defget_morphologies(self):""" Return the list of morphologies of this cell type. :rtype: List[~bsb.storage.interfaces.StoredMorphology] """if"morphologies"notinself.spatial:return[]else:returnself.scaffold.storage.morphologies.select(*self.spatial.morphologies)
[docs]defclear(self):""" Clear all the placement and connectivity data associated with this cell type. """self.clear_placement()self.clear_connections()
[docs]defclear_placement(self):""" Clear all the placement data associated with this cell type. Connectivity data will remain, but be invalid. """self.get_placement_set().clear()
[docs]defclear_connections(self):""" Clear all the connectivity data associated with this cell type. Any connectivity set that this cell type is a part of will be entirely removed. """forconn_setinself.scaffold.get_connectivity_sets():ifselfisconn_set.pre_typeorselfisconn_set.post_type:conn_set.clear()
# This property was mostly added so that accidental assignment to `ct.morphologies`# instead of `ct.spatial.morphologies` raises an error.@propertydefmorphologies(self):returnself.get_morphologies()@morphologies.setterdefmorphologies(self,value):raiseAttributeError("`cell_type.morphologies` is a readonly attribute. Did you mean"" `cell_type.spatial.morphologies`?")