brainsmatics 1.2.5 → 1.2.7

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.
Files changed (74) hide show
  1. package/README.md +25 -2
  2. package/dist/assets/nifti.worker-GfiCZEci.js +54 -0
  3. package/dist/basedecoder-CsHP9rmG.js +1 -0
  4. package/dist/{basedecoder-11034ec6.mjs → basedecoder-PoXbLGBV.mjs} +26 -27
  5. package/dist/component/3d/core/brainOutlineTransform.d.ts +10 -0
  6. package/dist/component/3d/sequenceRegistration/SequenceRegistrationPanel.d.ts +21 -0
  7. package/dist/component/3d/sequenceRegistration/api.d.ts +23 -0
  8. package/dist/component/3d/sequenceRegistration/atlasReslicingReference.d.ts +64 -0
  9. package/dist/component/3d/sequenceRegistration/brainShellConstraint.d.ts +6 -0
  10. package/dist/component/3d/sequenceRegistration/connection.d.ts +8 -0
  11. package/dist/component/3d/sequenceRegistration/exportResult.d.ts +4 -0
  12. package/dist/component/3d/sequenceRegistration/handoff.d.ts +11 -0
  13. package/dist/component/3d/sequenceRegistration/poseEditor.d.ts +26 -0
  14. package/dist/component/3d/sequenceRegistration/stamPlane.d.ts +99 -0
  15. package/dist/component/3d/sequenceRegistration/transformControls.d.ts +4 -0
  16. package/dist/component/3d/sequenceRegistration/types.d.ts +169 -0
  17. package/dist/component/store/auxiliaryPanelStore.d.ts +1 -0
  18. package/dist/deflate-DzTw4Khe.js +1 -0
  19. package/dist/deflate-KdkkW4Oc.mjs +10 -0
  20. package/dist/{index-0bbe4693.mjs → index-BDTXoGmb.mjs} +94956 -93733
  21. package/dist/{index-010cea48.js → index-Bf0sP4HG.js} +586 -756
  22. package/dist/index.js +1 -1
  23. package/dist/index.mjs +91 -93
  24. package/dist/{jpeg-335c778f.mjs → jpeg-CswQNKC_.mjs} +33 -15
  25. package/dist/jpeg-DAONfqvO.js +1 -0
  26. package/dist/lerc-BaRT9vdX.js +1 -0
  27. package/dist/lerc-yogyOyVb.mjs +1031 -0
  28. package/dist/{lzw-82d7fc69.mjs → lzw-BVXd_0ds.mjs} +1 -1
  29. package/dist/{lzw-f00e8c8c.js → lzw-Cbi9AOTI.js} +1 -1
  30. package/dist/{packbits-58fd9c05.js → packbits-BXw9Z-3g.js} +1 -1
  31. package/dist/{packbits-8b95f4d7.mjs → packbits-VhI6aGzE.mjs} +1 -1
  32. package/dist/{raw-c0fe1c20.mjs → raw-CaI5pWOy.mjs} +1 -1
  33. package/dist/{raw-9c0f4034.js → raw-Cm78EGPL.js} +1 -1
  34. package/dist/style.css +1 -1
  35. package/dist/{webimage-affb95d1.mjs → webimage-BDn0NB86.mjs} +1 -1
  36. package/dist/{webimage-bc81928d.js → webimage-CCSZWcNO.js} +1 -1
  37. package/package.json +18 -16
  38. package/dist/assets/nifti.worker-c7d5c88c.js +0 -54
  39. package/dist/basedecoder-0503cc54.js +0 -1
  40. package/dist/component/2d/charts/BarChart.stories.d.ts +0 -19
  41. package/dist/component/2d/charts/ChordChart.stories.d.ts +0 -19
  42. package/dist/component/2d/charts/HeatmapChart.stories.d.ts +0 -19
  43. package/dist/component/2d/charts/RadarChart.stories.d.ts +0 -19
  44. package/dist/component/2d/charts/SankeyChart.stories.d.ts +0 -22
  45. package/dist/component/2d/charts/SpatialAdjacencyChart.stories.d.ts +0 -23
  46. package/dist/component/2d/distribution/Distribution.stories.d.ts +0 -10
  47. package/dist/component/2d/mulifiveiewer/MulfiViewer.stories.d.ts +0 -10
  48. package/dist/component/2d/navtree/NavTree.stories.d.ts +0 -6
  49. package/dist/component/2d/tast1/Task1.stories.d.ts +0 -9
  50. package/dist/component/2d/thumbnail/Thumbnail.stories.d.ts +0 -6
  51. package/dist/component/2d/twoviewer/TwoViewer.stories.d.ts +0 -6
  52. package/dist/component/3d/aichat/AiViewer.stories.d.ts +0 -6
  53. package/dist/component/3d/cardData/Carddata.stories.d.ts +0 -170
  54. package/dist/component/3d/chartViewer/ChartViewer.stories.d.ts +0 -6
  55. package/dist/component/3d/functionLoop/SingleNeuronCard.stories.d.ts +0 -11
  56. package/dist/component/3d/inputgrey/InputGrey.stories.d.ts +0 -6
  57. package/dist/component/3d/lengthViewer/LengthViewer.stories.d.ts +0 -6
  58. package/dist/component/3d/registration/Registration.stories.d.ts +0 -6
  59. package/dist/component/3d/sangjiViewer/SangjiViewer.stories.d.ts +0 -6
  60. package/dist/component/3d/swctree/SwcTree.stories.d.ts +0 -6
  61. package/dist/component/3d/tabViewer/TabViewer.stories.d.ts +0 -6
  62. package/dist/component/3d/userUpload/UserUpload.stories.d.ts +0 -6
  63. package/dist/component/3d/wordMap/WordMap.stories.d.ts +0 -7
  64. package/dist/component/common/Button/Button.stories.d.ts +0 -9
  65. package/dist/component/common/Header/Header.stories.d.ts +0 -7
  66. package/dist/deflate-0e28ba51.mjs +0 -12
  67. package/dist/deflate-4c2ea997.js +0 -1
  68. package/dist/demos/AtlasViewer.d.ts +0 -3
  69. package/dist/demos/AtlasViewer.stories.d.ts +0 -9
  70. package/dist/demos/Task3D.stories.d.ts +0 -10
  71. package/dist/demos/task3D.d.ts +0 -4
  72. package/dist/jpeg-f3c7cefc.js +0 -1
  73. package/dist/lerc-7bdfbb67.js +0 -1
  74. package/dist/lerc-943ab02b.mjs +0 -1035
