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

Update Schema Handling #479

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 10 additions & 2 deletions schemas/base-metadata.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import baseMetadataSchema from './json/base_metadata_schema.json' assert { type: "json" }

baseMetadataSchema.properties.Subject.properties.weight.unit = 'kg' // Add unit to weight
export const preprocessMetadataSchema = (schema: any = baseMetadataSchema) => {

// Add unit to weight
schema.properties.Subject.properties.weight.unit = 'kg'

export default baseMetadataSchema
// Override description of keywords
schema.properties.NWBFile.properties.keywords.description = 'Terms to describe your dataset (e.g. Neural circuits, V1, etc.)' // Add description to keywords
return schema

}

export default preprocessMetadataSchema()
2 changes: 1 addition & 1 deletion schemas/json/base_metadata_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
},
"stimulus_notes": {
"type": "string",
"description": "Notes about data collection and analysis."
"description": "Notes about stimuli, such as how and where presented."
CodyCBakerPhD marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
Expand Down
74 changes: 0 additions & 74 deletions schemas/json/project/nwbfile.json

This file was deleted.

14 changes: 11 additions & 3 deletions schemas/source-data.schema.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
// import { merge } from "../src/renderer/src/stories/pages/utils"

export default function getSourceDataSchema (schema) {
// const copy = merge(schema, {})
export default function preprocessSourceDataSchema (schema) {

// Abstract across different interfaces
Object.values(schema.properties ?? {}).forEach((schema: any) => {
if (schema.properties.gain) schema.properties.gain.step = null // Do not show steps

// Do not show steps
if (schema.properties.gain) schema.properties.gain.step = null

// Add description to exclude_cluster_groups
if (schema.properties.exclude_cluster_groups) schema.properties.exclude_cluster_groups.description = 'Cluster groups to exclude (e.g. "noise" or ["noise", "mua"]).'

})


return schema
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SimpleTable } from "../../../SimpleTable.js";
import { onThrow } from "../../../../errors";
import { merge } from "../../utils.js";
import { NWBFilePreview } from "../../../preview/NWBFilePreview.js";
import { preprocessMetadataSchema } from "../../../../../../../schemas/base-metadata.schema";

const getInfoFromId = (key) => {
let [subject, session] = key.split("/");
Expand Down Expand Up @@ -106,7 +107,7 @@ export class GuidedMetadataPage extends ManagedPage {
const form = new JSONSchemaForm({
identifier: instanceId,
mode: "accordion",
schema,
schema: preprocessMetadataSchema(schema),
results,
globals: aggregateGlobalMetadata,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ManagedPage } from "./ManagedPage.js";
import { baseUrl } from "../../../../globals.js";
import { onThrow } from "../../../../errors";
import { merge } from "../../utils.js";
import getSourceDataSchema from "../../../../../../../schemas/source-data.schema";
import preprocessSourceDataSchema from "../../../../../../../schemas/source-data.schema";

export class GuidedSourceDataPage extends ManagedPage {
constructor(...args) {
Expand Down Expand Up @@ -109,12 +109,10 @@ export class GuidedSourceDataPage extends ManagedPage {
const schema = this.info.globalState.schema.source_data;
delete schema.description;

const schemaResolved = getSourceDataSchema(schema);

const form = new JSONSchemaForm({
identifier: instanceId,
mode: "accordion",
schema: schemaResolved,
schema: preprocessSourceDataSchema(schema),
results: info.source_data,
emptyMessage: "No source data required for this session.",
ignore: [
Expand Down
Loading