Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-explorer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiao Gui
siibra-explorer
Commits
0272b2a7
Commit
0272b2a7
authored
3 years ago
by
Xiao Gui
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: swc size
parent
8d1ad67e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/messaging/nmvSwc/index.spec.ts
+66
-0
66 additions, 0 deletions
src/messaging/nmvSwc/index.spec.ts
src/messaging/nmvSwc/index.ts
+55
-6
55 additions, 6 deletions
src/messaging/nmvSwc/index.ts
with
121 additions
and
6 deletions
src/messaging/nmvSwc/index.spec.ts
0 → 100644
+
66
−
0
View file @
0272b2a7
import
{
IAV_IDS
,
IAV_VOXEL_SIZES_NM
}
from
'
./index
'
const
waxholmTemplates
=
require
(
'
!json-loader!src/res/ext/waxholmRatV2_0.json
'
)
const
allenTemplates
=
require
(
'
!json-loader!src/res/ext/allenMouse.json
'
)
const
colinTemplates
=
require
(
'
!json-loader!src/res/ext/colin.json
'
)
const
mniTemplates
=
require
(
'
!json-loader!src/res/ext/MNI152.json
'
)
const
bbTemplates
=
require
(
'
!json-loader!src/res/ext/bigbrain.json
'
)
const
ratNehubaConfig
=
require
(
'
!json-loader!src/res/ext/waxholmRatV2_0NehubaConfig.json
'
)
const
mouseNehubaConfig
=
require
(
'
!json-loader!src/res/ext/allenMouseNehubaConfig.json
'
)
const
colinNehubaConfig
=
require
(
'
!json-loader!src/res/ext/colinNehubaConfig.json
'
)
const
icbmNehubaConfig
=
require
(
'
!json-loader!src/res/ext/MNI152NehubaConfig.json
'
)
const
bbNehubaConfig
=
require
(
'
!json-loader!src/res/ext/bigbrainNehubaConfig.json
'
)
const
tmplArr
=
[
waxholmTemplates
,
allenTemplates
,
colinTemplates
,
mniTemplates
,
bbTemplates
,
]
const
configArr
=
[
ratNehubaConfig
,
mouseNehubaConfig
,
colinNehubaConfig
,
icbmNehubaConfig
,
bbNehubaConfig
,
].
map
(
cfg
=>
{
return
{
layerNames
:
Object
.
keys
(
cfg
[
'
dataset
'
][
'
initialNgState
'
][
'
layers
'
]
),
voxelSize
:
cfg
[
'
dataset
'
][
'
initialNgState
'
][
'
navigation
'
][
'
pose
'
][
'
position
'
][
'
voxelSize
'
]
}
})
describe
(
'
> messaging/nmvSwc
'
,
()
=>
{
for
(
const
tmplKey
in
IAV_IDS
)
{
describe
(
`>
${
tmplKey
}
`
,
()
=>
{
let
tmpl
,
config
beforeAll
(()
=>
{
tmpl
=
tmplArr
.
find
(
t
=>
t
[
'
@id
'
]
===
IAV_IDS
[
tmplKey
])
config
=
tmpl
&&
configArr
.
find
(
cfg
=>
cfg
.
layerNames
.
includes
(
tmpl
[
'
ngId
'
])
)
})
it
(
'
> should be able to find tmpl by id
'
,
()
=>
{
expect
(
tmpl
).
toBeTruthy
()
})
it
(
'
> should be able to find the config
'
,
()
=>
{
expect
(
config
).
toBeTruthy
()
})
it
(
'
> voxelSize should match the hardcoded value
'
,
()
=>
{
expect
(
config
.
voxelSize
).
toEqual
(
IAV_VOXEL_SIZES_NM
[
tmplKey
])
})
})
}
})
This diff is collapsed.
Click to expand it.
src/messaging/nmvSwc/index.ts
+
55
−
6
View file @
0272b2a7
...
...
@@ -22,7 +22,7 @@ const NM_IDS = {
MNI152_2009C_ASYM
:
'
hbp:ICBM_Asym_r2009c(um)
'
,
}
const
IAV_IDS
=
{
export
const
IAV_IDS
=
{
AMBA_V3
:
'
minds/core/referencespace/v1.0.0/265d32a0-3d84-40a5-926f-bf89f68212b9
'
,
WAXHOLM_V1_01
:
'
minds/core/referencespace/v1.0.0/d5717c4a-0fa1-46e6-918c-b8003069ade8
'
,
BIG_BRAIN
:
'
minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588
'
,
...
...
@@ -30,6 +30,38 @@ const IAV_IDS = {
MNI152_2009C_ASYM
:
'
minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2
'
,
}
/**
* TODO, should unify navigation voxelSize
* the emitted voxelCoord should be calculated on the fly
*/
export
const
IAV_VOXEL_SIZES_NM
=
{
AMBA_V3
:
[
25000
,
25000
,
25000
],
WAXHOLM_V1_01
:
[
39062.5
,
39062.5
,
39062.5
],
BIG_BRAIN
:
[
21166.666015625
,
20000
,
21166.666015625
],
COLIN
:
[
1000000
,
1000000
,
1000000
,
],
MNI152_2009C_ASYM
:
[
1000000
,
1000000
,
1000000
]
}
const
translateSpace
=
(
spaceId
:
string
)
=>
{
for
(
const
key
in
NM_IDS
){
if
(
NM_IDS
[
key
]
===
spaceId
)
return
IAV_IDS
[
key
]
...
...
@@ -37,6 +69,13 @@ const translateSpace = (spaceId: string) => {
return
null
}
const
getVoxelFromSpace
=
(
spaceId
:
string
)
=>
{
for
(
const
key
in
NM_IDS
){
if
(
NM_IDS
[
key
]
===
spaceId
)
return
IAV_VOXEL_SIZES_NM
[
key
]
}
return
null
}
export
const
processJsonLd
=
(
json
:
{
[
key
:
string
]:
any
}):
Observable
<
IMessagingActions
<
keyof
IMessagingActionTmpl
>>
=>
{
const
subject
=
new
Subject
<
IMessagingActions
<
keyof
IMessagingActionTmpl
>>
()
const
main
=
(
async
()
=>
{
...
...
@@ -93,15 +132,25 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi
)
const
uuid
=
getUuid
()
// NG internal treats skeleton as mm
const
scaleUmToMm
=
1
e
-
3
// NG internal treats skeleton as mm
const
voxelSize
=
getVoxelFromSpace
(
toSpace
)
/**
* swc seem to scale with voxelSize... strangely enough
* voxelSize nm / voxel -> goal is 1 voxel/um
* 1e3 / voxelSize
*/
const
scaleUmToVoxelFixed
=
[
1
e3
/
voxelSize
[
0
],
1
e3
/
voxelSize
[
1
],
1
e3
/
voxelSize
[
2
],
]
// NG translation works on nm scale
const
scaleUmToNm
=
1
e3
const
{
mat3
,
vec3
}
=
(
window
as
any
).
export_nehuba
const
modA
=
mat3
.
fromValues
(
scaleUmTo
Mm
,
0
,
0
,
0
,
scaleUmTo
Mm
,
0
,
0
,
0
,
scaleUmTo
Mm
scaleUmTo
VoxelFixed
[
0
]
,
0
,
0
,
0
,
scaleUmTo
VoxelFixed
[
1
]
,
0
,
0
,
0
,
scaleUmTo
VoxelFixed
[
2
]
)
mat3
.
mul
(
modA
,
modA
,
[...
A
[
0
],
...
A
[
1
],
...
A
[
2
]])
const
modb
=
vec3
.
scale
(
vec3
.
create
(),
b
,
scaleUmToNm
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment