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

feat(render): uint16 render support #152

Merged
merged 2 commits into from
Jul 30, 2019
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
15 changes: 13 additions & 2 deletions src/neuroglancer/datasource/render/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {WithParameters} from 'neuroglancer/chunk_manager/backend';
import {PointMatchChunkSourceParameters, TileChunkSourceParameters} from 'neuroglancer/datasource/render/base';
import {ChunkDecoder} from 'neuroglancer/sliceview/backend_chunk_decoders';
import {decodeJpegChunk} from 'neuroglancer/sliceview/backend_chunk_decoders/jpeg';
import {decodeRawChunk} from 'neuroglancer/sliceview/backend_chunk_decoders/raw';
import {VectorGraphicsChunk, VectorGraphicsChunkSource} from 'neuroglancer/sliceview/vector_graphics/backend';
import {VolumeChunk, VolumeChunkSource} from 'neuroglancer/sliceview/volume/backend';
import {CancellationToken} from 'neuroglancer/util/cancellation';
Expand All @@ -26,9 +27,14 @@ import {vec3} from 'neuroglancer/util/geom';
import {cancellableFetchOk, responseArrayBuffer, responseJson} from 'neuroglancer/util/http_request';
import {parseArray, verify3dVec, verifyObject, verifyString} from 'neuroglancer/util/json';
import {registerSharedObject} from 'neuroglancer/worker_rpc';
import {Endianness} from 'neuroglancer/util/endian';

const chunkDecoders = new Map<string, ChunkDecoder>();
chunkDecoders.set('jpg', decodeJpegChunk);
chunkDecoders.set('raw16',
(chunk, cancellationToken, response) => {
return decodeRawChunk(chunk, cancellationToken, response, Endianness.BIG);
} );

@registerSharedObject() export class TileChunkSource extends
(WithParameters(VolumeChunkSource, TileChunkSourceParameters)) {
Expand Down Expand Up @@ -77,8 +83,13 @@ chunkDecoders.set('jpg', decodeJpegChunk);

// GET
// /v1/owner/{owner}/project/{project}/stack/{stack}/z/{z}/box/{x},{y},{width},{height},{scale}/jpeg-image
let path = `/render-ws/v1/owner/${parameters.owner}/project/${parameters.project}/stack/${parameters.stack}/z/${chunkPosition[2]}/box/${chunkPosition[0]},${chunkPosition[1]},${xTileSize},${yTileSize},${scale}/jpeg-image`;

let imageMethod:string;
if (parameters.encoding === 'raw16') {
imageMethod = 'raw16-image';
} else {
imageMethod = 'jpeg-image';
}
let path = `/render-ws/v1/owner/${parameters.owner}/project/${parameters.project}/stack/${parameters.stack}/z/${chunkPosition[2]}/box/${chunkPosition[0]},${chunkPosition[1]},${xTileSize},${yTileSize},${scale}/${imageMethod}`;
const response = await cancellableFetchOk(
`${parameters.baseUrl}${path}?${this.queryString}`, {}, responseArrayBuffer,
cancellationToken);
Expand Down
16 changes: 13 additions & 3 deletions src/neuroglancer/datasource/render/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {vec3} from 'neuroglancer/util/geom';
import {fetchOk} from 'neuroglancer/util/http_request';
import {parseArray, parseQueryStringParameters, verifyFloat, verifyObject, verifyObjectProperty, verifyOptionalBoolean, verifyOptionalInt, verifyOptionalString, verifyString} from 'neuroglancer/util/json';

const VALID_ENCODINGS = new Set<string>(['jpg']);
const VALID_ENCODINGS = new Set<string>(['jpg', 'raw16']);

const TileChunkSourceBase = WithParameters(VolumeChunkSource, TileChunkSourceParameters);
class TileChunkSource extends TileChunkSourceBase {}
Expand Down Expand Up @@ -191,10 +191,20 @@ function parseStackProject(stackIdObj: any): string {

export class MultiscaleVolumeChunkSource implements GenericMultiscaleVolumeChunkSource {
get dataType() {
return DataType.UINT8;
if (this.parameters.encoding === 'raw16') {
return DataType.UINT16;
} else {
// JPEG
return DataType.UINT8;
}
}
get numChannels() {
return 3;
if (this.parameters.encoding === 'raw16') {
return 1;
} else {
// JPEG
return 3;
}
}
get volumeType() {
return VolumeType.IMAGE;
Expand Down