Skip to content

Commit be742ab

Browse files
committed
ENH: Add support for _desc- entity to label different processings of a file
1 parent 4cde72f commit be742ab

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

dandi/consts.py

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def urls(self) -> Iterator[str]:
194194
"slice_id": {"format": "_slice-{}"},
195195
"cell_id": {"format": "_cell-{}"},
196196
# disambiguation ones
197+
"description": {"format": "_desc-{}", "type": "disambiguation"},
197198
"probe_ids": {"format": "_probe-{}", "type": "disambiguation"},
198199
"obj_id": {
199200
"format": "_obj-{}",

dandi/organize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ def msg_(msg, n, cond=None):
10321032
ORGANIZED_FILENAME_REGEX = (
10331033
rf"sub-{LABELREGEX}"
10341034
rf"(_ses-{LABELREGEX})?"
1035-
rf"(_(tis|slice|cell|probe|obj)-{LABELREGEX})*"
1035+
rf"(_(tis|slice|cell|desc|probe|obj)-{LABELREGEX})*"
10361036
r"(_[a-z]+(\+[a-z]+)*)?"
10371037
r"\.nwb"
10381038
)

dandi/tests/test_organize.py

+20
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,21 @@ def test_ambiguous_probe1() -> None:
237237
]
238238

239239

240+
def test_ambiguous_desc() -> None:
241+
base = dict(subject_id="1", session="2", modalities=["mod"], extension="nwb")
242+
# fake filenames should be ok since we never should get to reading them for object_id
243+
metadata = [
244+
dict(path="1.nwb", **base),
245+
dict(path="2.nwb", description="ms5", **base),
246+
]
247+
metadata_ = create_unique_filenames_from_metadata(metadata)
248+
assert metadata_ != metadata
249+
assert [m["dandi_path"] for m in metadata_] == [
250+
op.join("sub-1", "sub-1_mod.nwb"),
251+
op.join("sub-1", "sub-1_desc-ms5_mod.nwb"),
252+
]
253+
254+
240255
@pytest.mark.parametrize(
241256
"sym_success,hard_success,result",
242257
[
@@ -332,6 +347,11 @@ def test_video_organize_common(video_mode, nwbfiles_video_common):
332347
[
333348
("XCaMPgf/XCaMPgf_ANM471996_cell01.dat", []),
334349
("sub-RAT123/sub-RAT123.nwb", []),
350+
("sub-RAT123/sub-RAT123_desc-label.nwb", []), # _desc- is supported now
351+
(
352+
"sub-RAT123/sub-RAT123_notsupported-irrelevant.nwb",
353+
["DANDI.NON_DANDI_FILENAME"],
354+
),
335355
("sub-RAT123/sub-RAT124.nwb", ["DANDI.METADATA_MISMATCH_SUBJECT"]),
336356
("sub-RAT124.nwb", ["DANDI.NON_DANDI_FOLDERNAME"]),
337357
("foo/sub-RAT124.nwb", ["DANDI.NON_DANDI_FOLDERNAME"]),

0 commit comments

Comments
 (0)