Skip to content

Commit

Permalink
LIMS-140: Fix pia_estimated_d_min display on VMXi grid scans (#678)
Browse files Browse the repository at this point in the history
* LIMS-140: Fix pia_estimated_d_min display on VMXi grid scans

* LIMS-140: Clear up inverting of data

* Apply suggestions from code review

Co-authored-by: Guilherme Francisco <[email protected]>

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2023
1 parent 269cd3d commit 81fa9c0
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions client/src/js/modules/dc/views/gridplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ define(['jquery', 'marionette',
this.statusesLoaded = false
this.listenTo(options.imagestatuses, 'sync', this.setStatues, this)
this.noHeatMapResult = []
this.invertHeatMap = false

this._ready = []

Expand Down Expand Up @@ -130,6 +131,8 @@ define(['jquery', 'marionette',

loadAttachment: function() {
var a = this.attachments.findWhere({ 'DATACOLLECTIONFILEATTACHMENTID': this.ui.ty2.val() })
var selectedOption = this.ui.ty2.find('option:selected').text()
this.invertHeatMap = selectedOption === 'pia_estimated_d_min'
if (a) {
if (!a.get('DATA')) {
var self = this
Expand Down Expand Up @@ -411,12 +414,15 @@ define(['jquery', 'marionette',

if (d.length > 0) {
let max = 0
let power = this.invertHeatMap ? -1 : 1
let val = 0
_.each(d, function(v) {
if (v[1] > max) max = v[1]
val = Math.pow(v[1], power)
if (val > max) max = val
})

max = max === 0 ? 1 : max
if (this.getOption('padMax') && max < 10) max = max * 50
if (this.getOption('padMax') && max < 10 && !this.invertHeatMap) max = max * 50

var sw = (this.perceivedw-(this.offset_w*this.scale))/this.grid.get('STEPS_X')
var sh = (this.perceivedh-(this.offset_h*this.scale))/this.grid.get('STEPS_Y')
Expand All @@ -427,6 +433,7 @@ define(['jquery', 'marionette',
var data = []
_.each(d, function(v) {
var k = v[0] - 1
val = Math.pow(v[1], power)

// Account for vertical grid scans
let xstep, ystep, x, y
Expand Down Expand Up @@ -454,7 +461,10 @@ define(['jquery', 'marionette',
}

// Dont zero values < 1 if data is scaled to max==1
data.push({ x: x, y: y, value: v[1] < 1 && max > 1 ? 0 : v[1],
data.push({
x: x,
y: y,
value: val < 1 && max > 1 ? 0 : val,
radius: radius
})

Expand Down Expand Up @@ -514,7 +524,16 @@ define(['jquery', 'marionette',

_getVal: function(pos) {
var val = null
const d = Number(this.ui.ty.val()) > -1 ? this.distl.get('data')[Number(this.ui.ty.val())] : []
let d = []
if (this.ui.ty.is(":visible")) {
d = Number(this.ui.ty.val()) > -1 ? this.distl.get('data')[Number(this.ui.ty.val())] : []
}
if (this.ui.ty2.is(":visible")) {
let a = this.attachments.findWhere({ 'DATACOLLECTIONFILEATTACHMENTID': this.ui.ty2.val() })
if (a && a.get('DATA')) {
d = a.get('DATA')
}
}
_.each(d, function(v) {
// 1 indexed array
if (v[0] === pos+1) {
Expand Down

0 comments on commit 81fa9c0

Please sign in to comment.