brainsmatics 1.1.78 → 1.1.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,75 +1,359 @@
1
- # brain-ui
2
-
3
-
4
-
5
- ## Getting started
6
-
7
- To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
-
9
- Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
- ## Collaborate with your team
11
-
12
- - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
13
- - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
14
- - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
15
- - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
16
- - [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
17
-
18
- ## Test and Deploy
19
-
20
- Use the built-in continuous integration in GitLab.
21
-
22
- - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
23
- - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
24
- - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
25
- - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
26
- - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
27
-
28
- ***
29
-
30
- # Editing this README
31
-
32
- When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
33
-
34
- ## Suggestions for a good README
35
- Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
36
-
37
- ## Name
38
- Choose a self-explaining name for your project.
39
-
40
- ## Description
41
- Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
42
-
43
- ## Badges
44
- On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
45
-
46
- ## Visuals
47
- Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
48
-
49
- ## Installation
50
- Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
51
-
52
- ## Usage
53
- Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
54
-
55
- ## Support
56
- Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
57
-
58
- ## Roadmap
59
- If you have ideas for releases in the future, it is a good idea to list them in the README.
60
-
61
- ## Contributing
62
- State if you are open to contributions and what your requirements are for accepting them.
63
-
64
- For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
65
-
66
- You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
67
-
68
- ## Authors and acknowledgment
69
- Show your appreciation to those who have contributed to the project.
70
-
71
- ## License
72
- For open source projects, say how it is licensed.
73
-
74
- ## Project status
75
- If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
1
+ # brainsmatics
2
+
3
+ `brainsmatics` 是一个面向神经科学数据可视化的 React 组件库,用于构建脑图谱、神经元、血管、医学影像、功能环路和 AI 辅助分析相关的前端应用。
4
+
5
+ 项目提供可复用的 2D 查看组件、3D 脑数据可视化模块、医学图像加载能力、统计图表组件、上传管理组件,以及基于 Ant Design X 的 AI 对话组件。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install brainsmatics
11
+ ```
12
+
13
+ React React DOM peer dependencies,需要由业务项目安装:
14
+
15
+ ```bash
16
+ npm install react react-dom
17
+ ```
18
+
19
+ 在项目中导入组件:
20
+
21
+ ```tsx
22
+ import { BarChart, UserUpload, Atlas, UploadComponent } from "brainsmatics/STAM";
23
+ import "brainsmatics/style.css";
24
+ ```
25
+
26
+ ## 快速开始
27
+
28
+ ```tsx
29
+ import React from "react";
30
+ import { BarChart } from "brainsmatics/STAM";
31
+ import "brainsmatics/style.css";
32
+
33
+ export default function App() {
34
+ return (
35
+ <BarChart
36
+ title="脑区信号统计"
37
+ xAxisLabel="脑区"
38
+ yAxisLabel="数值"
39
+ height={420}
40
+ data={[
41
+ { name: "MOp", value: 42 },
42
+ { name: "SSp", value: 31 },
43
+ { name: "VIS", value: 26 }
44
+ ]}
45
+ onBarClick={(item) => console.log(item)}
46
+ />
47
+ );
48
+ }
49
+ ```
50
+
51
+ ## 项目可以做什么
52
+
53
+ `brainsmatics` 可以用于构建神经科学方向的可视化和分析系统,主要能力包括:
54
+
55
+ - 展示 3D 标准脑图谱。
56
+ - 在同一个 Three.js 场景中展示脑区、核团、血管、神经元等对象。
57
+ - 加载并展示 SWC 神经元形态数据。
58
+ - 将用户上传的数据插入 3D 场景并进行平移、旋转、缩放、调色和透明度调整。
59
+ - 加载 `.tif`、`.tiff` 图像栈,并以体数据方式渲染。
60
+ - 加载 `.nii.gz` 压缩 NIfTI 体数据。
61
+ - 展示 STL、OBJ、FBX、GLB 等 3D 模型。
62
+ - 展示 JSON 格式的线、点、点云、血管、神经元和环路数据。
63
+ - 提供 2D 图像浏览、缩略图、网格视图、双视图对比和多视图布局。
64
+ - 提供柱状图、热力图、雷达图、弦图、桑基图等神经科学分析图表。
65
+ - 支持 TIFF 脑片图像配准相关工作流。
66
+ - 支持 TIFF 图像栈体积分析相关工作流。
67
+ - 提供基于 Ant Design X 的 AI 对话界面,支持 Markdown、工具调用结果和图表结果展示。
68
+ - 支持功能环路分析,包括连接关系、基因表达、突触、单神经元等数据展示。
69
+
70
+ ## 主要导出
71
+
72
+ ### 3D 组件
73
+
74
+ ```tsx
75
+ import {
76
+ SideBar,
77
+ PipeLine,
78
+ Auxiliary,
79
+ BottomTabs,
80
+ Atlas,
81
+ AtlasSideBar,
82
+ AtlasBottomTabs,
83
+ ModalLoader,
84
+ Modal2DLoader,
85
+ StlLoader,
86
+ Swctree,
87
+ Sections,
88
+ ShowReglions,
89
+ Carddata,
90
+ FunctionLoop,
91
+ FunctionLoopSwc,
92
+ AiViewer,
93
+ UserUpload,
94
+ UploadComponent,
95
+ VolumeAnalysis
96
+ } from "brainsmatics/STAM";
97
+ ```
98
+
99
+ 这些组件主要用于完整的 3D 神经科学工作台。部分组件需要宿主应用提供 Three.js 的 renderer、camera、scene、controls、图谱状态、回调函数或后端接口。
100
+
101
+ ### 2D 组件
102
+
103
+ ```tsx
104
+ import {
105
+ GridViewer,
106
+ NavTree,
107
+ NaviGation,
108
+ InfoDiv,
109
+ TwoViewer,
110
+ Thumbnail,
111
+ MulfiViewer,
112
+ Distribution
113
+ } from "brainsmatics/STAM";
114
+ ```
115
+
116
+ 这些组件适合用于 2D 数据浏览、图像导航、缩略图展示、对比查看和多视图布局。
117
+
118
+ ### 图表组件
119
+
120
+ ```tsx
121
+ import {
122
+ BarChart,
123
+ HeatmapChart,
124
+ RadarChart,
125
+ ChordChart,
126
+ SankeyChart,
127
+ ChartViewer
128
+ } from "brainsmatics/STAM";
129
+ ```
130
+
131
+ 图表组件基于 ECharts,适合展示脑区统计、连接关系、证据矩阵、功能环路结果和分析摘要。
132
+
133
+ ### 通用组件和工具
134
+
135
+ ```tsx
136
+ import {
137
+ Header,
138
+ Button,
139
+ scene,
140
+ camera,
141
+ scale,
142
+ tranX,
143
+ tranY,
144
+ tranZ
145
+ } from "brainsmatics/STAM";
146
+ ```
147
+
148
+ 工具导出中包含部分 3D 模块共用的全局 Three.js 状态。
149
+
150
+ ## 支持的数据类型
151
+
152
+ | 数据类型 | 典型用途 |
153
+ | --- | --- |
154
+ | `.tif`、`.tiff` | 2D 脑片配准、3D TIFF 图像栈渲染 |
155
+ | `.nii.gz` | NIfTI 体数据渲染 |
156
+ | `.swc` | 神经元形态和骨架展示 |
157
+ | `.stl`、`.obj`、`.fbx`、`.glb` | 3D 形态模型展示 |
158
+ | `.json` | 点、线、点云、血管、神经元、环路数据 |
159
+ | `.png`、`.jpg`、`.jpeg`、`.gif` | 2D 图像平面和图像序列展示 |
160
+
161
+ ## 地址栏参数
162
+
163
+ 部分 3D 页面支持通过 URL query 参数恢复场景状态或加载数据。
164
+
165
+ ### 通过 URL 加载 TIFF 数据
166
+
167
+ `Auxiliary` 模块中有 `loadUrlTiffData` 逻辑,会读取以下参数:
168
+
169
+ ```text
170
+ tiffDataPath
171
+ tiffInfo
172
+ ```
173
+
174
+ 示例:
175
+
176
+ ```text
177
+ ?tiffDataPath=/staticresource/data/TIFF/test.tif&tiffInfo=%7B%22min%22%3A%7B%22x%22%3A0%2C%22y%22%3A0%2C%22z%22%3A0%7D%2C%22max%22%3A%7B%22x%22%3A11400%2C%22y%22%3A9000%2C%22z%22%3A14000%7D%2C%22max_resample%22%3A%7B%22x%22%3A1022%2C%22y%22%3A731%2C%22z%22%3A1400%7D%7D
178
+ ```
179
+
180
+ `tiffInfo` 解码后格式如下:
181
+
182
+ ```json
183
+ {
184
+ "min": { "x": 0, "y": 0, "z": 0 },
185
+ "max": { "x": 11400, "y": 9000, "z": 14000 },
186
+ "max_resample": { "x": 1022, "y": 731, "z": 1400 }
187
+ }
188
+ ```
189
+
190
+ `tiffDataPath` 必须是浏览器可以直接 `fetch` 到的 tif/tiff 地址。
191
+
192
+ ### 恢复上传到场景中的文件
193
+
194
+ `UploadComponent` 可以通过以下参数恢复已共享的上传文件:
195
+
196
+ ```text
197
+ userSceneFiles
198
+ ```
199
+
200
+ TIFF 示例:
201
+
202
+ ```json
203
+ [
204
+ {
205
+ "file_type": "TIFF",
206
+ "id": "file-id-from-server",
207
+ "original_filename": "sample.tif",
208
+ "translateX": 0,
209
+ "translateY": -1.5,
210
+ "translateZ": 0,
211
+ "scaleX": 1,
212
+ "scaleY": 1,
213
+ "scaleZ": 1,
214
+ "resolution": 10
215
+ }
216
+ ]
217
+ ```
218
+
219
+ NIfTI 示例:
220
+
221
+ ```json
222
+ [
223
+ {
224
+ "file_type": "NiiGZ",
225
+ "id": "file-id-from-server",
226
+ "original_filename": "sample.nii.gz",
227
+ "translateX": 0,
228
+ "translateY": -1.5,
229
+ "translateZ": 0,
230
+ "scaleX": 1,
231
+ "scaleY": 1,
232
+ "scaleZ": 1,
233
+ "resolution": 10
234
+ }
235
+ ]
236
+ ```
237
+
238
+ 组件会通过以下接口读取上传文件:
239
+
240
+ ```text
241
+ /app-api/userDB-api/files/{id}
242
+ ```
243
+
244
+ 因此文件需要已经存在于服务端,并且处于共享状态,或者当前浏览器拥有对应的访问 key。
245
+
246
+ ## 后端和运行环境说明
247
+
248
+ 本组件库中有一部分组件是纯前端 UI 组件,也有一部分组件依赖项目后端接口和静态资源。
249
+
250
+ 3D 工作台中常见的后端或静态资源路径包括:
251
+
252
+ ```text
253
+ /app-api/userDB-api/files/{id}
254
+ /app-api/neuron-reg/...
255
+ /staticresource/...
256
+ ```
257
+
258
+ 如果在其他项目中集成,需要在业务项目里配置代理或部署规则,确保这些路径能够正确访问。
259
+
260
+ 3D 体数据、图谱和医学影像组件依赖浏览器 WebGL 能力。TIFF 和 NIfTI 渲染路径使用 Three.js 3D texture 或 texture array,推荐使用支持 WebGL2 的现代浏览器。
261
+
262
+ ## 开发
263
+
264
+ 安装依赖:
265
+
266
+ ```bash
267
+ npm install
268
+ ```
269
+
270
+ 启动 Vite 开发服务:
271
+
272
+ ```bash
273
+ npm run dev
274
+ ```
275
+
276
+ 构建组件库:
277
+
278
+ ```bash
279
+ npm run build
280
+ ```
281
+
282
+ 启动 Storybook:
283
+
284
+ ```bash
285
+ npm run storybook
286
+ ```
287
+
288
+ 构建 Storybook:
289
+
290
+ ```bash
291
+ npm run build-storybook
292
+ ```
293
+
294
+ ## 发布
295
+
296
+ 当前包发布到 npm 的包名是:
297
+
298
+ ```text
299
+ brainsmatics
300
+ ```
301
+
302
+ 发布前建议先构建并检查 npm 包内容:
303
+
304
+ ```bash
305
+ npm run build
306
+ npm pack --dry-run
307
+ ```
308
+
309
+ 使用 npm 发布:
310
+
311
+ ```bash
312
+ npm publish
313
+ ```
314
+
315
+ 也可以使用 Yarn Classic 发布:
316
+
317
+ ```bash
318
+ yarn publish --force
319
+ ```
320
+
321
+ `package.json` 中配置了 `files` 字段,因此 npm 发布时只会包含:
322
+
323
+ - `dist`
324
+ - `package.json`
325
+ - `README.md`
326
+ - `LICENSE`
327
+
328
+ 这样可以避免把 `.env`、IDE 配置、日志、缓存、源码目录等开发文件发布到 npm。
329
+
330
+ ## 项目结构
331
+
332
+ ```text
333
+ src/
334
+ component/
335
+ 2d/ 2D 查看器、图表、导航、缩略图
336
+ 3d/ 3D 图谱、上传、AI 对话、体数据、配准模块
337
+ common/ 通用 UI 组件
338
+ types/ 公共 TypeScript 类型
339
+ util/ 公共工具和全局 Three.js 状态
340
+ stories/ Storybook 示例
341
+ assets/ 字体、图标和静态前端资源
342
+ ```
343
+
344
+ ## 技术栈
345
+
346
+ - React 18
347
+ - TypeScript
348
+ - Vite
349
+ - Ant Design
350
+ - Ant Design X
351
+ - Three.js
352
+ - ECharts
353
+ - GeoTIFF
354
+ - nifti-reader-js
355
+ - Storybook
356
+
357
+ ## 许可证
358
+
359
+ MIT
package/STAM.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/component/STAM";
@@ -1,4 +1,4 @@
1
- import { i as r } from "./index-96cc28b0.mjs";
1
+ import { i as r } from "./index-9c04856f.mjs";
2
2
  import { B as o } from "./basedecoder-11034ec6.mjs";
3
3
  import "react";
4
4
  import "react-dom";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-86f7d521.js"),t=require("./basedecoder-0503cc54.js");require("react");require("react-dom");class d extends t.BaseDecoder{decodeBlock(e){return r.inflate_1(new Uint8Array(e)).buffer}}exports.default=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-f2b2c4d0.js"),t=require("./basedecoder-0503cc54.js");require("react");require("react-dom");class d extends t.BaseDecoder{decodeBlock(e){return r.inflate_1(new Uint8Array(e)).buffer}}exports.default=d;
@@ -135423,11 +135423,11 @@ Tb(6, () => {
135423
135423
  throw new Error("old style JPEG compression is not supported.");
135424
135424
  });
135425
135425
  Tb(7, () => import("./jpeg-335c778f.mjs").then((t) => t.default));
135426
- Tb([8, 32946], () => import("./deflate-e1a71987.mjs").then((t) => t.default));
135426
+ Tb([8, 32946], () => import("./deflate-0d1418c9.mjs").then((t) => t.default));
135427
135427
  Tb(32773, () => import("./packbits-8b95f4d7.mjs").then((t) => t.default));
135428
135428
  Tb(
135429
135429
  34887,
135430
- () => import("./lerc-edcec007.mjs").then(async (t) => (await t.zstd.init(), t)).then((t) => t.default)
135430
+ () => import("./lerc-0ed75e7f.mjs").then(async (t) => (await t.zstd.init(), t)).then((t) => t.default)
135431
135431
  );
135432
135432
  Tb(50001, () => import("./webimage-affb95d1.mjs").then((t) => t.default));
135433
135433
  function dF(t, e, n, r = 1) {
@@ -155178,7 +155178,8 @@ const pQt = {
155178
155178
  const Le = {
155179
155179
  neurons: xe,
155180
155180
  feature_type: xc,
155181
- n_clusters: oc
155181
+ n_clusters: oc,
155182
+ base_url: `${window.location.origin}/staticresource/data/SWC/swc_foler`
155182
155183
  };
155183
155184
  xc === "merge" && (Le.weight1 = xu, Le.weight2 = Jc);
155184
155185
  const Ne = await fetch("/app-api/swc-chart-api/api/clustering", {