brainsmatics 1.2.7 → 1.2.8

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
@@ -56,6 +56,10 @@ export default function App() {
56
56
  - 在同一个 Three.js 场景中展示脑区、核团、血管、神经元等对象。
57
57
  - 各场景共用的模型右键菜单仅在右击时打开,并保留当次模型的操作目标;从模型移入菜单后可正常选择,移出菜单卡片、选择菜单项或点击外部后关闭,重新悬停模型不会自动打开。
58
58
  - 加载并展示 SWC 神经元形态数据;悬停时红色高亮,移至空白、其他神经元或画布外后恢复原色,快速移开同样生效。
59
+ - SideBar 搜索支持脑区缩写、英文全名和中文名,不区分大小写,忽略首尾及重复空格,支持多个关键词;Neurons 的脑区选项和已选标签仅显示缩写与英文全名,搜索结果优先显示精确匹配。输入搜索词不会修改已选筛选条件。
60
+ - Regions 搜索框内的 `Cc` 小图标用于切换严格匹配,悬浮显示说明,开启后高亮;严格模式仅完整匹配脑区缩写、英文全名或中文名(仍忽略大小写及多余空格)。原样式的放大镜按钮和回车均可立即执行搜索,修改文字仍自动搜索。Neurons 保持原来的下拉输入框样式,不显示 `Cc` 或额外搜索按钮,输入即搜索。
61
+ - 连续输入时,Neurons 脑区框独立维护搜索文本,匹配结果采用低优先级更新,不触发神经元表格重绘;Regions 树只渲染可视区节点,搜索高亮不重建节点标题和颜色选择器。
62
+ - Neurons 的投射脑区支持独立多选:选择 `grey` 等父脑区只保存该节点,不会批量勾选子节点;筛选范围仍覆盖其后代脑区,多选投射条件取并集,与胞体所在脑区条件取交集。投射集合缓存并去重,避免勾选神经元时重复汇总。
59
63
  - 将用户上传的数据插入 3D 场景并进行平移、旋转、缩放、调色和透明度调整。
60
64
  - 加载 `.tif`、`.tiff` 图像栈,并以体数据方式渲染。
61
65
  - 加载 `.nii.gz` 压缩 NIfTI 体数据。
@@ -67,11 +71,15 @@ export default function App() {
67
71
  - 支持 TIFF 图像栈体积分析相关工作流。
68
72
  - 提供基于 Ant Design X 的 AI 对话界面,支持 Markdown、工具调用结果和图表结果展示。
69
73
  - 支持功能环路分析,包括连接关系、基因表达、突触、单神经元等数据展示。
74
+ - 病毒示踪连接使用按端点距离弯曲的贝塞尔弧线,反向连接向另一侧展开,减少共线管道重叠;方向箭头沿曲线切线显示,保留证据数量对应的粗细与强度对应的透明度。鼠标悬停在弧线或自连接点上时高亮且光标变为手势指针,点击可弹出证据来源文献弹窗(与 Knowledge 卡片书籍按钮弹出的文献框一致),支持点击 DOI 跳转原文献。同一脑区到自身、或起终坐标重合的连接显示为单个蓝点,不生成管道、箭头或注射器;蓝点在脑区表面遮挡下仍可见。弧线仅表示脑区连接关系,不代表真实轴突轨迹或手术进针路径。
70
75
  - Knowledge 页签跟随全局语言(`en_us` / `zh_cn`)显示中英文:包括脑区选择提示、分析按钮、证据类型、分子指纹/连接卡片、图例、统计、悬浮说明及证据来源弹窗;脑区标识、基因/受体名称和文献内容保持原始数据。
71
76
  - Knowledge 基因分布按“基因名(不区分大小写)+脑区”过滤重复圆球和标签;保留原有圆球材质、颜色、透明度和立体文字,标签仍选取该组有 DOI 且影响因子最高的文献。
72
77
  - 文献文字不再显示“双击查看”悬浮提示;双击 DOI 跳转保持不变。
73
78
  - 文献立体文字在加入场景时立即对齐相机,字体首次异步加载和命中缓存时均生效,无需先操作场景。
74
79
  - 突触受体预览使用非负的固定随机种子计算球面偏移,避免部分受体(如 `beta2-containing nAChRs`)生成 NaN 坐标而无法显示。
80
+ - Knowledge 子项小眼睛、类型总开关及 AI 展示共用同一份选中状态:单次操作不会重复绘制,AI 展示后可直接用小眼睛关闭。神经递质/受体分布与突触连接独立控制,关闭一类不会改变另一类。
81
+ - 分析、连接展示及基因/受体预览复用现有 Loading 遮罩;并发或嵌套加载全部结束后才收起,失败时释放 loading 并提示错误。关闭或清空展示会取消在途预览,迟到的数据不会重新显示。
82
+ - `FunctionLoop` controller 的 `loadMethodData`、`previewGene`、`previewReceptor` 返回 `Promise<void>`,调用方应等待展示完成并处理失败;`removeGroupData` 同时更新场景与开关状态。
75
83
 
76
84
  ## 主要导出
77
85
 
@@ -104,6 +112,17 @@ import {
104
112
 
105
113
  这些组件主要用于完整的 3D 神经科学工作台。部分组件需要宿主应用提供 Three.js 的 renderer、camera、scene、controls、图谱状态、回调函数或后端接口。
106
114
 
115
+ #### 右侧功能面板导航
116
+
117
+ - 模式选择器由 `Auxiliary` 内部渲染,与下方 Tabs 共用宽度和纵向布局;宿主不再另放一条绝对定位的模式栏。英文、长译文和放大字体可以换行,折叠后模式选项纵向排列。未配置对应工具的模式不可选。
118
+ - 普通面板内容保持左右等量留白,清除右侧 Tabs 默认的额外页内边距。Knowledge 卡片使用完整内容宽度,其高度跟随 Tabs 的实际可用空间,不再按视口减固定值计算;只有内容超长时由 Knowledge 自身滚动,外层不叠加滚动条。
119
+ - `src/component/3d/auxiliary/panels.ts` 集中维护 `AuxiliaryPanelId`、工具名、URL 类型、页面标题及引导信息。新增面板时先更新此注册表,再添加对应内容,不要另建 index/URL 映射。
120
+ - 代码入口使用公开导出的 `AuxiliaryPanelId`,通过 `task3DStore.auxiliary.controller?.tabChange(AuxiliaryPanelId.FunctionalLoop)`(或 `Auxiliary` ref 上同一 controller)切换。已选页签不会重复重置;离开面板只清理该功能的临时对象,不清空核团、血管、神经元选择。直接设置 `rightTabIndex` 不是功能切换入口。
121
+ - 初始链接按 `rightTab` → `rightTabIndex` → `type` → `index` → 首个可用面板的优先级解析,并检查工具配置和模式。已有数字 ID、`type=slicing`、`index=Slicing` 等链接仍可打开;`rightTab=sequence-registration` 可直接打开序列配准。显式面板优先于旧链接残留的模式值。
122
+ - 切换后统一写入分享链接缓冲区的 `rightTab`、`rightTabIndex`、`type`、`mode`,移除旧引导 `index`;与原有分享机制一致,不修改浏览器地址栏。功能环路不会再落入体积分析的 URL/标题分支。
123
+ - 引导只维护一个 `activeTour` 面板 ID。旧链接的 `index` 只触发实际打开面板的引导,并遵守原有“不再显示”设置;工具栏引导入口可手动重新打开当前面板的引导。切换面板会关闭旧引导,长引导内容在视口内滚动。
124
+
125
+
107
126
  ### 2D 组件
108
127
 
109
128
  ```tsx
@@ -49,7 +49,6 @@ interface DataTypeButton {
49
49
  id: string;
50
50
  title: string;
51
51
  isLoading: boolean;
52
- isActive: boolean;
53
52
  hasData: boolean;
54
53
  }
55
54
  type WorkflowType = 'router' | 'linear' | SkillWorkflowType;
@@ -61,7 +61,6 @@ interface SideBarProps {
61
61
  childRef?: React.MutableRefObject<undefined>;
62
62
  setEchartValue?: React.Dispatch<React.SetStateAction<string>>;
63
63
  echartValue?: string;
64
- auxRef?: React.MutableRefObject<any>;
65
64
  PointShow?: React.MutableRefObject<{
66
65
  start: boolean;
67
66
  end: boolean;
@@ -87,6 +86,7 @@ interface SideBarProps {
87
86
  pluginTreeDatas?: dataType[];
88
87
  pluginRegionData?: string;
89
88
  pluginRegionFiles?: string[];
89
+ rightTabIndex?: number;
90
90
  }
91
91
  export declare let sphereflag: boolean;
92
92
  declare const AtlasSideBar: React.FC<SideBarProps>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface AuxiliaryModeSelectorProps {
3
+ mode: number;
4
+ onChange: (mode: number) => void;
5
+ expanded: boolean;
6
+ availableModes?: readonly number[];
7
+ t: (key: string) => string;
8
+ }
9
+ declare const AuxiliaryModeSelector: React.FC<AuxiliaryModeSelectorProps>;
10
+ export default AuxiliaryModeSelector;
@@ -0,0 +1,34 @@
1
+ export declare enum AuxiliaryPanelId {
2
+ Assembling = 1,
3
+ VirtualSurgery = 2,
4
+ Reslicing = 3,
5
+ Registration = 4,
6
+ Download = 5,
7
+ Mapping = 6,
8
+ Connectivity = 7,
9
+ NeuronAnalysis = 10,
10
+ FunctionalLoop = 12,
11
+ VolumeAnalysis = 13,
12
+ TerminalAnalysis = 14,
13
+ SequenceRegistration = 15
14
+ }
15
+ export interface AuxiliaryPanelDefinition {
16
+ readonly id: AuxiliaryPanelId;
17
+ readonly tool: string;
18
+ readonly urlType: string;
19
+ readonly title: string;
20
+ readonly tour?: {
21
+ readonly storageKey: string;
22
+ readonly urlIndex: string;
23
+ };
24
+ }
25
+ export declare const AUXILIARY_PANELS: readonly AuxiliaryPanelDefinition[];
26
+ export declare function getPanel(id: number | string): AuxiliaryPanelDefinition | undefined;
27
+ export declare function resolveInitialMode(params: URLSearchParams, fallback?: number): number;
28
+ export declare function isPanelAvailable(id: AuxiliaryPanelId, tools: readonly string[], mode: number): boolean;
29
+ export declare function resolveInitialPanel(params: URLSearchParams, tools: readonly string[], mode: number): AuxiliaryPanelId | undefined;
30
+ export declare function getPanelRoute(id: AuxiliaryPanelId, mode: number): {
31
+ type: string;
32
+ title: string;
33
+ };
34
+ export declare function writePanelParams(params: URLSearchParams, id: AuxiliaryPanelId, mode: number): void;
@@ -1,15 +1,13 @@
1
1
  import React from 'react';
2
2
  import './ConnectivityCard.css';
3
+ import { type LiteratureItem } from './LiteratureModal';
4
+ export type { LiteratureItem };
3
5
  interface ProgressSegment {
4
6
  value: number;
5
7
  color: string;
6
8
  count?: number;
7
9
  label?: string;
8
10
  }
9
- interface LiteratureItem {
10
- summary_statement: string;
11
- DOI: string;
12
- }
13
11
  export interface ProgressItem {
14
12
  name: string;
15
13
  segments: ProgressSegment[];
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import './ConnectivityCard.css';
3
+ export interface LiteratureItem {
4
+ summary_statement: string;
5
+ DOI: string;
6
+ }
7
+ export interface LiteratureModalProps {
8
+ open: boolean;
9
+ onCancel: () => void;
10
+ title?: string;
11
+ literature?: LiteratureItem[];
12
+ }
13
+ export declare const LiteratureModal: React.NamedExoticComponent<LiteratureModalProps>;
14
+ export default LiteratureModal;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import "./index.css";
3
+ import './ConnectivityCard.css';
3
4
  import { SwcTreeItem } from "../../util/global";
4
5
  interface FunctionloopProps {
5
6
  t: (key: string) => string;
@@ -2,6 +2,7 @@ export { default as SideBar } from "./sideBar";
2
2
  export { default as PipeLine } from "./pipeline";
3
3
  export { default as ModalLoader } from "./modalLoader";
4
4
  export { default as Auxiliary } from "./auxiliary";
5
+ export { AuxiliaryPanelId } from "./auxiliary/panels";
5
6
  export { default as AiViewer } from "./aichat";
6
7
  export { default as Sections } from "./section";
7
8
  export { default as StlLoader, type StlLoaderProps } from "./stlLoader";
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface ExactMatchButtonProps {
3
+ active: boolean;
4
+ label: string;
5
+ hint: string;
6
+ onToggle: () => void;
7
+ }
8
+ export default function ExactMatchButton({ active, label, hint, onToggle }: ExactMatchButtonProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { type RegionSearchEntry } from './regionSearch';
3
+ interface RegionFilterSelectProps {
4
+ index: RegionSearchEntry[];
5
+ entries: RegionSearchEntry[];
6
+ value: string | string[] | undefined;
7
+ placeholder: string;
8
+ multiple?: boolean;
9
+ onChange: (values: string[]) => void;
10
+ }
11
+ /** Typing updates only this control, not SideBar's table, charts or scene controls. */
12
+ declare const RegionFilterSelect: React.NamedExoticComponent<RegionFilterSelectProps>;
13
+ export default RegionFilterSelect;
@@ -0,0 +1,21 @@
1
+ export interface RegionSearchNode {
2
+ name: string;
3
+ fullname?: string;
4
+ cname?: string;
5
+ nameflag?: string;
6
+ children?: RegionSearchNode[];
7
+ }
8
+ export interface RegionSearchEntry {
9
+ name: string;
10
+ key: string;
11
+ value: string;
12
+ label: string;
13
+ ancestors: string[];
14
+ fields: string[];
15
+ children: RegionSearchEntry[];
16
+ }
17
+ export declare function normalizeRegionSearch(value: string): string;
18
+ export declare function indexRegions(nodes: RegionSearchNode[]): RegionSearchEntry[];
19
+ export declare function flattenRegions(nodes: RegionSearchEntry[]): RegionSearchEntry[];
20
+ /** Exact abbreviations first, then prefixes, substrings, and multi-word matches. */
21
+ export declare function searchRegions(entries: RegionSearchEntry[], value: string, strict?: boolean): RegionSearchEntry[];
@@ -1,12 +1,7 @@
1
1
  import { type StateUpdate } from "./stateUpdate";
2
+ import type { AuxiliaryPanelId } from "../3d/auxiliary/panels";
2
3
  export interface AuxiliaryPanelState {
3
- tour1Open: boolean;
4
- tour2Open: boolean;
5
- tour3Open: boolean;
6
- tour4Open: boolean;
7
- tour5Open: boolean;
8
- tour6Open: boolean;
9
- tour7Open: boolean;
4
+ activeTour: AuxiliaryPanelId | null;
10
5
  tour8Open: boolean;
11
6
  angleX: number;
12
7
  angleY: number;
@@ -28,7 +23,6 @@ export interface AuxiliaryPanelState {
28
23
  isDownloading: boolean;
29
24
  previewOpen: boolean;
30
25
  previewImage: string;
31
- registrationConfig: string;
32
26
  applyMode: string;
33
27
  swcSpace: string;
34
28
  analysisMode: number;
@@ -1,4 +1,5 @@
1
1
  import { AuxiliaryPanelStore } from "./auxiliaryPanelStore";
2
+ import { AuxiliaryPanelId } from "../3d/auxiliary/panels";
2
3
  import { type StateUpdate } from "./stateUpdate";
3
4
  export interface SectionInfo {
4
5
  gray?: string;
@@ -13,7 +14,7 @@ export interface SectionInfo {
13
14
  * registration so callers no longer need an `auxRef`.
14
15
  */
15
16
  export interface AuxiliaryController {
16
- tabChange(index: unknown, isFirst?: boolean, loadInterface?: boolean): void;
17
+ tabChange(index: AuxiliaryPanelId, isFirst?: boolean, loadInterface?: boolean): void;
17
18
  showInjectionPath(): void;
18
19
  }
19
20
  export declare class AuxiliaryStore {
@@ -13,64 +13,25 @@ export type FunctionLoopFilterGroup = {
13
13
  } | {
14
14
  gene_name: string;
15
15
  };
16
- /**
17
- * The imperative surface of one `Functionloop` instance — behaviour that only
18
- * the component can run.
19
- *
20
- * `clearFunctionLoopData` and `removeGroupData` tear down THREE scene objects,
21
- * and the other four forward into the `FunctionalAnalysisTab` child, whose
22
- * scene builders live there — since BRAI-10 by resolving `analysisController`
23
- * off this store rather than by holding a ref onto the child. Registered with
24
- * `setController` on mount, so a caller no longer needs a ref to a mounted
25
- * component.
26
- *
27
- * This interface had 11 members after BRAI-8. The 5 `setExpanded*Items` setters
28
- * and `setSelectedMethods` have been removed (BRAI-9) — those states are now
29
- * store fields, leaving 6 members: 2 scene teardown methods and 4 behavior
30
- * methods that still forward to the child.
31
- */
16
+ /** Scene and analysis actions exposed by the outer functional-loop panel. */
32
17
  export interface FunctionLoopController {
33
18
  clearFunctionLoopData(): void;
34
19
  removeGroupData(id: string, groupName?: string): void;
35
20
  triggerAnalysis(overrideRegions?: string[]): Promise<void>;
36
- loadMethodData(id: string, filterGroup?: FunctionLoopFilterGroup | null, externalData?: unknown): void;
37
- previewGene(geneName: string, excludeRegions?: string[]): void;
38
- previewReceptor(receptorName: string, excludeRegions?: string[]): void;
21
+ loadMethodData(id: string, filterGroup?: FunctionLoopFilterGroup | null, externalData?: unknown): Promise<void>;
22
+ previewGene(geneName: string, excludeRegions?: string[]): Promise<void>;
23
+ previewReceptor(receptorName: string, excludeRegions?: string[]): Promise<void>;
39
24
  }
40
- /**
41
- * The imperative surface of the `FunctionalAnalysisTab` child — the four
42
- * behaviours the outer `Functionloop` cannot run itself, because the THREE
43
- * scene builders and the analysis request live in the child.
44
- *
45
- * The outer component used to reach these through a `functionalAnalysisTabRef`;
46
- * the child registers here with `setAnalysisController` instead (BRAI-10), so
47
- * the four forwarding members of `FunctionLoopController` resolve through the
48
- * store rather than through a ref onto a mounted child.
49
- *
50
- * Deliberately not `FunctionLoopController`: that interface also carries
51
- * `clearFunctionLoopData` and `removeGroupData`, which are the outer
52
- * component's own scene teardown and have no counterpart in the child.
53
- */
25
+ /** Scene builders and pending-display cleanup owned by FunctionalAnalysisTab. */
54
26
  export interface FunctionalAnalysisController {
27
+ clearDisplay(): void;
28
+ removeGroupData(id: string, groupName?: string): void;
55
29
  triggerAnalysis(overrideRegions?: string[]): Promise<void>;
56
- loadMethodData(id: string, filterGroup?: FunctionLoopFilterGroup, externalData?: unknown): void;
57
- previewGene(geneName: string, excludeRegions?: string[]): void;
58
- previewReceptor(receptorName: string, excludeRegions?: string[]): void;
30
+ loadMethodData(id: string, filterGroup?: FunctionLoopFilterGroup, externalData?: unknown): Promise<void>;
31
+ previewGene(geneName: string, excludeRegions?: string[]): Promise<void>;
32
+ previewReceptor(receptorName: string, excludeRegions?: string[]): Promise<void>;
59
33
  }
60
- /**
61
- * Shared state of the functional-loop panel.
62
- *
63
- * These three fields used to be `useState` inside `Functionloop` and were
64
- * reachable from `aichat` only through an imperative handle — `setLinkRegions`,
65
- * `setLinkRegionsTitle` and `setFunctionLoopData` were pure `useState` setters
66
- * forwarded onto that handle. A caller now writes the store action directly and
67
- * no longer needs a ref to a mounted component.
68
- *
69
- * `selectedMethods` and the five `expanded*Items` used to be `useState` inside
70
- * `FunctionalAnalysisTab` and were reachable from the outer `Functionloop` only
71
- * through an imperative handle. They are store fields now: the component reads
72
- * them as an observer, and the outer component writes them directly.
73
- */
34
+ /** Shared analysis data and the canonical selection driving scene visibility. */
74
35
  export declare class FunctionLoopStore {
75
36
  /** Regions the analysis runs over. Driven by the region tree and by aichat. */
76
37
  linkRegions: string[];
@@ -85,14 +46,18 @@ export declare class FunctionLoopStore {
85
46
  * uses, so a stale instance cannot clear a newer one's registration.
86
47
  */
87
48
  analysisController: FunctionalAnalysisController | null;
88
- /** Selected method group keys in FunctionalAnalysisTab. */
49
+ /** Canonical `${id}_${displayName}` keys; swc_tree may use its bare type. */
89
50
  selectedMethods: string[];
90
- /** Expanded connection items per connectivity method type. */
91
- expandedViralItems: Set<string>;
92
- expandedMRIItems: Set<string>;
93
- expandedElectrophysiologyItems: Set<string>;
94
- expandedOptogeneticsItems: Set<string>;
95
- expandedSynapseItems: Set<string>;
51
+ private loadingCount;
52
+ get isLoading(): boolean;
53
+ get expandedViralItems(): Set<string>;
54
+ get expandedMRIItems(): Set<string>;
55
+ get expandedElectrophysiologyItems(): Set<string>;
56
+ get expandedOptogeneticsItems(): Set<string>;
57
+ get expandedSynapseItems(): Set<string>;
58
+ get expandedGeneNames(): Set<string>;
59
+ get expandedReceptorNames(): Set<string>;
60
+ getExpandedItems(id: string): Set<string>;
96
61
  constructor();
97
62
  setLinkRegions(value: StateUpdate<string[]>): void;
98
63
  setLinkRegionsTitle(value: StateUpdate<string>): void;
@@ -100,15 +65,7 @@ export declare class FunctionLoopStore {
100
65
  setController(controller: FunctionLoopController | null): void;
101
66
  setAnalysisController(controller: FunctionalAnalysisController | null): void;
102
67
  setSelectedMethods(value: StateUpdate<string[]>): void;
103
- setExpandedViralItems(value: StateUpdate<Set<string>>): void;
104
- setExpandedMRIItems(value: StateUpdate<Set<string>>): void;
105
- setExpandedElectrophysiologyItems(value: StateUpdate<Set<string>>): void;
106
- setExpandedOptogeneticsItems(value: StateUpdate<Set<string>>): void;
107
- setExpandedSynapseItems(value: StateUpdate<Set<string>>): void;
108
- /**
109
- * The store outlives the component, so what used to reset itself by being
110
- * `useState` has to be reset explicitly. Called during the first render of
111
- * each `Functionloop` mount — the same point the `useState` initializers ran.
112
- */
68
+ withLoading<T>(operation: () => T | Promise<T>): Promise<T>;
69
+ /** Reset panel selections without releasing loading operations still in flight. */
113
70
  resetPerMountState(): void;
114
71
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-Bf0sP4HG.js"),t=require("./basedecoder-CsHP9rmG.js");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-DEgHZlr6.js"),t=require("./basedecoder-CsHP9rmG.js");class d extends t.BaseDecoder{decodeBlock(e){return r.inflate_1(new Uint8Array(e)).buffer}}exports.default=d;
@@ -1,4 +1,4 @@
1
- import { i as r } from "./index-BDTXoGmb.mjs";
1
+ import { i as r } from "./index-tBE0HArS.mjs";
2
2
  import { B as a } from "./basedecoder-PoXbLGBV.mjs";
3
3
  class s extends a {
4
4
  decodeBlock(e) {