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 and plot errors in reconstructions. |
|
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.ElementValidationTask
Collect 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.ElementValidationTask
Extract 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.ElementValidationTask
Plot markers on morphologies.
Plot the markers extracted from
tasks.curation.ExtractMarkers
on the morphologies.
- class tasks.curation.CheckNeurites(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,data_validation_framework.task.ElementValidationTask
Detect 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
False
if 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_axon
oruse_dendrites
, our corresponding flags will match.Todo
Set various levels, a one section neurite can be set to
has_basal=False
for example.- mock_soma_type¶
Add a soma if missing of the given type
- Type:
- Choices:
{spherical, contour}
- 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
- ensure_axon_at_soma¶
Ensure all axons are connected to the soma, and not dendrites
- Type:
- Default value:
True
- class tasks.curation.Sanitize(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,data_validation_framework.task.ElementValidationTask
Sanitize 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.CheckNeurites
task 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.ElementValidationTask
Recenter 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.ElementValidationTask
Orient morphologies.
- Sometimes, morphologies are oriented along non-standard axis. At BBP, the standard axis is
y
for pia direction (apical trunk, minus main axon, etc…)z
is the slice direction is invitrox
the other direction
If
y
is provided (default value), no oriention will be applied. One can also use minus sign, as-y
to flip y axis.
- class tasks.curation.Align(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,SkippableMixin
(True
),data_validation_framework.task.ElementValidationTask
Align 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()
.method
can be:whole
,trunk
,first_segment
,first_section
,custom
If
method
iscustom
, 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:
{custom, first_section, first_segment, trunk, whole}
- Default value:
whole
- direction¶
- class tasks.curation.EnsureNeuritesOutsideSoma(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,SkippableMixin
(True
),data_validation_framework.task.ElementValidationTask
Fix 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.ElementValidationTask
Detect and plot 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
overlapping points
z-range (new error only present here, which check is the z thickness is larger than min_range)
This task uses
neuror.sanitize.annotate_neurolucida()
. This task creates new.asc
file with error annotated so it can be red by Neurolucida, and amorphology_workflows.marker_helper.MarkerSet
container of the errors, for later plotting.- overlapping_point_tolerance¶
Tolerance used to detect overlapping points.
- Type:
- Default value:
1e-06
- class tasks.curation.ErrorsReport(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,SkippableMixin
(),data_validation_framework.task.SetValidationTask
Save error report for all morphologies.
From the detected errors in
tasks.curation.DetectErrors
, create a CSV report.
- class tasks.curation.Resample(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,SkippableMixin
(),data_validation_framework.task.ElementValidationTask
Resample morphologies.
This tasks ensures a constant sampling rate of points along all branches using the
morph_tool.resampling.resample_linear_density()
function.
- class tasks.curation.PlotMorphologies(*args, **kwargs)¶
Bases:
morphology_workflows.utils.StrIndexMixin
,SkippableMixin
(),data_validation_framework.task.ElementValidationTask
Plot curated morphologies.
This tasks creates a single pdf with all morphologies to visualise them after curation.
The PDF file is created using the
neurom.view.matplotlib_impl.plot_morph()
function.