UNPKG

dicomweb-proxy

Version:

A proxy to translate between dicomweb and dimse

2 lines 30.7 kB
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[1919,4759,5674,8402],{75183:(e,t,n)=>{var a;n.d(t,{A:()=>i}),function(e){e.Interaction="Interaction",e.HandlesUpdated="HandlesUpdated",e.StatsUpdated="StatsUpdated",e.InitialSetup="InitialSetup",e.Completed="Completed",e.InterpolationUpdated="InterpolationUpdated",e.History="History",e.MetadataReferenceModified="MetadataReferenceModified",e.LabelChange="LabelChange"}(a||(a={}));const i=a},94021:(e,t,n)=>{var a;n.d(t,{A:()=>i}),function(e){e.TOOL_ACTIVATED="CORNERSTONE_TOOLS_TOOL_ACTIVATED",e.TOOLGROUP_VIEWPORT_ADDED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_ADDED",e.TOOLGROUP_VIEWPORT_REMOVED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED",e.TOOL_MODE_CHANGED="CORNERSTONE_TOOLS_TOOL_MODE_CHANGED",e.CROSSHAIR_TOOL_CENTER_CHANGED="CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED",e.ANNOTATION_ADDED="CORNERSTONE_TOOLS_ANNOTATION_ADDED",e.ANNOTATION_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_COMPLETED",e.ANNOTATION_MODIFIED="CORNERSTONE_TOOLS_ANNOTATION_MODIFIED",e.ANNOTATION_REMOVED="CORNERSTONE_TOOLS_ANNOTATION_REMOVED",e.ANNOTATION_SELECTION_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_SELECTION_CHANGE",e.ANNOTATION_LOCK_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",e.ANNOTATION_VISIBILITY_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",e.ANNOTATION_RENDERED="CORNERSTONE_TOOLS_ANNOTATION_RENDERED",e.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED",e.INTERPOLATED_ANNOTATIONS_REMOVED="CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED",e.SEGMENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",e.SEGMENTATION_RENDERED="CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",e.SEGMENTATION_REPRESENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED",e.SEGMENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_ADDED",e.SEGMENTATION_REPRESENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",e.SEGMENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",e.SEGMENTATION_REPRESENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",e.SEGMENTATION_DATA_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_DATA_MODIFIED",e.HISTORY_UNDO="CORNERSTONE_TOOLS_HISTORY_UNDO",e.HISTORY_REDO="CORNERSTONE_TOOLS_HISTORY_REDO",e.KEY_DOWN="CORNERSTONE_TOOLS_KEY_DOWN",e.KEY_UP="CORNERSTONE_TOOLS_KEY_UP",e.MOUSE_DOWN="CORNERSTONE_TOOLS_MOUSE_DOWN",e.MOUSE_UP="CORNERSTONE_TOOLS_MOUSE_UP",e.MOUSE_DOWN_ACTIVATE="CORNERSTONE_TOOLS_MOUSE_DOWN_ACTIVATE",e.MOUSE_DRAG="CORNERSTONE_TOOLS_MOUSE_DRAG",e.MOUSE_MOVE="CORNERSTONE_TOOLS_MOUSE_MOVE",e.MOUSE_CLICK="CORNERSTONE_TOOLS_MOUSE_CLICK",e.MOUSE_DOUBLE_CLICK="CORNERSTONE_TOOLS_MOUSE_DOUBLE_CLICK",e.MOUSE_WHEEL="CORNERSTONE_TOOLS_MOUSE_WHEEL",e.TOUCH_START="CORNERSTONE_TOOLS_TOUCH_START",e.TOUCH_START_ACTIVATE="CORNERSTONE_TOOLS_TOUCH_START_ACTIVATE",e.TOUCH_PRESS="CORNERSTONE_TOOLS_TOUCH_PRESS",e.TOUCH_DRAG="CORNERSTONE_TOOLS_TOUCH_DRAG",e.TOUCH_END="CORNERSTONE_TOOLS_TOUCH_END",e.TOUCH_TAP="CORNERSTONE_TOOLS_TAP",e.TOUCH_SWIPE="CORNERSTONE_TOOLS_SWIPE"}(a||(a={}));const i=a},18682:(e,t,n)=>{var a;n.d(t,{A:()=>i}),function(e){e.Labelmap="Labelmap",e.Contour="Contour",e.Surface="Surface"}(a||(a={}));const i=a},84093:(e,t,n)=>{var a;n.d(t,{A:()=>i}),function(e){e.OnInteractionStart="onInteractionStart",e.OnInteractionEnd="onInteractionEnd",e.Preview="preview",e.RejectPreview="rejectPreview",e.AcceptPreview="acceptPreview",e.Fill="fill",e.Interpolate="interpolate",e.StrategyFunction="strategyFunction",e.CreateIsInThreshold="createIsInThreshold",e.Initialize="initialize",e.INTERNAL_setValue="setValue",e.AddPreview="addPreview",e.ComputeInnerCircleRadius="computeInnerCircleRadius",e.GetStatistics="getStatistics",e.EnsureImageVolumeFor3DManipulation="ensureImageVolumeFor3DManipulation",e.EnsureSegmentationVolumeFor3DManipulation="ensureSegmentationVolumeFor3DManipulation"}(a||(a={}));const i=a},66452:(e,t,n)=>{var a,i;n.d(t,{i:()=>a,q:()=>i}),function(e){e[e.Primary=1]="Primary",e[e.Secondary=2]="Secondary",e[e.Primary_And_Secondary=3]="Primary_And_Secondary",e[e.Auxiliary=4]="Auxiliary",e[e.Primary_And_Auxiliary=5]="Primary_And_Auxiliary",e[e.Secondary_And_Auxiliary=6]="Secondary_And_Auxiliary",e[e.Primary_And_Secondary_And_Auxiliary=7]="Primary_And_Secondary_And_Auxiliary",e[e.Fourth_Button=8]="Fourth_Button",e[e.Fifth_Button=16]="Fifth_Button",e[e.Wheel=524288]="Wheel",e[e.Wheel_Primary=524289]="Wheel_Primary"}(a||(a={})),function(e){e[e.Shift=16]="Shift",e[e.Ctrl=17]="Ctrl",e[e.Alt=18]="Alt",e[e.Meta=91]="Meta",e[e.ShiftCtrl=1617]="ShiftCtrl",e[e.ShiftAlt=1618]="ShiftAlt",e[e.ShiftMeta=1691]="ShiftMeta",e[e.CtrlAlt=1718]="CtrlAlt",e[e.CtrlMeta=1791]="CtrlMeta",e[e.AltMeta=1891]="AltMeta"}(i||(i={}))},49892:(e,t,n)=>{var a;n.d(t,{A:()=>i}),function(e){e.Active="Active",e.Passive="Passive",e.Enabled="Enabled",e.Disabled="Disabled"}(a||(a={}));const i=a},10401:(e,t,n)=>{var a;n.d(t,{H:()=>a}),function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT"}(a||(a={}))},99737:(e,t,n)=>{n.r(t),n.d(t,{AnnotationStyleStates:()=>s,ChangeTypes:()=>p.A,Events:()=>l.A,KeyboardBindings:()=>i.q,MouseBindings:()=>i.i,SegmentationRepresentations:()=>c.A,StrategyCallbacks:()=>u.A,Swipe:()=>m.H,ToolModes:()=>o.A,WorkerTypes:()=>d});var a,i=n(66452),o=n(49892);!function(e){e.Default="",e.Highlighted="Highlighted",e.Selected="Selected",e.Locked="Locked",e.AutoGenerated="AutoGenerated"}(a||(a={}));const s=a;var r,l=n(94021),c=n(18682),m=n(10401),u=n(84093),p=n(75183);!function(e){e.POLYSEG_CONTOUR_TO_LABELMAP="Converting Contour to Labelmap",e.POLYSEG_SURFACE_TO_LABELMAP="Converting Surfaces to Labelmap",e.POLYSEG_CONTOUR_TO_SURFACE="Converting Contour to Surface",e.POLYSEG_LABELMAP_TO_SURFACE="Converting Labelmap to Surface",e.SURFACE_CLIPPING="Clipping Surfaces",e.COMPUTE_STATISTICS="Computing Statistics",e.INTERPOLATE_LABELMAP="Interpolating Labelmap",e.COMPUTE_LARGEST_BIDIRECTIONAL="Computing Largest Bidirectional",e.GENERATE_CONTOUR_SETS="Generating Contour Sets"}(r||(r={}));const d=r},14696:(e,t,n)=>{n.r(t),n.d(t,{default:()=>V});var a={};n.r(a),n.d(a,{updateSegmentationsChartDisplaySet:()=>O});const i=JSON.parse('{"UU":"@ohif/extension-cornerstone-dynamic-volume"}').UU;var o=n(62037),s=n(15327),r=n(4667);const l="CHT",c=o.Wp.guid(),m="1.9.451.13215.7.3.2.7.6.1",{utilities:u}=r;function p(e,t){const n=e.imageIds.reduce(((e,n)=>{const a=o.H8.getInstanceByImageId(n)[t];return void 0!==a&&e.add(a),e}),new Set);return Array.from(n).sort(((e,t)=>e-t))}function d(e,t,{servicesManager:n}){const{displaySetService:a,segmentationService:i,viewportGridService:r}=n.services;let l;const c=a.getActiveDisplaySets().find((e=>{const t=e.instances?.[0];return!!t&&(void 0!==t.FrameReferenceTime||void 0!==t.NumberOfTimeSlices)})).displaySetInstanceUID;for(const[e]of s.cache._volumeCache)if(e.includes(c)){l=e;break}let m;l&&(m=s.cache.getVolume(l));const{StudyInstanceUID:d,StudyDescription:S}=o.H8.getInstanceByImageId(m.imageIds[0]),O=i.getLabelmapVolume(e.segmentationId),E=O?.volumeId,[T,y]=u.dynamicVolume.getDataInTime(m,{maskVolumeId:E}),g=T.length;if(0===g)return[];const I=r.getActiveViewportId(),N=i.getSegmentColor(I,e.segmentationId,1),D=s.utilities.color.rgbToHex(N[0],N[1],N[2]);let v=t.get(m);v||(v=function(e){const t={FrameReferenceTime:{unit:"ms"}},n=Object.keys(t);let a,i;for(let o=0;o<n.length;o++){const s=n[o],r=p(e,s);if(r.length){a=r,i=t[s].unit;break}}if(!a.length){const e=n.join(", ");throw new Error(`Could not extract time points data for the following tags: ${e}`)}const o=function(e,t){const n=["ms","s","m","h"],a=[1e3,60,60],i=n.indexOf(t);let o=1;if(-1!==i){for(let s=i;s<n.length-1;s++){const i=o*a[s];if(e.filter((e=>e>i)).length<=e.length/2)break;o=i,t=n[s+1]}o>1&&(e=e.map((e=>e/o)))}return{timePoints:e,timePointsUnit:t}}(a,i);return a=o.timePoints,i=o.timePointsUnit,{timePoints:a,timePointsUnit:i}}(m),t.set(m,v));const{timePoints:_,timePointsUnit:C}=v;if(_.length!==T[0].length)throw new Error("Invalid number of time points returned");const R=_.length,f=new Array(R);for(let e=0;e<R;e++){const t=T.reduce(((t,n)=>t+n[e]/g),0);f[e]=[_[e],t]}return{StudyInstanceUID:d,StudyDescription:S,chartData:{series:{label:e.label,points:f,color:D},axis:{x:{label:`Time (${C})`},y:{label:"Vl (Bq/ml)"}}}}}function S(e,{servicesManager:t}){if(!e.length)return;const n=new WeakMap,a=e.map((e=>d(e,n,{servicesManager:t}))),{date:i,time:s}=function(){const e=new Date;return{date:e.getFullYear()+("0"+e.getUTCMonth()).slice(-2)+("0"+e.getUTCDate()).slice(-2),time:("0"+e.getUTCHours()).slice(-2)+("0"+e.getUTCMinutes()).slice(-2)+("0"+e.getUTCSeconds()).slice(-2)}}(),r=a.reduce(((e,t)=>[...e,t.chartData.series]),[]),u={SOPClassUID:m,Modality:l,SOPInstanceUID:o.Wp.guid(),SeriesDate:i,SeriesTime:s,SeriesInstanceUID:c,StudyInstanceUID:a[0].StudyInstanceUID,StudyDescription:a[0].StudyDescription,SeriesNumber:100,SeriesDescription:"Segmentation chart series data",chartData:{series:r,axis:{...a[0].chartData.axis}}};return{seriesMetadata:{StudyInstanceUID:u.StudyInstanceUID,StudyDescription:u.StudyDescription,SeriesInstanceUID:u.SeriesInstanceUID,SeriesDescription:u.SeriesDescription,SeriesNumber:u.SeriesNumber,SeriesTime:u.SeriesTime,SOPClassUID:u.SOPClassUID,Modality:u.Modality},instance:u}}function O({servicesManager:e}){const{segmentationService:t}=e.services,n=t.getSegmentations(),{seriesMetadata:a,instance:i}=S(n,{servicesManager:e})??{};a&&i&&(o.H8.addSeriesMetadata([a],!0),o.H8.addInstances([i],!0))}r.Enums.SegmentationRepresentations.Labelmap;const E=({commandsManager:e,servicesManager:t})=>{const n=t.services,{displaySetService:i,viewportGridService:o,segmentationService:l}=n,c={...a,getDynamic4DDisplaySet:()=>i.getActiveDisplaySets().find((e=>{const t=e.instances?.[0];return!!t&&(void 0!==t.FrameReferenceTime||void 0!==t.NumberOfTimeSlices||void 0!==t.TemporalPositionIdentifier)})),getComputedDisplaySets:()=>[...i.getDisplaySetCache().values()].filter((e=>e.isDerived)),exportTimeReportCSV:({segmentations:e,config:t,options:n,summaryStats:a})=>{const i=c.getDynamic4DDisplaySet(),o=i?.displaySetInstanceUID;let m,u;for(const[e]of s.cache._volumeCache)if(e.includes(o)){m=e;break}m&&(u=s.cache.getVolume(m));const p=i.instances[0],d=[];function S(e){const t=e.length,n=e.reduce(((e,t)=>e+t),0)/t,a=e.map((e=>(e-n)**2)).reduce(((e,t)=>e+t),0)/t;return Math.sqrt(a)}d.push(`Patient ID,${p.PatientID},`),d.push(`Study Date,${p.StudyDate},`),d.push(`StudyInstanceUID,${p.StudyInstanceUID},`),d.push(`StudyDescription,${p.StudyDescription},`),d.push(`SeriesInstanceUID,${p.SeriesInstanceUID},`),d.push(""),d.push(""),e.forEach((e=>{const t=l.getLabelmapVolume(e.segmentationId),[n,i]=r.utilities.dynamicVolume.getDataInTime(u,{maskVolumeId:t.volumeId});if(a){let t="Operation,Segmentation Label ID";const a=u.numTimePoints;for(let e=0;e<a;e++)t+=`,Time Point ${e}`;d.push(t);const o=[],s=[],r=[],l=[],c=[],m=[],p=n.length;for(let e=0;e<a;e++){const t=[];let a=0,u=1/0,d=-1/0,O=0,E=0;for(let i=0;i<p;i++){const o=n[i][e];t.push(o),a+=o,o<u&&(u=o,O=i),o>d&&(d=o,E=i)}o.push(a/p),s.push(u),r.push(i[O]),l.push(d),c.push(i[E]),m.push(S(t))}let O=`Mean,${e.label}`;for(let e=0;e<a;e++)O+=`,${o[e]}`;d.push(O),O=`Standard Deviation,${e.label}`;for(let e=0;e<a;e++)O+=`,${m[e]}`;d.push(O),O=`Min,${e.label}`;for(let e=0;e<a;e++)O+=`,${s[e]}`;d.push(O),O=`Max,${e.label}`;for(let e=0;e<a;e++)O+=`,${l[e]}`;d.push(O)}else{let t="Pixel Identifier (IJK),Segmentation Label ID";const a=u.numTimePoints;for(let e=0;e<a;e++)t+=`,Time Point ${e}`;d.push(t);for(let t=0;t<n.length;t++){let a=`${`${i[t][0]}_${i[t][1]}_${i[t][2]}`},${e.label}`;for(let e=0;e<n[t].length;e++)a+=`,${n[t][e]}`;d.push(a)}}}));const O=d.join("\n"),E=`${p.PatientID}.csv`,T=new Blob([O],{type:"text/csv;charset=utf-8;"}),y=document.createElement("a"),g=URL.createObjectURL(T);y.setAttribute("href",g),y.setAttribute("download",E),y.style.visibility="hidden",document.body.appendChild(y),y.click(),document.body.removeChild(y)},swapDynamicWithComputedDisplaySet:({displaySet:t})=>{const n=t,a=i.getDisplaySetCache(),s=[a.keys()],{displaySetInstanceUID:r}=n;s.includes(r)||a.set(r,n);const{viewports:l}=o.getState(),m=c.getDynamic4DDisplaySet(),u=[];for(const[e,t]of l){const e=t,n=e.viewportOptions,{displaySetInstanceUIDs:a}=e,i=a.indexOf(m.displaySetInstanceUID);if(-1!==i){const t={viewportId:e.viewportId,displaySetInstanceUIDs:[...a.slice(0,i),r,...a.slice(i+1)],viewportOptions:{initialImageOptions:n.initialImageOptions,viewportType:"volume",orientation:n.orientation,background:n.background}};u.push(t)}}e.run("setDisplaySetsForViewports",{viewportsToUpdate:u})},swapComputedWithDynamicDisplaySet:()=>{const t=c.getDynamic4DDisplaySet(),n=i.getDisplaySetCache(),a=[...n.keys()],{displaySetInstanceUID:s}=t;a.includes(s)||n.set(s,t);const{viewports:r}=o.getState(),l=c.getComputedDisplaySets()[0],m=[];for(const[e,t]of r){const e=t,n=e.viewportOptions,{displaySetInstanceUIDs:a}=e,i=a.indexOf(l.displaySetInstanceUID);if(-1!==i){const t={viewportId:e.viewportId,displaySetInstanceUIDs:[...a.slice(0,i),s,...a.slice(i+1)],viewportOptions:{initialImageOptions:n.initialImageOptions,viewportType:"volume",orientation:n.orientation,background:n.background}};m.push(t)}}e.run("setDisplaySetsForViewports",{viewportsToUpdate:m})},createNewLabelMapForDynamicVolume:async({label:e})=>{const{viewports:t,activeViewportId:n}=o.getState(),a=c.getDynamic4DDisplaySet(),s=a.displaySetInstanceUID;let r;if(t.get(n).displaySetInstanceUIDs.includes(s)&&(r=a),!r){const e=i.getDisplaySetCache();for(const[t,n]of e)if(n.referenceDisplaySetUID===s){r=n;break}}if(!r)throw new Error("No reference display set found based on the dynamic data");const m=i.getDisplaySetByUID(r.displaySetInstanceUID),u=await l.createLabelmapForDisplaySet(m,{label:e}),p=t.values().next().value;return await l.addSegmentationRepresentation(p.viewportId,{segmentationId:u}),u}},m={updateSegmentationsChartDisplaySet:{commandFn:c.updateSegmentationsChartDisplaySet,storeContexts:[],options:{}},exportTimeReportCSV:{commandFn:c.exportTimeReportCSV,storeContexts:[],options:{}},swapDynamicWithComputedDisplaySet:{commandFn:c.swapDynamicWithComputedDisplaySet,storeContexts:[],options:{}},createNewLabelMapForDynamicVolume:{commandFn:c.createNewLabelMapForDynamicVolume,storeContexts:[],options:{}},swapComputedWithDynamicDisplaySet:{commandFn:c.swapComputedWithDynamicDisplaySet,storeContexts:[],options:{}}};return{actions:c,definitions:m,defaultContext:"DYNAMIC-VOLUME:CORNERSTONE"}};var T=n(86326),y=n(2836);const g=e=>null==e?"":String(e).toUpperCase(),I=({title:e,tooltip:t})=>T.createElement("div",{className:"flex items-center space-x-1"},T.createElement(y.m_M,null,T.createElement(y.k$k,{asChild:!0},T.createElement("span",null,T.createElement(y.FI1.ByName,{name:"info-link",className:"text-primary h-3 w-3"}))),T.createElement(y.ZIw,{sideOffset:4,className:"max-w-xs"},T.createElement("div",null,t))),T.createElement("span",{className:"text-muted-foreground text-xs uppercase tracking-wide"},e)),N=({isPlaying:e,onPlayPauseChange:t,fps:n,onFpsChange:a,minFps:i,maxFps:o,currentDimensionGroupNumber:r,onDimensionGroupChange:l,numDimensionGroups:c,onGenerate:m,onDoubleRangeChange:u,rangeValues:p,onDynamicClick:d})=>{const[S,O]=(0,T.useState)(!1),[E,N]=(0,T.useState)(s.Enums.DynamicOperatorType.SUM);return T.createElement("div",{className:"flex select-none flex-col"},T.createElement(y.aUM,{defaultOpen:!0},T.createElement(y.aUM.Header,null,"Controls"),T.createElement(y.aUM.Content,{className:"bg-muted space-y-4 px-5 pt-2 pb-4"},T.createElement("div",{className:"mb-4"},T.createElement(I,{title:"View",tooltip:"Select the view mode, 4D to view the dynamic volume or Computed to view the computed volume"}),T.createElement(y.tUM,{value:S?"computed":"4d",onValueChange:e=>{const t="computed"===e;O(t),t||"function"!=typeof d||d()},className:"my-2 w-full"},T.createElement(y.j7C,{className:"w-full"},T.createElement(y.Xib,{value:"4d",className:"w-1/2"},"4D"),T.createElement(y.Xib,{value:"computed",className:"w-1/2"},"Computed")))),T.createElement("div",null,T.createElement(D,{onPlayPauseChange:t,isPlaying:e,computedView:S,fps:n,onFpsChange:a,minFps:i,maxFps:o,numDimensionGroups:c,onDimensionGroupChange:l,currentDimensionGroupNumber:r})),T.createElement("div",{className:"mt-3 flex flex-col "+(S?"":"ohif-disabled")},T.createElement(I,{title:"Computed Operation",tooltip:T.createElement("div",null,"Operation Buttons (SUM, AVERAGE, SUBTRACT): Select the mathematical operation to be applied to the data set.",T.createElement("br",null)," Range Slider: Choose the numeric range of dimension groups within which the operation will be performed.",T.createElement("br",null),"Generate Button: Execute the chosen operation on the specified range of data.")}),T.createElement(y.tUM,{value:String(E),onValueChange:e=>{N(e)},className:"mt-2 w-full"},T.createElement(y.j7C,{className:"w-full gap-1"}," ",T.createElement(y.Xib,{value:String(s.Enums.DynamicOperatorType.SUM),className:"w-1/3"},g(s.Enums.DynamicOperatorType.SUM)),T.createElement(y.Xib,{value:String(s.Enums.DynamicOperatorType.AVERAGE),className:"w-1/3"},g(s.Enums.DynamicOperatorType.AVERAGE)),T.createElement(y.Xib,{value:String(s.Enums.DynamicOperatorType.SUBTRACT),className:"w-1/3"},g(s.Enums.DynamicOperatorType.SUBTRACT)))),T.createElement("div",{className:"mt-2 w-full"},T.createElement(y.ewR.Container,{mode:"doubleRange",min:1,max:c||1,values:p||[1,c||1],onChange:u||(()=>{})},T.createElement(y.ewR.DoubleRange,{showNumberInputs:!0}))),T.createElement(y.$nd,{variant:"default",size:"sm",className:"mt-2 h-[26px] w-[115px] self-start p-0",onClick:()=>{try{"function"==typeof m?m(E):console.error("onGenerate is not a function",m)}catch(e){console.error("Error in onGenerate:",e)}}},"Generate")))))};function D({isPlaying:e,onPlayPauseChange:t,fps:n,minFps:a,maxFps:i,onFpsChange:o,numDimensionGroups:s,onDimensionGroupChange:r,currentDimensionGroupNumber:l,computedView:c}){return T.createElement("div",{className:c?"ohif-disabled":""},T.createElement(I,{title:"4D Controls",tooltip:T.createElement("div",null,"Play/Pause Button: Begin or pause the animation of the 4D visualization. ",T.createElement("br",null),"Dimension Group Selector: Navigate through individual dimension groups of the 4D data."," ",T.createElement("br",null),"FPS (Frames Per Second) Selector: Adjust the playback speed of the animation.")}),T.createElement("div",{className:"mt-3 flex justify-between"},T.createElement(y.$nd,{id:"play-pause-button",variant:"secondary",size:"default",className:"w-[58px]",onClick:()=>{"function"==typeof t&&t(!e)}},T.createElement(y.FI1.ByName,{name:e?"icon-pause":"icon-play",className:"text-foreground h-[24px] w-[24px]"})),T.createElement(y.ewR.Container,{mode:"stepper",value:l||1,onChange:r||(()=>{}),min:1,max:s||1,step:1},T.createElement("div",{className:"flex flex-col items-center"},T.createElement(y.ewR.NumberStepper,{className:"h-[28px] w-[58px]",direction:"horizontal"}),T.createElement(y.ewR.Label,{className:"text-muted-foreground mt-1 text-sm"},"Frame"))),T.createElement(y.ewR.Container,{mode:"stepper",value:n||1,onChange:o||(()=>{}),min:a||1,max:i||30,step:1},T.createElement("div",{className:"flex flex-col items-center"},T.createElement(y.ewR.NumberStepper,{className:"h-[28px] w-[58px]",direction:"horizontal"}),T.createElement(y.ewR.Label,{className:"text-muted-foreground mt-1 text-sm"},"FPS")))))}const v="@ohif/extension-default.sopClassHandlerModule.stack";function _({servicesManager:e,commandsManager:t}){const{cornerstoneViewportService:n,viewportGridService:a,displaySetService:i}=e.services,[{isCineEnabled:o},l]=(0,y.tqw)(),[{activeViewportId:c}]=(0,y.ihW)(),[m,u]=(0,T.useState)([1,1]),[p,d]=(0,T.useState)(null),[S,O]=(0,T.useState)(null),[E,g]=(0,T.useState)(20),[I,D]=(0,T.useState)(o),[_,C]=(0,T.useState)(null),[R,f]=(0,T.useState)(!1),h=(0,T.useRef)(s.utilities.uuidv4()),A=(0,T.useRef)(null),M=`cornerstoneStreamingImageVolume:${h.current}`;function w(e){t.runCommand("swapDynamicWithComputedDisplaySet",{displaySet:e}),f(!0)}(0,T.useEffect)((()=>{const t=n.EVENTS.VIEWPORT_DATA_CHANGED,a=e.services.cineService.EVENTS.CINE_STATE_CHANGED,{unsubscribe:i}=n.subscribe(t,(e=>{e.viewportData.data.forEach((e=>{if(e.volume?.isDynamicVolume()){O(e.volume),A.current=e.displaySetInstanceUID;const t=[1,e.volume.numDimensionGroups];u(t)}}))})),{unsubscribe:o}=e.services.cineService.subscribe(a,(e=>{D(e.isPlaying)}));return()=>{i(),o()}}),[n,l,e.services.cineService]),(0,T.useEffect)((()=>{const e=s.Enums.Events.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,t=e=>{C(e.detail.dimensionGroupNumber)};return s.eventTarget.addEventListener(e,t),()=>{s.eventTarget.removeEventListener(e,t)}}),[]),(0,T.useEffect)((()=>{const e=a.getDisplaySetsUIDsForViewport(c);if(!e?.length)return;const t=e.map(i.getDisplaySetByUID).find((e=>e.isDynamicVolume));if(!t)return;const n=s.cache.getVolumes().find((e=>e.volumeId.includes(t.displaySetInstanceUID)));n&&(O(n),A.current=t.displaySetInstanceUID,u([1,n.numDimensionGroups]))}),[c,a,i,n,l]);const L=()=>{D(!0);const e=n.getViewportInfo(c);if(!e)return;const{element:t}=e;l.playClip(t,{framesPerSecond:E,viewportId:c})},U=()=>{D(!1);const{element:e}=n.getViewportInfo(c);l.stopClip(e)};return T.createElement(N,{fps:E,isPlaying:I,onPlayPauseChange:e=>{e?L():U()},minFps:1,maxFps:50,onFpsChange:e=>{g(e),U(),L()},currentDimensionGroupNumber:_,numDimensionGroups:S?.numDimensionGroups||1,onDimensionGroupChange:e=>{S.dimensionGroupNumber=e},onGenerate:async function(e){const a=S.volumeId;if(!a)return;let i=s.cache.getVolume(M);i||(i=await s.volumeLoader.createAndCacheDerivedVolume(a,{volumeId:M}));const[o,l]=m,c=Array.from({length:l-o+1},((e,t)=>o+t)),u={dimensionGroupNumbers:"SUBTRACT"===e?[o,l]:c,targetVolume:i};if(r.utilities.dynamicVolume.updateVolumeFromTimeData(S,e,u),p)t.runCommand("updateVolumeData",{volume:i}),n.getRenderingEngine().render(),w(p);else{const e={volumeLoaderSchema:i.volumeId.split(":")[0],displaySetInstanceUID:h.current,SOPClassHandlerId:v,Modality:S.metadata.Modality,isMultiFrame:!1,numImageFrames:1,uid:h.current,referenceDisplaySetUID:S.volumeId.split(":")[1],madeInClient:!0,FrameOfReferenceUID:S.metadata.FrameOfReferenceUID,isDerived:!0,imageIds:i.imageIds};d(e),w(e)}},onDynamicClick:R?()=>{t.runCommand("swapComputedWithDynamicDisplaySet")}:null,onDoubleRangeChange:u,rangeValues:m})}const C=function({servicesManager:e,commandsManager:t,tab:n}){return T.createElement(T.Fragment,null,T.createElement("div",{className:"flex flex-col text-white","data-cy":"dynamic-volume-panel"},T.createElement(_,{commandsManager:t,servicesManager:e})))};var R=n(43984),f=n(7241);const h=function({commandsManager:e,servicesManager:t}){const n=(0,f.useSegmentations)({servicesManager:t});return n?.length?T.createElement("div",{className:"flex gap-2"},T.createElement("div",{className:"flex h-8 w-full items-center rounded pr-0.5"},T.createElement(y.$nd,{size:"sm",variant:"ghost",className:"pl-1.5",onClick:()=>{e.runCommand("exportTimeReportCSV",{segmentations:n,options:{filename:"TimeData.csv"}})}},T.createElement(y.FI1.Export,null),T.createElement("span",{className:"pl-1"},"Time Data"))),T.createElement("div",{className:"flex h-8 w-full items-center rounded pr-0.5"},T.createElement(y.$nd,{size:"sm",variant:"ghost",className:"pl-1.5",onClick:()=>{e.runCommand("exportTimeReportCSV",{segmentations:n,summaryStats:!0,options:{filename:"ROIStats.csv"}})}},T.createElement(y.FI1.Export,null),T.createElement("span",{className:"pl-1"},"ROI Stats")))):null};const A=function({commandsManager:e,extensionManager:t,servicesManager:n,configuration:a}){return[{name:"dynamic-volume",iconName:"tab-4d",iconLabel:"4D Workflow",label:"4D Workflow",component:()=>T.createElement(C,{commandsManager:e,servicesManager:n,extensionManager:t})},{name:"dynamic-segmentation",iconName:"tab-segmentation",iconLabel:"Segmentation",label:"Segmentation",component:()=>T.createElement(T.Fragment,null,T.createElement(R.Toolbox,{buttonSectionId:"dynamic-toolbox",title:"Threshold Tools"}),T.createElement(f.PanelSegmentation,{servicesManager:n,commandsManager:e,extensionManager:t,configuration:a},T.createElement(h,{servicesManager:n,commandsManager:e})))}]},M="2hot",w="dynamic4D-pt",L="dynamic4D-fusion",U="dynamic4D-ct";function b({colormap:e,voiInverted:t}={}){return{blendMode:"MIP",colormap:e,voi:{windowWidth:5,windowCenter:2.5},voiInverted:t}}function P(){const e={colormap:{name:M,opacity:[{value:0,opacity:0},{value:.1,opacity:1},{value:1,opacity:1}]},voiInverted:!1};return[{viewportOptions:{viewportId:"ptAxial",viewportType:"volume",orientation:"axial",toolGroupId:w,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"axialSync",source:!0,target:!0},{type:"voi",id:"ptWLSync",source:!0,target:!0}]},displaySets:[{id:"ptDisplaySet",options:{...b(e)}}]},{viewportOptions:{viewportId:"ptSagittal",viewportType:"volume",orientation:"sagittal",toolGroupId:w,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"sagittalSync",source:!0,target:!0},{type:"voi",id:"ptWLSync",source:!0,target:!0}]},displaySets:[{id:"ptDisplaySet",options:{...b(e)}}]},{viewportOptions:{viewportId:"ptCoronal",viewportType:"volume",orientation:"coronal",toolGroupId:w,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"coronalSync",source:!0,target:!0},{type:"voi",id:"ptWLSync",source:!0,target:!0}]},displaySets:[{id:"ptDisplaySet",options:{...b(e)}}]}]}function x(){const e={colormap:{name:M,opacity:[{value:0,opacity:0},{value:.1,opacity:.8},{value:1,opacity:.8}]}};return[{viewportOptions:{viewportId:"fusionAxial",viewportType:"volume",orientation:"axial",toolGroupId:L,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"axialSync",source:!0,target:!0},{type:"voi",id:"ctWLSync",source:!1,target:!0},{type:"voi",id:"fusionWLSync",source:!0,target:!0},{type:"voi",id:"ptFusionWLSync",source:!1,target:!0,options:{syncInvertState:!1}},{type:"hydrateseg",id:"sameFORId",source:!0,target:!0,options:{matchingRules:["sameFOR"]}}]},displaySets:[{id:"ctDisplaySet"},{options:{...b(e)},id:"ptDisplaySet"}]},{viewportOptions:{viewportId:"fusionSagittal",viewportType:"volume",orientation:"sagittal",toolGroupId:L,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"sagittalSync",source:!0,target:!0},{type:"voi",id:"ctWLSync",source:!1,target:!0},{type:"voi",id:"fusionWLSync",source:!0,target:!0},{type:"voi",id:"ptFusionWLSync",source:!1,target:!0,options:{syncInvertState:!1}},{type:"hydrateseg",id:"sameFORId",source:!0,target:!0,options:{matchingRules:["sameFOR"]}}]},displaySets:[{id:"ctDisplaySet"},{options:{...b(e)},id:"ptDisplaySet"}]},{viewportOptions:{viewportId:"fusionCoronal",viewportType:"volume",orientation:"coronal",toolGroupId:L,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"coronalSync",source:!0,target:!0},{type:"voi",id:"ctWLSync",source:!1,target:!0},{type:"voi",id:"fusionWLSync",source:!0,target:!0},{type:"voi",id:"ptFusionWLSync",source:!1,target:!0,options:{syncInvertState:!1}},{type:"hydrateseg",id:"sameFORId",source:!0,target:!0,options:{matchingRules:["sameFOR"]}}]},displaySets:[{id:"ctDisplaySet"},{options:{...b(e)},id:"ptDisplaySet"}]}]}const G={id:"default4D",locked:!0,hasUpdatedPriorsInformation:!1,name:"Default",createdDate:"2023-01-01T00:00:00.000Z",modifiedDate:"2023-01-01T00:00:00.000Z",availableTo:{},editableBy:{},imageLoadStrategy:"default",protocolMatchingRules:[{attribute:"ModalitiesInStudy",constraint:{contains:["CT","PT"]}}],numberOfPriorsReferenced:-1,displaySetSelectors:{defaultDisplaySetId:{imageMatchingRules:[],seriesMatchingRules:[{attribute:"numImageFrames",constraint:{greaterThan:{value:0}}}]},ctDisplaySet:{imageMatchingRules:[],seriesMatchingRules:[{attribute:"Modality",constraint:{equals:{value:"CT"}},required:!0},{attribute:"isReconstructable",constraint:{equals:{value:!0}},required:!0}]},ptDisplaySet:{imageMatchingRules:[],seriesMatchingRules:[{attribute:"Modality",constraint:{equals:"PT"},required:!0},{attribute:"isReconstructable",constraint:{equals:{value:!0}},required:!0},{attribute:"SeriesDescription",constraint:{contains:"Corrected"}},{weight:2,attribute:"SeriesDescription",constraint:{doesNotContain:{value:"Uncorrected"}}}]},chartDisplaySet:{imageMatchingRules:[],seriesMatchingRules:[{attribute:"Modality",constraint:{equals:{value:"CHT"}},required:!0}]}},stages:[{id:"dataPreparation",name:"Data Preparation",viewportStructure:{layoutType:"grid",properties:{rows:1,columns:3}},viewports:[...P()],createdDate:"2023-01-01T00:00:00.000Z"},{id:"registration",name:"Registration",viewportStructure:{layoutType:"grid",properties:{rows:3,columns:3}},viewports:[...x(),{viewportOptions:{viewportId:"ctAxial",viewportType:"volume",orientation:"axial",toolGroupId:U,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"axialSync",source:!0,target:!0},{type:"voi",id:"ctWLSync",source:!0,target:!0}]},displaySets:[{id:"ctDisplaySet"}]},{viewportOptions:{viewportId:"ctSagittal",viewportType:"volume",orientation:"sagittal",toolGroupId:U,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"sagittalSync",source:!0,target:!0},{type:"voi",id:"ctWLSync",source:!0,target:!0}]},displaySets:[{id:"ctDisplaySet"}]},{viewportOptions:{viewportId:"ctCoronal",viewportType:"volume",orientation:"coronal",toolGroupId:U,initialImageOptions:{preset:"middle"},syncGroups:[{type:"cameraPosition",id:"coronalSync",source:!0,target:!0},{type:"voi",id:"ctWLSync",source:!0,target:!0}]},displaySets:[{id:"ctDisplaySet"}]},...P()],createdDate:"2023-01-01T00:00:00.000Z"},{id:"roiQuantification",name:"ROI Quantification",viewportStructure:{layoutType:"grid",properties:{rows:1,columns:3}},viewports:[...x()],createdDate:"2023-01-01T00:00:00.000Z"},{id:"kineticAnalysis",name:"Kinetic Analysis",viewportStructure:{layoutType:"grid",properties:{rows:2,columns:3,layoutOptions:[{x:0,y:0,width:1/3,height:.5},{x:1/3,y:0,width:1/3,height:.5},{x:2/3,y:0,width:1/3,height:.5},{x:0,y:.5,width:1,height:.5}]}},viewports:[...x(),{viewportOptions:{viewportId:"seriesChart"},displaySets:[{id:"chartDisplaySet",options:{skipLoading:!0}}]}],createdDate:"2023-01-01T00:00:00.000Z"}]};const V={id:i,preRegistration:({servicesManager:e,commandsManager:t,configuration:n={}})=>{s.cache.setMaxCacheSize(5368709120)},getPanelModule:A,getHangingProtocolModule:function(){return[{name:G.id,protocol:G}]},getCommandsModule:({servicesManager:e,commandsManager:t,extensionManager:n})=>E({servicesManager:e,commandsManager:t,extensionManager:n})}}}]); //# sourceMappingURL=1919.bundle.7fe19b7e3f8c31b45991.js.map