diff --git a/+siibra/+internal/API.m b/+siibra/+internal/API.m index d3f1b6a..9291c82 100644 --- a/+siibra/+internal/API.m +++ b/+siibra/+internal/API.m @@ -79,7 +79,7 @@ function regionsJson = regions(parcellationId) absoluteLink = siibra.internal.API.absoluteLinkV3("regions"); - parameters = ["parcellation_id=" + parcellationId]; + parameters = "parcellation_id=" + parcellationId; regionsJson = siibra.internal.API.collectItemsAcrossPages( ... absoluteLink, parameters); end @@ -124,60 +124,17 @@ absoluteLink = siibra.internal.API.absoluteLinkV3(relativeLink); end - function absoluteLink = featuresPageForParcellation(atlasId, parcellationId, page, size) - relativeLink = "atlases/" + atlasId + ... - "/parcellations/" + parcellationId + ... - "/features?page=" + page + ... - "&size=" + size; - absoluteLink = siibra.internal.API.absoluteLinkV2(relativeLink); - end - function featureList = featuresForParcellation(atlasId, parcellationId) - featureList = {}; - page = 1; - size = 100; - firstPage = siibra.internal.API.doWebreadWithLongTimeout( ... - siibra.internal.API.featuresPageForParcellation( ... - atlasId, ... - parcellationId, ... - page, ... - size)... - ); - totalElements = firstPage.total; - featureList{1} = firstPage.items; - processedElements = numel(firstPage.items); - while processedElements < totalElements - page = page + 1; - nextPage = siibra.internal.API.doWebreadWithLongTimeout( ... - siibra.internal.API.featuresPageForParcellation( ... - atlasId, ... - parcellationId, ... - page, ... - size)... - ); - featureList{page} = nextPage.items; - processedElements = processedElements + numel(nextPage.items); - end - featureList = cat(1, featureList{:}); - end - function absoluteLink = parcellationFeature(atlasId, parcellationId, featureId) - % get specific feature by feature id. - relativeLink = "atlases/" + atlasId + ... - "/parcellations/" + parcellationId + ... - "/features/" + featureId; - absoluteLink = siibra.internal.API.absoluteLinkV2(relativeLink); - end - function absoluteLink = featuresForRegion(atlasId, parcellationId, regionName) - relativeLink = "atlases/" +atlasId + ... - "/parcellations/" + parcellationId + ... - "/regions/" + regionName + "/features"; - absoluteLink = siibra.internal.API.absoluteLinkV2(relativeLink); + function features = featuresForRegion(region) + relativeLink = "regions/" + region.Name + "/features"; + absoluteLink = siibra.internal.API.absoluteLinkV3(relativeLink); + parameters = "parcellation_id=" + region.Parcellation.Id; + features = siibra.internal.API.collectItemsAcrossPages(absoluteLink, parameters); end - function absoluteLink = regionFeature(atlasId, parcellationId, regionName, featureId) - relativeLink = "atlases/" +atlasId + ... - "/parcellations/" + parcellationId + ... - "/regions/" + regionName + ... - "/features/" + featureId; - absoluteLink = siibra.internal.API.absoluteLinkV2(relativeLink); + function absoluteLink = tabularFeature(region, featureId) + relativeLink = "feature/Tabular/" + featureId + ... + "?parcellation_id=" + region.Parcellation.Id + ... + "®ion_id=" + region.Name; + absoluteLink = siibra.internal.API.absoluteLinkV3(relativeLink); end end diff --git a/+siibra/+items/+features/ReceptorDensity.m b/+siibra/+items/+features/ReceptorDensity.m index 1042e8d..7074a23 100644 --- a/+siibra/+items/+features/ReceptorDensity.m +++ b/+siibra/+items/+features/ReceptorDensity.m @@ -7,7 +7,6 @@ Id string Description string Name string - DOI string Fingerprint string Unit string end @@ -15,19 +14,16 @@ methods function obj = ReceptorDensity(region, receptorJson) obj.Region = region; - obj.Id = receptorJson.x_id; - obj.Description = receptorJson.metadata.description; - obj.Name = receptorJson.metadata.fullName; - obj.DOI = "https://doi.org/" + receptorJson.urls.doi; + obj.Id = receptorJson.id; + obj.Description = receptorJson.description; + obj.Name = receptorJson.name; obj.Unit = "fmol/mg"; end function fingerprints = get.Fingerprint(obj) fingerprintJson = siibra.internal.API.doWebreadWithLongTimeout( ... - siibra.internal.API.regionFeature( ... - obj.Region.Parcellation.Atlas.Id, ... - obj.Region.Parcellation.Id, ... - obj.Region.Name, ... + siibra.internal.API.tabularFeature( ... + obj.Region, ... obj.Id)); fingerprintStruct = fingerprintJson.data.fingerprints; receptors = fieldnames(fingerprintStruct); diff --git a/+siibra/+items/Parcellation.m b/+siibra/+items/Parcellation.m index 2021d73..b0364af 100644 --- a/+siibra/+items/Parcellation.m +++ b/+siibra/+items/Parcellation.m @@ -85,6 +85,7 @@ end function features = getAllFeatures(obj) + error("API v3 has no features on parcellation level!"); cached_file_name = siibra.internal.cache(obj.Name + ".mat", "parcellation_features"); if ~isfile(cached_file_name) features = siibra.internal.API.featuresForParcellation(obj.Atlas.Id, obj.Id); diff --git a/+siibra/+items/Region.m b/+siibra/+items/Region.m index 287f4f0..56f57af 100644 --- a/+siibra/+items/Region.m +++ b/+siibra/+items/Region.m @@ -45,11 +45,7 @@ function features = getAllFeatures(obj) cached_file_name = siibra.internal.cache(obj.NormalizedName + ".mat", "region_features"); if ~isfile(cached_file_name) - features = siibra.internal.API.doWebreadWithLongTimeout( ... - siibra.internal.API.featuresForRegion( ... - obj.Parcellation.Atlas.Id, ... - obj.Parcellation.Id, ... - obj.Name)); + features = siibra.internal.API.featuresForRegion(obj); % make sure to always return a cell array if ~iscell(features) @@ -64,7 +60,8 @@ function receptorDensities = getReceptorDensities(obj) allFeatures = obj.getAllFeatures(); - receptorIdx = cellfun(@(e) strcmp(e.x_type,'siibra/features/receptor'), allFeatures); + featureTypes = cellfun(@(e) e.x_type, allFeatures, "UniformOutput",false); + receptorIdx = strcmp(featureTypes, "siibra-0.4/feature/tabular/receptor_density_fp"); if ~any(receptorIdx) receptorDensities = siibra.items.features.ReceptorDensity.empty; return