From f54e6b472b7abb629704a7a1a623af5d47aff3bd Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Tue, 13 Feb 2024 07:36:28 -0800 Subject: [PATCH 01/11] add descriptions for tags if they are present --- src/ui/segment_list.ts | 69 +++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/src/ui/segment_list.ts b/src/ui/segment_list.ts index 2d18e5f22..46f065d13 100644 --- a/src/ui/segment_list.ts +++ b/src/ui/segment_list.ts @@ -98,8 +98,7 @@ const tempUint64 = new Uint64(); abstract class SegmentListSource extends RefCounted - implements VirtualListSource -{ + implements VirtualListSource { length: number; changed = new Signal<(splices: readonly Readonly[]) => void>(); @@ -274,10 +273,10 @@ class SegmentQueryListSource extends SegmentListSource { this.selectedMatches = queryResult.count > 0 ? findQueryResultIntersectionSize( - segmentPropertyMap, - queryResult, - selectedSegments, - ) + segmentPropertyMap, + queryResult, + selectedSegments, + ) : 0; } @@ -285,10 +284,10 @@ class SegmentQueryListSource extends SegmentListSource { this.visibleMatches = queryResult.count > 0 ? findQueryResultIntersectionSize( - segmentPropertyMap, - queryResult, - visibleSegments, - ) + segmentPropertyMap, + queryResult, + visibleSegments, + ) : 0; } @@ -475,9 +474,8 @@ function updateColumnSortIcon( const order = sortBy?.find((s) => s.fieldId === id)?.order; sortIcon.textContent = order === ">" ? "▼" : "▲"; sortIcon.style.visibility = order === undefined ? "" : "visible"; - sortIcon.title = `Sort by ${id} in ${ - order === "<" ? "descending" : "ascending" - } order`; + sortIcon.title = `Sort by ${id} in ${order === "<" ? "descending" : "ascending" + } order`; } class NumericalPropertiesSummary extends RefCounted { @@ -511,9 +509,8 @@ class NumericalPropertiesSummary extends RefCounted { if (properties !== undefined && properties.length > 0) { listElement = document.createElement("details"); const summaryElement = document.createElement("summary"); - summaryElement.textContent = `${properties.length} numerical propert${ - properties.length > 1 ? "ies" : "y" - }`; + summaryElement.textContent = `${properties.length} numerical propert${properties.length > 1 ? "ies" : "y" + }`; listElement.appendChild(summaryElement); listElement.classList.add( "neuroglancer-segment-query-result-numerical-list", @@ -731,7 +728,7 @@ class NumericalPropertiesSummary extends RefCounted { updateInputBoundValue( e, this.bounds[boundType].value[propertyIndex][ - endpointIndex + endpointIndex ] as number, ); }); @@ -924,7 +921,7 @@ class NumericalPropertiesSummary extends RefCounted { computeInvlerp(propertyHistogram.window, constraintBounds[0]), ), ) * - (numBins - 2), + (numBins - 2), ); const constraintEndBin = Math.ceil( Math.max( @@ -934,7 +931,7 @@ class NumericalPropertiesSummary extends RefCounted { computeInvlerp(propertyHistogram.window, constraintBounds[1]), ), ) * - (numBins - 2), + (numBins - 2), ); const polyLine = makeCdfLine( constraintStartBin, @@ -990,12 +987,19 @@ function renderTagSummary( const filterQuery = queryResult.query as FilterQuery; const tagList = document.createElement("div"); tagList.classList.add("neuroglancer-segment-query-result-tag-list"); - for (const { tag, count } of tags) { + for (const { tag, count, desc } of tags) { const tagElement = document.createElement("div"); tagElement.classList.add("neuroglancer-segment-query-result-tag"); const tagName = document.createElement("span"); tagName.classList.add("neuroglancer-segment-query-result-tag-name"); - tagName.textContent = tag; + // if the tag is different than desc, show both + if (tag !== desc && desc !== undefined && desc !== "") { + tagName.textContent = tag + " (" + desc + ")"; + } + else { + tagName.textContent = tag; + } + tagList.appendChild(tagElement); const included = filterQuery.includeTags.includes(tag); const excluded = filterQuery.excludeTags.includes(tag); @@ -1026,8 +1030,7 @@ function renderTagSummary( "neuroglancer-segment-query-result-tag-toggle", ); includeElement.classList.add( - `neuroglancer-segment-query-result-tag-${ - include ? "include" : "exclude" + `neuroglancer-segment-query-result-tag-${include ? "include" : "exclude" }`, ); tagElement.appendChild(includeElement); @@ -1054,9 +1057,8 @@ function renderTagSummary( { text: include ? "+" : "-", enableTitle: `Add tag to ${include ? "required" : "exclusion"} set`, - disableTitle: `Remove tag from ${ - include ? "required" : "exclusion" - } set`, + disableTitle: `Remove tag from ${include ? "required" : "exclusion" + } set`, backgroundScheme: "dark", }, ).element, @@ -1247,12 +1249,10 @@ abstract class SegmentListGroupBase extends RefCounted { visibleSelectedCount > 0 && visibleSelectedCount !== totalDisplayed, ); selectionStatusMessage.textContent = statusMessage; - copyAllSegmentsButton.title = `Copy all ${totalDisplayed} ${ - numMatches ? "matching" : "starred" - } segment(s)`; - copyVisibleSegmentsButton.title = `Copy ${visibleDisplayedCount} ${ - numMatches ? "visible matching" : "visible" - } segment(s)`; + copyAllSegmentsButton.title = `Copy all ${totalDisplayed} ${numMatches ? "matching" : "starred" + } segment(s)`; + copyVisibleSegmentsButton.title = `Copy ${visibleDisplayedCount} ${numMatches ? "visible matching" : "visible" + } segment(s)`; copyAllSegmentsButton.style.visibility = totalDisplayed ? "visible" : "hidden"; @@ -1276,9 +1276,8 @@ abstract class SegmentListGroupBase extends RefCounted { ); let visibleToggleTitle: string; if (!allVisible) { - visibleToggleTitle = `Click to show ${ - totalDisplayed - visibleDisplayedCount - } segment ID(s).`; + visibleToggleTitle = `Click to show ${totalDisplayed - visibleDisplayedCount + } segment ID(s).`; } else { visibleToggleTitle = `Click to hide ${totalDisplayed} segment ID(s).`; } From 50c255705940c2b3f85038480df142b7a3ee25cd Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Tue, 13 Feb 2024 07:38:59 -0800 Subject: [PATCH 02/11] add tag description and searching --- .../property_map.ts | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index acb5131ca..6979a0bd0 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -806,6 +806,7 @@ export interface TagCount { tag: string; tagIndex: number; count: number; + desc: string; } export interface PropertyHistogram { @@ -860,7 +861,10 @@ export function executeSegmentQuery( } const properties = inlineProperties?.properties; const totalIds = inlineProperties.ids.length / 2; + const totalTags = db?.tags?.tags?.length || 0; let indices = makeIndicesArray(totalIds, totalIds); + let showTags = makeIndicesArray(totalTags, totalTags); + showTags.fill(1); for (let i = 0; i < totalIds; ++i) { indices[i] = i; } @@ -877,6 +881,23 @@ export function executeSegmentQuery( } indices = indices.subarray(0, outIndex); }; + const filterByTagDescriptions = (regexp: RegExp) => { + const tagDescriptions = db!.tags!.tagDescriptions!; + const tags = db!.tags!.tags!; + const matchingTagDescriptions = tagDescriptions + .map((desc, index) => ({ desc, index })) + .filter(({ desc }) => desc.match(regexp) !== null) + .map(({ index }) => index); + const matchingTags = tags + .map((tag, index) => ({ tag, index })) + .filter(({ tag }) => tag.match(regexp) !== null) + .map(({ index }) => index); + + // set showTags based on matchingTags + showTags.fill(0); + matchingTagDescriptions.forEach((index) => (showTags[index] = 1)); + matchingTags.forEach((index) => (showTags[index] = 1)); + }; // Filter by label if (query.regexp !== undefined || query.prefix !== undefined) { @@ -885,11 +906,25 @@ export function executeSegmentQuery( if (regexp !== undefined) { filterIndices((index) => values[index].match(regexp) !== null); } + // if the regular expression returns nothing + // then assume the user wants to search through the tags + // and/or tag descriptions + if (indices.length == 0 && regexp !== undefined) { + indices = makeIndicesArray(totalIds, totalIds); + for (let i = 0; i < totalIds; ++i) { + indices[i] = i; + } + filterByTagDescriptions(regexp); + // reset regexp to none so that it doesn't get applied again + query.regexp = undefined; + } if (prefix !== undefined) { + console.log("prefix", prefix); filterIndices((index) => values[index].startsWith(prefix)); } } + // Filter by tags const { includeTags, excludeTags } = query; const tagsProperty = db!.tags; @@ -924,7 +959,6 @@ export function executeSegmentQuery( const regexp = new RegExp(pattern); filterIndices((index) => values[index].match(regexp) !== null); } - let intermediateIndicesMask: IndicesArray | undefined; let intermediateIndices: IndicesArray | undefined; @@ -970,7 +1004,7 @@ export function executeSegmentQuery( let tagStatistics: TagCount[] = []; if (tagsProperty !== undefined) { const tagStatisticsInQuery: TagCount[] = []; - const { tags, values } = tagsProperty; + const { tags, values, tagDescriptions } = tagsProperty; const tagCounts = new Uint32Array(tags.length); for (let i = 0, n = indices.length; i < n; ++i) { const value = values[indices[i]]; @@ -983,9 +1017,11 @@ export function executeSegmentQuery( tagIndex < numTags; ++tagIndex ) { + if (showTags[tagIndex] === 0) continue; const count = tagCounts[tagIndex]; const tag = tags[tagIndex]; - const tagCount = { tag, tagIndex, count: tagCounts[tagIndex] }; + const tagDesc = tagDescriptions[tagIndex]; + const tagCount = { tag, tagIndex, count: tagCounts[tagIndex], desc: tagDesc }; if (query.includeTags.includes(tag) || query.excludeTags.includes(tag)) { tagStatisticsInQuery.push(tagCount); } else if (count > 0) { @@ -1079,7 +1115,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1097,7 +1133,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From 4cd8ebe2375edd0cb1a84fbcb0e6b271559c5880 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Wed, 21 Feb 2024 16:49:47 -0800 Subject: [PATCH 03/11] fix formatting --- .../property_map.ts | 12 ++-- src/ui/segment_list.ts | 61 +++++++++++-------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index 6979a0bd0..a3e070abb 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -924,7 +924,6 @@ export function executeSegmentQuery( } } - // Filter by tags const { includeTags, excludeTags } = query; const tagsProperty = db!.tags; @@ -1021,7 +1020,12 @@ export function executeSegmentQuery( const count = tagCounts[tagIndex]; const tag = tags[tagIndex]; const tagDesc = tagDescriptions[tagIndex]; - const tagCount = { tag, tagIndex, count: tagCounts[tagIndex], desc: tagDesc }; + const tagCount = { + tag, + tagIndex, + count: tagCounts[tagIndex], + desc: tagDesc, + }; if (query.includeTags.includes(tag) || query.excludeTags.includes(tag)) { tagStatisticsInQuery.push(tagCount); } else if (count > 0) { @@ -1115,7 +1119,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1133,7 +1137,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } diff --git a/src/ui/segment_list.ts b/src/ui/segment_list.ts index 46f065d13..ccadae84a 100644 --- a/src/ui/segment_list.ts +++ b/src/ui/segment_list.ts @@ -98,7 +98,8 @@ const tempUint64 = new Uint64(); abstract class SegmentListSource extends RefCounted - implements VirtualListSource { + implements VirtualListSource +{ length: number; changed = new Signal<(splices: readonly Readonly[]) => void>(); @@ -273,10 +274,10 @@ class SegmentQueryListSource extends SegmentListSource { this.selectedMatches = queryResult.count > 0 ? findQueryResultIntersectionSize( - segmentPropertyMap, - queryResult, - selectedSegments, - ) + segmentPropertyMap, + queryResult, + selectedSegments, + ) : 0; } @@ -284,10 +285,10 @@ class SegmentQueryListSource extends SegmentListSource { this.visibleMatches = queryResult.count > 0 ? findQueryResultIntersectionSize( - segmentPropertyMap, - queryResult, - visibleSegments, - ) + segmentPropertyMap, + queryResult, + visibleSegments, + ) : 0; } @@ -474,8 +475,9 @@ function updateColumnSortIcon( const order = sortBy?.find((s) => s.fieldId === id)?.order; sortIcon.textContent = order === ">" ? "▼" : "▲"; sortIcon.style.visibility = order === undefined ? "" : "visible"; - sortIcon.title = `Sort by ${id} in ${order === "<" ? "descending" : "ascending" - } order`; + sortIcon.title = `Sort by ${id} in ${ + order === "<" ? "descending" : "ascending" + } order`; } class NumericalPropertiesSummary extends RefCounted { @@ -509,8 +511,9 @@ class NumericalPropertiesSummary extends RefCounted { if (properties !== undefined && properties.length > 0) { listElement = document.createElement("details"); const summaryElement = document.createElement("summary"); - summaryElement.textContent = `${properties.length} numerical propert${properties.length > 1 ? "ies" : "y" - }`; + summaryElement.textContent = `${properties.length} numerical propert${ + properties.length > 1 ? "ies" : "y" + }`; listElement.appendChild(summaryElement); listElement.classList.add( "neuroglancer-segment-query-result-numerical-list", @@ -728,7 +731,7 @@ class NumericalPropertiesSummary extends RefCounted { updateInputBoundValue( e, this.bounds[boundType].value[propertyIndex][ - endpointIndex + endpointIndex ] as number, ); }); @@ -921,7 +924,7 @@ class NumericalPropertiesSummary extends RefCounted { computeInvlerp(propertyHistogram.window, constraintBounds[0]), ), ) * - (numBins - 2), + (numBins - 2), ); const constraintEndBin = Math.ceil( Math.max( @@ -931,7 +934,7 @@ class NumericalPropertiesSummary extends RefCounted { computeInvlerp(propertyHistogram.window, constraintBounds[1]), ), ) * - (numBins - 2), + (numBins - 2), ); const polyLine = makeCdfLine( constraintStartBin, @@ -995,8 +998,7 @@ function renderTagSummary( // if the tag is different than desc, show both if (tag !== desc && desc !== undefined && desc !== "") { tagName.textContent = tag + " (" + desc + ")"; - } - else { + } else { tagName.textContent = tag; } @@ -1030,7 +1032,8 @@ function renderTagSummary( "neuroglancer-segment-query-result-tag-toggle", ); includeElement.classList.add( - `neuroglancer-segment-query-result-tag-${include ? "include" : "exclude" + `neuroglancer-segment-query-result-tag-${ + include ? "include" : "exclude" }`, ); tagElement.appendChild(includeElement); @@ -1057,8 +1060,9 @@ function renderTagSummary( { text: include ? "+" : "-", enableTitle: `Add tag to ${include ? "required" : "exclusion"} set`, - disableTitle: `Remove tag from ${include ? "required" : "exclusion" - } set`, + disableTitle: `Remove tag from ${ + include ? "required" : "exclusion" + } set`, backgroundScheme: "dark", }, ).element, @@ -1249,10 +1253,12 @@ abstract class SegmentListGroupBase extends RefCounted { visibleSelectedCount > 0 && visibleSelectedCount !== totalDisplayed, ); selectionStatusMessage.textContent = statusMessage; - copyAllSegmentsButton.title = `Copy all ${totalDisplayed} ${numMatches ? "matching" : "starred" - } segment(s)`; - copyVisibleSegmentsButton.title = `Copy ${visibleDisplayedCount} ${numMatches ? "visible matching" : "visible" - } segment(s)`; + copyAllSegmentsButton.title = `Copy all ${totalDisplayed} ${ + numMatches ? "matching" : "starred" + } segment(s)`; + copyVisibleSegmentsButton.title = `Copy ${visibleDisplayedCount} ${ + numMatches ? "visible matching" : "visible" + } segment(s)`; copyAllSegmentsButton.style.visibility = totalDisplayed ? "visible" : "hidden"; @@ -1276,8 +1282,9 @@ abstract class SegmentListGroupBase extends RefCounted { ); let visibleToggleTitle: string; if (!allVisible) { - visibleToggleTitle = `Click to show ${totalDisplayed - visibleDisplayedCount - } segment ID(s).`; + visibleToggleTitle = `Click to show ${ + totalDisplayed - visibleDisplayedCount + } segment ID(s).`; } else { visibleToggleTitle = `Click to hide ${totalDisplayed} segment ID(s).`; } From e77bd2cc27fa05cbb33d0d2732120b10d7a2ba9c Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Wed, 21 Feb 2024 16:55:17 -0800 Subject: [PATCH 04/11] fix const array --- src/segmentation_display_state/property_map.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index a3e070abb..8265f6bf3 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -863,7 +863,7 @@ export function executeSegmentQuery( const totalIds = inlineProperties.ids.length / 2; const totalTags = db?.tags?.tags?.length || 0; let indices = makeIndicesArray(totalIds, totalIds); - let showTags = makeIndicesArray(totalTags, totalTags); + const showTags = makeIndicesArray(totalTags, totalTags); showTags.fill(1); for (let i = 0; i < totalIds; ++i) { indices[i] = i; @@ -1119,7 +1119,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1137,7 +1137,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From ab8a98a2136f46432ef8576e6e8392aaecc18669 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Wed, 21 Feb 2024 16:58:28 -0800 Subject: [PATCH 05/11] fix formatting again --- src/segmentation_display_state/property_map.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index 8265f6bf3..36444e7e6 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -1119,7 +1119,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1137,7 +1137,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From 2e4dd7366a08e612f77b7995531dcb64d7b8e109 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Tue, 27 Feb 2024 11:59:37 -0800 Subject: [PATCH 06/11] allow tag searching with no labels --- .../property_map.ts | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index 36444e7e6..c62d3fb08 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -677,7 +677,7 @@ export function parseSegmentQuery( }); continue; } - if (labels === undefined) { + if (labels === undefined && tagNames.length == 0) { errors.push({ begin: startIndex, end: endIndex, @@ -778,7 +778,7 @@ export function parseSegmentQuery( }); continue; } - if (labels === undefined) { + if (labels === undefined && tagNames.length == 0) { errors.push({ begin: startIndex, end: endIndex, @@ -901,15 +901,24 @@ export function executeSegmentQuery( // Filter by label if (query.regexp !== undefined || query.prefix !== undefined) { - const values = db!.labels!.values; const { regexp, prefix } = query; - if (regexp !== undefined) { - filterIndices((index) => values[index].match(regexp) !== null); + if (db!.labels !== undefined) { + console.log('test') + const values = db!.labels!.values; + if (regexp !== undefined) { + filterIndices((index) => values[index].match(regexp) !== null); + } + if (prefix !== undefined) { + console.log("prefix", prefix); + filterIndices((index) => values[index].startsWith(prefix)); + } } + console.log(indices.length) // if the regular expression returns nothing - // then assume the user wants to search through the tags + // then assudme the user wants to search through the tags // and/or tag descriptions - if (indices.length == 0 && regexp !== undefined) { + if ((indices.length == 0 && regexp !== undefined) || (db!.labels == undefined && regexp != undefined)) { + console.log('test3') indices = makeIndicesArray(totalIds, totalIds); for (let i = 0; i < totalIds; ++i) { indices[i] = i; @@ -918,10 +927,6 @@ export function executeSegmentQuery( // reset regexp to none so that it doesn't get applied again query.regexp = undefined; } - if (prefix !== undefined) { - console.log("prefix", prefix); - filterIndices((index) => values[index].startsWith(prefix)); - } } // Filter by tags @@ -1119,7 +1124,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1137,7 +1142,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From 748a1d3c2d7158c38dc5f6e177a5c994540f3022 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Tue, 27 Feb 2024 12:08:36 -0800 Subject: [PATCH 07/11] formatting fix --- src/segmentation_display_state/property_map.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index c62d3fb08..0a16db0b3 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -903,7 +903,7 @@ export function executeSegmentQuery( if (query.regexp !== undefined || query.prefix !== undefined) { const { regexp, prefix } = query; if (db!.labels !== undefined) { - console.log('test') + console.log("test"); const values = db!.labels!.values; if (regexp !== undefined) { filterIndices((index) => values[index].match(regexp) !== null); @@ -913,12 +913,15 @@ export function executeSegmentQuery( filterIndices((index) => values[index].startsWith(prefix)); } } - console.log(indices.length) + console.log(indices.length); // if the regular expression returns nothing // then assudme the user wants to search through the tags // and/or tag descriptions - if ((indices.length == 0 && regexp !== undefined) || (db!.labels == undefined && regexp != undefined)) { - console.log('test3') + if ( + (indices.length == 0 && regexp !== undefined) || + (db!.labels == undefined && regexp != undefined) + ) { + console.log("test3"); indices = makeIndicesArray(totalIds, totalIds); for (let i = 0; i < totalIds; ++i) { indices[i] = i; @@ -1124,7 +1127,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1142,7 +1145,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From a4ba48defdf17ba03380f5fde8ee459a9411d8f8 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Wed, 28 Feb 2024 07:42:37 -0800 Subject: [PATCH 08/11] removing console.log messages --- src/segmentation_display_state/property_map.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index 0a16db0b3..09d6962dc 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -903,17 +903,14 @@ export function executeSegmentQuery( if (query.regexp !== undefined || query.prefix !== undefined) { const { regexp, prefix } = query; if (db!.labels !== undefined) { - console.log("test"); const values = db!.labels!.values; if (regexp !== undefined) { filterIndices((index) => values[index].match(regexp) !== null); } if (prefix !== undefined) { - console.log("prefix", prefix); filterIndices((index) => values[index].startsWith(prefix)); } } - console.log(indices.length); // if the regular expression returns nothing // then assudme the user wants to search through the tags // and/or tag descriptions @@ -921,7 +918,6 @@ export function executeSegmentQuery( (indices.length == 0 && regexp !== undefined) || (db!.labels == undefined && regexp != undefined) ) { - console.log("test3"); indices = makeIndicesArray(totalIds, totalIds); for (let i = 0; i < totalIds; ++i) { indices[i] = i; @@ -1127,7 +1123,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1145,7 +1141,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From 601df64844da34cf061df1a9c6de0d6720de860d Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Wed, 28 Feb 2024 17:09:27 -0800 Subject: [PATCH 09/11] format fix --- src/segmentation_display_state/property_map.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index 09d6962dc..ce7cdd21f 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -1123,7 +1123,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1141,7 +1141,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From 3d478af50034974ba24c57d3b5ef65f56086e650 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Sun, 10 Mar 2024 16:24:18 -0700 Subject: [PATCH 10/11] change to for loop implementation --- .../property_map.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index ce7cdd21f..fb5604857 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -884,19 +884,19 @@ export function executeSegmentQuery( const filterByTagDescriptions = (regexp: RegExp) => { const tagDescriptions = db!.tags!.tagDescriptions!; const tags = db!.tags!.tags!; - const matchingTagDescriptions = tagDescriptions - .map((desc, index) => ({ desc, index })) - .filter(({ desc }) => desc.match(regexp) !== null) - .map(({ index }) => index); - const matchingTags = tags - .map((tag, index) => ({ tag, index })) - .filter(({ tag }) => tag.match(regexp) !== null) - .map(({ index }) => index); - - // set showTags based on matchingTags + + // reset showTags showTags.fill(0); - matchingTagDescriptions.forEach((index) => (showTags[index] = 1)); - matchingTags.forEach((index) => (showTags[index] = 1)); + + // iterate over tagDescriptions with a for loop + for (let i = 0; i < tagDescriptions.length; i++) { + if (tagDescriptions[i].match(regexp) !== null) { + showTags[i] = 1; + } + if (tags[i].match(regexp) !== null) { + showTags[i] = 1; + } + } }; // Filter by label @@ -1123,7 +1123,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1141,7 +1141,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } From fa07cf7f91c7a2dfb7b0b8cb6a2c1bec1a3d029c Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Sun, 10 Mar 2024 16:26:00 -0700 Subject: [PATCH 11/11] format fix --- src/segmentation_display_state/property_map.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/segmentation_display_state/property_map.ts b/src/segmentation_display_state/property_map.ts index fb5604857..aa1c79853 100644 --- a/src/segmentation_display_state/property_map.ts +++ b/src/segmentation_display_state/property_map.ts @@ -1123,7 +1123,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } } @@ -1141,7 +1141,7 @@ function updatePropertyHistogram( ++histogram[ (Math.min(numBins - 1, Math.max(-1, (value - min) * multiplier)) + 1) >>> - 0 + 0 ]; } }