diff --git a/README.md b/README.md index ded324f2f..fa1896157 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@

Mac Build Windows Build + Downloads

Python code style: black 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 f29239361..15d47df9c 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 @@ -269,9 +269,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 = @@ -283,12 +284,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 6cfdbfaf0..763322aa0 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -754,9 +754,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, ) @@ -764,9 +763,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() @@ -780,23 +820,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] = []