Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add support for _desc- entity to label different processings of a file #1315

Merged
merged 1 commit into from
Aug 11, 2023
Merged
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
1 change: 1 addition & 0 deletions dandi/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def urls(self) -> Iterator[str]:
"slice_id": {"format": "_slice-{}"},
"cell_id": {"format": "_cell-{}"},
# disambiguation ones
"description": {"format": "_desc-{}", "type": "disambiguation"},
"probe_ids": {"format": "_probe-{}", "type": "disambiguation"},
"obj_id": {
"format": "_obj-{}",
Expand Down
2 changes: 1 addition & 1 deletion dandi/organize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def msg_(msg, n, cond=None):
ORGANIZED_FILENAME_REGEX = (
rf"sub-{LABELREGEX}"
rf"(_ses-{LABELREGEX})?"
rf"(_(tis|slice|cell|probe|obj)-{LABELREGEX})*"
rf"(_(tis|slice|cell|desc|probe|obj)-{LABELREGEX})*"
r"(_[a-z]+(\+[a-z]+)*)?"
r"\.nwb"
)
Expand Down
20 changes: 20 additions & 0 deletions dandi/tests/test_organize.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ def test_ambiguous_probe1() -> None:
]


def test_ambiguous_desc() -> None:
base = dict(subject_id="1", session="2", modalities=["mod"], extension="nwb")
# fake filenames should be ok since we never should get to reading them for object_id
metadata = [
dict(path="1.nwb", **base),
dict(path="2.nwb", description="ms5", **base),
]
metadata_ = create_unique_filenames_from_metadata(metadata)
assert metadata_ != metadata
assert [m["dandi_path"] for m in metadata_] == [
op.join("sub-1", "sub-1_mod.nwb"),
op.join("sub-1", "sub-1_desc-ms5_mod.nwb"),
]


@pytest.mark.parametrize(
"sym_success,hard_success,result",
[
Expand Down Expand Up @@ -332,6 +347,11 @@ def test_video_organize_common(video_mode, nwbfiles_video_common):
[
("XCaMPgf/XCaMPgf_ANM471996_cell01.dat", []),
("sub-RAT123/sub-RAT123.nwb", []),
("sub-RAT123/sub-RAT123_desc-label.nwb", []), # _desc- is supported now
(
"sub-RAT123/sub-RAT123_notsupported-irrelevant.nwb",
["DANDI.NON_DANDI_FILENAME"],
),
("sub-RAT123/sub-RAT124.nwb", ["DANDI.METADATA_MISMATCH_SUBJECT"]),
("sub-RAT124.nwb", ["DANDI.NON_DANDI_FOLDERNAME"]),
("foo/sub-RAT124.nwb", ["DANDI.NON_DANDI_FOLDERNAME"]),
Expand Down
Loading