diff --git a/src/ibl_to_nwb/_scripts/convert_brainwide_map_processed_only_local_testing.py b/src/ibl_to_nwb/_scripts/convert_brainwide_map_processed_only_local_testing.py index 836c8a8..6a3da46 100644 --- a/src/ibl_to_nwb/_scripts/convert_brainwide_map_processed_only_local_testing.py +++ b/src/ibl_to_nwb/_scripts/convert_brainwide_map_processed_only_local_testing.py @@ -3,16 +3,14 @@ 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, @@ -20,7 +18,6 @@ RoiMotionEnergyInterface, WheelInterface, ) - from ibl_to_nwb.testing._consistency_checks import check_written_nwbfile_for_consistency base_path = Path.home() / "ibl_scratch" # local directory @@ -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)) diff --git a/src/ibl_to_nwb/_scripts/convert_brainwide_map_raw_only_local_testing.py b/src/ibl_to_nwb/_scripts/convert_brainwide_map_raw_only_local_testing.py index 37b4751..904acdf 100644 --- a/src/ibl_to_nwb/_scripts/convert_brainwide_map_raw_only_local_testing.py +++ b/src/ibl_to_nwb/_scripts/convert_brainwide_map_raw_only_local_testing.py @@ -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 @@ -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", @@ -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) diff --git a/src/ibl_to_nwb/_scripts/download_data.py b/src/ibl_to_nwb/_scripts/download_data.py index b0e07ca..93fd184 100644 --- a/src/ibl_to_nwb/_scripts/download_data.py +++ b/src/ibl_to_nwb/_scripts/download_data.py @@ -1,5 +1,6 @@ # %% from pathlib import Path + from one.api import ONE # %% diff --git a/src/ibl_to_nwb/converters/_ibl_spikeglx_converter.py b/src/ibl_to_nwb/converters/_ibl_spikeglx_converter.py index b52c74a..a9bf223 100644 --- a/src/ibl_to_nwb/converters/_ibl_spikeglx_converter.py +++ b/src/ibl_to_nwb/converters/_ibl_spikeglx_converter.py @@ -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): diff --git a/src/ibl_to_nwb/datainterfaces/_ibl_sorting_extractor.py b/src/ibl_to_nwb/datainterfaces/_ibl_sorting_extractor.py index b698da3..c7bb03f 100644 --- a/src/ibl_to_nwb/datainterfaces/_ibl_sorting_extractor.py +++ b/src/ibl_to_nwb/datainterfaces/_ibl_sorting_extractor.py @@ -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() diff --git a/src/ibl_to_nwb/datainterfaces/_pose_estimation.py b/src/ibl_to_nwb/datainterfaces/_pose_estimation.py index 94946b7..5e0e49f 100644 --- a/src/ibl_to_nwb/datainterfaces/_pose_estimation.py +++ b/src/ibl_to_nwb/datainterfaces/_pose_estimation.py @@ -1,4 +1,3 @@ -from datetime import datetime from typing import Optional import numpy as np diff --git a/src/ibl_to_nwb/datainterfaces/_pupil_tracking.py b/src/ibl_to_nwb/datainterfaces/_pupil_tracking.py index 0477795..fb7b626 100644 --- a/src/ibl_to_nwb/datainterfaces/_pupil_tracking.py +++ b/src/ibl_to_nwb/datainterfaces/_pupil_tracking.py @@ -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"]: diff --git a/src/ibl_to_nwb/testing/_consistency_checks.py b/src/ibl_to_nwb/testing/_consistency_checks.py index 7cc6811..dc922df 100644 --- a/src/ibl_to_nwb/testing/_consistency_checks.py +++ b/src/ibl_to_nwb/testing/_consistency_checks.py @@ -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):