Skip to content

Commit

Permalink
feat: access Gleason patterns data in read only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lucalianas committed Oct 31, 2023
1 parent e27e629 commit 0931eda
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
vm._createListItem = _createListItem;
vm._createNewSubtree = _createNewSubtree;
vm._focusOnShape = _focusOnShape;
vm._clearGleasonSubregions = _clearGleasonSubregions;
vm.showROIPanel = showROIPanel;
vm.selectROI = selectROI;
vm.deselectROI = deselectROI;
Expand Down Expand Up @@ -134,6 +135,7 @@
$rootScope.cores = [];
$rootScope.focus_regions = [];
$rootScope.gleason_patterns = [];
$rootScope.gleason_patterns_subregions = [];

ClinicalAnnotationStepService.getDetails(vm.clinical_annotation_step_label)
.then(getClinicalAnnotationStepSuccessFn, getClinicalAnnotationStepErrorFn);
Expand All @@ -145,6 +147,7 @@

$scope.$on('annotation_panel.closed',
function () {
vm._clearGleasonSubregions();
vm.allModesOff();
}
);
Expand Down Expand Up @@ -387,6 +390,12 @@
AnnotationsViewerService.focusOnShape(shape_id);
}

function _clearGleasonSubregions() {
while($rootScope.gleason_patterns_subregions.length > 0) {
AnnotationsViewerService.deleteShape($rootScope.gleason_patterns_subregions.pop());
}
}