package/README.md CHANGED
@@ -54,7 +54,8 @@ export default function App() {
54
54
 
55
55
  - 展示 3D 标准脑图谱。
56
56
  - 在同一个 Three.js 场景中展示脑区、核团、血管、神经元等对象。
57
- - 加载并展示 SWC 神经元形态数据。
57
+ - 各场景共用的模型右键菜单仅在右击时打开,并保留当次模型的操作目标;从模型移入菜单后可正常选择,移出菜单卡片、选择菜单项或点击外部后关闭,重新悬停模型不会自动打开。
58
+ - 加载并展示 SWC 神经元形态数据;悬停时红色高亮,移至空白、其他神经元或画布外后恢复原色,快速移开同样生效。
58
59
  - 将用户上传的数据插入 3D 场景并进行平移、旋转、缩放、调色和透明度调整。
59
60
  - 加载 `.tif`、`.tiff` 图像栈,并以体数据方式渲染。
60
61
  - 加载 `.nii.gz` 压缩 NIfTI 体数据。
@@ -281,10 +282,12 @@ NIfTI 示例:
281
282
 
282
283
  ## 开发
283
284
 
285
+ 开发环境需要 Node.js `20.19+` 或 `22.12+`,建议使用 Node.js 24。当前工具链为 Storybook `10.6.2`、Vite `7.3.7` 和 React 18。
286
+
284
287
  安装依赖:
285
288
 
286
289
  ```bash
287
- npm install
290
+ npm ci
288
291
  ```
289
292
 
290
293
  启动 Vite 开发服务:
@@ -305,6 +308,26 @@ npm run build
305
308
  npm run storybook
306
309
  ```
307
310
 
311
+ 也可使用 `bun run storybook`。Storybook 会自动发现 `.storybook/middleware.js` 并加载 API 代理,无需在 `.storybook/main.ts` 中导入或注册;代理仍使用 CommonJS,已有环境变量覆盖和 WebSocket 路由保持不变。
312
+
313
+ ### 组件故事的组织方式
314
+
315
+ - `.storybook/main.ts`:类型化的 ESM 配置,加载 React Vite 框架、Docs 和 MSW 插件;监视器排除 `dist`、`storybook-static` 等产物,避免 Windows 上并行构建触发文件锁错误。
316
+ - `.storybook/preview.tsx`:统一 Ant Design 主题、目录排序和 MSW 2 worker;不再修改原生 `Headers`。
317
+ - `src/component/**/组件名.stories.tsx`:与组件同目录的 CSF3 示例,按 `Charts`、`2D`、`3D`、`Common` 分类。
318
+ - `src/demos/`:完整工作台及图谱演示,统一归入 `Demo`;查看器故事的场景包装也放在这里,不进入组件库构建。
319
+ - `Meta` / `StoryObj` 从 `@storybook/react-vite` 导入;回调使用 `storybook/test` 的 `fn()`,交互使用同一入口的测试工具。Controls、Actions、Interactions 已由 Storybook 内置,无需旧版 Essentials / Interactions 插件。
320
+
321
+ 现有 28 组组件及演示文档包含 73 个故事。静态图表示例可通过 Controls 修改参数;Carddata 的授权、查询失败、克隆权限和披露级别等场景使用 MSW 本地响应。新增示例沿用上述目录和 CSF3 格式。
322
+
323
+ 更新 MSW worker:
324
+
325
+ ```bash
326
+ npm run init-msw
327
+ ```
328
+
329
+ 2D 查看器故事使用 `public/monkey` 中的真实样例,需要服务器支持 ZIF 字节范围请求。查看器挂载期间调整窗口大小仍会刷新页面,保留原组件行为。实时功能环路图表、上传、AI 和完整 3D 工作台仍依赖相应后端、数据资源及 WebGL;本次升级未将它们替换为模拟组件。静态部署 Storybook 时需由部署环境配置 API 代理。
330
+
308
331
  构建 Storybook:
309
332
 
310
333
  ```bash
@@ -0,0 +1,54 @@
1
+ (function(){"use strict";var U=Uint8Array,L=Uint16Array,ut=Int32Array,et=new U([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nt=new U([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),mt=new U([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),st=function(r,i){for(var t=new L(31),s=0;s<31;++s)t[s]=i+=1<<r[s-1];for(var e=new ut(t[30]),s=1;s<30;++s)for(var o=t[s];o<t[s+1];++o)e[o]=o-t[s]<<5|s;return{b:t,r:e}},rt=st(et,2),at=rt.b,At=rt.r;at[28]=258,At[258]=28;for(var xt=st(nt,0),It=xt.b,Q=new L(32768),A=0;A<32768;++A){var P=(A&43690)>>1|(A&21845)<<1;P=(P&52428)>>2|(P&13107)<<2,P=(P&61680)>>4|(P&3855)<<4,Q[A]=((P&65280)>>8|(P&255)<<8)>>1}for(var K=(function(r,i,t){for(var s=r.length,e=0,o=new L(i);e<s;++e)r[e]&&++o[r[e]-1];var n=new L(i);for(e=1;e<i;++e)n[e]=n[e-1]+o[e-1]<<1;var c;if(t){c=new L(1<<i);var f=15-i;for(e=0;e<s;++e)if(r[e])for(var _=e<<4|r[e],E=i-r[e],a=n[r[e]-1]++<<E,d=a|(1<<E)-1;a<=d;++a)c[Q[a]>>f]=_}else for(c=new L(s),e=0;e<s;++e)r[e]&&(c[e]=Q[n[r[e]-1]++]>>15-r[e]);return c}),V=new U(288),A=0;A<144;++A)V[A]=8;for(var A=144;A<256;++A)V[A]=9;for(var A=256;A<280;++A)V[A]=7;for(var A=280;A<288;++A)V[A]=8;for(var ot=new U(32),A=0;A<32;++A)ot[A]=5;var St=K(V,9,1),pt=K(ot,5,1),j=function(r){for(var i=r[0],t=1;t<r.length;++t)r[t]>i&&(i=r[t]);return i},F=function(r,i,t){var s=i/8|0;return(r[s]|r[s+1]<<8)>>(i&7)&t},W=function(r,i){var t=i/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(i&7)},Ct=function(r){return(r+7)/8|0},vt=function(r,i,t){return(t==null||t>r.length)&&(t=r.length),new U(r.subarray(i,t))},Mt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],N=function(r,i,t){var s=new Error(i||Mt[r]);if(s.code=r,Error.captureStackTrace&&Error.captureStackTrace(s,N),!t)throw s;return s},J=function(r,i,t,s){var e=r.length,o=0;if(!e||i.f&&!i.l)return t||new U(0);var n=!t,c=n||i.i!=2,f=i.i;n&&(t=new U(e*3));var _=function(dt){var Et=t.length;if(dt>Et){var gt=new U(Math.max(Et*2,dt));gt.set(t),t=gt}},E=i.f||0,a=i.p||0,d=i.b||0,m=i.l,u=i.d,g=i.m,x=i.n,b=e*8;do{if(!m){E=F(r,a,1);var p=F(r,a+1,3);if(a+=3,p)if(p==1)m=St,u=pt,g=9,x=5;else if(p==2){var k=F(r,a,31)+257,Y=F(r,a+10,15)+4,Z=k+F(r,a+5,31)+1;a+=14;for(var B=new U(Z),z=new U(19),v=0;v<Y;++v)z[mt[v]]=F(r,a+v*3,7);a+=Y*3;for(var y=j(z),I=(1<<y)-1,O=K(z,y,1),v=0;v<Z;){var q=O[F(r,a,I)];a+=q&15;var C=q>>4;if(C<16)B[v++]=C;else{var T=0,D=0;for(C==16?(D=3+F(r,a,3),a+=2,T=B[v-1]):C==17?(D=3+F(r,a,7),a+=3):C==18&&(D=11+F(r,a,127),a+=7);D--;)B[v++]=T}}var w=B.subarray(0,k),S=B.subarray(k);g=j(w),x=j(S),m=K(w,g,1),u=K(S,x,1)}else N(1);else{var C=Ct(a)+4,R=r[C-4]|r[C-3]<<8,G=C+R;if(G>e){f&&N(0);break}c&&_(d+R),t.set(r.subarray(C,G),d),i.b=d+=R,i.p=a=G*8,i.f=E;continue}if(a>b){f&&N(0);break}}c&&_(d+131072);for(var kt=(1<<g)-1,Lt=(1<<x)-1,$=a;;$=a){var T=m[W(r,a)&kt],X=T>>4;if(a+=T&15,a>b){f&&N(0);break}if(T||N(2),X<256)t[d++]=X;else if(X==256){$=a,m=null;break}else{var ht=X-254;if(X>264){var v=X-257,H=et[v];ht=F(r,a,(1<<H)-1)+at[v],a+=H}var tt=u[W(r,a)&Lt],it=tt>>4;tt||N(3),a+=tt&15;var S=It[it];if(it>3){var H=nt[it];S+=W(r,a)&(1<<H)-1,a+=H}if(a>b){f&&N(0);break}c&&_(d+131072);var ct=d+ht;if(d<S){var _t=o-S,Yt=Math.min(S,ct);for(_t+d<0&&N(3);d<Yt;++d)t[d]=s[_t+d]}for(;d<ct;++d)t[d]=t[d-S]}}i.l=m,i.p=$,i.b=d,i.f=E,m&&(E=1,i.m=g,i.d=u,i.n=x)}while(!E);return d!=t.length&&n?vt(t,0,d):t.subarray(0,d)},yt=new U(0),Tt=function(r){(r[0]!=31||r[1]!=139||r[2]!=8)&&N(6,"invalid gzip data");var i=r[3],t=10;i&4&&(t+=(r[10]|r[11]<<8)+2);for(var s=(i>>3&1)+(i>>4&1);s>0;s-=!r[t++]);return t+(i&2)},bt=function(r){var i=r.length;return(r[i-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0},Ut=function(r,i){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&N(6,"invalid zlib data"),(r[1]>>5&1)==1&&N(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function Nt(r,i){return J(r,{i:2},i,i)}function Dt(r,i){var t=Tt(r);return t+8>r.length&&N(6,"invalid gzip data"),J(r.subarray(t,-8),{i:2},new U(bt(r)),i)}function Ft(r,i){return J(r.subarray(Ut(r),-4),{i:2},i,i)}function qt(r,i){return r[0]==31&&r[1]==139&&r[2]==8?Dt(r,i):(r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31?Nt(r,i):Ft(r,i)}var wt=typeof TextDecoder<"u"&&new TextDecoder,Ot=0;try{wt.decode(yt,{stream:!0}),Ot=1}catch{}class Bt{esize;ecode;edata;littleEndian;constructor(i,t,s,e){if(i%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=i,this.ecode=t,this.edata=s,this.littleEndian=e}toArrayBuffer(){let i=new Uint8Array(this.esize),t=new Uint8Array(this.edata);i.set(t,8);let s=new DataView(i.buffer);return s.setInt32(0,this.esize,this.littleEndian),s.setInt32(4,this.ecode,this.littleEndian),i.buffer}}class l{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(i,t,s){var e="",o,n;for(o=t;o<s;o+=1)n=i.getUint8(o),n!==0&&(e+=String.fromCharCode(n));return e}static getByteAt=function(i,t){return i.getUint8(t)};static getShortAt=function(i,t,s){return i.getInt16(t,s)};static getIntAt(i,t,s){return i.getInt32(t,s)}static getFloatAt(i,t,s){return i.getFloat32(t,s)}static getDoubleAt(i,t,s){return i.getFloat64(t,s)}static getInt64At(i,t,s){const e=i.getUint32(t,s),o=i.getInt32(t+4,s);let n;return s?n=o*2**32+e:n=e*2**32+o,o<0&&(n+=-1*2**32*2**32),n}static getUint64At(i,t,s){const e=i.getUint32(t+(s?0:4),s),o=i.getUint32(t+(s?4:0),s);return s?o*2**32+e:e*2**32+o}static getExtensionsAt(i,t,s,e){let o=[],n=t;for(;n<e;){let c=s,f=l.getIntAt(i,n,s);if(!f)break;if(f+n>e&&(c=!c,f=l.getIntAt(i,n,c),f+n>e))throw new Error("This does not appear to be a valid NIFTI extension");if(f%16!=0)throw new Error("This does not appear to be a NIFTI extension");let _=l.getIntAt(i,n+4,c),E=i.buffer.slice(n+8,n+f),a=new Bt(f,_,E,c);o.push(a),n+=f}return o}static toArrayBuffer(i){var t,s,e;for(t=new ArrayBuffer(i.length),s=new Uint8Array(t),e=0;e<i.length;e+=1)s[e]=i[e];return t}static isString(i){return typeof i=="string"||i instanceof String}static formatNumber(i,t=void 0){let s;return l.isString(i)?s=Number(i):s=i,t?s=s.toPrecision(5):s=s.toPrecision(7),parseFloat(s)}static makeCRCTable(){let i,t=[];for(var s=0;s<256;s++){i=s;for(var e=0;e<8;e++)i=i&1?3988292384^i>>>1:i>>>1;t[s]=i}return t}static crc32(i){l.crcTable||(l.crcTable=l.makeCRCTable());const t=l.crcTable;let s=-1;for(var e=0;e<i.byteLength;e++)s=s>>>8^t[(s^i.getUint8(e))&255];return(s^-1)>>>0}}class h{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description="";aux_file="";intent_name="";qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic="0";isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(i){var t=new DataView(i),s=l.getIntAt(t,0,this.littleEndian),e,o,n,c;if(s!==h.MAGIC_COOKIE&&(this.littleEndian=!0,s=l.getIntAt(t,0,this.littleEndian)),s!==h.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=l.getByteAt(t,39),e=0;e<8;e+=1)c=40+e*2,this.dims[e]=l.getShortAt(t,c,this.littleEndian);for(this.intent_p1=l.getFloatAt(t,56,this.littleEndian),this.intent_p2=l.getFloatAt(t,60,this.littleEndian),this.intent_p3=l.getFloatAt(t,64,this.littleEndian),this.intent_code=l.getShortAt(t,68,this.littleEndian),this.datatypeCode=l.getShortAt(t,70,this.littleEndian),this.numBitsPerVoxel=l.getShortAt(t,72,this.littleEndian),this.slice_start=l.getShortAt(t,74,this.littleEndian),e=0;e<8;e+=1)c=76+e*4,this.pixDims[e]=l.getFloatAt(t,c,this.littleEndian);if(this.vox_offset=l.getFloatAt(t,108,this.littleEndian),this.scl_slope=l.getFloatAt(t,112,this.littleEndian),this.scl_inter=l.getFloatAt(t,116,this.littleEndian),this.slice_end=l.getShortAt(t,120,this.littleEndian),this.slice_code=l.getByteAt(t,122),this.xyzt_units=l.getByteAt(t,123),this.cal_max=l.getFloatAt(t,124,this.littleEndian),this.cal_min=l.getFloatAt(t,128,this.littleEndian),this.slice_duration=l.getFloatAt(t,132,this.littleEndian),this.toffset=l.getFloatAt(t,136,this.littleEndian),this.description=l.getStringAt(t,148,228),this.aux_file=l.getStringAt(t,228,252),this.qform_code=l.getShortAt(t,252,this.littleEndian),this.sform_code=l.getShortAt(t,254,this.littleEndian),this.quatern_b=l.getFloatAt(t,256,this.littleEndian),this.quatern_c=l.getFloatAt(t,260,this.littleEndian),this.quatern_d=l.getFloatAt(t,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(Math.pow(this.quatern_b,2)+Math.pow(this.quatern_c,2)+Math.pow(this.quatern_d,2))),this.qoffset_x=l.getFloatAt(t,268,this.littleEndian),this.qoffset_y=l.getFloatAt(t,272,this.littleEndian),this.qoffset_z=l.getFloatAt(t,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){const f=this.quatern_a,_=this.quatern_b,E=this.quatern_c,a=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[f*f+_*_-E*E-a*a,2*_*E-2*f*a,2*_*a+2*f*E],[2*_*E+2*f*a,f*f+E*E-_*_-a*a,2*E*a-2*f*_],[2*_*a-2*f*E,2*E*a+2*f*_,f*f+a*a-E*E-_*_]],o=0;o<3;o+=1)for(n=0;n<3;n+=1)this.affine[o][n]=this.quatern_R[o][n]*this.pixDims[n+1],n===2&&(this.affine[o][n]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(o=0;o<3;o+=1)for(n=0;n<4;n+=1)c=280+(o*4+n)*4,this.affine[o][n]=l.getFloatAt(t,c,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=l.getStringAt(t,328,344),this.magic=l.getStringAt(t,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,h.MAGIC_NUMBER2),t.byteLength>h.MAGIC_COOKIE){this.extensionFlag[0]=l.getByteAt(t,348),this.extensionFlag[1]=l.getByteAt(t,349),this.extensionFlag[2]=l.getByteAt(t,350),this.extensionFlag[3]=l.getByteAt(t,351);let f=!0;!this.isHDR&&this.vox_offset<=352&&(f=!1),t.byteLength<=368&&(f=!1),f&&this.extensionFlag[0]&&(this.extensions=l.getExtensionsAt(t,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var i=l.formatNumber,t="";return t+="Dim Info = "+this.dim_info+`
2
+ `,t+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
3
+ `,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
4
+ `,t+="Intent Code = "+this.intent_code+`
5
+ `,t+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`)
6
+ `,t+="Bits Per Voxel = "+this.numBitsPerVoxel+`
7
+ `,t+="Slice Start = "+this.slice_start+`
8
+ `,t+="Voxel Dimensions (1-8): "+i(this.pixDims[0])+", "+i(this.pixDims[1])+", "+i(this.pixDims[2])+", "+i(this.pixDims[3])+", "+i(this.pixDims[4])+", "+i(this.pixDims[5])+", "+i(this.pixDims[6])+", "+i(this.pixDims[7])+`
9
+ `,t+="Image Offset = "+this.vox_offset+`
10
+ `,t+="Data Scale: Slope = "+i(this.scl_slope)+" Intercept = "+i(this.scl_inter)+`
11
+ `,t+="Slice End = "+this.slice_end+`
12
+ `,t+="Slice Code = "+this.slice_code+`
13
+ `,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(h.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(h.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
14
+ `,t+="Display Range: Max = "+i(this.cal_max)+" Min = "+i(this.cal_min)+`
15
+ `,t+="Slice Duration = "+this.slice_duration+`
16
+ `,t+="Time Axis Shift = "+this.toffset+`
17
+ `,t+='Description: "'+this.description+`"
18
+ `,t+='Auxiliary File: "'+this.aux_file+`"
19
+ `,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`)
20
+ `,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`)
21
+ `,t+="Quaternion Parameters: b = "+i(this.quatern_b)+" c = "+i(this.quatern_c)+" d = "+i(this.quatern_d)+`
22
+ `,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+`
23
+ `,t+="S-Form Parameters X: "+i(this.affine[0][0])+", "+i(this.affine[0][1])+", "+i(this.affine[0][2])+", "+i(this.affine[0][3])+`
24
+ `,t+="S-Form Parameters Y: "+i(this.affine[1][0])+", "+i(this.affine[1][1])+", "+i(this.affine[1][2])+", "+i(this.affine[1][3])+`
25
+ `,t+="S-Form Parameters Z: "+i(this.affine[2][0])+", "+i(this.affine[2][1])+", "+i(this.affine[2][2])+", "+i(this.affine[2][3])+`
26
+ `,t+='Intent Name: "'+this.intent_name+`"
27
+ `,this.extensionFlag[0]&&(t+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+`
28
+ `),t}getDatatypeCodeString=function(i){return i===h.TYPE_UINT8?"1-Byte Unsigned Integer":i===h.TYPE_INT16?"2-Byte Signed Integer":i===h.TYPE_INT32?"4-Byte Signed Integer":i===h.TYPE_FLOAT32?"4-Byte Float":i===h.TYPE_FLOAT64?"8-Byte Float":i===h.TYPE_RGB24?"RGB":i===h.TYPE_INT8?"1-Byte Signed Integer":i===h.TYPE_UINT16?"2-Byte Unsigned Integer":i===h.TYPE_UINT32?"4-Byte Unsigned Integer":i===h.TYPE_INT64?"8-Byte Signed Integer":i===h.TYPE_UINT64?"8-Byte Unsigned Integer":"Unknown"};getTransformCodeString=function(i){return i===h.XFORM_SCANNER_ANAT?"Scanner":i===h.XFORM_ALIGNED_ANAT?"Aligned":i===h.XFORM_TALAIRACH?"Talairach":i===h.XFORM_MNI_152?"MNI":"Unknown"};getUnitsCodeString=function(i){return i===h.UNITS_METER?"Meters":i===h.UNITS_MM?"Millimeters":i===h.UNITS_MICRON?"Microns":i===h.UNITS_SEC?"Seconds":i===h.UNITS_MSEC?"Milliseconds":i===h.UNITS_USEC?"Microseconds":i===h.UNITS_HZ?"Hz":i===h.UNITS_PPM?"PPM":i===h.UNITS_RADS?"Rads":"Unknown"};getQformMat(){return this.convertNiftiQFormToNiftiSForm(this.quatern_b,this.quatern_c,this.quatern_d,this.qoffset_x,this.qoffset_y,this.qoffset_z,this.pixDims[1],this.pixDims[2],this.pixDims[3],this.pixDims[0])}convertNiftiQFormToNiftiSForm(i,t,s,e,o,n,c,f,_,E){var a=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],d,m=i,u=t,g=s,x,b,p;return a[3][0]=a[3][1]=a[3][2]=0,a[3][3]=1,d=1-(m*m+u*u+g*g),d<1e-7?(d=1/Math.sqrt(m*m+u*u+g*g),m*=d,u*=d,g*=d,d=0):d=Math.sqrt(d),x=c>0?c:1,b=f>0?f:1,p=_>0?_:1,E<0&&(p=-p),a[0][0]=(d*d+m*m-u*u-g*g)*x,a[0][1]=2*(m*u-d*g)*b,a[0][2]=2*(m*g+d*u)*p,a[1][0]=2*(m*u+d*g)*x,a[1][1]=(d*d+u*u-m*m-g*g)*b,a[1][2]=2*(u*g-d*m)*p,a[2][0]=2*(m*g-d*u)*x,a[2][1]=2*(u*g+d*m)*b,a[2][2]=(d*d+g*g-u*u-m*m)*p,a[0][3]=e,a[1][3]=o,a[2][3]=n,a}convertNiftiSFormToNEMA(i){var t,s,e,o,n,c,f,_,E,a,d,m,u,g,x,b,p,C,R,G,k,Y,Z,B,z,v,y,I,O,q,T,D,w,S;if(x=0,y=[[0,0,0],[0,0,0],[0,0,0]],I=[[0,0,0],[0,0,0],[0,0,0]],t=i[0][0],s=i[0][1],e=i[0][2],o=i[1][0],n=i[1][1],c=i[1][2],f=i[2][0],_=i[2][1],E=i[2][2],a=Math.sqrt(t*t+o*o+f*f),a===0||(t/=a,o/=a,f/=a,a=Math.sqrt(s*s+n*n+_*_),a===0))return null;if(s/=a,n/=a,_/=a,a=t*s+o*n+f*_,Math.abs(a)>1e-4){if(s-=a*t,n-=a*o,_-=a*f,a=Math.sqrt(s*s+n*n+_*_),a===0)return null;s/=a,n/=a,_/=a}if(a=Math.sqrt(e*e+c*c+E*E),a===0?(e=o*_-f*n,c=f*s-_*t,E=t*n-o*s):(e/=a,c/=a,E/=a),a=t*e+o*c+f*E,Math.abs(a)>1e-4){if(e-=a*t,c-=a*o,E-=a*f,a=Math.sqrt(e*e+c*c+E*E),a===0)return null;e/=a,c/=a,E/=a}if(a=s*e+n*c+_*E,Math.abs(a)>1e-4){if(e-=a*s,c-=a*n,E-=a*_,a=Math.sqrt(e*e+c*c+E*E),a===0)return null;e/=a,c/=a,E/=a}if(y[0][0]=t,y[0][1]=s,y[0][2]=e,y[1][0]=o,y[1][1]=n,y[1][2]=c,y[2][0]=f,y[2][1]=_,y[2][2]=E,d=this.nifti_mat33_determ(y),d===0)return null;for(v=-666,R=Y=Z=B=1,G=2,k=3,u=1;u<=3;u+=1)for(g=1;g<=3;g+=1)if(u!==g){for(x=1;x<=3;x+=1)if(!(u===x||g===x))for(I[0][0]=I[0][1]=I[0][2]=I[1][0]=I[1][1]=I[1][2]=I[2][0]=I[2][1]=I[2][2]=0,b=-1;b<=1;b+=2)for(p=-1;p<=1;p+=2)for(C=-1;C<=1;C+=2)I[0][u-1]=b,I[1][g-1]=p,I[2][x-1]=C,m=this.nifti_mat33_determ(I),m*d>0&&(z=this.nifti_mat33_mul(I,y),a=z[0][0]+z[1][1]+z[2][2],a>v&&(v=a,R=u,G=g,k=x,Y=b,Z=p,B=C))}switch(O=q=T=D=w=S="",R*Y){case 1:O="X",D="+";break;case-1:O="X",D="-";break;case 2:O="Y",D="+";break;case-2:O="Y",D="-";break;case 3:O="Z",D="+";break;case-3:O="Z",D="-";break}switch(G*Z){case 1:q="X",w="+";break;case-1:q="X",w="-";break;case 2:q="Y",w="+";break;case-2:q="Y",w="-";break;case 3:q="Z",w="+";break;case-3:q="Z",w="-";break}switch(k*B){case 1:T="X",S="+";break;case-1:T="X",S="-";break;case 2:T="Y",S="+";break;case-2:T="Y",S="-";break;case 3:T="Z",S="+";break;case-3:T="Z",S="-";break}return O+q+T+D+w+S}nifti_mat33_mul=function(i,t){var s=[[0,0,0],[0,0,0],[0,0,0]],e,o;for(e=0;e<3;e+=1)for(o=0;o<3;o+=1)s[e][o]=i[e][0]*t[0][o]+i[e][1]*t[1][o]+i[e][2]*t[2][o];return s};nifti_mat33_determ=function(i){var t,s,e,o,n,c,f,_,E;return t=i[0][0],s=i[0][1],e=i[0][2],o=i[1][0],n=i[1][1],c=i[1][2],f=i[2][0],_=i[2][1],E=i[2][2],t*n*E-t*_*c-o*s*E+o*_*e+f*s*c-f*n*e};getExtensionLocation(){return h.MAGIC_COOKIE+4}getExtensionSize(i){return l.getIntAt(i,this.getExtensionLocation(),this.littleEndian)}getExtensionCode(i){return l.getIntAt(i,this.getExtensionLocation()+4,this.littleEndian)}addExtension(i,t=-1){t==-1?this.extensions.push(i):this.extensions.splice(t,0,i),this.vox_offset+=i.esize}removeExtension(i){let t=this.extensions[i];t&&(this.vox_offset-=t.esize),this.extensions.splice(i,1)}toArrayBuffer(i=!1){let e=352;if(i)for(let f of this.extensions)e+=f.esize;let o=new Uint8Array(e),n=new DataView(o.buffer);n.setInt32(0,348,this.littleEndian),n.setUint8(39,this.dim_info);for(let f=0;f<8;f++)n.setUint16(40+2*f,this.dims[f],this.littleEndian);n.setFloat32(56,this.intent_p1,this.littleEndian),n.setFloat32(60,this.intent_p2,this.littleEndian),n.setFloat32(64,this.intent_p3,this.littleEndian),n.setInt16(68,this.intent_code,this.littleEndian),n.setInt16(70,this.datatypeCode,this.littleEndian),n.setInt16(72,this.numBitsPerVoxel,this.littleEndian),n.setInt16(74,this.slice_start,this.littleEndian);for(let f=0;f<8;f++)n.setFloat32(76+4*f,this.pixDims[f],this.littleEndian);n.setFloat32(108,this.vox_offset,this.littleEndian),n.setFloat32(112,this.scl_slope,this.littleEndian),n.setFloat32(116,this.scl_inter,this.littleEndian),n.setInt16(120,this.slice_end,this.littleEndian),n.setUint8(122,this.slice_code),n.setUint8(123,this.xyzt_units),n.setFloat32(124,this.cal_max,this.littleEndian),n.setFloat32(128,this.cal_min,this.littleEndian),n.setFloat32(132,this.slice_duration,this.littleEndian),n.setFloat32(136,this.toffset,this.littleEndian),o.set(new TextEncoder().encode(this.description),148),o.set(new TextEncoder().encode(this.aux_file),228),n.setInt16(252,this.qform_code,this.littleEndian),n.setInt16(254,this.sform_code,this.littleEndian),n.setFloat32(256,this.quatern_b,this.littleEndian),n.setFloat32(260,this.quatern_c,this.littleEndian),n.setFloat32(264,this.quatern_d,this.littleEndian),n.setFloat32(268,this.qoffset_x,this.littleEndian),n.setFloat32(272,this.qoffset_y,this.littleEndian),n.setFloat32(276,this.qoffset_z,this.littleEndian);const c=this.affine.flat();for(let f=0;f<12;f++)n.setFloat32(280+4*f,c[f],this.littleEndian);if(o.set(new TextEncoder().encode(this.intent_name),328),o.set(new TextEncoder().encode(this.magic),344),i){o.set(Uint8Array.from([1,0,0,0]),348);let f=this.getExtensionLocation();for(const _ of this.extensions)n.setInt32(f,_.esize,_.littleEndian),n.setInt32(f+4,_.ecode,_.littleEndian),o.set(new Uint8Array(_.edata),f+8),f+=_.esize}else o.set(new Uint8Array(4).fill(0),348);return o.buffer}}class M{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description="";aux_file="";intent_name="";qform_code=0;sform_code=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];magic="0";extensionFlag=[0,0,0,0];extensions=[];extensionSize=0;extensionCode=0;static MAGIC_COOKIE=540;static MAGIC_NUMBER_LOCATION=4;static MAGIC_NUMBER=[110,43,50,0,13,10,26,10];static MAGIC_NUMBER2=[110,105,50,0,13,10,26,10];readHeader(i){var t=new DataView(i),s=l.getIntAt(t,0,this.littleEndian),e,o,n,c;if(s!==M.MAGIC_COOKIE&&(this.littleEndian=!0,s=l.getIntAt(t,0,this.littleEndian)),s!==M.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.magic=l.getStringAt(t,4,12),this.datatypeCode=l.getShortAt(t,12,this.littleEndian),this.numBitsPerVoxel=l.getShortAt(t,14,this.littleEndian),e=0;e<8;e+=1)c=16+e*8,this.dims[e]=l.getInt64At(t,c,this.littleEndian);for(this.intent_p1=l.getDoubleAt(t,80,this.littleEndian),this.intent_p2=l.getDoubleAt(t,88,this.littleEndian),this.intent_p3=l.getDoubleAt(t,96,this.littleEndian),e=0;e<8;e+=1)c=104+e*8,this.pixDims[e]=l.getDoubleAt(t,c,this.littleEndian);for(this.vox_offset=l.getInt64At(t,168,this.littleEndian),this.scl_slope=l.getDoubleAt(t,176,this.littleEndian),this.scl_inter=l.getDoubleAt(t,184,this.littleEndian),this.cal_max=l.getDoubleAt(t,192,this.littleEndian),this.cal_min=l.getDoubleAt(t,200,this.littleEndian),this.slice_duration=l.getDoubleAt(t,208,this.littleEndian),this.toffset=l.getDoubleAt(t,216,this.littleEndian),this.slice_start=l.getInt64At(t,224,this.littleEndian),this.slice_end=l.getInt64At(t,232,this.littleEndian),this.description=l.getStringAt(t,240,320),this.aux_file=l.getStringAt(t,320,344),this.qform_code=l.getIntAt(t,344,this.littleEndian),this.sform_code=l.getIntAt(t,348,this.littleEndian),this.quatern_b=l.getDoubleAt(t,352,this.littleEndian),this.quatern_c=l.getDoubleAt(t,360,this.littleEndian),this.quatern_d=l.getDoubleAt(t,368,this.littleEndian),this.qoffset_x=l.getDoubleAt(t,376,this.littleEndian),this.qoffset_y=l.getDoubleAt(t,384,this.littleEndian),this.qoffset_z=l.getDoubleAt(t,392,this.littleEndian),o=0;o<3;o+=1)for(n=0;n<4;n+=1)c=400+(o*4+n)*8,this.affine[o][n]=l.getDoubleAt(t,c,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.slice_code=l.getIntAt(t,496,this.littleEndian),this.xyzt_units=l.getIntAt(t,500,this.littleEndian),this.intent_code=l.getIntAt(t,504,this.littleEndian),this.intent_name=l.getStringAt(t,508,524),this.dim_info=l.getByteAt(t,524),t.byteLength>M.MAGIC_COOKIE&&(this.extensionFlag[0]=l.getByteAt(t,540),this.extensionFlag[1]=l.getByteAt(t,541),this.extensionFlag[2]=l.getByteAt(t,542),this.extensionFlag[3]=l.getByteAt(t,543),this.extensionFlag[0]&&(this.extensions=l.getExtensionsAt(t,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))}toFormattedString(){var i=l.formatNumber,t="";return t+="Datatype = "+ +this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`)
29
+ `,t+="Bits Per Voxel = = "+this.numBitsPerVoxel+`
30
+ `,t+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
31
+ `,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
32
+ `,t+="Voxel Dimensions (1-8): "+i(this.pixDims[0])+", "+i(this.pixDims[1])+", "+i(this.pixDims[2])+", "+i(this.pixDims[3])+", "+i(this.pixDims[4])+", "+i(this.pixDims[5])+", "+i(this.pixDims[6])+", "+i(this.pixDims[7])+`
33
+ `,t+="Image Offset = "+this.vox_offset+`
34
+ `,t+="Data Scale: Slope = "+i(this.scl_slope)+" Intercept = "+i(this.scl_inter)+`
35
+ `,t+="Display Range: Max = "+i(this.cal_max)+" Min = "+i(this.cal_min)+`
36
+ `,t+="Slice Duration = "+this.slice_duration+`
37
+ `,t+="Time Axis Shift = "+this.toffset+`
38
+ `,t+="Slice Start = "+this.slice_start+`
39
+ `,t+="Slice End = "+this.slice_end+`
40
+ `,t+='Description: "'+this.description+`"
41
+ `,t+='Auxiliary File: "'+this.aux_file+`"
42
+ `,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`)
43
+ `,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`)
44
+ `,t+="Quaternion Parameters: b = "+i(this.quatern_b)+" c = "+i(this.quatern_c)+" d = "+i(this.quatern_d)+`
45
+ `,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+`
46
+ `,t+="S-Form Parameters X: "+i(this.affine[0][0])+", "+i(this.affine[0][1])+", "+i(this.affine[0][2])+", "+i(this.affine[0][3])+`
47
+ `,t+="S-Form Parameters Y: "+i(this.affine[1][0])+", "+i(this.affine[1][1])+", "+i(this.affine[1][2])+", "+i(this.affine[1][3])+`
48
+ `,t+="S-Form Parameters Z: "+i(this.affine[2][0])+", "+i(this.affine[2][1])+", "+i(this.affine[2][2])+", "+i(this.affine[2][3])+`
49
+ `,t+="Slice Code = "+this.slice_code+`
50
+ `,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(h.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(h.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
51
+ `,t+="Intent Code = "+this.intent_code+`
52
+ `,t+='Intent Name: "'+this.intent_name+`"
53
+ `,t+="Dim Info = "+this.dim_info+`
54
+ `,t}getExtensionLocation=function(){return M.MAGIC_COOKIE+4};getExtensionSize=h.prototype.getExtensionSize;getExtensionCode=h.prototype.getExtensionCode;addExtension=h.prototype.addExtension;removeExtension=h.prototype.removeExtension;getDatatypeCodeString=h.prototype.getDatatypeCodeString;getTransformCodeString=h.prototype.getTransformCodeString;getUnitsCodeString=h.prototype.getUnitsCodeString;getQformMat=h.prototype.getQformMat;convertNiftiQFormToNiftiSForm=h.prototype.convertNiftiQFormToNiftiSForm;convertNiftiSFormToNEMA=h.prototype.convertNiftiSFormToNEMA;nifti_mat33_mul=h.prototype.nifti_mat33_mul;nifti_mat33_determ=h.prototype.nifti_mat33_determ;toArrayBuffer(i=!1){let e=544;if(i)for(let f of this.extensions)e+=f.esize;let o=new Uint8Array(e),n=new DataView(o.buffer);n.setInt32(0,540,this.littleEndian),o.set(new TextEncoder().encode(this.magic),4),n.setInt16(12,this.datatypeCode,this.littleEndian),n.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let f=0;f<8;f++)n.setBigInt64(16+8*f,BigInt(this.dims[f]),this.littleEndian);n.setFloat64(80,this.intent_p1,this.littleEndian),n.setFloat64(88,this.intent_p2,this.littleEndian),n.setFloat64(96,this.intent_p3,this.littleEndian);for(let f=0;f<8;f++)n.setFloat64(104+8*f,this.pixDims[f],this.littleEndian);n.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),n.setFloat64(176,this.scl_slope,this.littleEndian),n.setFloat64(184,this.scl_inter,this.littleEndian),n.setFloat64(192,this.cal_max,this.littleEndian),n.setFloat64(200,this.cal_min,this.littleEndian),n.setFloat64(208,this.slice_duration,this.littleEndian),n.setFloat64(216,this.toffset,this.littleEndian),n.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),n.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),o.set(new TextEncoder().encode(this.description),240),o.set(new TextEncoder().encode(this.aux_file),320),n.setInt32(344,this.qform_code,this.littleEndian),n.setInt32(348,this.sform_code,this.littleEndian),n.setFloat64(352,this.quatern_b,this.littleEndian),n.setFloat64(360,this.quatern_c,this.littleEndian),n.setFloat64(368,this.quatern_d,this.littleEndian),n.setFloat64(376,this.qoffset_x,this.littleEndian),n.setFloat64(384,this.qoffset_y,this.littleEndian),n.setFloat64(392,this.qoffset_z,this.littleEndian);const c=this.affine.flat();for(let f=0;f<12;f++)n.setFloat64(400+8*f,c[f],this.littleEndian);if(n.setInt32(496,this.slice_code,this.littleEndian),n.setInt32(500,this.xyzt_units,this.littleEndian),n.setInt32(504,this.intent_code,this.littleEndian),o.set(new TextEncoder().encode(this.intent_name),508),n.setUint8(524,this.dim_info),i){o.set(Uint8Array.from([1,0,0,0]),540);let f=this.getExtensionLocation();for(const _ of this.extensions)n.setInt32(f,_.esize,_.littleEndian),n.setInt32(f+4,_.ecode,_.littleEndian),o.set(new Uint8Array(_.edata),f+8),f+=_.esize}else o.set(new Uint8Array(4).fill(0),540);return o.buffer}}function Pt(r,i=!1){var t,s,e,o;return r.byteLength<h.STANDARD_HEADER_SIZE?!1:(t=new DataView(r),t&&(s=t.getUint8(h.MAGIC_NUMBER_LOCATION)),e=t.getUint8(h.MAGIC_NUMBER_LOCATION+1),o=t.getUint8(h.MAGIC_NUMBER_LOCATION+2),i&&s===h.MAGIC_NUMBER2[0]&&e===h.MAGIC_NUMBER2[1]&&o===h.MAGIC_NUMBER2[2]?!0:s===h.MAGIC_NUMBER[0]&&e===h.MAGIC_NUMBER[1]&&o===h.MAGIC_NUMBER[2])}function zt(r,i=!1){var t,s,e,o;return r.byteLength<h.STANDARD_HEADER_SIZE?!1:(t=new DataView(r),s=t.getUint8(M.MAGIC_NUMBER_LOCATION),e=t.getUint8(M.MAGIC_NUMBER_LOCATION+1),o=t.getUint8(M.MAGIC_NUMBER_LOCATION+2),i&&s===M.MAGIC_NUMBER2[0]&&e===M.MAGIC_NUMBER2[1]&&o===M.MAGIC_NUMBER2[2]?!0:s===M.MAGIC_NUMBER[0]&&e===M.MAGIC_NUMBER[1]&&o===M.MAGIC_NUMBER[2])}function lt(r){var i,t,s;return!!(r&&(i=new DataView(r),t=i.getUint8(0),s=i.getUint8(1),t===l.GUNZIP_MAGIC_COOKIE1||s===l.GUNZIP_MAGIC_COOKIE2))}function ft(r){return qt(new Uint8Array(r)).buffer}function Rt(r,i=!1){let t=null;if(lt(r)&&(r=ft(r)),Pt(r,i)?t=new h:zt(r,i)&&(t=new M),t)t.readHeader(r);else throw new Error("That file does not appear to be NIFTI!");return t}function Gt(r,i){var t=r.vox_offset,s=1,e=1;r.dims[4]&&(s=r.dims[4]),r.dims[5]&&(e=r.dims[5]);var o=r.dims[1]*r.dims[2]*r.dims[3]*s*e*(r.numBitsPerVoxel/8);return i.slice(t,t+o)}self.onmessage=r=>{try{const i=r.data,t=lt(i)?ft(i):i,s=t instanceof ArrayBuffer?t:new Uint8Array(t).slice().buffer,e=Rt(s);if(!e)throw new Error("Invalid NIfTI header");const o=Gt(e,s);self.postMessage({header:{dims:e.dims,datatypeCode:e.datatypeCode,littleEndian:e.littleEndian},image:o})}catch(i){const t=i instanceof Error?i:new Error(String(i));self.postMessage({error:{message:t.message,stack:t.stack,name:t.name}})}}})();
@@ -0,0 +1 @@
1
+ "use strict";function l(o,e){let t=o.length-e,r=0;do{for(let c=e;c>0;c--)o[r+e]+=o[r],r++;t-=e}while(t>0)}function d(o,e,t){let r=0,c=o.length;const i=c/t;for(;c>e;){for(let n=e;n>0;--n)o[r+e]+=o[r],++r;c-=e}const s=o.slice();for(let n=0;n<i;++n)for(let a=0;a<t;++a)o[t*n+a]=s[(t-a-1)*i+n]}function f(o,e,t,r,c,i){if(e===1)return o;for(let a=0;a<c.length;++a){if(c[a]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(c[a]!==c[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const s=c[0]/8,n=i===2?1:c.length;for(let a=0;a<r&&!(a*n*t*s>=o.byteLength);++a){let h;if(e===2){switch(c[0]){case 8:h=new Uint8Array(o,a*n*t*s,n*t*s);break;case 16:h=new Uint16Array(o,a*n*t*s,n*t*s/2);break;case 32:h=new Uint32Array(o,a*n*t*s,n*t*s/4);break;default:throw new Error(`Predictor 2 not allowed with ${c[0]} bits per sample.`)}l(h,n)}else e===3&&(h=new Uint8Array(o,a*n*t*s,n*t*s),d(h,n,s))}return o}class g{async decode(e,t){const r=await this.decodeBlock(t),c=e.Predictor||1;if(c!==1){const i=!e.StripOffsets,s=i?e.TileWidth:e.ImageWidth,n=i?e.TileLength:e.RowsPerStrip||e.ImageLength;return f(r,c,s,n,e.BitsPerSample,e.PlanarConfiguration)}return r}}exports.BaseDecoder=g;
@@ -1,26 +1,26 @@
1
1
  function l(o, n) {
2
- let t = o.length - n, r = 0;
2
+ let t = o.length - n, s = 0;
3
3
  do {
4
4
  for (let a = n; a > 0; a--)
5
- o[r + n] += o[r], r++;
5
+ o[s + n] += o[s], s++;
6
6
  t -= n;
7
7
  } while (t > 0);
8
8
  }
9
9
  function d(o, n, t) {
10
- let r = 0, a = o.length;
10
+ let s = 0, a = o.length;
11
11
  const i = a / t;
12
12
  for (; a > n; ) {
13
13
  for (let e = n; e > 0; --e)
14
- o[r + n] += o[r], ++r;
14
+ o[s + n] += o[s], ++s;
15
15
  a -= n;
16
16
  }
17
- const s = o.slice();
17
+ const r = o.slice();
18
18
  for (let e = 0; e < i; ++e)
19
19
  for (let c = 0; c < t; ++c)
20
- o[t * e + c] = s[(t - c - 1) * i + e];
20
+ o[t * e + c] = r[(t - c - 1) * i + e];
21
21
  }
22
- function f(o, n, t, r, a, i) {
23
- if (!n || n === 1)
22
+ function f(o, n, t, s, a, i) {
23
+ if (n === 1)
24
24
  return o;
25
25
  for (let c = 0; c < a.length; ++c) {
26
26
  if (a[c] % 8 !== 0)
@@ -28,60 +28,59 @@ function f(o, n, t, r, a, i) {
28
28
  if (a[c] !== a[0])
29
29
  throw new Error("When decoding with predictor, all samples must have the same size.");
30
30
  }
31
- const s = a[0] / 8, e = i === 2 ? 1 : a.length;
32
- for (let c = 0; c < r && !(c * e * t * s >= o.byteLength); ++c) {
31
+ const r = a[0] / 8, e = i === 2 ? 1 : a.length;
32
+ for (let c = 0; c < s && !(c * e * t * r >= o.byteLength); ++c) {
33
33
  let h;
34
34
  if (n === 2) {
35
35
  switch (a[0]) {
36
36
  case 8:
37
37
  h = new Uint8Array(
38
38
  o,
39
- c * e * t * s,
40
- e * t * s
39
+ c * e * t * r,
40
+ e * t * r
41
41
  );
42
42
  break;
43
43
  case 16:
44
44
  h = new Uint16Array(
45
45
  o,
46
- c * e * t * s,
47
- e * t * s / 2
46
+ c * e * t * r,
47
+ e * t * r / 2
48
48
  );
49
49
  break;
50
50
  case 32:
51
51
  h = new Uint32Array(
52
52
  o,
53
- c * e * t * s,
54
- e * t * s / 4
53
+ c * e * t * r,
54
+ e * t * r / 4
55
55
  );
56
56
  break;
57
57
  default:
58
58
  throw new Error(`Predictor 2 not allowed with ${a[0]} bits per sample.`);
59
59
  }
60
60
  l(h, e);
61
- } else
62
- n === 3 && (h = new Uint8Array(
63
- o,
64
- c * e * t * s,
65
- e * t * s
66
- ), d(h, e, s));
61
+ } else n === 3 && (h = new Uint8Array(
62
+ o,
63
+ c * e * t * r,
64
+ e * t * r
65
+ ), d(h, e, r));
67
66
  }
68
67
  return o;
69
68
  }
70
69
  class g {
71
70
  async decode(n, t) {
72
- const r = await this.decodeBlock(t), a = n.Predictor || 1;
71
+ const s = await this.decodeBlock(t), a = n.Predictor || 1;
73
72
  if (a !== 1) {
74
- const i = !n.StripOffsets, s = i ? n.TileWidth : n.ImageWidth, e = i ? n.TileLength : n.RowsPerStrip || n.ImageLength;
73
+ const i = !n.StripOffsets, r = i ? n.TileWidth : n.ImageWidth, e = i ? n.TileLength : n.RowsPerStrip || n.ImageLength;
75
74
  return f(
76
- r,
77
- a,
78
75
  s,
76
+ a,
77
+ r,
79
78
  e,
80
79
  n.BitsPerSample,
81
80
  n.PlanarConfiguration
82
81
  );
83
82
  }
84
- return r;
83
+ return s;
85
84
  }
86
85
  }
87
86
  export {
@@ -0,0 +1,10 @@
1
+ import * as THREE from "three";
2
+ /** The same model-space -> Viewer transform used by the existing FBX scene. */
3
+ export declare function applyBrainOutlineTransform(object: THREE.Object3D, options?: {
4
+ scale?: number;
5
+ offsetScale?: number;
6
+ translateX?: number;
7
+ translateY?: number;
8
+ translateZ?: number;
9
+ offsetZ?: number;
10
+ }): THREE.Object3D<THREE.Object3DEventMap>;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import type { SequenceLivePose, SequenceVolumeGeometry } from "./stamPlane";
3
+ import type { SequenceDisplayMode, SequenceSlice, SequenceTransform, SequenceTransformMode } from "./types";
4
+ import "./index.css";
5
+ interface Props {
6
+ onShowSlice?: (slice: SequenceSlice, mode: SequenceDisplayMode) => void | Promise<void>;
7
+ onHideSlice?: (sliceId: string) => void;
8
+ onSectionChange?: (slice: SequenceSlice, section: 0 | 1 | 2) => Promise<void>;
9
+ onTransformModeChange?: (mode: SequenceTransformMode) => void;
10
+ onSaveTransform?: (slice: SequenceSlice, transform: SequenceTransform) => Promise<number>;
11
+ onRegisterTransformSaver?: (saver: (sliceId: string, transform: SequenceTransform) => Promise<number>) => void;
12
+ onRegisterLivePoseListener?: (listener: ((sliceId: string, pose: SequenceLivePose, committed: boolean) => void) | null) => void;
13
+ onSequenceVolumeGeometry?: (geometry: SequenceVolumeGeometry | null) => void;
14
+ onGetExportPose?: (slice: SequenceSlice, size: {
15
+ width: number;
16
+ height: number;
17
+ }) => SequenceLivePose | null;
18
+ onGetLivePose?: (sliceId: string) => SequenceLivePose | null;
19
+ }
20
+ declare const SequenceRegistrationPanel: React.FC<Props>;
21
+ export default SequenceRegistrationPanel;
@@ -0,0 +1,23 @@
1
+ import type { SequenceSession, SequenceSlice, SequenceTransform } from "./types";
2
+ export declare function configureSequenceConnection(token: unknown, loginId: unknown): boolean;
3
+ export declare function clearSequenceConnection(): void;
4
+ export declare function sequenceAuthToken(): string;
5
+ export declare function sequenceRequest<T>(path: string, init?: RequestInit): Promise<T>;
6
+ export declare function sequenceImageBlob(url: string): Promise<Blob>;
7
+ export declare function sequenceTiffPreviewBlob(url: string): Promise<Blob>;
8
+ export declare const listSequenceSessions: () => Promise<SequenceSession[]>;
9
+ export declare const getSequenceSession: (id: string) => Promise<SequenceSession & {
10
+ slices: SequenceSlice[];
11
+ }>;
12
+ export declare function createSequenceSession(input: Pick<SequenceSession, "name" | "startFrame" | "spacingMode" | "defaultSpacingUm">): Promise<SequenceSession>;
13
+ export declare function updateSequenceSession(sessionId: string, input: Partial<Pick<SequenceSession, "name" | "startFrame" | "spacingMode" | "defaultSpacingUm">>): Promise<SequenceSession>;
14
+ export declare function uploadSequenceSlice(sessionId: string, file: File, idempotencyKey: string): Promise<SequenceSlice>;
15
+ export declare function updateSequenceSlice(sessionId: string, slice: SequenceSlice, patch: Partial<Pick<SequenceSlice, "targetFrame" | "sec" | "positionOffsetUm">>): Promise<SequenceSlice>;
16
+ export declare function reorderSequenceSlices(sessionId: string, sliceIds: string[]): Promise<{
17
+ ok: boolean;
18
+ }>;
19
+ export declare function saveSequenceTransform(sessionId: string, sliceId: string, revision: number, transform: SequenceTransform): Promise<{
20
+ revision: number;
21
+ transform: SequenceTransform;
22
+ }>;
23
+ export declare function deleteSequenceSlice(sessionId: string, sliceId: string): Promise<void>;
@@ -0,0 +1,64 @@
1
+ /** Coordinate conversions shared with the existing Atlas Reslicing routes. */
2
+ export type AtlasReferencePositionMm = readonly [x: number, y: number, z: number];
3
+ export type AtlasReferenceVoxelXYZ = [x: number, y: number, z: number];
4
+ export interface TargetTifGeometry {
5
+ available: boolean;
6
+ reason?: string;
7
+ atlas_id?: string;
8
+ geometry_revision?: string;
9
+ shape_zyx?: [number, number, number];
10
+ target_volume?: {
11
+ dataset_id?: string;
12
+ dataset_version?: string;
13
+ shape_zyx?: [number, number, number];
14
+ pixel_size_x_um?: number | null;
15
+ pixel_size_y_um?: number | null;
16
+ pixel_size_z_um?: number | null;
17
+ };
18
+ axis_order?: "xyz";
19
+ frame_axis?: "cor";
20
+ coordinate_unit?: "um";
21
+ physical_to_voxel_um?: number[][];
22
+ }
23
+ export type TargetTifFrameMapping = {
24
+ available: false;
25
+ reason: string;
26
+ } | {
27
+ available: true;
28
+ datasetId: string;
29
+ datasetRevision: string;
30
+ mappingId: string;
31
+ frameAxis: "cor";
32
+ voxelXYZ: [number, number, number];
33
+ continuousFrameIndex: number;
34
+ frameIndex: number;
35
+ systemFrame: number;
36
+ frameCount: number;
37
+ mappingType?: "physical-affine" | "reference-resolution-scale";
38
+ referenceResolutionUm?: number;
39
+ targetResolutionUm?: number;
40
+ shapeZYX?: [number, number, number];
41
+ };
42
+ /** Existing standard coronal reference page number (`inp`, 1-based). */
43
+ export declare function coronalReferenceInput(positionZMm: number): number | null;
44
+ /**
45
+ * Position in the legacy higher-resolution reference image coordinate
46
+ * system. These values are voxel-like reference coordinates, not physical
47
+ * micrometers; they must never be fed directly into a physical affine.
48
+ */
49
+ export declare function atlasReferenceVoxelCoordinates(positionMm: AtlasReferencePositionMm): AtlasReferenceVoxelXYZ | null;
50
+ /** JavaScript parseInt(number.toString()) behavior used by the legacy URL. */
51
+ export declare function truncateAtlasReferencePosition(position: AtlasReferenceVoxelXYZ): AtlasReferenceVoxelXYZ;
52
+ /**
53
+ * Map the 1 µm Atlas Reslicing reference grid to the matching 10 µm
54
+ * annotation volume. This mapping is only valid for the full atlas volume
55
+ * dimensions; cropped or differently sampled TIFFs need a physical affine.
56
+ */
57
+ export declare function mapAtlasReferencePositionTo10umTif(referenceVoxelXYZ: readonly [number, number, number] | null | undefined, geometry: TargetTifGeometry | null | undefined, sourceAtlasId: string | null | undefined): TargetTifFrameMapping;
58
+ /**
59
+ * Map a canonical STAM physical center (µm) to a target TIFF only when both
60
+ * Atlas ID and geometry revision agree. Legacy reference-image coordinates
61
+ * are intentionally not accepted here because their physical calibration is
62
+ * not established by the old URL formula.
63
+ */
64
+ export declare function mapAtlasPhysicalPoseToTifFrame(physicalXYZUm: readonly [number, number, number] | null | undefined, geometry: TargetTifGeometry | null | undefined, sourceAtlasId: string | null | undefined, sourceGeometryRevision: string | null | undefined): TargetTifFrameMapping;
@@ -0,0 +1,6 @@
1
+ import * as THREE from "three";
2
+ export interface BrainShellClampResult {
3
+ point: THREE.Vector3;
4
+ constrained: boolean;
5
+ }
6
+ export declare const clampPointToBrainShell: (root: THREE.Object3D, candidate: THREE.Vector3, previousLegalPoint?: THREE.Vector3 | null) => BrainShellClampResult;
@@ -0,0 +1,8 @@
1
+ /** Storybook's manager owns the opener; its preview iframe uses a narrow bridge. */
2
+ export declare function sequenceLaunchParams(win?: Window): URLSearchParams;
3
+ export declare function sequenceConnection(win?: Window): {
4
+ handoffId: string;
5
+ returnOrigin: string;
6
+ peer: Window;
7
+ transportOrigin: string;
8
+ } | null;
@@ -0,0 +1,4 @@
1
+ import type { SequenceLivePose } from "./stamPlane";
2
+ import type { SequenceRegistrationExportV3, SequenceSlice } from "./types";
3
+ export declare function createSequenceExportResult(slice: SequenceSlice, pose: SequenceLivePose, exportId: string): SequenceRegistrationExportV3;
4
+ export declare function mapSequenceExports<T, R>(items: T[], operation: (item: T, index: number) => Promise<R>): Promise<R[]>;
@@ -0,0 +1,11 @@
1
+ export interface SequenceRegistrationAckExpectation {
2
+ exportId: string;
3
+ sliceId: string;
4
+ }
5
+ export declare function isMatchingSequenceRegistrationAck(data: unknown, expected: SequenceRegistrationAckExpectation, handoffId: string): data is {
6
+ type: "stam.sequence-registration.ack";
7
+ handoffId: string;
8
+ exportId: string;
9
+ sliceId: string;
10
+ accepted: boolean;
11
+ };
@@ -0,0 +1,26 @@
1
+ export { sequenceSectionFromAngles } from "./stamPlane";
2
+ import type { SequencePoseGeometry } from "./types";
3
+ type Options = {
4
+ geometry: SequencePoseGeometry;
5
+ shape: number[];
6
+ center: number[];
7
+ angles: number[];
8
+ imageUrl?: string;
9
+ outlineUrl?: string;
10
+ onOutlineStatus?: (status: string) => void;
11
+ onChange: (center: number[], angles: number[]) => void;
12
+ onCommit?: (center: number[], angles: number[]) => void;
13
+ };
14
+ /** Standalone build of the Viewer controls; no auth or annotation state. */
15
+ export declare function mountPoseEditor(host: HTMLElement, options: Options): {
16
+ setPose: (center: number[], angles: number[]) => void;
17
+ setSection: (section: 0 | 1 | 2) => void;
18
+ setSliceImage: (url?: string, definition?: {
19
+ centerVoxelXYZ: number[];
20
+ uExtentVoxelXYZ: number[];
21
+ vExtentVoxelXYZ: number[];
22
+ }) => void;
23
+ fit: () => void;
24
+ setMode: (mode: "translate" | "rotate") => void;
25
+ dispose: () => void;
26
+ };
@@ -0,0 +1,99 @@
1
+ import * as THREE from "three";
2
+ import type { SequenceSlice, StamPlane } from "./types";
3
+ import type { TargetTifFrameMapping, TargetTifGeometry } from "./atlasReslicingReference";
4
+ export interface SequenceSlicePose {
5
+ centerMm: [number, number, number];
6
+ orientation: THREE.Quaternion;
7
+ }
8
+ export declare function standardSequenceQuaternion(section: 0 | 1 | 2): THREE.Quaternion;
9
+ export declare function sequenceSectionFromAngles(angles?: number[]): -1 | 0 | 1 | 2;
10
+ export interface AtlasReslicingPose extends SequenceSlicePose {
11
+ angles: [number, number, number];
12
+ }
13
+ export interface SequencePhysicalPose {
14
+ centerUm: [number, number, number];
15
+ uAxis: [number, number, number];
16
+ vAxis: [number, number, number];
17
+ normal: [number, number, number];
18
+ }
19
+ export interface SequenceVolumeGeometry extends TargetTifGeometry {
20
+ }
21
+ type DefaultSequencePlacement = Pick<SequenceSlice, "targetFrame" | "sequenceOrder" | "positionOffsetUm">;
22
+ export interface SequenceLivePose {
23
+ annotationTarget?: {
24
+ datasetId: string;
25
+ datasetVersion: string;
26
+ };
27
+ poseGeometry?: import("./types").SequencePoseGeometry;
28
+ centerMm: [number, number, number];
29
+ /** Scene-local XYZ Euler degrees used by the original high-resolution jump. */
30
+ angles: [number, number, number];
31
+ referenceVoxelXYZ?: [number, number, number];
32
+ referenceVoxelXYZRaw?: [number, number, number];
33
+ referenceInp?: number;
34
+ targetTif?: Extract<TargetTifFrameMapping, {
35
+ available: true;
36
+ }>;
37
+ physicalXYZUm?: [number, number, number];
38
+ uAxis?: [number, number, number];
39
+ vAxis?: [number, number, number];
40
+ normal?: [number, number, number];
41
+ voxelXYZ?: [number, number, number];
42
+ frameAxis?: "cor";
43
+ systemFrame?: number;
44
+ frameIndex?: number;
45
+ tifFrameCount?: number;
46
+ frameCalculationReason?: string;
47
+ atlasId?: string;
48
+ atlasGeometryRevision?: string;
49
+ poseRevision?: string;
50
+ poseSaved?: boolean;
51
+ obliquePlane?: {
52
+ schemaVersion: 1;
53
+ coordinateSpace: "target-tif-voxel-xyz";
54
+ datasetId: string;
55
+ datasetRevision: string;
56
+ mappingId: string;
57
+ centerVoxelXYZ: [number, number, number];
58
+ uExtentVoxelXYZ: [number, number, number];
59
+ vExtentVoxelXYZ: [number, number, number];
60
+ widthPx: number;
61
+ heightPx: number;
62
+ };
63
+ }
64
+ export interface StamGeometryMetadata {
65
+ atlasId: string;
66
+ atlasGeometryRevision: string;
67
+ sliceCoordinateToPhysicalUm: number[];
68
+ }
69
+ export declare function applyStamGeometryMetadata(brain: THREE.Object3D, value: unknown): boolean;
70
+ /**
71
+ * Derive the default coronal plane position from the sequence's one-based
72
+ * target frame and physical spacing. The known 10 µm reference mapping uses
73
+ * the same [-7, +7] mm Z range as Atlas Reslicing; other volumes use their
74
+ * declared physical affine and the Viewer-to-STAM geometry manifest.
75
+ */
76
+ export declare function getDefaultSequencePlaneCenter(placement: DefaultSequencePlacement, brain: THREE.Object3D, geometry: SequenceVolumeGeometry | null | undefined, fallbackCenter: THREE.Vector3): THREE.Vector3 | null;
77
+ export declare function getSequenceSlicePose(mesh: THREE.Mesh, brain: THREE.Object3D): SequenceSlicePose | null;
78
+ /**
79
+ * Convert a viewer plane to the pose convention used by the slicing API:
80
+ * center in the slicing coordinate frame and XYZ Euler angles after the same
81
+ * +90 degree X correction used by `/c-api/slicing`.
82
+ */
83
+ export declare function getAtlasReslicingPose(mesh: THREE.Mesh, brain: THREE.Object3D): AtlasReslicingPose | null;
84
+ export declare function getSequenceSlicePhysicalPose(mesh: THREE.Mesh, brain: THREE.Object3D): SequencePhysicalPose | null;
85
+ export declare function getSequenceLivePose(mesh: THREE.Mesh, brain: THREE.Object3D): SequenceLivePose | null;
86
+ /** Export the same geometry used above, rather than making the annotation UI
87
+ * guess the Atlas Euler baseline, scene scale or the TIFF's voxel spacing. */
88
+ export declare function getSequencePoseEditGeometry(mesh: THREE.Mesh, brain: THREE.Object3D, pose: SequenceLivePose): {
89
+ outlineModelMatrix: THREE.Matrix4Tuple;
90
+ schemaVersion: 1;
91
+ voxelFromAtlasLinear: number[][];
92
+ voxelFromViewerAffine: number[][];
93
+ planeAxes: [[number, number, number], [number, number, number]];
94
+ planeSize: [number, number];
95
+ } | undefined;
96
+ export declare function buildStamPlane(mesh: THREE.Mesh, brain: THREE.Object3D): StamPlane | null;
97
+ export declare function hasCurrentStamPlane(plane: StamPlane | undefined, brain: THREE.Object3D): boolean;
98
+ export declare function quaternionFromStamPlane(plane: StamPlane): THREE.Quaternion;
99
+ export {};
@@ -0,0 +1,4 @@
1
+ import * as THREE from "three";
2
+ import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
3
+ /** Shared by the full Viewer and the annotation pose dialog. */
4
+ export declare function createSequenceTransformControls(camera: THREE.Camera, element: HTMLElement, plane: THREE.Object3D, mode: "translate" | "rotate"): TransformControls;