Skip to content

Commit

Permalink
Merge branch 'main' into backend-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Jun 4, 2024
2 parents d6a05ac + 1057450 commit 8e7c997
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<p align="center">
<a href="https://github.com/NeurodataWithoutBorders/nwb-guide/actions/workflows/build_and_deploy_mac.yml"><img src="https://github.com/NeurodataWithoutBorders/nwb-guide/actions/workflows/build_and_deploy_mac.yml/badge.svg" alt="Mac Build"></a>
<a href="https://github.com/NeurodataWithoutBorders/nwb-guide/actions/workflows/build_and_deploy_win.yml"><img src="https://github.com/NeurodataWithoutBorders/nwb-guide/actions/workflows/build_and_deploy_win.yml/badge.svg" alt="Windows Build"></a>
<a href="https://img.shields.io/github/downloads/neurodatawithoutborders/nwb-guide/total.svg"><img src="https://img.shields.io/github/downloads/neurodatawithoutborders/nwb-guide/total.svg" alt="Downloads"></a>
</p>
<p align="center">
<a href="https://github.com/psf/black"><img alt="Python code style: black" src="https://img.shields.io/badge/python_code_style-black-000000.svg"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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(
`<h4 style="margin: 0">Time Alignment Failed</h4><small>Please ensure that all source data is specified.</small>`,
Expand Down
62 changes: 43 additions & 19 deletions src/pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,19 +754,59 @@ 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,
)
from neuroconv.datainterfaces.ecephys.basesortingextractorinterface import (
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()
Expand All @@ -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] = []
Expand Down

0 comments on commit 8e7c997

Please sign in to comment.