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

chore: integrate dwm pmap preview

parent 7147effb
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ const fs = require('fs')
const request = require('request')
const path = require('path')
const { getPreviewFile, hasPreview } = require('./supplements/previewFile')
const { manualFilter: manualFilterDWM, manualMap: manualMapDWM } = require('./supplements/util/mapDwm')
const kgQueryUtil = require('./../auth/util')
......@@ -137,18 +138,19 @@ const filter = (datasets = [], {templateName, parcellationName}) => datasets
return ds.referenceSpaces.some(rs => rs.name === templateName)
}
if (parcellationName) {
if (parcellationName === 'Fibre Bundle Atlas - Long Bundle'){
return manualFilterDWM(ds)
}
return ds.parcellationRegion.length > 0
? filterByPRs(
ds.parcellationRegion,
parcellationName === 'JuBrain Cytoarchitectonic Atlas' && juBrain
? juBrain
: parcellationName === 'Fibre Bundle Atlas - Long Bundle' && longBundle
? longBundle
: parcellationName === 'Fibre Bundle Atlas - Short Bundle' && shortBundle
? shortBundle
: parcellationName === 'Waxholm Space rat brain atlas v.2.0'
? waxholm
: null
: parcellationName === 'Fibre Bundle Atlas - Short Bundle' && shortBundle
? shortBundle
: parcellationName === 'Waxholm Space rat brain atlas v.2.0'
? waxholm
: null
)
: manualFilter({ parcellationName, dataset: ds })
}
......@@ -156,6 +158,9 @@ const filter = (datasets = [], {templateName, parcellationName}) => datasets
return false
})
.map(ds => {
if (parcellationName && parcellationName === 'Fibre Bundle Atlas - Long Bundle') {
return manualMapDWM(ds)
}
return {
...ds,
...parcellationName && ds.parcellationRegion.length === 0
......
This diff is collapsed.
......@@ -3,14 +3,17 @@ const path = require('path')
const DISABLE_RECEPTOR_PREVIEW = process.env.DISABLE_RECEPTOR_PREVIEW
const DISABLE_JUBRAIN_PMAP = process.env.DISABLE_JUBRAIN_PMAP
const DISABLE_DWM_PMAP = process.env.DISABLE_DWM_PMAP
let previewMap = new Map(),
previewMapKeySet = new Set()
const readFile = (filename) => new Promise((resolve) => {
fs.readFile(path.join(__dirname, 'data', filename), 'utf-8', (err, data) => {
if (err)
throw err
if (err){
console.log('read file error', err)
return resolve([])
}
resolve(JSON.parse(data))
})
})
......@@ -18,6 +21,7 @@ const readFile = (filename) => new Promise((resolve) => {
Promise.all([
DISABLE_RECEPTOR_PREVIEW ? Promise.resolve([]) : readFile('receptorPreview.json'),
DISABLE_JUBRAIN_PMAP ? Promise.resolve([]) : readFile('pmapJubrainPreview.json'),
DISABLE_DWM_PMAP ? Promise.resolve([]) : readFile('pmapDWMPreview.json')
])
.then(arrOfA => arrOfA.reduce((acc, item) => acc.concat(item), []))
.then(iterable => {
......
exports.manualFilter = (dataset) => dataset
&& dataset.project
&& dataset.project instanceof Array
&& dataset.project.some(p => p === 'Atlas of deep white matter fibre bundles, version 2018')
const dict = [ [ 'Probabilistic map of the anterior segment of the left arcuate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Arcuate_Anterior - Left' ],
[ 'Probabilistic map of the direct segment of the left arcuate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Arcuate - Left' ],
[ 'Probabilistic map of the posterior segment of the left arcuate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Arcuate_Posterior - Left' ],
[ 'Probabilistic map of the left long cingulate fibres (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Cingulum_Long - Left' ],
[ 'Probabilistic map of the left short cingulate fibres (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Cingulum_Short - Left' ],
[ 'Probabilistic map of the left temporal cingulate fibres (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Cingulum_Temporal - Left' ],
[ 'Probabilistic map of the left corticospinal tract (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/CorticoSpinalTract - Left' ],
[ 'Probabilistic map of the left fornix (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Fornix - Left' ],
[ 'Probabilistic map of the left inferior fronto-occipital fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/InferiorFrontoOccipital - Left' ],
[ 'Probabilistic map of the left inferior longitudinal fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/InferiorLongitudinal - Left' ],
[ 'Probabilistic map of the left uncinate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Uncinate - Left' ],
[ 'Probabilistic map of the anterior segment of the right arcuate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Arcuate_Anterior - Right' ],
[ 'Probabilistic map of the posterior segment of the right arcuate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Arcuate_Posterior - Right' ],
[ 'Probabilistic map of the posterior segment of the right arcuate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Arcuate - Right' ],
[ 'Probabilistic map of the right long cingulate fibres (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Cingulum_Long - Right' ],
[ 'Probabilistic map of the right short cingulate fibres (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Cingulum_Short - Right' ],
[ 'Probabilistic map of the right temporal cingulate fibres (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Cingulum_Temporal - Right' ],
[ 'Probabilistic map of the right corticospinal tract (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/CorticoSpinalTract - Right' ],
[ 'Probabilistic map of the right fornix (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Fornix - Right' ],
[ 'Probabilistic map of the right inferior fronto-occipital fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/InferiorFrontoOccipital - Right' ],
[ 'Probabilistic map of the right inferior longitudinal fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/InferiorLongitudinal - Right' ],
[ 'Probabilistic map of the right uncinate fasciculus (atlas of deep white matter fibre bundles, version 2018)',
'Fibre Bundle Atlas - Long Bundle/Uncinate - Right' ] ]
const dsNameToIdMap = new Map(dict)
const getIdFromDataset = (dataset) => {
const id = dsNameToIdMap.get(dataset.name)
if (id) return id
return null
}
exports.manualMap = (dataset) => {
return {
preview: !process.env.DISABLE_DWM_PMAP,
...dataset,
parcellationRegion: dataset.parcellationRegion.map(r => {
return {
...r,
id: getIdFromDataset(dataset)
}
})
}
}
\ No newline at end of file
......@@ -65,6 +65,7 @@ export interface DataEntry{
}
export interface ParcellationRegion {
id?: string
name: string
}
......
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
import { Component, OnDestroy, OnInit, ViewChild, Input } from "@angular/core";
import { DataEntry } from "src/services/stateStore.service";
import { Subscription, merge } from "rxjs";
import { DatabrowserService, CountedDataModality } from "../databrowser.service";
......@@ -14,8 +14,13 @@ import { ModalityPicker } from "../modalityPicker/modalityPicker.component";
export class DataBrowser implements OnDestroy,OnInit{
@Input()
public regions: any[] = []
@Input()
public template: any
@Input()
public parcellation: any
public dataentries: DataEntry[] = []
......@@ -55,6 +60,15 @@ export class DataBrowser implements OnDestroy,OnInit{
ngOnInit(){
this.regions = this.regions.map(r => {
/**
* TODO to be replaced with properly region UUIDs from KG
*/
return {
id: `${this.parcellation.name}/${r.name}`,
...r
}
})
const { regions, parcellation, template } = this
this.fetchingFlag = true
this.dbService.getDataByRegion({ regions, parcellation, template })
......
......@@ -10,6 +10,9 @@ export class FilterDataEntriesByRegion implements PipeTransform{
return dataentries && selectedRegions && selectedRegions.length > 0
? dataentries.filter(de =>
de.parcellationRegion.some(pr => {
if (pr.id && selectedRegions.some(r => r.id === pr.id)) {
return true
}
/**
* TODO: temporary hack, some dataset region name is not exactly the same as region
......
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