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] Typescript TRK reader for visualising Tractography Data #11

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
624 changes: 601 additions & 23 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
},
"devDependencies": {
"@types/codemirror": "5.60.15",
"@types/dotenv": "^6.1.1",
"@types/gl-matrix": "^2.4.5",
"@types/lodash-es": "^4.17.12",
"@types/mathjs": "^9.4.1",
"@types/node": "^20.14.12",
"@types/pako": "^2.0.3",
"@types/yargs": "^17.0.32",
Expand All @@ -53,7 +55,6 @@
"css-loader": "^7.1.2",
"esbuild": "^0.23.0",
"esbuild-loader": "^4.2.2",
"eslint": "^8.56.0",
"eslint-formatter-codeframe": "^7.32.1",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-interactive": "^10.8.0",
Expand All @@ -77,14 +78,20 @@
"webpack-merge": "^6.0.1"
},
"dependencies": {
"axios": "^1.7.7",
"browserify-fs": "^1.0.0",
"buffer": "^6.0.3",
"codemirror": "^5.61.1",
"dotenv": "^16.4.5",
"gl-matrix": "3.1.0",
"glsl-editor": "^1.0.0",
"ikonate": "github:mikolajdobrucki/ikonate#a86b4107c6ec717e7877f880a930d1ccf0b59d89",
"lodash-es": "^4.17.21",
"mathjs": "^13.2.0",
"nifti-reader-js": "^0.6.8",
"numcodecs": "^0.3.1",
"pako": "^2.1.0"
"pako": "^2.1.0",
"path-browserify": "^1.0.1"
},
"overrides": {
"@puppeteer/browsers": ">=2"
Expand All @@ -96,8 +103,8 @@
"type": "module",
"exports": {
".": "./src/main_module.ts",
"./unstable/*.js": "./src/*.ts",
"./unstable/*": "./src/*"
"./*.js": "./src/*.ts",
"./*": "./src/*"
},
"imports": {
"#src/third_party/jpgjs/jpg.js": "./src/third_party/jpgjs/jpg.js",
Expand Down Expand Up @@ -335,6 +342,24 @@
"neuroglancer/datasource/render:disabled": "./src/datasource/render/register_default.ts",
"default": "./src/datasource/render/register_default.ts"
},
"#datasource/trk/backend": {
"neuroglancer/datasource/trk:enabled": "./src/datasource/trk/backend.ts",
"neuroglancer/datasource:none_by_default": "./src/util/false.ts",
"neuroglancer/datasource/trk:disabled": "./src/datasource/trk/backend.ts",
"default": "./src/datasource/trk/backend.ts"
},
"#datasource/trk/async_computation": {
"neuroglancer/datasource/trk:enabled": "./src/datasource/trk/async_computation.ts",
"neuroglancer/datasource:none_by_default": "./src/util/false.ts",
"neuroglancer/datasource/trk:disabled": "./src/datasource/trk/async_computation.ts",
"default": "./src/datasource/trk/async_computation.ts"
},
"#datasource/trk/register_default": {
"neuroglancer/datasource/trk:enabled": "./src/datasource/trk/register_default.ts",
"neuroglancer/datasource:none_by_default": "./src/util/false.ts",
"neuroglancer/datasource/trk:disabled": "./src/datasource/trk/register_default.ts",
"default": "./src/datasource/trk/register_default.ts"
},
"#datasource/vtk/backend": {
"neuroglancer/datasource/vtk:enabled": "./src/datasource/vtk/backend.ts",
"neuroglancer/datasource:none_by_default": "./src/util/false.ts",
Expand Down
1 change: 1 addition & 0 deletions src/datasource/enabled_async_computation_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ import "#datasource/nifti/async_computation";
import "#datasource/obj/async_computation";
import "#datasource/precomputed/async_computation";
import "#datasource/render/async_computation";
import "#datasource/trk/async_computation";
import "#datasource/vtk/async_computation";
import "#datasource/zarr/async_computation";
1 change: 1 addition & 0 deletions src/datasource/enabled_backend_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import "#datasource/obj/backend";
import "#datasource/precomputed/backend";
import "#datasource/python/backend";
import "#datasource/render/backend";
import "#datasource/trk/backend";
import "#datasource/vtk/backend";
import "#datasource/zarr/backend";
1 change: 1 addition & 0 deletions src/datasource/enabled_frontend_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ import "#datasource/nifti/register_default";
import "#datasource/obj/register_default";
import "#datasource/precomputed/register_default";
import "#datasource/render/register_default";
import "#datasource/trk/register_default";
import "#datasource/vtk/register_default";
import "#datasource/zarr/register_default";
Empty file.
48 changes: 48 additions & 0 deletions src/datasource/trk/backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @license
* Copyright 2016 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


import { WithParameters } from "#src/chunk_manager/backend.js";
import { WithSharedCredentialsProviderCounterpart } from "#src/credentials_provider/shared_counterpart.js";
import {
SkeletonSourceParameters,
} from "#src/datasource/trk/base.js";
import type { SkeletonChunk } from "#src/skeleton/backend.js";
import { SkeletonSource } from "#src/skeleton/backend.js";
import { decodeSkeletonChunk } from "#src/skeleton/decode_precomputed_skeleton.js";
import type {
SpecialProtocolCredentials,
} from "#src/util/special_protocol_request.js";
import { registerSharedObject } from "#src/worker_rpc.js";


console.log(import.meta.url);

@registerSharedObject()
export class trkSkeletonSource extends WithParameters(
WithSharedCredentialsProviderCounterpart<SpecialProtocolCredentials>()(
SkeletonSource,
),
SkeletonSourceParameters,
) {
async download(chunk: SkeletonChunk,
) {
const { parameters } = this;

decodeSkeletonChunk(chunk, parameters.skeletonBuffer, parameters.metadata.vertexAttributes);
}
}

41 changes: 41 additions & 0 deletions src/datasource/trk/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @license
* Copyright 2016 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { VertexAttributeInfo } from "#src/skeleton/base.js";
import type { mat4 } from "#src/util/geom.js";


export enum DataEncoding {
RAW = 0,
GZIP = 1,
}

export enum ShardingHashFunction {
IDENTITY = 0,
MURMURHASH3_X86_128 = 1,
}

export interface SkeletonMetadata {
transform: mat4;
vertexAttributes: Map<string, VertexAttributeInfo>;
}

export class SkeletonSourceParameters {
url: string;
metadata: SkeletonMetadata;
skeletonBuffer: ArrayBuffer;
static RPC_ID = "trk/SkeletonSource";
}
Loading
Loading