diff --git a/src/components/PatientStudyVolumeBrowser.vue b/src/components/PatientStudyVolumeBrowser.vue index ffed6b9b..c14f5da0 100644 --- a/src/components/PatientStudyVolumeBrowser.vue +++ b/src/components/PatientStudyVolumeBrowser.vue @@ -17,6 +17,10 @@ function dicomCacheKey(volKey: string) { return `dicom-${volKey}`; } +type Thumbnail = + | { kind: 'image'; value: string } + | { kind: 'text'; value: string }; + // Assume itkImage type is Uint8Array function itkImageToURI(itkImage: Image) { const [width, height] = itkImage.size; @@ -116,7 +120,7 @@ export default defineComponent({ // --- thumbnails --- // - const thumbnailCache = reactive>({}); + const thumbnailCache = reactive>({}); watch( volumeKeys, @@ -131,7 +135,12 @@ export default defineComponent({ const thumb = await generateDICOMThumbnail(dicomStore, key); if (thumb !== null) { const encodedImage = itkImageToURI(thumb); - thumbnailCache[cacheKey] = encodedImage; + thumbnailCache[cacheKey] = { kind: 'image', value: encodedImage }; + } else { + thumbnailCache[cacheKey] = { + kind: 'text', + value: dicomStore.volumeInfo[key].Modality, + }; } } catch (err) { if (err instanceof Error) { @@ -140,6 +149,10 @@ export default defineComponent({ details: `${err}. More details can be found in the developer's console.`, }); } + thumbnailCache[cacheKey] = { + kind: 'text', + value: dicomStore.volumeInfo[key].Modality, + }; } }); @@ -240,7 +253,12 @@ export default defineComponent({ cover height="150" width="150" - :src="(thumbnailCache || {})[volume.cacheKey] || ''" + :src=" + (thumbnailCache[volume.cacheKey] && + thumbnailCache[volume.cacheKey].kind === 'image' && + thumbnailCache[volume.cacheKey].value) || + '' + " >