Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 11, 2024
1 parent 58ccd21 commit 5e17eec
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
os.environ["JUPYTER_PLATFORM_DIRS"] = "1" # Annoying

import os

from pathlib import Path
from shutil import rmtree

from one.api import ONE

from ibl_to_nwb.converters import BrainwideMapConverter, IblSpikeGlxConverter
from ibl_to_nwb.converters import BrainwideMapConverter
from ibl_to_nwb.datainterfaces import (
BrainwideMapTrialsInterface,
)
from ibl_to_nwb.datainterfaces import (
IblPoseEstimationInterface,
IblSortingInterface,
LickInterface,
PupilTrackingInterface,
RoiMotionEnergyInterface,
WheelInterface,
)

from ibl_to_nwb.testing._consistency_checks import check_written_nwbfile_for_consistency

base_path = Path.home() / "ibl_scratch" # local directory
Expand Down Expand Up @@ -66,12 +63,16 @@
pupil_tracking_files = session_one.list_datasets(eid=session, filename="*features*")
for pupil_tracking_file in pupil_tracking_files:
camera_name = pupil_tracking_file.replace("alf/_ibl_", "").replace(".features.pqt", "")
data_interfaces.append(PupilTrackingInterface(one=session_one, session=session, camera_name=camera_name, revision=revision))
data_interfaces.append(
PupilTrackingInterface(one=session_one, session=session, camera_name=camera_name, revision=revision)
)

roi_motion_energy_files = session_one.list_datasets(eid=session, filename="*ROIMotionEnergy.npy*")
for roi_motion_energy_file in roi_motion_energy_files:
camera_name = roi_motion_energy_file.replace("alf/", "").replace(".ROIMotionEnergy.npy", "")
data_interfaces.append(RoiMotionEnergyInterface(one=session_one, session=session, camera_name=camera_name, revision=revision))
data_interfaces.append(
RoiMotionEnergyInterface(one=session_one, session=session, camera_name=camera_name, revision=revision)
)

if session_one.list_datasets(eid=session, collection="alf", filename="licks*"):
data_interfaces.append(LickInterface(one=session_one, session=session, revision=revision))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# %%
from pathlib import Path

from one.api import ONE

from ibl_to_nwb.converters import BrainwideMapConverter, IblSpikeGlxConverter
from ibl_to_nwb.datainterfaces import RawVideoInterface

Expand All @@ -15,7 +17,7 @@
nwbfiles_folder_path.mkdir(exist_ok=True)

# Initialize IBL (ONE) client to download processed data for this session
one_cache_folder_path = base_path / 'ibl_conversion' / eid / 'cache'
one_cache_folder_path = base_path / "ibl_conversion" / eid / "cache"
one = ONE(
base_url="https://openalyx.internationalbrainlab.org",
password="international",
Expand All @@ -27,7 +29,7 @@

# %% ephys
session_folder = one.eid2path(eid)
spikeglx_source_folder_path = session_folder / 'raw_ephys_data'
spikeglx_source_folder_path = session_folder / "raw_ephys_data"

# Specify the path to the SpikeGLX files on the server but use ONE API for timestamps
spikeglx_subconverter = IblSpikeGlxConverter(folder_path=spikeglx_source_folder_path, one=one, eid=eid)
Expand Down
1 change: 1 addition & 0 deletions src/ibl_to_nwb/_scripts/download_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# %%
from pathlib import Path

from one.api import ONE

# %%
Expand Down
4 changes: 2 additions & 2 deletions src/ibl_to_nwb/converters/_ibl_spikeglx_converter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
from brainbox.io.one import EphysSessionLoader, SpikeSortingLoader
from neuroconv.converters import SpikeGLXConverterPipe
from one.api import ONE
from pydantic import DirectoryPath
from pynwb import NWBFile
import numpy as np
from brainbox.io.one import SpikeSortingLoader, EphysSessionLoader


class IblSpikeGlxConverter(SpikeGLXConverterPipe):
Expand Down
2 changes: 1 addition & 1 deletion src/ibl_to_nwb/datainterfaces/_ibl_sorting_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, session: str, cache_folder: Optional[DirectoryPath] = None, r
silent=True,
cache_dir=cache_folder,
)
if revision is None: # latest
if revision is None: # latest
revision = one.list_revisions(session)[-1]

atlas = AllenAtlas()
Expand Down
1 change: 0 additions & 1 deletion src/ibl_to_nwb/datainterfaces/_pose_estimation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from datetime import datetime
from typing import Optional

import numpy as np
Expand Down
4 changes: 3 additions & 1 deletion src/ibl_to_nwb/datainterfaces/_pupil_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def get_metadata(self) -> dict:
def add_to_nwbfile(self, nwbfile, metadata: dict):
left_or_right = self.camera_name[:5].rstrip("C")

camera_data = self.one.load_object(id=self.session, obj=self.camera_name, collection="alf", revision=self.revision)
camera_data = self.one.load_object(
id=self.session, obj=self.camera_name, collection="alf", revision=self.revision
)

pupil_time_series = list()
for ibl_key in ["pupilDiameter_raw", "pupilDiameter_smooth"]:
Expand Down
2 changes: 1 addition & 1 deletion src/ibl_to_nwb/testing/_consistency_checks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path

import numpy as np
from brainbox.io.one import SpikeSortingLoader
from numpy.testing import assert_array_equal, assert_array_less
from one.api import ONE
from pandas.testing import assert_frame_equal
from pynwb import NWBHDF5IO, NWBFile
from brainbox.io.one import SpikeSortingLoader


def check_written_nwbfile_for_consistency(*, one: ONE, nwbfile_path: Path):
Expand Down

0 comments on commit 5e17eec

Please sign in to comment.