tasks.curation¶
Curation tasks.
Module Contents¶
Classes¶
Collect external dataset from .csv file. |
|
Extract marker information from the original morphology files, if any. |
|
Plot markers on morphologies. |
|
Detect which neurites are present in the morphology, and add soma if missing. |
|
Sanitize the morphologies. |
|
Recenter morphologies. |
|
Orient morphologies. |
|
Align morphologies. |
|
Fix radius of the soma of each morphology and cut the root section of neurites if needed. |
|
Detect errors in reconstructions. |
|
Plot detected errors. |
|
Save error report for all morphologies. |
|
Resample morphologies. |
|
Plot curated morphologies. |
Attributes¶
- tasks.curation.logger¶
- class tasks.curation.Collect(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,data_validation_framework.task.ElementValidationTaskCollect external dataset from .csv file.
Original dataset has to have a ‘morph_name’ and ‘morph_path’ columns, with the name and path to the corresponding morphologies. Any other valid columns will be gathered as well. In addition, it will only collect morphologies with allowed extension:
.asc,.h5,.swc.
- class tasks.curation.ExtractMarkers(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskExtract marker information from the original morphology files, if any.
Markers are additional spatial information contained in some reconstructed morphologies. Some can be read by MorphIO (https://github.com/BlueBrain/MorphIO/pull/186). The markers are stored in a custom API:
morphology_workflows.marker_helper.
- class tasks.curation.PlotMarkers(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskPlot markers on morphologies.
Plot the markers extracted from
tasks.curation.ExtractMarkerson the morphologies.
- class tasks.curation.CheckNeurites(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,data_validation_framework.task.ElementValidationTaskDetect which neurites are present in the morphology, and add soma if missing.
- This task adds three important boolean flags:
has_axon
has_basal
has_apical
set to
Falseif any are absent.For the axon, if it only has fewer sections than
axon_n_section_min, it will be considered ashas_axon=False.If soma is absent, a soma is added as a circle, with center the mean of the first points of root sections, and radius as standard deviation of these points around the center.
If the input dataset has columns
use_axonoruse_dendrites, our corresponding flags will match.Todo
Set various levels, a one section neurite can be set to
has_basal=Falsefor example.- mock_soma_type¶
Add a soma if missing of the given type
- Type:
- Choices:
{contour, spherical}
- Default value:
spherical
- axon_n_section_min¶
Minimum number of sections in an axon to consider it valid
- Type:
- Default value:
5
- ensure_stub_axon¶
Add a stub axon if there is no axon on the morphology
- Type:
- Default value:
False
- class tasks.curation.Sanitize(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,data_validation_framework.task.ElementValidationTaskSanitize the morphologies.
Sanitization is done with
neuror.sanitize.sanitize()and does the following:ensures it can be loaded with MorphIO
raises if the morphology has no soma or of invalid format
removes unifurcations
set negative diameters to zero
raises if the morphology has a neurite whose type changes along the way
removes segments with near zero lengths (shorter than 1e-4)
Note that the
tasks.curation.CheckNeuritetask adds a soma if missing, so a failure here means that the soma does not have a valid type.
- class tasks.curation.Recenter(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskRecenter morphologies.
Often, morphologies do not have a soma centered at
[0, 0, 0], so we recenter and save the original location, in case it is important to know where the morphology is located in atlas.
- class tasks.curation.Orient(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,data_validation_framework.task.ElementValidationTaskOrient morphologies.
- Sometimes, morphologies are oriented along non-standard axis. At BBP, the standard axis is
yfor pia direction (apical trunk, minus main axon, etc…)zis the slice direction is invitroxthe other direction
If
yis provided (default value), no oriention will be applied.
- class tasks.curation.Align(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(True),data_validation_framework.task.ElementValidationTaskAlign morphologies.
Sometimes, a morphology is not aligned with any consistent direction, so we can try here to align them using a various algorithms from
morph_tool.transform.align_morphology().methodcan be:whole,trunk,first_segment,first_section,customIf
methodiscustom, one must provide external orientation direction in a json file via the parametercustom_orientation_json_path.TODO: implement the axon_collateral method (for thalamus or example), following https://bbpgitlab.epfl.ch/cells/archive/iavarone/thalamus_pipeline/-/blob/master/notebooks/cell_alignement/Rt_TC_rotations_AxonCollaterals_Releases2019.ipynb
By default, this task is skipped.
- method¶
Method to align morphology
- Type:
- Choices:
{trunk, first_section, first_segment, whole, custom}
- Default value:
whole
- direction¶
- class tasks.curation.EnsureNeuritesOutsideSoma(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(True),data_validation_framework.task.ElementValidationTaskFix radius of the soma of each morphology and cut the root section of neurites if needed.
- class tasks.curation.DetectErrors(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskDetect errors in reconstructions.
Reconstructions may contain errors, which are detected here. They are of the following type:
fat ends
z-jumps
narrow start
dangling branch
multifurcation
z-range (new error only present here, which check is the z thickness is larger than min_range)
This task uses NeuroR/neuror/error_annotation.py (https://github.com/BlueBrain/NeuroR), and reproduuces part of what is in MorphService. This task creates new .asc file with error annotated so it can be red by Neuroluscida, and a MarkerSet container of the errors, for later plotting.
- class tasks.curation.PlotErrors(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskPlot detected errors.
From the detected errors in
tasks.curation.DetectErrors, plot them on the morphologies.
- class tasks.curation.ErrorsReport(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.SetValidationTaskSave error report for all morphologies.
- class tasks.curation.Resample(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskResample morphologies.
This tasks ensures a constant sampling rate of points along all branches.
- class tasks.curation.PlotMorphologies(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin,SkippableMixin(),data_validation_framework.task.ElementValidationTaskPlot curated morphologies.
This tasks creates a single pdf with all morphologies to visualise them after curation.