Skip to content

Commit

Permalink
ENH: Add support for _desc- entity to label different processings of …
Browse files Browse the repository at this point in the history
…a file
  • Loading branch information
yarikoptic committed Aug 9, 2023
1 parent 4cde72f commit be742ab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
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

0 comments on commit be742ab

Please sign in to comment.