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

Electrode helper functions #603

Merged
merged 31 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
515c589
add some draft electrode helpers
CodyCBakerPhD Feb 7, 2024
4c83d50
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 7, 2024
cb1340b
Updated to allow visualization on the frontend. Has commented out cod…
garrettmflynn Feb 9, 2024
f5186fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 9, 2024
e3ffee8
Merge branch 'ephys-metadata-v2' into electrode_helpers
CodyCBakerPhD Feb 12, 2024
0341f94
Merge branch 'ephys-metadata-v2' into electrode_helpers
CodyCBakerPhD Feb 12, 2024
e39ccd7
Generalized handler substantially
garrettmflynn Feb 12, 2024
1060fd9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 12, 2024
b3a9922
Merge branch 'ephys-metadata-v2' into electrode_helpers
CodyCBakerPhD Feb 21, 2024
d2c9ec7
Merge branch 'ephys-metadata-v2' into electrode_helpers
CodyCBakerPhD Feb 28, 2024
eae9aa4
unpack contact vector
Feb 28, 2024
d421849
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
4245327
Add option to set DANDI_CACHE environment variable to "ignore" (#623)
garrettmflynn Feb 29, 2024
8e0589b
Version bump (#631)
CodyCBakerPhD Feb 29, 2024
58d0699
Propertly unfold dtypes in contact_vector, but provide original info …
garrettmflynn Feb 29, 2024
66b0262
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 29, 2024
6476d0d
ignore contact_vector
Mar 3, 2024
c23d6c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2024
7e1fdf8
Clean up property exclusion and commented future code
garrettmflynn Mar 4, 2024
7b6ad13
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 4, 2024
f671e9d
Ignore contact shapes
garrettmflynn Mar 4, 2024
9dbac92
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 4, 2024
86a5e9d
Fix validation and auto-update group name changes
garrettmflynn Mar 5, 2024
340bc04
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2024
3be6a6d
Merge branch 'main' into electrode_helpers
garrettmflynn Mar 5, 2024
83a45a0
Merge branch 'electrode_helpers' of https://github.com/NeurodataWitho…
garrettmflynn Mar 5, 2024
4dbb245
Catch invalid columns in the electrode table
garrettmflynn Mar 5, 2024
4ddadf2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2024
922b17f
Fix validation for electrode columns and electrodes
garrettmflynn Mar 6, 2024
63bfe4d
Merge branch 'electrode_helpers' of https://github.com/NeurodataWitho…
garrettmflynn Mar 6, 2024
018c244
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 6, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ src/build
.env
.env.local
.env.production

# Spyder
.spyproject/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nwb-guide",
"productName": "NWB GUIDE",
"version": "0.0.14",
"version": "0.0.15",
"description": "NWB GUIDE is a desktop app that provides a no-code user interface for converting neurophysiology data to NWB.",
"main": "./build/main/main.js",
"engine": {
Expand Down
278 changes: 236 additions & 42 deletions pyflask/manageNeuroconv/manage_neuroconv.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion schemas/base-metadata.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ export const preprocessMetadataSchema = (schema: any = baseMetadataSchema, globa
// Change rendering order for electrode table columns
const electrodesProp = ecephys.properties["Electrodes"]
for (let name in electrodesProp.properties) {
electrodesProp.properties[name].items.order = ["channel_name", "group_name", "shank_electrode_number"];
const interfaceProps = electrodesProp.properties[name].properties
interfaceProps["Electrodes"].items.order = ["channel_name", "group_name", "shank_electrode_number"];
interfaceProps["ElectrodeColumns"].items.order = ["name", "description", "data_type"];

}

}
Expand Down
8 changes: 7 additions & 1 deletion schemas/json/dandi/upload.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
"min": 1,
"default": 1
},
"ignore_cache": {
"type": "boolean",
"description": "Ignore the cache used by DANDI to speed up repeated operations.",
"default": false
},
"cleanup": {
"type": "boolean",
"title": "Delete Local Files After Upload",
"title": "Cleanup Local Filesystem",
"description": "Delete local files after upload",
"default": false
}
}
Expand Down
63 changes: 49 additions & 14 deletions src/renderer/src/stories/BasicTable.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { LitElement, css, html } from "lit";
import { LitElement, css, html, unsafeCSS } from "lit";
import { styleMap } from "lit/directives/style-map.js";
import { header } from "./forms/utils";
import { checkStatus } from "../validation";
import { errorHue, warningHue } from "./globals";
import { emojiFontFamily, errorHue, warningHue } from "./globals";

import * as promises from "../promises";

import "./Button";
import { sortTable } from "./Table";
import tippy from "tippy.js";
import { getIgnore } from "./JSONSchemaForm";

export class BasicTable extends LitElement {
static get styles() {
Expand Down Expand Up @@ -65,6 +66,12 @@ export class BasicTable extends LitElement {
user-select: none;
}

.relative .info {
margin: 0px 5px;
font-size: 80%;
font-family: ${unsafeCSS(emojiFontFamily)};
}

th span {
display: inline-block;
}
Expand Down Expand Up @@ -159,8 +166,28 @@ export class BasicTable extends LitElement {
};

#renderHeader = (str, { description }) => {
if (description) return html`<th title="${description}">${this.#renderHeaderContent(str)}</th>`;
return html`<th>${this.#renderHeaderContent(str)}</th>`;
const th = document.createElement("th");

const required = this.#itemSchema.required ? this.#itemSchema.required.includes(str) : false;
const container = document.createElement("div");
container.classList.add("relative");
const span = document.createElement("span");
span.textContent = header(str);
if (required) span.setAttribute("required", "");
container.appendChild(span);

// Add Description Tooltip
if (description) {
const span = document.createElement("span");
span.classList.add("info");
span.innerText = "ℹ️";
container.append(span);
tippy(span, { content: `${description[0].toUpperCase() + description.slice(1)}`, allowHTML: true });
}

th.appendChild(container);

return th;
};

#getRowData(row, cols = this.colHeaders) {
Expand All @@ -169,13 +196,12 @@ export class BasicTable extends LitElement {
let value;
if (col === this.keyColumn) {
if (hasRow) value = row;
else return "";
else return;
} else
value =
(hasRow ? this.data[row][col] : undefined) ??
// this.globals[col] ??
this.#itemSchema.properties[col].default ??
"";
this.#itemSchema.properties[col]?.default;
return value;
});
}
Expand Down Expand Up @@ -210,7 +236,7 @@ export class BasicTable extends LitElement {
onStatusChange = () => {};
onLoaded = () => {};

#validateCell = (value, col, parent) => {
#validateCell = (value, col, row, parent) => {
if (!value && !this.validateEmptyCells) return true; // Empty cells are valid
if (!this.validateOnChange) return true;

Expand Down Expand Up @@ -243,11 +269,12 @@ export class BasicTable extends LitElement {
else if (value !== "" && type && inferredType !== type) {
result = [{ message: `${col} is expected to be of type ${ogType}, not ${inferredType}`, type: "error" }];
}

// Otherwise validate using the specified onChange function
else result = this.validateOnChange(col, parent, value, this.#itemProps[col]);
else result = this.validateOnChange([row, col], parent, value, this.#itemProps[col]);

// Will run synchronously if not a promise result
return promises.resolve(result, () => {
return promises.resolve(result, (result) => {
let info = {
title: undefined,
warning: undefined,
Expand Down Expand Up @@ -278,7 +305,7 @@ export class BasicTable extends LitElement {

const results = this.#data.map((v, i) => {
return v.map((vv, j) => {
const info = this.#validateCell(vv, this.colHeaders[j], { ...this.data[rows[i]] }); // Could be a promise or a basic response
const info = this.#validateCell(vv, this.colHeaders[j], i, { ...this.data[rows[i]] }); // Could be a promise or a basic response
return promises.resolve(info, (info) => {
if (info === true) return;
const td = this.shadowRoot.getElementById(`i${i}_j${j}`);
Expand Down Expand Up @@ -367,9 +394,11 @@ export class BasicTable extends LitElement {
render() {
this.#updateRendered();

this.schema = this.schema; // Always update the schema

console.warn("RERENDERING");

const entries = this.#itemProps;
for (let key in this.ignore) delete entries[key];
for (let key in this.ignore["*"] ?? {}) delete entries[key];

// Add existing additional properties to the entries variable if necessary
if (this.#itemSchema.additionalProperties) {
Expand All @@ -385,6 +414,10 @@ export class BasicTable extends LitElement {
}, entries);
}

// Ignore any additions in the ignore configuration
for (let key in this.ignore) delete entries[key];
for (let key in this.ignore["*"] ?? {}) delete entries[key];

// Sort Columns by Key Column and Requirement
const keys =
(this.#keys =
Expand Down Expand Up @@ -419,7 +452,9 @@ export class BasicTable extends LitElement {
${data.map(
(row, i) =>
html`<tr>
${row.map((col, j) => html`<td id="i${i}_j${j}"><div>${col}</div></td>`)}
${row.map(
(col, j) => html`<td id="i${i}_j${j}"><div>${JSON.stringify(col)}</div></td>`
)}
</tr>`
)}
</tbody>
Expand Down
Loading
Loading