Skip to content

Commit

Permalink
Bugfix for multiple targets in provdata
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed May 6, 2024
1 parent 7edc193 commit 76dd72b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ def bidsprov(bidsfolder: Path, source: Path=Path(), runid: str='', datatype: str
:param runid: The bidsmap runid (provenance) that was used to map the source data, e.g. as returned from get_matching_run()
:param datatype: The BIDS datatype/name of the subfolder where the targets are saved (e.g. extra_data)
:param targets: The set of output files
:return: The dataframe with the provenance data
:return: The dataframe with the provenance data (index_col='source', columns=['runid', 'datatype', 'targets'])
"""

# Check the input
Expand Down
9 changes: 5 additions & 4 deletions bidscoin/bidsapps/fixmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ def fixmeta(bidsdir: str, pattern: str, metadata: dict, subjects: list, bidsmapf
for target in targets:

# Lookup the source folder in the bidscoiner.tsv provenance logs and get a datasource from it
provtarget = provdata['targets'] == target.name
sourcedir = provdata.loc[provtarget].index[-1] if not provtarget.empty else ''
sourcedir = ''
for source, row in provdata.iterrows():
if isinstance(row['targets'], str) and target.name in row['targets']:
sourcedir = source
datasource = bids.get_datasource(Path(sourcedir), plugins)
if datasource.is_datasource():
LOGGER.bcdebug(f"Using datasource '{datasource.path}'")
LOGGER.bcdebug(f"Using datasource: '{datasource.path}'" if datasource.is_datasource() else f"Could not find a datasource for: '{target.name}'")

# Load/copy over the source meta-data
jsonfile = target.with_suffix('').with_suffix('.json')
Expand Down

0 comments on commit 76dd72b

Please sign in to comment.