Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | /**
* Naturalized DICOM instance used by display-set split rules and metadata.
* OHIF naturalized instances satisfy this type; additional tags are allowed.
*/
export type NaturalizedInstance = {
imageId?: string;
Modality?: string;
SOPClassUID?: string;
Rows?: number;
Columns?: number;
NumberOfFrames?: number;
SliceLocation?: number;
SeriesInstanceUID?: string;
InstanceNumber?: number;
DiffusionBValue?: number;
TransferSyntaxUID?: string;
AvailableTransferSyntaxUID?: string;
[key: string]: unknown;
};
export type ViewportTypeHint =
| 'stack'
| 'volume'
| 'volume3d'
| 'video'
| 'wholeslide'
| 'ecg'
| string;
/**
* Series-level statistics aggregated once over a series' instances (see
* {@link buildSeriesInfo}). Independent of split rules - a rule derives its own
* facts through its `series` hook (see {@link RuleContext}), not here.
*/
export type SeriesInfo = {
NumberOfSeriesRelatedInstances: number;
numberOfFrames: number;
numImageFrames: number;
numberOfNonImageObjects: number;
numberOfSOPInstanceUIDsPerSeries: number;
[key: string]: unknown;
};
/**
* Derived series-level facts a rule's `series` hook returns, keyed by name and
* read back by that same rule's `matches`/`groupBy` via {@link RuleContext}.
*/
export type SeriesFacts = Record<string, unknown>;
/**
* Argument to a rule's `series` hook: the whole resolved series.
*/
export type SeriesContext = {
instances: NaturalizedInstance[];
};
/**
* Argument to a rule's `matches` predicate and to its `groupBy` extractor
* functions: the facts this rule's `series` hook derived (an empty object when
* the rule has no `series` hook). Scoped per rule - a rule never sees another
* rule's derived facts.
*/
export type RuleContext = {
series: SeriesFacts;
};
export type SplitRuleCustomAttributesContext = {
instance: NaturalizedInstance;
isMultiFrame?: boolean;
sopClassUids?: string[];
viewportTypes?: readonly ViewportTypeHint[];
[key: string]: unknown;
};
export type SplitRuleOptions = {
instances: NaturalizedInstance[];
splitNumber?: number;
descriptionName?: string;
};
export type SplitRule = {
id?: string;
/** Allowed viewport types; index 0 is the preferred viewport type. */
viewportTypes?: readonly ViewportTypeHint[];
/**
* Optional. Runs once per rule per split operation, before matching, and
* returns derived facts for THIS rule - read back by `matches`/`groupBy`
* through `context.series`. Use it only when a rule needs a value computed
* from the whole series (e.g. "does this series mix b-value and non-b-value
* frames?"). Must be pure: return facts, do not mutate shared state.
*/
series?: (context: SeriesContext) => SeriesFacts;
/**
* Predicate deciding whether this rule claims a given instance. Omit to match
* every instance (a catch-all rule). Evaluated in rule order; first match wins.
* The second argument carries this rule's derived `series` facts.
*/
matches?: (instance: NaturalizedInstance, context: RuleContext) => boolean;
/**
* Recipe for the bucket an instance is grouped under once this rule claims it:
* an ordered list of tag names and/or extractor functions. Instances whose
* parts are all equal land in the same group (one group -> one display set).
* Defaults to `['SeriesInstanceUID']` (one group per series). Extractor
* functions receive this rule's derived `series` facts as their second
* argument. The computed result is stored on the produced
* {@link InstanceGroup} as `splitKey`.
*/
groupBy?: (
| string
| ((instance: NaturalizedInstance, context: RuleContext) => unknown)
)[];
customAttributes?: (
attributes: SplitRuleCustomAttributesContext,
options: SplitRuleOptions
) => Record<string, unknown>;
};
export type SplitContext = {
getNaturalizedInstance: (imageId: string) => NaturalizedInstance | undefined;
};
export type InstanceGroup = {
instances: NaturalizedInstance[];
matchedRule: SplitRule;
/**
* Deterministic, rule-namespaced bucket key this group was collected under.
* Stable for a given set of instances regardless of input order, so it can
* seed a stable display set identity. Set by `groupInstancesBySplitRules`;
* optional so hand-built groups don't need it.
*/
splitKey?: string;
};
|