function canCloseAnnotation() {
// only cores annotation is mandatory
for (var x in vm.cores_edit_mode) {
Expand Down Expand Up @@ -546,6 +555,7 @@
}

function showROIPanel(roi_type, roi_id) {
vm._clearGleasonSubregions();
if (!vm.roisTreeLocked) {
var edit_mode = undefined;
switch (roi_type) {
Expand Down Expand Up @@ -3288,10 +3298,22 @@
vm.slide_id = undefined;
vm.case_id = undefined;
vm.gleason_pattern_id = undefined;
vm.shape_label = undefined;
vm.pattern_type = undefined;
vm.pattern_label = undefined;
vm.subregions = undefined;
vm.subregions_active = undefined;

vm.locked = undefined;

vm.isReadOnly = isReadOnly;
vm.destroy = destroy;
vm.subregionsExist = subregionsExist;
vm.isShapeActive = isShapeActive;
vm.selectShape = selectShape;
vm.deselectShape = deselectShape;
vm.focusOnShape = focusOnShape;
vm.switchShapeActiveState = switchShapeActiveState;

activate();

Expand All @@ -3300,17 +3322,36 @@
vm.case_id = CurrentSlideDetailsService.getCaseId();

vm.clinical_annotation_step_label = $routeParams.label;

$scope.$on('gleason_pattern.show',
function(event, gleason_pattern_id) {
vm.subregions = {};
vm.subregions_active = {};
vm.locked = false;
vm.gleason_pattern_id = gleason_pattern_id;
GleasonPatternAnnotationsManagerService.getAnnotation(vm.gleason_pattern_id)
then(getGleasonPatternSuccessFn, getGleasonPatternErrorFn);
.then(getGleasonPatternSuccessFn, getGleasonPatternErrorFn);
}
);

function getGleasonPatternSuccessFn(response) {
console.log(response);
vm.shape_label = response.data.label;
vm.pattern_type = response.data.gleason_type;
vm.pattern_label = response.data.gleason_label;
for (var s_index in response.data.subregions) {
var subr = response.data.subregions[s_index];
vm.subregions[subr.label] = {
"label": subr.label,
"area": subr.area,
"id": subr.id,
"type": $.parseJSON(subr.details_json)["type"],
"json_path": $.parseJSON(subr.roi_json)
};
vm.subregions_active[subr.label] = true;
AnnotationsViewerService.drawShape($.parseJSON(subr.roi_json));
$rootScope.gleason_patterns_subregions.push(subr.label);
}
}

function getGleasonPatternErrorFn(response) {
Expand All @@ -3323,5 +3364,52 @@
return true;
}

function destroy() {
$rootScope.$broadcast('annotation_panel.closed');
}

function subregionsExist() {
if (typeof(vm.subregions) == "undefined") {
return false;
} else {
return (Object.keys(vm.subregions).length > 0);
}
}

function isShapeActive(shape_id) {
return vm.subregions_active[shape_id];
}

function selectShape(shape_id) {
if (vm.isShapeActive(shape_id)) {
AnnotationsViewerService.selectShape(shape_id);
}
}

function deselectShape(shape_id) {
if (vm.isShapeActive(shape_id)) {
AnnotationsViewerService.deselectShape(shape_id);
}
}

function focusOnShape(shape_id) {
if (vm.isShapeActive(shape_id)) {
AnnotationsViewerService.focusOnShape(shape_id);
}
}

function switchShapeActiveState(shape_id) {
vm.subregions_active[shape_id] = !vm.subregions_active[shape_id];
if(vm.subregions_active[shape_id]) {
AnnotationsViewerService.drawShape(vm.subregions[shape_id].json_path);
vm.selectShape(shape_id);
$("#" + shape_id + "_showhide").removeClass('prm-pale-icon');
} else {
AnnotationsViewerService.deleteShape(shape_id);
vm.deselectShape(shape_id);
$("#" + shape_id + "_showhide").addClass('prm-pale-icon');
}
}

}
})();
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ <h4 class="text-right">{{ cmCtrl.shape_label }}</h4>
</div>
</div>
<!-- END OF SELECT GLEASON PATTERN TYPE -->
<!-- SHOW GLEASON PATTERN TYPE -->
<div class="form-group row" ng-show="cmCtrl.isReadOnly()">
<div class="prm-label-elem col-sm-6">
<label>Pattern Type</label>
</div>
<div class="col-sm-6 text-right">
<p>{{cmCtrl.pattern_label}}</p>
</div>
</div>
<!-- END SHOW GLEASON PATTERN TYPE -->

<!-- NEW SUBLEMENTS CREATION-->
<div class="form-group row">
Expand Down Expand Up @@ -318,8 +328,8 @@ <h4 class="text-right">{{ cmCtrl.shape_label }}</h4>
</div>
</div>
<!-- END OF NEW SUBELEMENTS CREATION -->
<!-- SUBREGIONS LIST -->
<fieldset class="promort_fieldset" ng-show="cmCtrl.subregionsExist()">
<!-- SUBREGIONS LIST - CREATION MODE-->
<fieldset class="promort_fieldset" ng-show="cmCtrl.subregionsExist() && !cmCtrl.isReadOnly()">
<legend class="prm-legend">Subregions</legend>

<div class="form-group row">
Expand All @@ -346,5 +356,33 @@ <h4 class="text-right">{{ cmCtrl.shape_label }}</h4>
</div>
</div>
</fieldset>
<!-- END OF SUBREGIONS LIST -->
<!-- END OF SUBREGIONS LIST - CREATION MODE-->
<!-- SUBREGIONS LIST - READ ONLY MODE -->
<fieldset class="promort_fieldset" ng-show="cmCtrl.subregionsExist() && cmCtrl.isReadOnly()">
<legend class="prm-legend">Subregions</legend>

<div class="form-group row">
<div class="col-sm-12 prm-row-elem" ng-repeat="(label, sub_reg) in cmCtrl.subregions">
<div class="prm-label-elem prm-valign col-sm-7">
<label> {{ sub_reg.type }}</label>
</div><!--
--><div class="prm-valign prm-form-elem text-right col-sm-5">
<button class="btn btn-default prm-icon-btn"
ng-mouseenter="cmCtrl.selectShape(label)"
ng-mouseleave="cmCtrl.deselectShape(label)"
ng-click="cmCtrl.focusOnShape(label)"
ng-disabled="!cmCtrl.isShapeActive(label)">
<i id="{{ label }}_find" class="icon-magnifying"></i>
</button>
<button class="btn btn-default prm-icon-btn"
ng-mouseenter="cmCtrl.selectShape(label)"
ng-mouseleave="cmCtrl.deselectShape(label)"
ng-click="cmCtrl.switchShapeActiveState(label)">
<i id="{{ label }}_showhide" class="icon-eye"></i>
</button>
</div>
</div>
</div>
</fieldset>
<!-- END OF SUBREGIONS LIST - READ ONLY MODE -->
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ <h4 class="text-left">ROIs list</h4>
<new-gleason-pattern-annotation-form></new-gleason-pattern-annotation-form>
<new-gleason-pattern-annotation-buttons></new-gleason-pattern-annotation-buttons>
</div>
<div ng-controller="NewScopeController as nsc" ng-show="cmc.showGleasonPatternAnnotationModeActive()">
<show-gleason-pattern-annotation-form></show-gleason-pattern-annotation-form>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 0931eda

Please sign in to comment.