Skip to content

Commit 35585fe

Browse files
committed
Take feature.id from config if available
1 parent aac72eb commit 35585fe

11 files changed

+46
-15
lines changed

siibra/configuration/factory.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ def build_receptor_density_fingerprint(cls, spec):
365365
tsvfile=spec['file'],
366366
anchor=cls.extract_anchor(spec),
367367
datasets=cls.extract_datasets(spec),
368+
id=spec.get("id", None)
368369
)
369370

370371
@classmethod
@@ -375,6 +376,7 @@ def build_cell_density_fingerprint(cls, spec):
375376
layerfiles=spec['layerfiles'],
376377
anchor=cls.extract_anchor(spec),
377378
datasets=cls.extract_datasets(spec),
379+
id=spec.get("id", None)
378380
)
379381

380382
@classmethod
@@ -385,6 +387,7 @@ def build_receptor_density_profile(cls, spec):
385387
tsvfile=spec['file'],
386388
anchor=cls.extract_anchor(spec),
387389
datasets=cls.extract_datasets(spec),
390+
id=spec.get("id", None)
388391
)
389392

390393
@classmethod
@@ -396,6 +399,7 @@ def build_cell_density_profile(cls, spec):
396399
url=spec['file'],
397400
anchor=cls.extract_anchor(spec),
398401
datasets=cls.extract_datasets(spec),
402+
id=spec.get("id", None)
399403
)
400404

401405
@classmethod
@@ -408,6 +412,7 @@ def build_section(cls, spec):
408412
"space_spec": vol._space_spec,
409413
"providers": vol._providers.values(),
410414
"datasets": cls.extract_datasets(spec),
415+
"id": spec.get("id", None)
411416
}
412417
modality = spec.get('modality', "")
413418
if modality == "cell body staining":
@@ -425,6 +430,7 @@ def build_volume_of_interest(cls, spec):
425430
"space_spec": vol._space_spec,
426431
"providers": vol._providers.values(),
427432
"datasets": cls.extract_datasets(spec),
433+
"id": spec.get("id", None)
428434
}
429435
modality = spec.get('modality', "")
430436
if modality == "cell body staining":
@@ -495,7 +501,8 @@ def build_connectivity_matrix(cls, spec):
495501
"filename": filename,
496502
"subject": fkey if files_indexed_by == "subject" else "average",
497503
"feature": fkey if files_indexed_by == "feature" else None,
498-
"connector": repo_connector or base_url + filename
504+
"connector": repo_connector or base_url + filename,
505+
"id": spec.get("id", None)
499506
})
500507
conn_by_file.append(conn_cls(**kwargs))
501508
return conn_by_file
@@ -528,7 +535,8 @@ def build_activity_timeseries(cls, spec):
528535
for fkey, filename in files.items():
529536
kwargs.update({
530537
"filename": filename,
531-
"subject": fkey
538+
"subject": fkey,
539+
"id": spec.get("id", None)
532540
})
533541
timeseries_by_file.append(timeseries_cls(**kwargs))
534542
return timeseries_by_file

