Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/gating'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 6, 2023
2 parents 184ac72 + b56b78f commit d4c963f
Show file tree
Hide file tree
Showing 11 changed files with 777 additions and 91 deletions.
22 changes: 22 additions & 0 deletions minerva_analysis/client/src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,25 @@ label {

.col-svg-wrapper {
}

.lasso_selection_toggle {
float: right;
margin-left: auto;
margin-top: 3px;
margin-right: 20px;
color: orange;
}

.lasso_polygon {
fill-opacity: 0;
stroke: orange;
stroke-width: 3px;
vector-effect: non-scaling-stroke;
}

.btn_lasso_delete {
float: right;
padding-top: 0;
padding-bottom: 0;
border: 1px;
}
13 changes: 12 additions & 1 deletion minerva_analysis/client/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function init(config) {

//Create image viewer
const imageArgs = [imgMetadata, numericData, eventHandler];
const seaDragonViewer = new ImageViewer(config, ...imageArgs);
const seaDragonViewer = new ImageViewer(config, dataLayer, ...imageArgs);
const viewerManager = new ViewerManager(seaDragonViewer, channelList);

//Initialize with database description
Expand Down Expand Up @@ -166,12 +166,23 @@ async function init(config) {
seaDragonViewer.forceRepaint();
}

/**
* Add picked cell ids from lasso selection
*/
const imageLassoSel = (d) => {
updateSeaDragonSelection(d);
csv_gatingList.updateGMM(d['picked']);
};
eventHandler.bind(ImageViewer.events.imageLassoSel, imageLassoSel);

/**
* Remove currently selected picked cell ids
*/
function clearSeaDragonSelection() {
updateSeaDragonSelection({ picked: [] });
csv_gatingList.updateGMM([]);
}
eventHandler.bind(ImageViewer.events.clearImageLasso, clearSeaDragonSelection);

const handler = () => updateSeaDragonSelection();
eventHandler.bind(CSVGatingList.events.GATING_BRUSH_END, handler);
Expand Down
85 changes: 76 additions & 9 deletions minerva_analysis/client/src/js/services/dataLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class DataLayer {
}
}

downloadGatingCSV(channels, selections, fullCsv = false) {
downloadGatingCSV(channels, selections, lassos, selection_ids, fullCsv = false) {
let form = document.createElement("form");
form.action = "/download_gating_csv";

Expand Down Expand Up @@ -133,17 +133,29 @@ class DataLayer {
channelsElement.name = "channels";
form.appendChild(channelsElement);

let lassosElement = document.createElement("input");
lassosElement.type = "hidden";
lassosElement.value = JSON.stringify(lassos);
lassosElement.name = "lassos";
form.appendChild(lassosElement);

let idsElement = document.createElement("input");
idsElement.type = "hidden";
idsElement.value = JSON.stringify(selection_ids);
idsElement.name = "selection_ids";
form.appendChild(idsElement);

let datasourceElement = document.createElement("input");
datasourceElement.type = "hidden";
datasourceElement.value = datasource;
datasourceElement.name = "datasource";
form.appendChild(datasourceElement);

document.body.appendChild(form);
form.submit()

}

async saveGatingList(channels, selections) {
async saveGatingList(channels, selections, lassos) {
const self = this;
try {
let response = await fetch('/save_gating_list', {
Expand All @@ -156,7 +168,8 @@ class DataLayer {
{
datasource: datasource,
filter: selections,
channels: channels
channels: channels,
lassos: lassos
}
)
});
Expand Down Expand Up @@ -363,12 +376,22 @@ class DataLayer {
}
}

async getGatingGMM(channel) {
async getGatingGMM(channel, selection_ids) {
try {
let response = await fetch('/get_gating_gmm?' + new URLSearchParams({
channel: channel,
datasource: datasource
}))
let response = await fetch('/get_gating_gmm', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(
{
channel: channel,
datasource: datasource,
selection_ids: selection_ids
}
)
});
let packet_gmm = await response.json();
return packet_gmm;
} catch (e) {
Expand Down Expand Up @@ -557,4 +580,48 @@ class DataLayer {
return false;
}

async getCellsInPolygon(points) {
try {
let response = await fetch('/get_cells_in_polygon', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(
{
datasource: datasource,
points: points,
}
)
});
let cells = await response.json();
return cells;
} catch (e) {
console.log("Error Getting Polygon Cells", e);
}
}

async getCellsInLassos(list_lassos) {
try {
let response = await fetch('/get_cells_in_lassos', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(
{
datasource: datasource,
list_lassos: list_lassos,
}
)
});
let cells = await response.json();
return cells;
} catch (e) {
console.log("Error Getting Cells in Lassos", e);
}
}

}
Loading

0 comments on commit d4c963f

Please sign in to comment.