neurocarto.util.edit.checking
- neurocarto.util.edit.checking.use_probe(probe=<class 'neurocarto.probe.ProbeDesp'>, code=None, *, create=None, check=True)
Decorate a blueprint script (
BlueprintScript) to indicate this function request a particular probe type.@use_probe('npx', 24) # checking and creating probe if necessary def my_probe(bp: BlueprintFunctions): bp.check_probe('npx', 24) # no need anymore in common case.
It also allows
BlueprintScriptViewto filter suitable scripts for a probe.- Parameters:
probe (str | type[ProbeDesp]) – probe type or its name. It is omitted, just check a probe is existed.
code (int | tuple[int, ...] | None) – channelmap code
create (bool | None) – create the probe if there is no probe in the main figure. If
True, it requires code should be notNone. ForceFalseif probe is omitted.check – check the current probe type automatically before entering the script.
- See:
- See:
BlueprintFunctions.
check_probe()
- neurocarto.util.edit.checking.check_probe(self, probe=None, code=None)
check request probe type and channelmap code.
- Parameters:
self (BlueprintFunctions)
probe (str | type[ProbeDesp] | RequestChannelmapType | None) – request probe type. It could be family name (via
get_probe_desp()),ProbeDesptype or class name. ItNone, checking a probe has created, and its type doesn’t matter.code (int) – request channelmap code
- Raises:
RequestChannelmapTypeError – when check failed.
- neurocarto.util.edit.checking.get_use_probe(func)
-
- Parameters:
func – blueprint script function
- Returns:
- Return type:
RequestChannelmapType | None
- class neurocarto.util.edit.checking.RequestChannelmapType
An annotation data to indicate the probe request for a blueprint script.
Do not create by yourself. In order to use this, use
use_probe()andget_use_probe()instead.- code: int | tuple[int, ...] | None
request channelmap code.
- create: bool
create a channelmap when it is missing.
- check: bool
check it is existed and match to the request. raise error when mis-match
- property probe_name: str
Probe name
- exception neurocarto.util.edit.checking.RequestChannelmapTypeError
- __init__(request)
- Parameters:
request (RequestChannelmapType) – request probe type.
- neurocarto.util.edit.checking.use_view(view)
Decorate a blueprint script (
BlueprintScript) to indicate this function request a particularViewBaseto work.@use_view('AtlasView') def my_function(bp: BlueprintFunctions): if (atlas := bp.use_view('AtlasView')) is None: raise RuntimeError('AtlasView is not loaded')
It also allows
BlueprintScriptViewto filter suitable scripts, which depends on existed views.- Parameters:
view (str | type[neurocarto.views.base.ViewBase]) – request view name or type.
- Returns:
- See:
- See:
BlueprintFunctions.
use_view()
- neurocarto.util.edit.checking.get_use_view(func)
Get
RequestView.- Parameters:
func – blueprint script function
- Returns:
- Return type:
RequestView | None
- class neurocarto.util.edit.checking.RequestView
An annotation data to indicate the view dependency for a blueprint script.
Do not create by yourself. In order to use this, use
use_view()andget_use_view()instead.- static __new__(_cls, view_type)
Create new instance of RequestView(view_type,)
- Parameters:
view_type (str | type[ViewBase])
- view_type: str | type[neurocarto.views.base.ViewBase]
request view name or type.