Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions minerva_analysis/client/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,13 @@ eventHandler.bind(ChannelList.events.CHANNELS_CHANGE, actionChannelsToRenderChan
const actionImageClickedMultiSel = (d) => {
d3.select("body").style("cursor", "progress");
// add newly clicked item to selection
if (!Array.isArray(d.item)) {
dataLayer.addToCurrentSelection(d.item, true, d.clearPriors);
updateSeaDragonSelection([d.item]);
} else {
dataLayer.addAllToCurrentSelection(d.item);
updateSeaDragonSelection(d.item);
}
const isArray = Array.isArray(d.item);
const items = isArray ? d.item : [d.item];
updateSeaDragonSelection(items);
d3.select("body").style("cursor", "default");
};
eventHandler.bind(ImageViewer.events.imageClickedMultiSel, actionImageClickedMultiSel);

/**
* Listen to Channel Select Click Events.
*
* @param sels - The selected/deselected channels
*/
const channelSelect = async (sels) => {
updateSeaDragonSelection();
let channelCells = await dataLayer.getChannelCellIds(sels);
dataLayer.addAllToCurrentSelection(channelCells);
};
eventHandler.bind(ChannelList.events.CHANNEL_SELECT, channelSelect);

/**
* Listens to and updates based on selection changes (specific for seadragon).
*
Expand All @@ -162,6 +146,7 @@ function updateSeaDragonSelection(ids = []) {
}

const handler = () => updateSeaDragonSelection();
eventHandler.bind(ChannelList.events.CHANNEL_SELECT, handler);
eventHandler.bind(CSVGatingList.events.GATING_BRUSH_END, handler);
eventHandler.bind(CSVGatingList.events.GATING_BRUSH_MOVE, handler);

Expand Down
41 changes: 0 additions & 41 deletions minerva_analysis/client/src/js/services/colorScheme.js

This file was deleted.

163 changes: 1 addition & 162 deletions minerva_analysis/client/src/js/services/dataLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class DataLayer {
this.config = config;
//all image channels
this.imageChannels = imageChannels;

this.imageBitRange = [0, 65536];
//selections
this.currentSelection = new Map();

//x,z coords
this.x = this.config["featureData"][dataSrcIndex]["xCoordinate"];
this.y = this.config["featureData"][dataSrcIndex]["yCoordinate"];
Expand All @@ -29,19 +27,6 @@ class DataLayer {
}
}

async getRow(row) {
try {
let response = await fetch('/get_database_row?' + new URLSearchParams({
row: row,
datasource: datasource
}))
let response_data = await response.json();
return response_data;
} catch (e) {
console.log("Error Getting Row", e);
}
}

async getUploadedGatingCsvValues() {
try {
let response = await fetch('/get_uploaded_gating_csv_values?' + new URLSearchParams({
Expand Down Expand Up @@ -246,19 +231,6 @@ class DataLayer {
}
}

async getColumnDistributions(columns) {
try {
let response = await fetch('/get_column_distributions?' + new URLSearchParams({
columns: columns,
datasource: datasource
}))
let distributions = await response.json();
return distributions;
} catch (e) {
console.log("Error Getting Nearest Cell", e);
}
}

async submitGatingUpload(formData) {
try {
formData.append('datasource', datasource);
Expand Down Expand Up @@ -306,38 +278,6 @@ class DataLayer {
}
}

async getGatedCellIds(filter, start_keys) {
try {
let response = await fetch('/get_gated_cell_ids?' + new URLSearchParams({
filter: JSON.stringify(filter),
start_keys: start_keys,
datasource: datasource
}))
let cellIds = await response.json();
return cellIds;
} catch (e) {
console.log("Error Getting Gated Cell Ids", e);
}
}

async getGatedCellIdsCustom(filter, start_keys) {
try {
// const start = performance.now()
let response = await fetch('/get_gated_cell_ids_custom?' + new URLSearchParams({
filter: JSON.stringify(filter),
start_keys: start_keys,
datasource: datasource
}))
let cellIds = await response.json();
// const end = performance.now()
// console.log(end - start)
// console.log(cellIds)
return cellIds;
} catch (e) {
console.log("Error Getting Gated Cell Ids", e);
}
}

async getDatabaseDescription() {
try {
let response = await fetch('/get_database_description?' + new URLSearchParams({
Expand Down Expand Up @@ -376,19 +316,6 @@ class DataLayer {
}
}

async getChannelCellIds(sels) {
try {
let response = await fetch('/get_channel_cell_ids?' + new URLSearchParams({
filter: JSON.stringify(sels),
datasource: datasource
}))
let cellIds = await response.json();
return cellIds;
} catch (e) {
console.log("Error Getting Channel Cell Ids", e);
}
}

async getChannelNames(shortNames = true) {
try {
let response = await fetch('/get_channel_names?' + new URLSearchParams({
Expand All @@ -402,19 +329,6 @@ class DataLayer {
}
}

async getColorScheme(refresh = false) {
try {
let response = await fetch('/get_color_scheme?' + new URLSearchParams({
datasource: datasource,
refresh: refresh
}))
let response_data = await response.json();
return response_data;
} catch (e) {
console.log("Error Getting Sample Row", e);
}
}

async getNearestCell(point_x, point_y) {
try {
let response = await fetch('/get_nearest_cell?' + new URLSearchParams({
Expand All @@ -429,34 +343,6 @@ class DataLayer {
}
}

async getNeighborhood(maxDistance, x, y) {
try {
let response = await fetch('/get_neighborhood?' + new URLSearchParams({
point_x: x,
point_y: y,
max_distance: maxDistance,
datasource: datasource
}))
let neighborhood = await response.json();
return neighborhood;
} catch (e) {
console.log("Error Getting Nearest Cell", e);
}
}

async getNeighborhoodForCell(maxDistance, selectedCell) {
return this.getNeighborhood(maxDistance, selectedCell[this.x], selectedCell[this.y]);
}


getCurrentSelection() {
return this.currentSelection;
}

clearCurrentSelection() {
this.currentSelection.clear();
}

getImageBitRange(float = false) {
const self = this;
if (!float) {
Expand All @@ -466,53 +352,6 @@ class DataLayer {
}
}

addToCurrentSelection(item, allowDelete, clearPriors) {

// delete item on second click
if (allowDelete && this.currentSelection.has(item)) {
this.currentSelection.delete(item);
if (clearPriors) {
this.currentSelection.clear();
}

// console.log('current selection size:', this.currentSelection.size);
if (this.currentSelection.size > 0) {
// console.log('id: ', this.currentSelection.values().next().value.id);
}
return;
}

// clear previous items
if (clearPriors) {
this.currentSelection.clear();
}

// add new item
this.currentSelection.set(item[config.featureData[0].idField], item);

// console.log('current selection size:', this.currentSelection.size);
if (this.currentSelection.size > 0) {
// console.log('id: ', this.currentSelection.values().next().value.id);
}
}


addAllToCurrentSelection(items, allowDelete, clearPriors) {
// console.log("update current selection")
var that = this;
let idField = this.config.featureData[0].idField
that.currentSelection = new Map(items.map(i => [(i[idField]), i]));
// console.log("update current selection done")
}

isImageFeature(key) {
if (this.imageChannels.hasOwnProperty(key)
&& key != 'CellId' && key != 'id' && key != 'CellID' && key != 'ID' && key != 'Area') {
return true;
}
return false;
}

getShortChannelName(fullname) {
var shortname = fullname;
this.config["imageData"].forEach(function (channel) {
Expand Down
Loading