Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display biolucida images in gallery based on scicrunch #152

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions components/ImagesGallery/ImagesGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { baseName, extractSection, extractS3BucketName } from '@/utils/common'
* @param {Number} datasetId
*/
const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFacetsData) => {
let biolucidaImageData = {}
let scicrunchData = {}
let scicrunch_response = []
let biolucida_response = []
Expand All @@ -59,19 +58,15 @@ const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFa
biolucida_response = response
})

if (biolucida_response.status === 'success') {
const scicrunchData = pathOr([], ['data','result'], scicrunch_response)
biolucidaImageData = biolucida_response
biolucidaImageData['discover_dataset_version'] = datasetVersion
biolucidaImageData['dataset_info'] = scicrunchData.length > 0 ? scicrunchData[0] : {}
}

if (scicrunch_response.data.result.length > 0) {
scicrunchData = scicrunch_response.data.result[0]
scicrunchData.discover_dataset = {
id: Number(datasetId),
version: datasetVersion
}
if (biolucida_response.status === 'success') {
scicrunchData['dataset_images'] = pathOr([], ['dataset_images'], biolucida_response)
}
// Check for flatmap data
if (scicrunchData.organs) {
let flatmapData = []
Expand Down Expand Up @@ -133,13 +128,11 @@ const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFa
e
)
return {
biolucidaImageData: {},
scicrunchData: {},
hasError: true
}
}
return {
biolucidaImageData,
scicrunchData,
hasError: false
}
Expand Down Expand Up @@ -213,7 +206,6 @@ export default {
timeseriesItems: [],
timeseriesData: [],
datasetScicrunch: {},
datasetBiolucida: {},
}
},
computed: {
Expand Down Expand Up @@ -259,13 +251,12 @@ export default {
},
async created() {
this.loading = true
const { biolucidaImageData, scicrunchData, hasError } = await getThumbnailData(
const { scicrunchData, hasError } = await getThumbnailData(
this.datasetInfo.doi,
this.datasetId,
this.datasetInfo.version,
this.datasetFacetsData
)
this.datasetBiolucida = biolucidaImageData
this.datasetScicrunch = scicrunchData
this.hasError = hasError

Expand Down Expand Up @@ -324,6 +315,7 @@ export default {
immediate: true,
handler: function(scicrunchData) {
let items = []
let bItems = []
const baseRoute = this.$router.options.base || '/'
let datasetId = -1
let datasetVersion = -1
Expand Down Expand Up @@ -510,31 +502,29 @@ export default {
)
}
this.scicrunchItems = items
}
},
datasetBiolucida: {
deep: true,
immediate: true,
handler: function(biolucidaData) {
const biolucida2DItems = pathOr([], ['dataset_info','biolucida-2d'], biolucidaData)
let items = []
const baseRoute = this.$router.options.base || '/'
if ('dataset_images' in biolucidaData) {
items.push(
...Array.from(biolucidaData.dataset_images.filter((obj, index) => {
return index === biolucidaData.dataset_images.findIndex(o => obj.image_id === o.image_id);
}), dataset_image => {

if ('dataset_images' in scicrunchData && ('biolucida-2d' in scicrunchData || 'biolucida-3d' in scicrunchData)) {
const biolucida2DItems = pathOr([],['biolucida-2d'], scicrunchData)
// Images need to exist in both Scicrunch and Biolucida
const biolucidaItems = biolucida2DItems.concat(pathOr([],['biolucida-3d'], scicrunchData)).filter((bObject) => {
return scicrunchData['dataset_images'].some(image => image.image_id == pathOr("", ['biolucida','identifier'], bObject))
})
bItems.push(
...Array.from(biolucidaItems, biolucida_item => {
let filePath = ""
const dataset_image = scicrunchData['dataset_images'].find((image) => {
return image.image_id == pathOr("", ['biolucida','identifier'], biolucida_item)
})
biolucida2DItems.forEach(biolucida2DItem => {
if (pathOr("", ['biolucida','identifier'], biolucida2DItem) == dataset_image.image_id) {
filePath = "files/" + pathOr("", ['dataset','path'], biolucida2DItem)
}
})
this.getThumbnailFromBiolucida(items, {
this.getThumbnailFromBiolucida(bItems, {
id: dataset_image.image_id,
fetchAttempts: 0
})
this.getImageInfoFromBiolucida(items, {
this.getImageInfoFromBiolucida(bItems, {
id: dataset_image.image_id,
fetchAttempts: 0
})
Expand All @@ -545,16 +535,16 @@ export default {
// If we can naviagte directly to the file path then do it, otherwise we have to redirect from the datasets/biolucida page
let linkUrl = filePath != "" ?
baseRoute +
`datasets/file/${biolucidaData.discover_dataset_id}/${biolucidaData.discover_dataset_version}?path=${filePath}` :
`datasets/file/${datasetId}/${datasetVersion}?path=${filePath}` :
baseRoute +
'datasets/biolucidaviewer/' +
dataset_image.image_id +
'?view=' +
viewEncoding +
'&dataset_version=' +
biolucidaData.discover_dataset_version +
datasetVersion +
'&dataset_id=' +
biolucidaData.discover_dataset_id +
datasetId +
'&item_id=' +
dataset_image.sourcepkg_id

Expand All @@ -568,7 +558,7 @@ export default {
})
)
}
this.biolucidaItems = items
this.biolucidaItems = bItems
}
}
},
Expand Down
Loading