diff --git a/src/electron/frontend/core/components/pages/Page.js b/src/electron/frontend/core/components/pages/Page.js index e883814ef..93bc5047d 100644 --- a/src/electron/frontend/core/components/pages/Page.js +++ b/src/electron/frontend/core/components/pages/Page.js @@ -185,6 +185,7 @@ export class Page extends LitElement { ...conversionOptions, // Any additional conversion options override the defaults interfaces: globalState.interfaces, + alignment, }; fileConfiguration.push(payload); diff --git a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedSourceData.js b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedSourceData.js index 7bf1029c1..4a84177ba 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedSourceData.js +++ b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedSourceData.js @@ -274,9 +274,10 @@ export class GuidedSourceDataPage extends ManagedPage { if (alignment) { globalState.project.alignment = alignment.results; this.unsavedUpdates = "conversions"; - await this.save(); } + await this.save(); + const sourceCopy = structuredClone(globalState.results[subject][session].source_data); const alignmentInfo = @@ -288,12 +289,16 @@ export class GuidedSourceDataPage extends ManagedPage { alignment: alignmentInfo, }; + console.warn("Sending", sessionInfo); + const data = await run("neuroconv/alignment", sessionInfo, { title: "Checking Alignment", message: "Please wait...", }); const { metadata } = data; + console.warn("GOT", data); + if (Object.keys(metadata).length === 0) { this.notify( `

Time Alignment Failed

Please ensure that all source data is specified.`, diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index dc9bfa63c..2e02e1640 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -751,9 +751,8 @@ def set_interface_alignment(converter: dict, alignment_info: dict) -> dict: return errors -def get_interface_alignment(info: dict) -> dict: +def get_compatible_interfaces(info: dict) -> dict: - from neuroconv.basetemporalalignmentinterface import BaseTemporalAlignmentInterface from neuroconv.datainterfaces.ecephys.baserecordingextractorinterface import ( BaseRecordingExtractorInterface, ) @@ -761,9 +760,50 @@ def get_interface_alignment(info: dict) -> dict: BaseSortingExtractorInterface, ) + converter = instantiate_custom_converter(source_data=info["source_data"], interface_class_dict=info["interfaces"]) + + compatible = {} + + for name, interface in converter.data_interface_objects.items(): + + is_sorting = isinstance(interface, BaseSortingExtractorInterface) + + if is_sorting is True: + compatible[name] = [] + + # If at least one recording and sorting interface is selected on the formats page + # Then it is possible the two could be linked (the sorting was applied to the recording) + # But there are very strict conditions from SpikeInterface determining compatibility + # Those conditions are not easily exposed so we just 'try' to register them and skip on error + sibling_recording_interfaces = { + interface_key: interface + for interface_key, interface in converter.data_interface_objects.items() + if isinstance(interface, BaseRecordingExtractorInterface) + } + + for recording_interface_key, recording_interface in sibling_recording_interfaces.items(): + try: + interface.register_recording(recording_interface=recording_interface) + compatible[name].append(recording_interface_key) + except Exception: + pass + + return compatible + + +def get_interface_alignment(info: dict) -> dict: + + from neuroconv.basetemporalalignmentinterface import BaseTemporalAlignmentInterface + from neuroconv.datainterfaces.ecephys.basesortingextractorinterface import ( + BaseSortingExtractorInterface, + ) + alignment_info = info.get("alignment", dict()) + converter = instantiate_custom_converter(source_data=info["source_data"], interface_class_dict=info["interfaces"]) + compatibility = get_compatible_interfaces(info) + errors = set_interface_alignment(converter=converter, alignment_info=alignment_info) metadata = dict() @@ -777,23 +817,7 @@ def get_interface_alignment(info: dict) -> dict: metadata[name]["sorting"] = is_sorting if is_sorting is True: - metadata[name]["compatible"] = [] - - # If at least one recording and sorting interface is selected on the formats page - # Then it is possible the two could be linked (the sorting was applied to the recording) - # But there are very strict conditions from SpikeInterface determining compatibility - # Those conditions are not easily exposed so we just 'try' to register them and skip on error - sibling_recording_interfaces = { - interface_key: interface - for interface_key, interface in converter.data_interface_objects.items() - if isinstance(interface, BaseRecordingExtractorInterface) - } - for recording_interface_key, recording_interface in sibling_recording_interfaces.items(): - try: - interface.register_recording(recording_interface=recording_interface) - metadata[name]["compatible"].append(recording_interface_key) - except Exception: - pass + metadata[name]["compatible"] = compatibility.get(name, None) if not isinstance(interface, BaseTemporalAlignmentInterface): timestamps[name] = []