Skip to content

Commit 032f82d

Browse files
authored
Merge pull request #169 from akhuoa/feature/scaffold-connectivity-filters
Enable organs and nerves clickable for neuron connection mode
2 parents 25a588b + cadf5fb commit 032f82d

File tree

3 files changed

+72
-15
lines changed

3 files changed

+72
-15
lines changed

src/components/ScaffoldVuer.vue

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ import { SearchIndex } from "../scripts/Search.js";
460460
import { mapState, mapStores } from 'pinia';
461461
import { useMainStore } from "@/store/index";
462462
import { getNerveMaps } from "../scripts/MappedNerves.js";
463+
import { getOrganMaps } from '../scripts/MappedOrgans.js';
463464
const nervesMap = getNerveMaps();
465+
const organsMap = getOrganMaps();
464466
let totalNerves = 0, foundNerves = 0;
465467
466468
const haveSameElements = (arr1, arr2) => {
@@ -1063,7 +1065,7 @@ export default {
10631065
},
10641066
*/
10651067
/**
1066-
*
1068+
*
10671069
* @param nerves array of nerve names, show all nerves if empty
10681070
* @param processed boolean, whether unselect all checkboxes
10691071
*/
@@ -1119,6 +1121,10 @@ export default {
11191121
if (this.timeVarying === false && zincObject.isTimeVarying()) {
11201122
this.timeVarying = true;
11211123
}
1124+
const groupName = zincObject.groupName.toLowerCase();
1125+
if (groupName in organsMap) {
1126+
zincObject.setAnatomicalId(organsMap[groupName]);
1127+
}
11221128
//Temporary way to mark an object as nerves
11231129
const regions = this.isNerves?.regions;
11241130
if (regions) {
@@ -1128,17 +1134,14 @@ export default {
11281134
zincObject.userData.isNerves = true;
11291135
zincObject.userData.defaultColour = `#${zincObject.getColourHex()}`;
11301136
zincObject.userData.isGreyScale = false;
1131-
const groupName = zincObject.groupName.toLowerCase();
11321137
if (groupName in nervesMap) {
11331138
foundNerves++;
11341139
zincObject.setAnatomicalId(nervesMap[groupName]);
1135-
//console.log(groupName, zincObject.anatomicalId, zincObject.uuid)
11361140
}
11371141
} else {
11381142
zincObject.userData.isNerves = false;
11391143
}
11401144
}
1141-
11421145
}
11431146
/**
11441147
* Emit when a new object is added to the scene
@@ -1746,6 +1749,7 @@ export default {
17461749
this.$refs.scaffoldTreeControls.removeActive(false);
17471750
}
17481751
}
1752+
17491753
//Store the following for state saving. Search will handle the case with more than 1
17501754
//identifiers.
17511755
if (event.identifiers.length === 1) {
@@ -2195,7 +2199,7 @@ export default {
21952199
* Optional, can be used to update the view mode.
21962200
*/
21972201
changeViewingMode: function (modeName) {
2198-
let nonNervesIsPickable = true;
2202+
let objectIsPickable = true;
21992203
if (this.$module) {
22002204
if (modeName) {
22012205
this.viewingMode = modeName;
@@ -2220,7 +2224,8 @@ export default {
22202224
this.activeDrawMode = undefined;
22212225
this.createData.shape = "";
22222226
} else if (this.viewingMode === "Neuron Connection") {
2223-
nonNervesIsPickable = false;
2227+
// enable to make organs and nerves clickable and searchable for neuron connection mode
2228+
objectIsPickable = false;
22242229
}
22252230
if ((this.viewingMode === "Exploration") ||
22262231
(this.viewingMode === "Neuron Connection") ||
@@ -2232,7 +2237,7 @@ export default {
22322237
}
22332238
this.cancelCreate();
22342239
if (modeName) {
2235-
this.setNonNervesIsPickable(nonNervesIsPickable);
2240+
this.setObjectIsPickable(objectIsPickable);
22362241
}
22372242
}
22382243
},
@@ -2259,13 +2264,15 @@ export default {
22592264
this.tData.region = undefined;
22602265
},
22612266
/**
2262-
* Currently will only apply to non-nerve object
2267+
* Currently will apply to non-nerve object and object without anatomical id
22632268
* @param flag boolean to control whether objects pickable
22642269
*/
2265-
setNonNervesIsPickable: function (flag) {
2270+
setObjectIsPickable: function (flag) {
22662271
const objects = this.$module.scene.getRootRegion().getAllObjects(true);
22672272
objects.forEach((zincObject) => {
2268-
if (!zincObject.userData.isNerves) zincObject.setIsPickable(flag);
2273+
if (!zincObject.userData?.isNerves && !zincObject.anatomicalId) {
2274+
zincObject.setIsPickable(flag);
2275+
}
22692276
});
22702277
},
22712278
/**
@@ -2299,7 +2306,7 @@ export default {
22992306
*/
23002307
setColour: function (flag, forced = false) {
23012308
if (this.isReady && this.$module.scene &&
2302-
typeof flag === "boolean" &&
2309+
typeof flag === "boolean" &&
23032310
(forced || flag !== this.colourRadio)) {
23042311
this.loading = true;
23052312
//This can take sometime to finish , nextTick does not bring out
@@ -2310,7 +2317,7 @@ export default {
23102317
this.colourRadio = flag;
23112318
}, 100);
23122319
}
2313-
},
2320+
},
23142321
/**
23152322
* @public
23162323
* Function to toggle lines graphics.
@@ -2319,7 +2326,7 @@ export default {
23192326
*/
23202327
setOutlines: function (flag, forced = false) {
23212328
if (this.isReady && this.$module.scene &&
2322-
typeof flag === "boolean" &&
2329+
typeof flag === "boolean" &&
23232330
(forced || flag !== this.outlinesRadio)) {
23242331
this.outlinesRadio = flag;
23252332
this.$nextTick(() => this.$refs.scaffoldTreeControls.setOutlines(flag));
@@ -2495,7 +2502,7 @@ export default {
24952502
if (options.offlineAnnotations) {
24962503
sessionStorage.setItem('anonymous-annotation', options.offlineAnnotations);
24972504
}
2498-
if ("outlines" in options) {
2505+
if ("outlines" in options) {
24992506
this.setOutlines(options.outlines);
25002507
}
25012508
if (options.viewingMode) {

src/scripts/MappedOrgans.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const organsWithAnatomicalIds = [
2+
{
3+
"label": "urinary bladder",
4+
"anatomicalId": "UBERON:0001255",
5+
},
6+
{
7+
"label": "brainstem",
8+
"anatomicalId": "UBERON:0002298",
9+
},
10+
{
11+
"label": "caecum",
12+
"anatomicalId": "UBERON:0001153",
13+
},
14+
{
15+
"label": "colon",
16+
"anatomicalId": "UBERON:0001155",
17+
},
18+
{
19+
"label": "esophagus",
20+
"anatomicalId": "UBERON:0001043",
21+
},
22+
{
23+
"label": "small intestine",
24+
"anatomicalId": "UBERON:0002108",
25+
},
26+
{
27+
"label": "stomach",
28+
"anatomicalId": "UBERON:0000945",
29+
},
30+
{
31+
"label": "heart",
32+
"anatomicalId": "UBERON:0000948",
33+
},
34+
{
35+
"label": "lung",
36+
"anatomicalId": "UBERON:0002048",
37+
},
38+
];
39+
40+
const getOrganMaps = () => {
41+
const curatedMap = {};
42+
organsWithAnatomicalIds.forEach((item) => {
43+
const label = item.label.toLowerCase();
44+
if (!(label in curatedMap))
45+
curatedMap[label.toLowerCase()] = item["anatomicalId"];
46+
});
47+
return curatedMap;
48+
};
49+
50+
export { getOrganMaps };

src/scripts/OrgansRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ const OrgansSceneData = function() {
257257
*/
258258
const _pickingCallback = function() {
259259
return function(intersects, window_x, window_y) {
260-
if (ignorePicking) return;
261260
const intersected = _this.getIntersectedObject(intersects);
262261
const idObject = getIdObjectFromIntersect(intersected);
263262
const extraData = {
@@ -285,6 +284,7 @@ const OrgansSceneData = function() {
285284
}
286285
return;
287286
} else {
287+
if (ignorePicking) return;
288288
_this.setSelectedByObjects([], coords, extraData, true);
289289
}
290290
}

0 commit comments

Comments
 (0)