Skip to content

Commit

Permalink
one instantiation removed in IblSortingInterface, but requires hack i…
Browse files Browse the repository at this point in the history
…n neuroconv
  • Loading branch information
grg2rsr committed Dec 18, 2024
1 parent b640ee6 commit 45cbaca
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
data_interfaces = list()

# These interfaces should always be present in source data
# data_interfaces.append(IblSortingInterface(session=eid, cache_folder=one_cache_folder_path / "sorting", revision=revision))

data_interfaces.append(IblSortingInterface(one=one, session=eid, revision=revision))
data_interfaces.append(BrainwideMapTrialsInterface(one=one, session=eid, revision=revision))
data_interfaces.append(WheelInterface(one=one, session=eid, revision=revision))
Expand Down Expand Up @@ -88,11 +86,6 @@
metadata=metadata,
overwrite=True,
)
# automatic_dandi_upload(
# dandiset_id="000409",
# nwb_folder_path=nwbfile_path.parent,
# cleanup=cleanup,
# )

# if cleanup:
# rmtree(cache_folder)
Expand Down
2 changes: 2 additions & 0 deletions src/ibl_to_nwb/_scripts/convert_brainwide_map_raw_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
data_interfaces = []

# spikeglx_source_folder_path = Path("D:/example_data/ephy_testing_data/spikeglx/Noise4Sam_g0")
session_folder = ibl_client.eid2path(session_id)
spikeglx_source_folder_path = session_folder / "raw_ephys_data"
spikeglx_subconverter = IblSpikeGlxConverter(folder_path=spikeglx_source_folder_path, one=ibl_client)
data_interfaces.append(spikeglx_subconverter)

Expand Down
13 changes: 3 additions & 10 deletions src/ibl_to_nwb/converters/_ibl_spikeglx_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class IblSpikeGlxConverter(SpikeGLXConverterPipe):
def __init__(self, folder_path: DirectoryPath, one: ONE, eid: str) -> None:
super().__init__(folder_path=folder_path)
self.one = one
self.eid = eid # probably should better name this session_id ?
self.eid = eid

def temporally_align_data_interfaces(self) -> None:
"""Align the raw data timestamps to the other data streams using the ONE API."""
Expand All @@ -22,21 +22,14 @@ def temporally_align_data_interfaces(self) -> None:
}

ephys_session_loader = EphysSessionLoader(one=self.one, eid=self.eid)
probes = ephys_session_loader.probes
for probe_name, pid in ephys_session_loader.probes.items():
spike_sorting_loader = SpikeSortingLoader(pid=pid, one=self.one)

probe_index = probe_to_imec_map[probe_name]
for band in ["ap", "lf"]:
recording_interface = self.data_interface_objects[f"imec{probe_index}.{band}"]
# recording_interface = next(
# interface
# for interface in self.data_interface_objects
# if f"imec{probe_index}.{band}" in interface.source_data["file_path"]
# )

band_info = spike_sorting_loader.raw_electrophysiology(band=band, stream=True)
aligned_timestamps = spike_sorting_loader.samples2times(np.arange(0, band_info.ns), direction="forward")
sl = spike_sorting_loader.raw_electrophysiology(band=band, stream=True)
aligned_timestamps = spike_sorting_loader.samples2times(np.arange(0, sl.ns), direction="forward")
recording_interface.set_aligned_timestamps(aligned_timestamps=aligned_timestamps)
pass

Expand Down
2 changes: 1 addition & 1 deletion src/ibl_to_nwb/datainterfaces/_brainwide_map_trials.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pathlib import Path
from typing import Optional

from brainbox.io.one import SessionLoader
from hdmf.common import VectorData
from neuroconv.basedatainterface import BaseDataInterface
from neuroconv.utils import load_dict_from_file
from one.api import ONE
from pynwb import NWBFile
from pynwb.epoch import TimeIntervals
from brainbox.io.one import SessionLoader


