feat: make hanging protocol work on displaySets instead of series (#2837)

* feat(HP): Apply HP to display sets, fix race condition

* fix: displaySetService no event not needed (#2912)

* fix various styles and renamings

* feat: refactored hp service

* fix: use HP service event for viewport grid

* remove unnecessary doc

* fix test

* apply review comment

* fix: segmentation creation

Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
Bill WallaceandAlireza authored and GitHub committed 2022-09-07 11:59:11 -04:00
1 parent 7c0756824e
commit e1d366e1e1
26 files changed
+893 -979

No files matched your search

+21 -18
View File
@@ -41,9 +41,9 @@ const commandsModule = ({
}
function _getMatchedViewportsToolGroupIds() {
const [matchedViewports] = HangingProtocolService.getState();
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const toolGroupIds = [];
matchedViewports.forEach(({ viewportOptions }) => {
viewportMatchDetails.forEach(({ viewportOptions }) => {
const { toolGroupId } = viewportOptions;
if (toolGroupIds.indexOf(toolGroupId) === -1) {
toolGroupIds.push(toolGroupId);
@@ -54,33 +54,30 @@ const commandsModule = ({
}
const actions = {
getMatchingPTDisplaySet: () => {
getMatchingPTDisplaySet: ({ viewportMatchDetails }) => {
// Todo: this is assuming that the hanging protocol has successfully matched
// the correct PT. For future, we should have a way to filter out the PTs
// that are in the viewer layout (but then we have the problem of the attenuation
// corrected PT vs the non-attenuation correct PT)
const matches = HangingProtocolService.getDisplaySetsMatchDetails();
const matchedSeriesInstanceUIDs = Array.from(matches.values()).map(
({ SeriesInstanceUID }) => SeriesInstanceUID
);
let ptDisplaySet = null;
for (const SeriesInstanceUID of matchedSeriesInstanceUIDs) {
const displaySets = DisplaySetService.getDisplaySetsForSeries(
SeriesInstanceUID
for (const matched of viewportMatchDetails) {
const { displaySetsInfo } = matched;
const displaySets = displaySetsInfo.map(({ displaySetInstanceUID }) =>
DisplaySetService.getDisplaySetByUID(displaySetInstanceUID)
);
if (!displaySets || displaySets.length === 0) {
continue;
}
const displaySet = displaySets[0];
if (displaySet.Modality !== 'PT') {
continue;
}
ptDisplaySet = displaySets.find(
displaySet => displaySet.Modality === 'PT'
);
ptDisplaySet = displaySet;
if (ptDisplaySet) {
break;
}
}
return ptDisplaySet;
@@ -121,7 +118,10 @@ const commandsModule = ({
createNewLabelmapFromPT: async () => {
// Create a segmentation of the same resolution as the source data
// using volumeLoader.createAndCacheDerivedVolume.
const ptDisplaySet = actions.getMatchingPTDisplaySet();
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const ptDisplaySet = actions.getMatchingPTDisplaySet({
viewportMatchDetails,
});
if (!ptDisplaySet) {
UINotificationService.error('No matching PT display set found');
@@ -565,8 +565,11 @@ const commandsModule = ({
},
setFusionPTColormap: ({ toolGroupId, colormap }) => {
const toolGroup = ToolGroupService.getToolGroup(toolGroupId);
const { viewportMatchDetails } = HangingProtocolService.getMatchDetails();
const ptDisplaySet = actions.getMatchingPTDisplaySet();
const ptDisplaySet = actions.getMatchingPTDisplaySet({
viewportMatchDetails,
});
if (!ptDisplaySet) {
return;