Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(measurement): Add support measurement label autocompletion #3855

Merged

Conversation

nithin-trenser
Copy link
Contributor

@nithin-trenser nithin-trenser commented Dec 15, 2023

Context

This PR is a prior feature needed for upcoming fetal ultra sound mode by FlyWheel.io.
This enables developers to optionally configure a list of predefined labels to be auto-populated when annotating the tissues applicable in that mode. As such this doesnot change current behaviour of the viewer.

Changes & Results

The below configurations allows to concluded the behaviour of suggested label list.

  • items: This is the optional list of labels configurable for each mode.
    Labels property will be used for display and value property will be assigned to annotation.
  • labelOnMeasure: If this is set, the list will be automatically shown after user draws a measurement. Otherwise, the label list will be shown only when user tries to manually label from side panel or annotation context menu.
  • exclusive: If it is set, the user will be restricted to choose a label from the provided label list. Otherwise, the list will act as suggestions, but users still have the ability to type in custom labels as needed. If no items configured, exlcusive will be ignored and allows users to provide custom labels.

By default the behaviour will be similar to the configuration

{
	items:[],
	labelOnMeasure: false,
	exclusive: false
}

To show the label popup irrespective of tracked/untracked mode, a new state(labellingOnly) is introduced to prevent machine from turning off When selecting 'No, do not ask again' tracking prompt UI.

Testing

We can configure some labels in mode configuration like below, you need to add the following via customizationService

customizationService.addModeCustomizations([
        {
          id: 'measurementLabels',
          labelOnMeasure: true,
          exclusive: true,
          items: [
            { value: 'Head', label: 'Head' },
            { value: 'Shoulder', label: 'Shoulder' },
            { value: 'Knee', label: 'Knee' },
            { value: 'Toe', label: 'Toe' },
          ],
        },
      ]);

A demo video for this behaviour is attached below.

autocompletoin-measurement-labels.mp4

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • OS: Windows 10 with WSL.2
  • Node version: 16.19.1
  • Browser: Chrome 120.0.6099.71

Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for ohif-platform-docs ready!

Name Link
🔨 Latest commit b1acb80
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/660f63064f7d5b0007163af3
😎 Deploy Preview https://deploy-preview-3855--ohif-platform-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit b1acb80
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/660f6306a6bb1700084b2d90
😎 Deploy Preview https://deploy-preview-3855--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.37%. Comparing base (8a335bd) to head (b1acb80).
Report is 281 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3855      +/-   ##
==========================================
- Coverage   46.23%   44.37%   -1.87%     
==========================================
  Files          78       80       +2     
  Lines        1276     1334      +58     
  Branches      312      327      +15     
==========================================
+ Hits          590      592       +2     
- Misses        548      589      +41     
- Partials      138      153      +15     

see 10 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 807afb8...b1acb80. Read the comment docs.

@raveeshtv1988 raveeshtv1988 mentioned this pull request Dec 15, 2023
6 tasks
@sedghi
Copy link
Member

sedghi commented Feb 27, 2024

Thanks @nithin-trenser for this amazing PR, as discussed in our zoom meeting, I'm starting to review this but @IbrahimCSAE will take care of addressing the comments

Comment on lines 1 to 105
interface PropType {
labellingDoneCallback: (label: string) => void;
measurementData: any;
labelData: any;
exclusive: boolean;
componentClassName: any;
}

interface StateType {
location: Location;
label: string;
componentClassName: any;
confirmationState: boolean;
displayComponent: boolean;
}

export interface LabelInfo {
label: string;
value: string;
}

class LabellingFlow extends Component<PropType> {
currentItems: Array<LabelInfo> = [];
state: StateType;
mainElement;

constructor(props) {
super(props);
const { label } = props.measurementData;
let className = props.componentClassName;

this.state = {
location,
label,
componentClassName: className,
confirmationState: false,
displayComponent: true,
};
this.mainElement = React.createRef();
}

render() {
if (this.props.labelData) {
this.currentItems = cloneDeep(this.props.labelData);
}

const className = Object.assign({}, this.state.componentClassName);

return (
<LabellingTransition
displayComponent={this.state.displayComponent}
onTransitionExit={this.props.labellingDoneCallback}
>
<>
<div
className={className}
ref={this.mainElement}
>
{this.labellingStateFragment()}
</div>
</>
</LabellingTransition>
);
}

closePopup = () => {
this.setState({
displayComponent: false,
});

setTimeout(() => {
this.setState({
displayComponent: false,
});
}, 2000);
};

selectTreeSelectCalback = (event, itemSelected) => {
const label = itemSelected.value;
this.closePopup();
return this.props.labellingDoneCallback(label);
};

labellingStateFragment = () => {
return (
<SelectTree
items={this.currentItems}
columns={1}
onSelected={this.selectTreeSelectCalback}
closePopup={this.closePopup}
selectTreeFirstTitle="Annotation"
exclusive={this.props.exclusive}
label={this.state.label}
/>
);
};

}

export default LabellingFlow;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to talk to Dan for this design

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sedghi Other comments are resolved. Please let us know if any change in UI design is required.

@sedghi
Copy link
Member

sedghi commented Mar 5, 2024

@IbrahimCSAE we should make this such that it works for segmentation label editing as well

@IbrahimCSAE IbrahimCSAE requested a review from sedghi April 4, 2024 02:13
Copy link
Member

@sedghi sedghi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is great sutff!

@sedghi sedghi changed the title Support measurement label autocompletion from items configured in modes. feat(measurement): Add support measurement label autocompletion Apr 5, 2024
@sedghi sedghi merged commit 56b1eae into OHIF:master Apr 5, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants