Skip to content
Snippets Groups Projects
Unverified Commit 7fa2c2cc authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #337 from HumanBrainProject/feat/updateDatasetFetchLog

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