Skip to content

Commit

Permalink
Create anchors of BigBrainIntensity features in bigbrain.py to use th…
Browse files Browse the repository at this point in the history
…e same logic and avoid unnecessary imports
  • Loading branch information
AhmetNSimsek committed Dec 14, 2023
1 parent 09c8830 commit 4d6f42f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
13 changes: 3 additions & 10 deletions siibra/features/tabular/bigbrain_intensity_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from typing import List, TYPE_CHECKING
if TYPE_CHECKING:
from ...locations import point
from ...features.anchor import AnatomicalAnchor


class BigBrainIntensityProfile(
Expand All @@ -40,18 +40,11 @@ class BigBrainIntensityProfile(

def __init__(
self,
regionname: str,
anchor: "AnatomicalAnchor",
depths: list,
values: list,
boundaries: list,
location: 'point.Point'
boundaries: list
):
from ..anchor import AnatomicalAnchor
anchor = AnatomicalAnchor(
location=location,
region=regionname,
species='Homo sapiens'
)
cortical_profile.CorticalProfile.__init__(
self,
description=self.DESCRIPTION,
Expand Down
12 changes: 5 additions & 7 deletions siibra/features/tabular/layerwise_bigbrain_intensities.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import pandas as pd
import numpy as np

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ...features.anchor import AnatomicalAnchor


class LayerwiseBigBrainIntensities(
tabular.Tabular,
Expand All @@ -39,16 +43,10 @@ class LayerwiseBigBrainIntensities(

def __init__(
self,
regionname: str,
anchor: "AnatomicalAnchor",
means: list,
stds: list,
):

from ..anchor import AnatomicalAnchor
anchor = AnatomicalAnchor(
region=regionname,
species='Homo sapiens',
)
data = pd.DataFrame(
np.array([means, stds]).T,
columns=['mean', 'std'],
Expand Down
18 changes: 13 additions & 5 deletions siibra/livequeries/bigbrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ def query(self, concept: structure.BrainStructure, **kwargs) -> List[bigbrain_in
matched = concept.intersection(pointset.PointSet(loader._vertices, space='bigbrain'))
assert matched.labels is not None
for i in matched.labels:
anchor = _anchor.AnatomicalAnchor(
location=point.Point(loader._vertices[i], space='bigbrain'),
region=str(concept),
species='Homo sapiens'
)
prof = bigbrain_intensity_profile.BigBrainIntensityProfile(
regionname=str(concept),
anchor=anchor,
depths=loader.profile_labels,
values=loader._profiles[i],
boundaries=loader._boundary_depths[i],
location=point.Point(loader._vertices[i], space='bigbrain')
boundaries=loader._boundary_depths[i]
)
prof.anchor._assignments[concept] = _anchor.AnatomicalAssignment(
query_structure=concept,
Expand Down Expand Up @@ -128,12 +132,16 @@ def query(self, concept: structure.BrainStructure, **kwargs) -> List[layerwise_b
for b in boundary_depths
]).reshape((-1, 200))

anchor = _anchor.AnatomicalAnchor(
location=pointset.PointSet(loader._vertices[indices, :], space='bigbrain'),
region=str(concept),
species='Homo sapiens'
)
result = layerwise_bigbrain_intensities.LayerwiseBigBrainIntensities(
regionname=str(concept),
anchor=anchor,
means=[matched_profiles[layer_labels == layer].mean() for layer in range(1, 7)],
stds=[matched_profiles[layer_labels == layer].std() for layer in range(1, 7)],
)
result.anchor._location_cached = pointset.PointSet(loader._vertices[indices, :], space='bigbrain')
result.anchor._assignments[concept] = _anchor.AnatomicalAssignment(
query_structure=concept,
assigned_structure=concept,
Expand Down

0 comments on commit 4d6f42f

Please sign in to comment.