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

Fix Interleaved RGB Handling In Avivator #475

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
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
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