Skip to content

Commit

Permalink
WIP: minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Sep 18, 2023
1 parent f12013b commit f76666f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/spyglass/common/common_behav.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ def _no_transaction_make(self, key):
for time in [pos_times[0][0], pos_times[-1][-1]]
]
):
matching_pos_intervals.append(pos_intervals)
matching_pos_intervals.append(pos_interval)

if len(matching_pos_intervals) > 1:
break

# Check that each pos interval was matched to only one epoch
if len(matching_pos_intervals) != 1:
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/common_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def insert_from_nwbfile(cls, nwbf):
The NWB file with experimenter information.
"""
if isinstance(nwbf, str):
nwb_file_abspath = Nwbfile.get_abs_path(nwbf)
nwb_file_abspath = Nwbfile.get_abs_path(nwbf, new_file=True)
nwbf = get_nwb_file(nwb_file_abspath)

if nwbf.experimenter is None:
Expand Down
3 changes: 2 additions & 1 deletion src/spyglass/common/common_nwbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def _get_file_name(cls, nwb_file_name: str) -> str:
return query.fetch1("nwb_file_name")

raise ValueError(
f"Found {len(query)} matches for {nwb_file_name}: \n{query}"
f"Found {len(query)} matches for {nwb_file_name} in Nwbfile table:"
+ f" \n{query}"
)

@classmethod
Expand Down
8 changes: 5 additions & 3 deletions src/spyglass/data_import/insert_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pynwb

from ..common import Nwbfile, get_raw_eseries, populate_all_common
from ..settings import raw_dir
from ..settings import debug_mode, raw_dir
from ..utils.nwb_helper_fn import get_nwb_copy_filename


Expand Down Expand Up @@ -50,7 +50,7 @@ def insert_sessions(nwb_file_names: Union[str, List[str]]):
)

# file name for the copied raw data
out_nwb_file_name = get_nwb_copy_filename(nwb_file_abs_path.stem)
out_nwb_file_name = get_nwb_copy_filename(nwb_file_abs_path.name)

# Check whether the file already exists in the Nwbfile table
if len(Nwbfile() & {"nwb_file_name": out_nwb_file_name}):
Expand Down Expand Up @@ -97,7 +97,9 @@ def copy_nwb_link_raw_ephys(nwb_file_name, out_nwb_file_name):
out_nwb_file_name, new_file=True
)

if os.path.exists(out_nwb_file_name):
if os.path.exists(out_nwb_file_abs_path):
if debug_mode:
return out_nwb_file_abs_path
warnings.warn(
f"Output file {out_nwb_file_abs_path} exists and will be "
+ "overwritten."
Expand Down

0 comments on commit f76666f

Please sign in to comment.