siibra/features/connectivity/regional_connectivity.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def __init__(
5757
description: str = "",
5858
datasets: list = [],
5959
subject: str = "average",
60-
feature: str = None
60+
feature: str = None,
61+
id: str = None
6162
):
6263
"""
6364
Construct a parcellation-averaged connectivity matrix.
@@ -91,6 +92,7 @@ def __init__(
9192
description=description,
9293
anchor=anchor,
9394
datasets=datasets,
95+
id=id
9496
)
9597
self.cohort = cohort.upper()
9698
if isinstance(connector, str) and connector:

siibra/features/feature.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def __init__(
9898
modality: str,
9999
description: str,
100100
anchor: _anchor.AnatomicalAnchor,
101-
datasets: List['TypeDataset'] = []
101+
datasets: List['TypeDataset'] = [],
102+
id: str = None
102103
):
103104
"""
104105
Parameters
@@ -115,6 +116,7 @@ def __init__(
115116
self._description = description
116117
self._anchor_cached = anchor
117118
self.datasets = datasets
119+
self._id = id
118120

119121
@property
120122
def modality(self):
@@ -262,6 +264,9 @@ def last_match_description(self):
262264

263265
@property
264266
def id(self):
267+
if self._id:
268+
return self._id
269+
265270
prefix = ''
266271
for ds in self.datasets:
267272
if hasattr(ds, "id"):

siibra/features/image/image.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ def __init__(
6363
providers: List[provider.VolumeProvider],
6464
region: str = None,
6565
datasets: List = [],
66+
id: str = None
6667
):
6768
feature.Feature.__init__(
6869
self,
6970
modality=modality,
7071
description=None, # lazy implementation below!
7172
anchor=None, # lazy implementation below!
72-
datasets=datasets
73+
datasets=datasets,
74+
id=id
7375
)
7476

7577
_volume.Volume.__init__(

siibra/features/tabular/cell_density_profile.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def __init__(
6969
patch: int,
7070
url: str,
7171
anchor: _anchor.AnatomicalAnchor,
72-
datasets: list = []
72+
datasets: list = [],
73+
id: str = None
7374
):
7475
"""
7576
Generate a cell density profile from a URL to a cloud folder
@@ -82,6 +83,7 @@ def __init__(
8283
unit="cells / 0.1mm3",
8384
anchor=anchor,
8485
datasets=datasets,
86+
id=id
8587
)
8688
self._step = 0.01
8789
self._url = url

siibra/features/tabular/cortical_profile.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def __init__(
5656
values: Union[list, np.ndarray] = None,
5757
unit: str = None,
5858
boundary_positions: Dict[Tuple[int, int], float] = None,
59-
datasets: list = []
59+
datasets: list = [],
60+
id: str = None
6061
):
6162
"""Initialize profile.
6263
@@ -96,7 +97,8 @@ def __init__(
9697
description=description,
9798
anchor=anchor,
9899
data=None, # lazy loader below
99-
datasets=datasets
100+
datasets=datasets,
101+
id=id
100102
)
101103

102104
def _check_sanity(self):

siibra/features/tabular/layerwise_cell_density.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ def __init__(
5656
layerfiles: list,
5757
anchor: _anchor.AnatomicalAnchor,
5858
datasets: list = [],
59+
id: str = None
5960
):
6061
tabular.Tabular.__init__(
6162
self,
6263
description=self.DESCRIPTION,
6364
modality="Cell body density",
6465
anchor=anchor,
6566
datasets=datasets,
66-
data=None # lazy loading below
67+
data=None, # lazy loading below
68+
id=id
6769
)
6870
self.unit = "# detected cells/0.1mm3"
6971
self._filepairs = list(zip(segmentfiles, layerfiles))

siibra/features/tabular/receptor_density_fingerprint.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def __init__(
4242
self,
4343
tsvfile: str,
4444
anchor: _anchor.AnatomicalAnchor,
45-
datasets: list = []
45+
datasets: list = [],
46+
id: str = None
4647
):
4748
""" Generate a receptor fingerprint from a URL to a .tsv file
4849
formatted according to the structure used by Palomero-Gallagher et al.
@@ -54,6 +55,7 @@ def __init__(
5455
anchor=anchor,
5556
data=None, # lazy loading below
5657
datasets=datasets,
58+
id=id
5759
)
5860
self._loader = requests.HttpRequest(tsvfile)
5961

siibra/features/tabular/receptor_density_profile.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def __init__(
4141
receptor: str,
4242
tsvfile: str,
4343
anchor: _anchor.AnatomicalAnchor,
44-
datasets: list = []
44+
datasets: list = [],
45+
id: str = None
4546
):
4647
"""Generate a receptor density profile from a URL to a .tsv file
4748
formatted according to the structure used by Palomero-Gallagher et al.
@@ -52,6 +53,7 @@ def __init__(
5253
modality="Receptor density",
5354
anchor=anchor,
5455
datasets=datasets,
56+
id=id
5557
)
5658
self.receptor = receptor
5759
self._data_cached = None

siibra/features/tabular/regional_timeseries_activity.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def __init__(
4848
timestep: str,
4949
description: str = "",
5050
datasets: list = [],
51-
subject: str = "average"
51+
subject: str = "average",
52+
id: str = None
5253
):
5354
"""
5455
"""
@@ -58,7 +59,8 @@ def __init__(
5859
description=description,
5960
anchor=anchor,
6061
datasets=datasets,
61-
data=None # lazy loading below
62+
data=None, # lazy loading below
63+
id=id
6264
)
6365
self.cohort = cohort.upper()
6466
if isinstance(connector, str) and connector:

siibra/features/tabular/tabular.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ def __init__(
4444
modality: str,
4545
anchor: _anchor.AnatomicalAnchor,
4646
data: pd.DataFrame, # sample x feature dimension
47-
datasets: list = []
47+
datasets: list = [],
48+
id: str = None
4849
):
4950
feature.Feature.__init__(
5051
self,
5152
modality=modality,
5253
description=description,
5354
anchor=anchor,
54-
datasets=datasets
55+
datasets=datasets,
56+
id=id
5557
)
5658
self._data_cached = data
5759

0 commit comments

Comments
 (0)