From bcf39e417b1fc0043b1548ff315e4bf0d5beb121 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Wed, 3 Apr 2024 12:50:01 -0700 Subject: [PATCH 1/2] Render empty subject if not locating data with multiple sessions --- pyflask/manageNeuroconv/manage_neuroconv.py | 2 + .../guided-mode/data/GuidedPathExpansion.js | 45 +++++++++++-------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/pyflask/manageNeuroconv/manage_neuroconv.py b/pyflask/manageNeuroconv/manage_neuroconv.py index e1ffbf67a..79c6f781b 100644 --- a/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/pyflask/manageNeuroconv/manage_neuroconv.py @@ -1230,6 +1230,8 @@ def get_unit_table_json(interface) -> List[Dict[str, Any]]: unit_column = dict() for property_name in properties: + + # Separate this so that unit_id and unit_name exist (LOOK FURTHER) if property_name == "unit_name": sorting_property_value = str(unit_id) # Insert unit_id as name (str) elif property_name in SORTING_INTERFACE_PROPERTY_OVERRIDES: diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js index dc5d5fbe4..edf3913ae 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -274,7 +274,7 @@ export class GuidedPathExpansionPage extends Page { // Force single subject/session if not keeping existing data // if (!globalState.results) { - const subject_id = this.workflow.subject_id.value; + const subject_id = this.workflow.subject_id.value; const session_id = this.workflow.session_id.value; // Map existing results to new subject information (if available) @@ -289,24 +289,33 @@ export class GuidedPathExpansionPage extends Page { if (existing) source_data[key] = existing ?? {}; } - globalState.results = { - [subject_id]: { - [session_id]: { - source_data, - metadata: { - NWBFile: { - session_id: session_id, - ...(existingMetadata?.NWBFile ?? {}), - }, - Subject: { - subject_id: subject_id, - ...(existingMetadata?.Subject ?? {}), - }, + const sub_id = subject_id ?? '' + const ses_id = session_id ?? '' + + // Skip if results already exist without manual IDs + if ((!subject_id || !session_id) && globalState.results) return + + // Otherwise reset the results to the new subject/session + else { + globalState.results = {} + + globalState.results[sub_id] = {} + + globalState.results[sub_id][ses_id] = { + source_data, + metadata: { + NWBFile: { + session_id: ses_id, + ...(existingMetadata?.NWBFile ?? {}), }, - }, - }, - }; - // } + Subject: { + subject_id: sub_id, + ...(existingMetadata?.Subject ?? {}), + }, + } + }; + + } this.save({}, false); // Ensure this structure is saved }, From 7ebe046ca403e3ba353b31417dc5e80d7fedb043 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:51:31 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../guided-mode/data/GuidedPathExpansion.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js index edf3913ae..74e1103c1 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -274,7 +274,7 @@ export class GuidedPathExpansionPage extends Page { // Force single subject/session if not keeping existing data // if (!globalState.results) { - const subject_id = this.workflow.subject_id.value; + const subject_id = this.workflow.subject_id.value; const session_id = this.workflow.session_id.value; // Map existing results to new subject information (if available) @@ -289,18 +289,17 @@ export class GuidedPathExpansionPage extends Page { if (existing) source_data[key] = existing ?? {}; } - const sub_id = subject_id ?? '' - const ses_id = session_id ?? '' + const sub_id = subject_id ?? ""; + const ses_id = session_id ?? ""; // Skip if results already exist without manual IDs - if ((!subject_id || !session_id) && globalState.results) return - + if ((!subject_id || !session_id) && globalState.results) return; // Otherwise reset the results to the new subject/session else { - globalState.results = {} + globalState.results = {}; + + globalState.results[sub_id] = {}; - globalState.results[sub_id] = {} - globalState.results[sub_id][ses_id] = { source_data, metadata: { @@ -312,9 +311,8 @@ export class GuidedPathExpansionPage extends Page { subject_id: sub_id, ...(existingMetadata?.Subject ?? {}), }, - } + }, }; - } this.save({}, false); // Ensure this structure is saved