|
21 | 21 | import numpy as np
|
22 | 22 |
|
23 | 23 | from . import query as _query
|
24 |
| -from ..core import space as _space, structure |
| 24 | +from ..core import structure |
25 | 25 | from ..features import anchor as _anchor
|
26 | 26 | from ..features.tabular.gene_expression import GeneExpressions
|
27 | 27 | from ..commons import logger, Species
|
28 |
| -from ..locations import point, pointcloud |
| 28 | +from ..locations import pointcloud |
29 | 29 | from ..retrieval import HttpRequest
|
30 | 30 | from ..vocabularies import GENE_NAMES
|
31 | 31 |
|
@@ -144,27 +144,25 @@ def query(self, concept: structure.BrainStructure) -> List[GeneExpressions]:
|
144 | 144 | 'https://github.com/FZJ-INM1-BDA/siibra-python/issues/636.'
|
145 | 145 | )
|
146 | 146 |
|
147 |
| - mnispace = _space.Space.registry().get('mni152') |
148 |
| - |
149 | 147 | # Match the microarray probes to the query mask.
|
150 | 148 | # Record matched instances and their locations.
|
151 |
| - measurements = [] |
152 |
| - coordinates = [] |
153 |
| - for measurement in self: |
154 |
| - pt = point.Point(measurement['mni_xyz'], space=mnispace, sigma_mm=LOCATION_PRECISION_MM) |
155 |
| - if pt in concept: |
156 |
| - measurements.append(measurement) |
157 |
| - coordinates.append(pt) |
158 |
| - |
159 |
| - if len(coordinates) == 0: |
| 149 | + all_mes_points = pointcloud.PointCloud( |
| 150 | + [measurement['mni_xyz'] for measurement in self], |
| 151 | + space='mni152', |
| 152 | + sigma_mm=LOCATION_PRECISION_MM |
| 153 | + ) |
| 154 | + intersecting_points = concept.intersection(all_mes_points) |
| 155 | + measurements = [mes for mes in self if mes['mni_xyz'] in intersecting_points.coordinates] |
| 156 | + |
| 157 | + if len(intersecting_points) == 0: |
160 | 158 | logger.info(f"No probes found that lie within {concept}")
|
161 | 159 | return []
|
162 | 160 |
|
163 | 161 | # Build the anatomical anchor and assignment to the query concept.
|
164 | 162 | # It will be attached to the returned feature, with the set of matched
|
165 | 163 | # MNI coordinates as anchor's location.
|
166 | 164 | anchor = _anchor.AnatomicalAnchor(
|
167 |
| - location=pointcloud.from_points(coordinates), |
| 165 | + location=pointcloud.from_points(intersecting_points), |
168 | 166 | species=self.species
|
169 | 167 | )
|
170 | 168 | explanation = f"MNI coordinates of tissue samples were filtered using {concept}"
|
|
0 commit comments