Skip to content

Commit

Permalink
skip video if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Dec 14, 2023
1 parent 986c3b8 commit 7725def
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Base class for converting raw video data."""
from pynwb import NWBFile
from datetime import datetime
from pytz import timezone
import h5py
from pathlib import Path

import numpy as np
import pandas as pd
from pynwb import NWBFile
from neuroconv.datainterfaces import VideoInterface

from .basedattainterface import BaseDattaInterface
from .utils import convert_timestamps_to_seconds


class BaseVideoInterface(BaseDattaInterface):
"""Base video interface for markowitz_gillis_nature_2023 conversion"""
"""Base video interface for markowitz_gillis_nature_2023 conversion."""

def __init__(
self,
Expand Down Expand Up @@ -51,6 +51,9 @@ def align_timestamps(self, metadata: dict) -> np.ndarray:
def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict) -> None:
timestamps = self.align_timestamps(metadata=metadata)

if not Path(self.source_data["data_path"]).exists():
return

video_interface = VideoInterface(file_paths=[self.source_data["data_path"]], verbose=True)
video_interface.set_aligned_timestamps(aligned_timestamps=[timestamps])
video_interface.add_to_nwbfile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def dataset_to_nwb(
folder
for folder in raw_dir_path.iterdir()
if folder.is_dir() and folder.name not in skip_experiments and folder.name.startswith("_")
][11:]
]
for experimental_folder in tqdm(
iterable=experimental_folders, position=0, desc="Converting experiments...", leave=False
):
Expand Down Expand Up @@ -157,7 +157,7 @@ def dataset_to_nwb(


if __name__ == "__main__":
number_of_jobs = 2
number_of_jobs = 1

processed_path = Path("E:/Datta/dopamine-reinforces-spontaneous-behavior")
raw_dir_path = Path("E:/Datta")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def session_to_nwb(
session_id = f"{experiment_type}-{session_uuid}"

nwbfile_path = output_dir_path / f"{session_id}.nwb"
if (
nwbfile_path.parent.parent / "initial_nwbfiles" / nwbfile_path.name
).exists() or nwbfile_path.exists(): # temporary
if nwbfile_path.exists():
return

photometry_path = processed_path / "dlight_raw_data/dlight_photometry_processed_full.parquet"
Expand Down

0 comments on commit 7725def

Please sign in to comment.