Package qupath.ext.braian
Class AtlasManager
java.lang.Object
qupath.ext.braian.AtlasManager
This class helps managing and exporting results for each brain region. It works closely with ABBA's QuPath extension.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final qupath.lib.objects.classes.PathClass
static final qupath.lib.objects.classes.PathClass
static final qupath.lib.objects.classes.PathClass
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionAtlasManager
(String atlasName, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Constructs a manager of the specified atlas imported with ABBA.AtlasManager
(qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Constructs a manager of the first available atlas imported with ABBA. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Attempts to fix possible mistakes with the exclusions, such as: Exclusion of the "Root" hierarchy annotation rather than a proper region If a region was excluded within the atlas hierarchyList<qupath.lib.objects.PathObject>
flatten()
Flattens the atlas's ontology into a list of annotations.List<qupath.lib.objects.PathObject>
flatten
(List<AbstractDetections> detections) Flattens the atlas ontology into a list of annotations.Set<qupath.lib.objects.PathObject>
Gets all the brain regions that should be excluded from further analysis due to being missing or badly aligned to the image.qupath.lib.objects.PathObject
getRoot()
static boolean
isImported
(String atlasName, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Checks whether a specific ABBA atlas was previously imported.static boolean
isImported
(qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Checks whether at least one ABBA atlas was previously imported.boolean
isSplit()
Return whether the current atlas is split between left and right hemispheres.boolean
saveExcludedRegions
(File file) Saves a file containing, on each line, the name and hemisphere of the regions to be excluded.boolean
saveResults
(List<AbstractDetections> detections, File file) Saves a TSV file containing data for each brain region of the atlas.
-
Field Details
-
um
-
EXCLUDE_CLASSIFICATION
public static final qupath.lib.objects.classes.PathClass EXCLUDE_CLASSIFICATION -
ABBA_LEFT
public static final qupath.lib.objects.classes.PathClass ABBA_LEFT -
ABBA_RIGHT
public static final qupath.lib.objects.classes.PathClass ABBA_RIGHT
-
-
Constructor Details
-
AtlasManager
Constructs a manager of the specified atlas imported with ABBA.- Parameters:
atlasName
- the name of the atlas that was imported with ABBA. If null, it selects the first available.hierarchy
- where to search for the atlas- Throws:
qupath.ext.braian.ImportedAtlasNotFound
- if the specified atlas was not foundqupath.ext.braian.DisruptedAtlasHierarchy
- if the found atlas hierarchy was disrupted
-
AtlasManager
public AtlasManager(qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Constructs a manager of the first available atlas imported with ABBA.- Parameters:
hierarchy
- where to search for an atlas- Throws:
qupath.ext.braian.ImportedAtlasNotFound
- if no atlas was not found in the object hierarchyqupath.ext.braian.DisruptedAtlasHierarchy
- if the found atlas hierarchy was disrupted- See Also:
-
-
Method Details
-
isImported
public static boolean isImported(qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Checks whether at least one ABBA atlas was previously imported.- Parameters:
hierarchy
- where to search for the atlas- Returns:
- true if an ABBA atlas was previously imported
-
isImported
public static boolean isImported(String atlasName, qupath.lib.objects.hierarchy.PathObjectHierarchy hierarchy) Checks whether a specific ABBA atlas was previously imported.- Parameters:
atlasName
- the name of the atlas to check. If null, it checks whether any atlas was imported with ABBAhierarchy
- where to search for the atlas- Returns:
- true if the atlas was previously imported
-
getRoot
public qupath.lib.objects.PathObject getRoot()- Returns:
- the annotations that contains all atlas annotations.
-
flatten
Flattens the atlas's ontology into a list of annotations. It may return some non-region annotations too, if the atlas hierarchy was modified with added/removed elements.- Returns:
- the list of all brain regions in the atlas
- Throws:
qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce- See Also:
-
flatten
Flattens the atlas ontology into a list of annotations. If the atlas hierarchy was modified by addingAbstractDetections
's containers, it filters them from the current brain hierarchy.
It may still return some non-region annotations, if the atlas hierarchy was further modified with added/removed elements.- Returns:
- the list of all brain regions in the atlas
- Throws:
qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce- See Also:
-
saveResults
Saves a TSV file containing data for each brain region of the atlas. Namely, Image name, brain region name, hemisphere, area in µm², number of detections for each of the given types. The table is saved as a CSV (comma-separated values) file if 'file' ends with ".csv"- Parameters:
detections
- the list of detection of which to gather the data for each regionfile
- the file where it should write to. Note that if the file exists, it will be overwritten- Throws:
qupath.ext.braian.ExclusionMistakeException
- if the atlas hierarchy contains regions classified asEXCLUDE_CLASSIFICATION
.qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce
-
getExcludedBrainRegions
Gets all the brain regions that should be excluded from further analysis due to being missing or badly aligned to the image. A brain region, in order to be excluded, must:- either be contained into a larger annotation, classified as "Exclude"
- or be duplicated (SHIFT+D) outside the Atlas's hierarchy, and then classified as "Exclude"
- Returns:
- a set of brain regions' annotations that should be excluded.
- Throws:
qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce
-
saveExcludedRegions
Saves a file containing, on each line, the name and hemisphere of the regions to be excluded.- Parameters:
file
- the file where it should write to. Note that if the file exists, it will be overwritten- Returns:
- true if the file was correctly saved.
- Throws:
qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce- See Also:
-
isSplit
public boolean isSplit()Return whether the current atlas is split between left and right hemispheres. Atlas hierarchies that were modified by deleting one of the two hemispheres, are still recognised as split.- Returns:
- true if the current atlas is split between left and right hemispheres.
- Throws:
qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce whether the atlas was split between left and right.
-
fixExclusions
public void fixExclusions()Attempts to fix possible mistakes with the exclusions, such as:- Exclusion of the "Root" hierarchy annotation rather than a proper region
- If a region was excluded within the atlas hierarchy
- Throws:
qupath.ext.braian.DisruptedAtlasHierarchy
- if the current atlas hierarchy was disrupted, and it is not possible to deduce
-