Skip to content
Snippets Groups Projects
Unverified Commit dd4aaa35 authored by Xiao Gui's avatar Xiao Gui
Browse files

chore: rm unused components

parent 21bfad9e
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 573 deletions
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from "@angular/core";
import { Feature } from "src/atlasComponents/sapi/sxplrTypes";
import { CONST } from "common/constants"
import { translateV3Entities } from "src/atlasComponents/sapi/translateV3"
const RESTRICTED_ACCESS_ID = "https://nexus.humanbrainproject.org/v0/data/minds/core/embargostatus/v1.0.0/3054f80d-96a8-4dce-9b92-55c68a8b5efd"
@Component({
selector: `sxplr-sapiviews-core-datasets-dataset`,
templateUrl: './dataset.template.html',
styleUrls: [
`./dataset.style.css`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DatasetView implements OnChanges{
@Input('sxplr-sapiviews-core-datasets-dataset-input')
dataset: Feature
public isRestricted = false
public CONST = CONST
ngOnChanges(changes: SimpleChanges): void {
const { dataset } = changes
if (dataset) {
throw new Error(`Fix this`)
// this.isRestricted = (dataset.currentValue as Feature)?.metadata?.accessibility?.["@id"] === RESTRICTED_ACCESS_ID
}
}
}
import { CommonModule } from "@angular/common"
import { HttpClientModule } from "@angular/common/http"
import { Meta, moduleMetadata, Story } from "@storybook/angular"
import { SAPI } from "src/atlasComponents/sapi"
import { getHoc1RightFeatureDetail, getHoc1RightFeatures, provideDarkTheme } from "src/atlasComponents/sapi/stories.base"
import { SapiViewsCoreDatasetModule } from ".."
import { DatasetView } from "./dataset.component"
export default {
component: DatasetView,
decorators: [
moduleMetadata({
imports: [
CommonModule,
HttpClientModule,
SapiViewsCoreDatasetModule,
],
providers: [
SAPI,
...provideDarkTheme,
],
declarations: []
})
],
} as Meta
const Template: Story<DatasetView> = (args: DatasetView, { loaded }) => {
const { feature } = loaded
return ({
props: {
...args,
dataset: feature,
},
})
}
const loadFeat = async () => {
const features = await getHoc1RightFeatures()
const receptorfeat = features.find(f => f['@type'] === "siibra/features/receptor")
const feature = await getHoc1RightFeatureDetail(receptorfeat["@id"])
return {
feature
}
}
export const ReceptorDataset = Template.bind({})
ReceptorDataset.args = {
}
ReceptorDataset.loaders = [
async () => {
const { feature } = await loadFeat()
return {
feature
}
}
]
\ No newline at end of file
<ng-template #headerTmpl>
<ng-content select="[header]"></ng-content>
</ng-template>
<mat-card *ngIf="!dataset">
<ng-template [ngTemplateOutlet]="headerTmpl"></ng-template>
<span>
Dataset not specified.
</span>
</mat-card>
<mat-card *ngIf="dataset"
class="mat-elevation-z4 sxplr-z-4">
<mat-card-title>
<ng-template [ngTemplateOutlet]="headerTmpl"></ng-template>
<span>
{{ dataset.name }}
</span>
</mat-card-title>
<mat-card-subtitle class="sxplr-d-inline-flex sxplr-align-items-stretch">
<mat-icon class="sxplr-m-a" fontSet="fas" fontIcon="fa-database"></mat-icon>
<span class="sxplr-m-a">
EBRAINS dataset
</span>
<button *ngIf="isRestricted"
[matTooltip]="CONST.GDPR_TEXT"
mat-icon-button color="warn">
<i class="fas fa-exclamation-triangle"></i>
</button>
<mat-divider class="sxplr-pl-1" [vertical]="true"></mat-divider>
<!-- <a mat-icon-button sxplr-hide-when-local *ngFor="let url of dataset.link" [href]="url.doi | parseDoi" target="_blank">
<i class="fas fa-external-link-alt"></i>
</a> -->
</mat-card-subtitle>
</mat-card>
<mat-card *ngIf="dataset" class="sxplr-z-0">
<mat-card-content>
<markdown-dom class="sxplr-muted" [markdown]="dataset?.desc">
</markdown-dom>
</mat-card-content>
</mat-card>
export {
SapiViewsCoreDatasetModule
} from "./module"
export {
DatasetView
} from "./dataset/dataset.component"
\ No newline at end of file
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { MarkdownModule } from "src/components/markdown";
import { AngularMaterialModule } from "src/sharedModules";
import { StrictLocalModule } from "src/strictLocal";
import { SapiViewsUtilModule } from "../../util/module";
import { DatasetView } from "./dataset/dataset.component";
@NgModule({
imports: [
CommonModule,
AngularMaterialModule,
MarkdownModule,
SapiViewsUtilModule,
StrictLocalModule,
],
declarations: [
DatasetView,
],
exports: [
DatasetView
]
})
export class SapiViewsCoreDatasetModule{}
\ No newline at end of file
import { Pipe, PipeTransform } from "@angular/core";
import { SapiParcellationModel } from "src/atlasComponents/sapi/type";
export function getTraverseFunctions(parcellations: SapiParcellationModel[], skipDeprecated: boolean = true) {
const getTraverse = (key: 'prev' | 'next') => {
const returnFunction = (parc: SapiParcellationModel) => {
if (!parc.version) {
throw new Error(`parcellation ${parc.name} does not have version defined!`)
}
if (!parc.version[key]) {
return null
}
const found = parcellations.find(p => p["@id"] === parc.version[key]["@id"])
if (!found) {
throw new Error(`parcellation ${parc.name} references ${parc.version[key]['@id']} as ${key} version, but it cannot be found.`)
}
if (skipDeprecated && found.version.deprecated) {
return returnFunction(found)
}
return found
}
return returnFunction
}
const findNewer = getTraverse('next')
const findOlder = getTraverse('prev')
const getFindMostFn = (findNewest) => {
const useFn = findNewest
? findNewer
: findOlder
return () => {
let cursor = parcellations[0]
let returnParc: SapiParcellationModel
while (cursor) {
returnParc = cursor
cursor = useFn(cursor)
}
return returnParc
}
}
return {
findNewer,
findOlder,
findNewest: getFindMostFn(true),
findOldest: getFindMostFn(false)
}
}
@Pipe({
name: 'orderParcellationByVersion',
pure: true
})
export class OrderParcellationByVersionPipe implements PipeTransform{
public transform(parcellations: SapiParcellationModel[], newestFirst: boolean = true, index: number = 0) {
const {
findNewer,
findOlder
} = getTraverseFunctions(parcellations)
const findMostFn = newestFirst ? findNewer : findOlder
const tranverseFn = newestFirst ? findOlder : findNewer
const mostParc = (() => {
let cursor = parcellations[0]
let returnParc: SapiParcellationModel
while (cursor) {
returnParc = cursor
cursor = findMostFn(cursor)
}
return returnParc
})()
let idx = 0
let cursor = mostParc
while (idx < index) {
cursor = tranverseFn(cursor)
if (!cursor) {
throw new Error(`index out of bound`)
}
idx ++
}
return cursor
}
}
import { CommonModule } from "@angular/common"
import { HttpClientModule } from "@angular/common/http"
import { Component } from "@angular/core"
import { provideMockStore } from "@ngrx/store/testing"
import { Meta, moduleMetadata, Story } from "@storybook/angular"
import { SAPI } from "src/atlasComponents/sapi"
import { getHoc1RightFeatureDetail, getHoc1RightFeatures, getHoc1Right, getHumanAtlas, getJba29, getMni152, provideDarkTheme, getMni152SpatialFeatureHoc1Right } from "src/atlasComponents/sapi/stories.base"
import { AngularMaterialModule } from "src/sharedModules"
import { cleanIeegSessionDatasets, SapiAtlasModel, SapiFeatureModel, SapiParcellationModel, SapiRegionModel, SapiSpaceModel } from "../sapi/type"
import { SapiViewsFeaturesModule } from "./features"
@Component({
selector: `rich-dataset-wrapper-cmp`,
template: `
<div *ngIf="!dataset">
Dataset must be provided
</div>
<mat-card *ngIf="dataset">
<sxplr-sapiviews-core-datasets-dataset
[sxplr-sapiviews-core-datasets-dataset-input]="dataset">
</sxplr-sapiviews-core-datasets-dataset>
<sxplr-sapiviews-features-entry
[sxplr-sapiviews-features-entry-atlas]="atlas"
[sxplr-sapiviews-features-entry-space]="template"
[sxplr-sapiviews-features-entry-parcellation]="parcellation"
[sxplr-sapiviews-features-entry-region]="region"
[sxplr-sapiviews-features-entry-feature]="dataset">
</sxplr-sapiviews-features-entry>
</mat-card>
`,
styles: [
`mat-card { max-width: 40rem; }`
]
})
class RichDatasetWrapperCmp {
atlas: SapiAtlasModel
parcellation: SapiParcellationModel
template: SapiSpaceModel
region: SapiRegionModel
dataset: SapiFeatureModel
}
export default {
component: RichDatasetWrapperCmp,
decorators: [
moduleMetadata({
imports: [
AngularMaterialModule,
CommonModule,
HttpClientModule,
SapiViewsFeaturesModule,
],
providers: [
SAPI,
provideMockStore(),
...provideDarkTheme,
],
declarations: []
})
],
} as Meta
const Template: Story<RichDatasetWrapperCmp> = (args: RichDatasetWrapperCmp, { loaded }) => {
const {
atlas,
parcellation,
template,
region,
feature
} = loaded
return ({
props: {
atlas,
parcellation,
template,
region,
dataset: feature,
},
})
}
const loadRegionMetadata = async () => {
const atlas = await getHumanAtlas()
const parcellation = await getJba29()
const template = await getMni152()
const region = await getHoc1Right()
return {
atlas,
parcellation,
template,
region,
}
}
const loadFeat = async () => {
const features = await getHoc1RightFeatures()
return { features }
}
export const ReceptorDataset = Template.bind({})
ReceptorDataset.args = {
}
ReceptorDataset.loaders = [
async () => {
return await loadRegionMetadata()
},
async () => {
const { features } = await loadFeat()
const receptorfeat = features.find(f => f['@type'] === "siibra/features/receptor")
const feature = await getHoc1RightFeatureDetail(receptorfeat["@id"])
return { feature }
}
]
export const IeegDataset = Template.bind({})
IeegDataset.args = {
}
IeegDataset.loaders = [
async () => {
return await loadRegionMetadata()
},
async () => {
const features = await getMni152SpatialFeatureHoc1Right()
const spatialFeats = features.filter(f => f["@type"] === "siibra/features/ieegSession")
const feature = cleanIeegSessionDatasets(spatialFeats)[0]
return { feature }
}
]
import { CommonModule } from "@angular/common"
import { HttpClientModule } from "@angular/common/http"
import {ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA} from "@angular/core"
import { FormsModule } from "@angular/forms"
import { BrowserAnimationsModule } from "@angular/platform-browser/animations"
import { Meta, moduleMetadata, Story } from "@storybook/angular"
import { SAPI, SapiAtlasModel, SapiParcellationModel } from "src/atlasComponents/sapi"
import { getJba29Features, getHumanAtlas, getJba29 } from "src/atlasComponents/sapi/stories.base"
import {SapiParcellationFeatureMatrixModel, SapiParcellationFeatureModel} from "src/atlasComponents/sapi/type"
import { AngularMaterialModule } from "src/sharedModules"
import {PARSE_TYPEDARRAY} from "src/atlasComponents/sapi/sapi.service";
import {catchError, take} from "rxjs/operators"
import {of} from "rxjs";
import { ConnectivityBrowserComponent } from "./connectivityBrowser.component"
@Component({
selector: 'autoradiograph-wrapper-cmp',
template: `
<button mat-button (click)="datasetSliderChanged(1)" class="mb-3">Load Connectivity</button>
<div class="d-flex">Source: {{regionName}}</div>
<mat-label>
Dataset
</mat-label>
<mat-slider [min]="1"
[max]="numberOfDatasets"
(change)="datasetSliderChanged($event.value)"
[value]="pageNumber"
thumbLabel
step="1"
class="w-100">
</mat-slider>
<hbp-connectivity-matrix-row
#connectivityComponent
[region]="regionName"
[connections]="connectionsString"
showSource="true"
theme="light">
</hbp-connectivity-matrix-row>
`,
styles: [
`
:host
{
display: block;
max-width: 60rem;
max-height: 60rem;
}
`
]
})
class ExampleConnectivityBrowserWrapper {
atlas: SapiAtlasModel
parcellation: SapiParcellationModel
features: SapiParcellationFeatureModel[] = []
featureId: string
regionName: string = 'Area TE 3 (STG) right'
type: string = 'siibra/features/connectivity/streamlineCounts'
pageNumber = 1
numberOfDatasets = 1
private regionIndexInMatrix = -1
public connectionsString: string
constructor(private sapi: SAPI, private cdf: ChangeDetectorRef) {
}
datasetSliderChanged(pageNumber) {
this.pageNumber = pageNumber
this.loadDataset()
}
loadDataset() {
return this.sapi.getParcellation(this.atlas["@id"], this.parcellation["@id"])
.getFeatures({type: this.type, page: this.pageNumber, size: 1})
.pipe(
take(1),
catchError(() => {
return of(null)
})
).subscribe((res: any) => {
if (res && res.items) {
this.numberOfDatasets = res.total
this.featureId = res.items[0]['@id']
this.fetchConnectivity()
}
})
}
fetchConnectivity() {
this.sapi.getParcellation(this.atlas["@id"], this.parcellation["@id"]).getFeatureInstance(this.featureId)
.pipe(take(1))
.subscribe(ds=> {
const matrixData = ds as SapiParcellationFeatureMatrixModel
this.regionIndexInMatrix = (matrixData.columns as Array<string>).findIndex(md => md === this.regionName)
this.sapi.processNpArrayData<PARSE_TYPEDARRAY.RAW_ARRAY>(matrixData.matrix, PARSE_TYPEDARRAY.RAW_ARRAY)
.then(matrix => {
const areas = {}
matrix.rawArray[this.regionIndexInMatrix].forEach((value, i) => {
areas[matrixData.columns[i]] = value
})
this.connectionsString = JSON.stringify(areas)
this.cdf.detectChanges()
})
})
}
}
export default {
component: ExampleConnectivityBrowserWrapper,
decorators: [
moduleMetadata({
imports: [
CommonModule,
AngularMaterialModule,
HttpClientModule,
BrowserAnimationsModule,
],
providers: [
SAPI
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA,
],
declarations: [
ConnectivityBrowserComponent
]
})
],
} as Meta
const Template: Story<ExampleConnectivityBrowserWrapper> = (args: ExampleConnectivityBrowserWrapper, { loaded }) => {
const { atlas, parc, features } = loaded
return ({
props: {
...args,
atlas: atlas,
parcellation: parc,
features
},
})
}
Template.loaders = [
async () => {
const atlas = await getHumanAtlas()
const parc = await getJba29()
const features = await getJba29Features()
return {
atlas, parc, features
}
}
]
export const Default = Template.bind({})
Default.args = {
}
Default.loaders = [
...Template.loaders
]
import { SapiParcellationModel, SapiRegionModel } from "src/atlasComponents/sapi";
export type ParcVolumeSpec = {
volumeSrc: string
parcellation: SapiParcellationModel
regions: {
labelIndex: number
region: SapiRegionModel
}[]
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment