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

feat: update server logic on dataset fetch

parent 4012c518
No related branches found
No related tags found
No related merge requests found
......@@ -9,5 +9,5 @@ module.exports = (raw, req, res, next) => {
trace,
raw
})
res.status(code).send()
res.status(code || 500).end()
}
\ No newline at end of file
......@@ -124,8 +124,11 @@ const populateSet = (flattenedRegions, set = new Set()) => {
let juBrainSet = new Set(),
shortBundleSet = new Set(),
longBundleSet = new Set(),
waxholmSet = new Set(),
allenSet = new Set()
waxholm1Set = new Set(),
waxholm2Set = new Set(),
waxholm3Set = new Set(),
allen2015Set = new Set(),
allen2017Set = new Set()
readConfigFile('colin.json')
.then(data => JSON.parse(data))
......@@ -160,7 +163,10 @@ readConfigFile('allenMouse.json')
.then(data => JSON.parse(data))
.then(json => {
const flattenedAllen = flattenArray(json.parcellations[0].regions)
allenSet = populateSet(flattenedAllen)
allen2017Set = populateSet(flattenedAllen)
const flattenedAllen2017 = flattenArray(json.parcellations[1].regions)
allen2017Set = populateSet(flattenedAllen2017)
})
const filterByPRSet = (prs, atlasPrSet = new Set()) => {
......@@ -183,19 +189,28 @@ const filter = (datasets = [], { templateName, parcellationName }) => datasets
switch (parcellationName) {
case 'JuBrain Cytoarchitectonic Atlas':
useSet = juBrainSet
break;
break;
case 'Fibre Bundle Atlas - Short Bundle':
useSet = shortBundleSet
break;
break;
case 'Fibre Bundle Atlas - Long Bundle':
useSet = longBundleSet
break;
case 'Waxholm Space rat brain MRI/DTI':
useSet = waxholmSet
break;
break;
case 'Waxholm Space rat brain atlas v1':
useSet = waxholm1Set
break;
case 'Waxholm Space rat brain atlas v2':
useSet = waxholm2Set
break;
case 'Waxholm Space rat brain atlas v3':
useSet = waxholm3Set
break;
case 'Allen Mouse Common Coordinate Framework v3 2015':
useSet = allenSet
break;
useSet = allen2015Set
break;
case 'Allen Mouse Common Coordinate Framework v3 2017':
useSet = allen2017Set
break;
default:
useSet = new Set()
}
......
......@@ -7,8 +7,8 @@ const humanTemplateSet = new Set([
const humanParcellationSet = new Set([
'Grey/White matter',
'Area V1',
'Area V2',
'Cytoarchitectonic Maps',
'BigBrain Cortical Layers Segmentation',
'JuBrain Cytoarchitectonic Atlas',
'Fibre Bundle Atlas - Short Bundle',
'Fibre Bundle Atlas - Long Bundle'
......@@ -19,7 +19,9 @@ const ratTemplateSet = new Set([
])
const ratParcellationSet = new Set([
'Waxholm Space rat brain MRI/DTI'
'Waxholm Space rat brain atlas v1',
'Waxholm Space rat brain atlas v2',
'Waxholm Space rat brain atlas v3'
])
const mouseTemplateSet = new Set([
......@@ -27,6 +29,7 @@ const mouseTemplateSet = new Set([
])
const mouseParcellationSet = new Set([
'Allen Mouse Common Coordinate Framework v3 2017',
'Allen Mouse Common Coordinate Framework v3 2015'
])
......
......@@ -35,23 +35,26 @@ Promise.all([
console.error('preview file error', e)
})
exports.getPreviewFile = ({ datasetName, templateSelected }) => Promise.resolve(
previewMap.get(datasetName)
.filter(({ templateSpace }) => {
if (!templateSpace) return true
if (!templateSelected) return true
return templateSpace === templateSelected
})
.map(file => {
return {
...file,
...(file.url && !/^http/.test(file.url)
? {
url: `${HOSTNAME}/${file.url}`
exports.getPreviewFile = ({ datasetName, templateSelected }) => previewMap.get(datasetName)
? Promise.resolve(
previewMap.get(datasetName)
.filter(({ templateSpace }) => {
if (!templateSpace) return true
if (!templateSelected) return true
return templateSpace === templateSelected
})
.map(file => {
return {
...file,
...(file.url && !/^http/.test(file.url)
? {
url: `${HOSTNAME}/${file.url}`
}
: {})
}
: {})
}
})
)
})
)
: Promise.reject(`Preview file cannot be found!`)
exports.getAllPreviewDSNames = () => Array.from(previewMap.keys())
exports.hasPreview = ({ datasetName }) => previewMapKeySet.has(datasetName)
\ No newline at end of file
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