From d73e6cdbe4938e16a7fbc914827a07f007278b6d Mon Sep 17 00:00:00 2001 From: ilan-gold Date: Wed, 28 Jul 2021 15:50:03 -0400 Subject: [PATCH] Fix Interleaved RGB Handling In Avivator --- CHANGELOG.md | 2 ++ avivator/src/hooks.js | 55 ++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 906a6c80d..4f26e319d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ ### Added ### Changed + - Fix Galaxy note in the README.md. +- Fix interleaved RGB issue in Avivator when setting up viewer initially. ## 0.10.4 diff --git a/avivator/src/hooks.js b/avivator/src/hooks.js index 6776fd875..7a6b69126 100644 --- a/avivator/src/hooks.js +++ b/avivator/src/hooks.js @@ -11,7 +11,8 @@ import { buildDefaultSelection, guessRgb, getMultiSelectionStats, - getBoundingCube + getBoundingCube, + isInterleaved } from './utils'; import { COLOR_PALLETE, FILL_PIXEL_VALUE } from './constants'; @@ -47,23 +48,38 @@ export const useImage = (source, history) => { const { Channels } = nextMeta.Pixels; const channelOptions = Channels.map((c, i) => c.Name ?? `Channel ${i}`); // Default RGB. - let newSliders = [ - [0, 255], - [0, 255], - [0, 255] - ]; - let newDomains = [ - [0, 255], - [0, 255], - [0, 255] - ]; - let newColors = [ - [255, 0, 0], - [0, 255, 0], - [0, 0, 255] - ]; + let newSliders = []; + let newDomains = []; + let newColors = []; const isRgb = guessRgb(nextMeta); - if (!isRgb) { + if (isRgb) { + if (isInterleaved(nextLoader[0].shape)) { + // These don't matter because the data is interleaved. + newSliders = [[0, 255]]; + newDomains = [[0, 255]]; + newColors = [[255, 0, 0]]; + } else { + newSliders = [ + [0, 255], + [0, 255], + [0, 255] + ]; + newDomains = [ + [0, 255], + [0, 255], + [0, 255] + ]; + newColors = [ + [255, 0, 0], + [0, 255, 0], + [0, 0, 255] + ]; + } + if (isLensOn) { + toggleIsLensOn(); + } + setViewerState({ useColormap: false, useLens: false }); + } else { const stats = await getMultiSelectionStats({ loader: nextLoader, selections: newSelections, @@ -80,11 +96,6 @@ export const useImage = (source, history) => { useLens: channelOptions.length !== 1, useColormap: true }); - } else { - if (isLensOn) { - toggleIsLensOn(); - } - setViewerState({ useColormap: false, useLens: false }); } addChannels({ ids: newDomains.map(() => String(Math.random())),