class BrainwideMapTrialsInterface(BaseDataInterface):
Expand Down
12 changes: 3 additions & 9 deletions src/ibl_to_nwb/datainterfaces/_ibl_sorting_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import numpy as np
import pandas as pd
from pydantic import DirectoryPath
from spikeinterface import BaseSorting, BaseSortingSegment
from one.api import ONE
from brainbox.io.one import SpikeSortingLoader
from iblatlas.atlas import AllenAtlas
from iblatlas.regions import BrainRegions
from one.api import ONE
from pydantic import DirectoryPath
from spikeinterface import BaseSorting, BaseSortingSegment


class IblSortingExtractor(BaseSorting):
Expand All @@ -27,12 +27,6 @@ def __init__(
session: str,
revision: Optional[str] = None,
):
# one = ONE(
# base_url="https://openalyx.internationalbrainlab.org",
# password="international",
# silent=True,
# cache_dir=cache_folder,
# )
if revision is None: # latest
revision = one.list_revisions(session)[-1]

Expand Down
12 changes: 4 additions & 8 deletions src/ibl_to_nwb/datainterfaces/_ibl_sorting_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,21 @@
BaseSortingExtractorInterface,
)
from neuroconv.utils import load_dict_from_file
from pydantic import DirectoryPath
from one.api import ONE

from ._ibl_sorting_extractor import IblSortingExtractor
from one.api import ONE


class IblSortingInterface(BaseSortingExtractorInterface):
Extractor = IblSortingExtractor

def __init__(
self,
one: ONE,
session: str,
# cache_folder: Optional[DirectoryPath] = None,
one: ONE,
revision: Optional[str] = None,
# verbose: bool = False,
):
# super().__init__(verbose, session=session, cache_folder=cache_folder, revision=revision)
super().__init__(one=one, session=session, revision=revision)
super().__init__(session=session, one=one, revision=revision)

def get_metadata(self) -> dict:
metadata = super().get_metadata()
Expand All @@ -40,4 +37,3 @@ def get_metadata(self) -> dict:
)

return metadata

2 changes: 1 addition & 1 deletion src/ibl_to_nwb/datainterfaces/_lick_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from one.api import ONE
from pynwb import NWBFile
from pynwb.file import DynamicTable
from brainbox.io.one import SessionLoader


class LickInterface(BaseDataInterface):
def __init__(self, one: ONE, session: str, revision: Optional[str] = None):
Expand Down
3 changes: 2 additions & 1 deletion src/ibl_to_nwb/datainterfaces/_pupil_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from typing import Optional

import numpy as np
from brainbox.io.one import SessionLoader
from neuroconv.basedatainterface import BaseDataInterface
from neuroconv.tools.nwb_helpers import get_module
from neuroconv.utils import load_dict_from_file
from one.api import ONE
from pynwb import TimeSeries
from pynwb.behavior import PupilTracking
from brainbox.io.one import SessionLoader


class PupilTrackingInterface(BaseDataInterface):
def __init__(self, one: ONE, session: str, camera_name: str, revision: Optional[str] = None):
Expand Down
3 changes: 2 additions & 1 deletion src/ibl_to_nwb/datainterfaces/_wheel_movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from typing import Optional

from brainbox.behavior import wheel as wheel_methods
from brainbox.io.one import SessionLoader
from neuroconv.basedatainterface import BaseDataInterface
from neuroconv.tools.nwb_helpers import get_module
from neuroconv.utils import load_dict_from_file
from one.api import ONE
from pynwb import TimeSeries
from pynwb.behavior import CompassDirection, SpatialSeries
from pynwb.epoch import TimeIntervals
from brainbox.io.one import SessionLoader


class WheelInterface(BaseDataInterface):
def __init__(self, one: ONE, session: str, revision: Optional[str] = None):
Expand Down

0 comments on commit 45cbaca

Please sign in to comment.