dandi.organize¶
Organize and structure NWB files according to DANDI conventions.
This module provides functionality for organizing neuroscience data files according to DANDI’s file organization schema. Features include: - Automatic path generation from metadata - BIDS-like subject/session organization - Metadata-driven file naming - Validation of organized paths - Support for videos and generic files
Functions
|
|
|
Create unique filenames given metadata |
|
Determine what type of links the filesystem will let us make from the file |
|
Split into two lists - valid and invalid entries |
|
Given full object_id, get its shortened version |
|
Return True if None or an empty container |
|
|
|
Organizes the external_files into the new Dandiset folder structure. |
|
|
|
Classes
|
An enumeration. |
|
An enumeration. |
|
An enumeration. |
- class dandi.organize.CopyMode(value)[source]¶
An enumeration.
- COPY = 'copy'¶
- HARDLINK = 'hardlink'¶
- MOVE = 'move'¶
- SYMLINK = 'symlink'¶
- class dandi.organize.FileOperationMode(value)[source]¶
An enumeration.
- AUTO = 'auto'¶
- COPY = 'copy'¶
- DRY = 'dry'¶
- HARDLINK = 'hardlink'¶
- MOVE = 'move'¶
- SIMULATE = 'simulate'¶
- SYMLINK = 'symlink'¶
- dandi.organize.create_unique_filenames_from_metadata(metadata: list[dict], required_fields: Sequence[str] | None = None) list[dict][source]¶
Create unique filenames given metadata
- Parameters:
metadata (list of dict) – List of metadata records
required_fields (sequence of str, optional) – Names from
dandi_layout_fieldsto consider"required_if_not_empty"
- Returns:
Adjusted metadata. A copy, which might have removed some metadata fields Do not rely on it being the same
- Return type:
list of dict
- dandi.organize.detect_link_type(srcfile: str | Path, destdir: str | Path) FileOperationMode[source]¶
Determine what type of links the filesystem will let us make from the file
srcfileto the directorydestdir. If symlinks are allowed, returns"symlink". Otherwise, if hard links are allowed, returns"hardlink". Otherwise, returns"copy".
- dandi.organize.filter_invalid_metadata_rows(metadata_rows)[source]¶
Split into two lists - valid and invalid entries
- dandi.organize.organize(paths: Sequence[str], dandiset_path: str | None = None, invalid: OrganizeInvalid = OrganizeInvalid.FAIL, files_mode: FileOperationMode = FileOperationMode.AUTO, devel_debug: bool = False, update_external_file_paths: bool = False, media_files_mode: CopyMode | None = None, required_fields: Sequence[str] | None = None, jobs: int | None = None) None[source]¶
- dandi.organize.organize_external_files(metadata: list[dict], dandiset_path: str, copy_mode: CopyMode) None[source]¶
Organizes the external_files into the new Dandiset folder structure.
- Parameters:
metadata (list) – list of metadata dictionaries created during the call to pynwb_utils._get_pynwb_metadata
dandiset_path (str) – full path of the main dandiset folder.
copy_mode (CopyMode)
- dandi.organize.validate_organized_path(asset_path: str, filepath: Path, dandiset_path: Path) list[ValidationResult][source]¶
- Parameters:
asset_path (str) – The forward-slash-separated path to the asset within its local Dandiset (i.e., relative to the Dandiset’s root)
filepath (pathlib.Path) – The actual filesystem path of the asset (used to construct
ValidationResultobjects)dandiset_path (pathlib.Path) – The path to the root of the Dandiset (used to construct
ValidationResultobjects)