Discovery¶
find_dataset_spreadsheets(raw_path, sheet_info, extension='ods')
¶
Locate and parse participant and phenotype data from a spreadsheet.
Searches for a unique spreadsheet file and attempts to extract two distinct datasets based on the provided sheet information. If the phenotype data fails to load, it is returned as None while logging an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_path
|
Path
|
The directory path to search for the spreadsheet file. |
required |
sheet_info
|
dict[str, dict]
|
A dictionary containing configuration details for the sheets to be read (e.g., sheet names or column mappings). |
required |
extension
|
str
|
The file extension to search for, by default "ods". |
'ods'
|
Returns:
| Name | Type | Description |
|---|---|---|
participant_data |
dict
|
The parsed data for participants. |
phenotype_data |
dict or None
|
The parsed phenotype data, or None if the data could not be loaded. |
Notes
This function utilises find_file, which raises a ValueError if
the spreadsheet is not uniquely identified.
Source code in src/rs_bidsify/discovery.py
find_description_spec(raw_path, extension='toml')
¶
Locate and load the dataset description metadata file.
Utilises file discovery to find a unique metadata file with the specified extension and parses its content into a DescriptionSpec object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_path
|
Path
|
The directory path to search for the description file. |
required |
extension
|
str
|
The file extension to search for, by default "toml". |
'toml'
|
Returns:
| Type | Description |
|---|---|
DescriptionSpec
|
The parsed metadata specification object. |
Notes
This function relies on find_file, which will raise a ValueError if
zero or multiple files matching the extension are found.
Source code in src/rs_bidsify/discovery.py
find_file(path, ext, keyword='')
¶
Locate a single file with a specific extension within a directory.
This function searches the specified directory for files matching the provided extension, and keyword. It enforces a strict requirement that exactly one matching file must exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The directory path to search within. |
required |
ext
|
str
|
The file extension to look for (e.g., 'json', 'nii.gz'). Do not include the leading dot. |
required |
keyword
|
str
|
An additional label for identifying the file to find. Default = "" |
''
|
Returns:
| Type | Description |
|---|---|
Path
|
The path to the unique file found. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no files or multiple files with the given keyword and extension are found in the directory. |
Source code in src/rs_bidsify/discovery.py
find_missing_subjects(expected_ids, out_path)
¶
Identify expected subjects that are missing from the BIDS output directory.
Scans the filesystem to determine which participants from the initial protocol were not successfully exported, allowing for targeted metadata cleanup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected_ids
|
list[str]
|
A list of BIDS-compliant subject strings (e.g., ['sub-01', 'sub-02']) originally slated for processing. |
required |
out_path
|
Path
|
The root directory of the BIDS dataset to be scanned for subject folders. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of subject identifiers present in 'expected_ids' but missing from the physical directory. |