Skip to content

Commit

Permalink
Fix Interleaved RGB Handling In Avivator (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold authored Jul 28, 2021
1 parent eacf516 commit ca1e4ee
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 33 additions & 22 deletions avivator/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
buildDefaultSelection,
guessRgb,
getMultiSelectionStats,
getBoundingCube
getBoundingCube,
isInterleaved
} from './utils';
import { COLOR_PALLETE, FILL_PIXEL_VALUE } from './constants';

Expand Down Expand Up @@ -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,
Expand All @@ -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())),
Expand Down

0 comments on commit ca1e4ee

Please sign in to comment.