Skip to content

Commit

Permalink
Merge branch 'main' into bruker-single-converter
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Oct 31, 2023
2 parents 94e668e + 4815403 commit 5e1b58e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 85 deletions.
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."
}
}
},
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

0 comments on commit 5e1b58e

Please sign in to comment.