Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/spyglass/utils/dj_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ def fetch_nwb(query_expression, nwb_master, *attrs, **kwargs):
tbl.proj(nwb2load_filepath=attr_name), **arg
)

# Fix for custom analysis tables #1435
if attrs and "nwb2load_filepath" not in attrs:
attrs = list(attrs) + ["nwb2load_filepath"]

rec_dicts = query_table.fetch(*attrs, **kwargs)
# get filepath for each. Use datajoint for checksum if local
for rec_dict in rec_dicts:
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/utils/mixins/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def get_abs_path(
cls()._ext_tbl & f"filepath LIKE '%{analysis_nwb_file_name}'"
)
if len(query) == 1: # Else try the standard way
return Path(cls()._analysis_dir) / query.fetch1("filepath")
return str(Path(cls()._analysis_dir) / query.fetch1("filepath"))
cls()._logger.warning(
f"Found {len(query)} files for: {analysis_nwb_file_name}"
)
Expand Down
18 changes: 12 additions & 6 deletions src/spyglass/utils/nwb_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ def _open_nwb_file(nwb_file_path, source="local"):
elif source == "dandi":
from ..common.common_dandi import DandiPath

if DandiPath().has_file_path(nwb_file_path):
path_to_load = nwb_file_path
elif DandiPath().has_raw_path(nwb_file_path):
path_to_load = DandiPath().raw_from_path(nwb_file_path)["filename"]
else:
raise ValueError(
f"File not found in Dandi: {Path(nwb_file_path).name}"
)
io, nwbfile = DandiPath().fetch_file_from_dandi(
nwb_file_path=nwb_file_path
nwb_file_path=path_to_load
)
else:
raise ValueError(f"Invalid open_nwb source: {source}")
Expand Down Expand Up @@ -99,13 +107,11 @@ def get_nwb_file(nwb_file_path, query_expression=None):
# Dandi fallback SB 2024-04-03
from ..common.common_dandi import DandiPath

if DandiPath().has_file_path(file_path=nwb_file_path):
if DandiPath().has_file_path(
file_path=nwb_file_path
) or DandiPath().has_raw_path(file_path=nwb_file_path):
return _open_nwb_file(nwb_file_path, source="dandi")

if DandiPath().has_raw_path(file_path=nwb_file_path):
raw = DandiPath().raw_from_path(file_path=nwb_file_path)["filename"]
return _open_nwb_file(raw, source="dandi")

if hasattr(query_expression, "_make_file"):
# if the query_expression has a _make_file method, call it to
# recompute the file
Expand Down
Loading