diff --git a/bidscoin/bids.py b/bidscoin/bids.py index ed248999..f5b4613e 100644 --- a/bidscoin/bids.py +++ b/bidscoin/bids.py @@ -1274,6 +1274,9 @@ def get_matching_run(self, datasource: DataSource, runtime=False) -> Tuple[RunIt If there is a match, the provenance of the bidsmap entry is returned, otherwise it will be '' """ + if not datasource.dataformat and not datasource.has_plugin(): + LOGGER.bcdebug(f"No dataformat/plugin support found when getting a matching run for: {datasource}") + unknowndatatypes = self.options.get('unknowntypes') or ['unknown_data'] ignoredatatypes = self.options.get('ignoretypes') or [] normaldatatypes = [dtype.datatype for dtype in self.dataformat(datasource.dataformat).datatypes if dtype not in unknowndatatypes + ignoredatatypes] @@ -1366,6 +1369,9 @@ def get_run(self, datatype: Union[str, DataType], suffix_idx: Union[int, str], d otherwise an empty dict """ + if not datasource.dataformat and not datasource.has_plugin(): + LOGGER.bcdebug(f"No dataformat/plugin support found when getting a run for: {datasource}") + datatype = str(datatype) for index, _runitem in enumerate(self.dataformat(datasource.dataformat).datatype(datatype).runitems): diff --git a/bidscoin/plugins/nibabel2bids.py b/bidscoin/plugins/nibabel2bids.py index 5e295aad..580e2ddc 100644 --- a/bidscoin/plugins/nibabel2bids.py +++ b/bidscoin/plugins/nibabel2bids.py @@ -129,7 +129,7 @@ def bidsmapper_plugin(session: Path, bidsmap_new: BidsMap, bidsmap_old: BidsMap, for sourcefile in [file for file in session.rglob('*') if has_support(file)]: # See if we can find a matching run in the old bidsmap - datasource = bids.DataSource(sourcefile, plugins, datasource.dataformat) + datasource = bids.DataSource(sourcefile, plugins, has_support(sourcefile)) run, match = bidsmap_old.get_matching_run(datasource) # If not, see if we can find a matching run in the template @@ -185,7 +185,7 @@ def bidscoiner_plugin(session: Path, bidsmap: BidsMap, bidsses: Path) -> None: # Collect the different Nibabel source files for all files in the session for source in sourcefiles: - datasource = bids.DataSource(source, {'nibabel2bids': options}) + datasource = bids.DataSource(source, {'nibabel2bids': options}, has_support(source)) run, runid = bidsmap.get_matching_run(datasource, runtime=True) # Check if we should ignore this run diff --git a/bidscoin/plugins/spec2nii2bids.py b/bidscoin/plugins/spec2nii2bids.py index 83b0c325..e5a98675 100644 --- a/bidscoin/plugins/spec2nii2bids.py +++ b/bidscoin/plugins/spec2nii2bids.py @@ -123,7 +123,7 @@ def bidsmapper_plugin(session: Path, bidsmap_new: BidsMap, bidsmap_old: BidsMap, # Update the bidsmap with the info from the source files for sourcefile in [file for file in session.rglob('*') if has_support(file)]: - datasource = bids.DataSource(sourcefile, plugins) + datasource = bids.DataSource(sourcefile, plugins, has_support(sourcefile)) # Input checks if datasource.dataformat not in template.dataformats + bidsmap_old.dataformats: @@ -192,7 +192,7 @@ def bidscoiner_plugin(session: Path, bidsmap: BidsMap, bidsses: Path) -> Union[N for source in sourcefiles: # Get a data source, a matching run from the bidsmap - datasource = bids.DataSource(source, {'spec2nii2bids': options}) + datasource = bids.DataSource(source, {'spec2nii2bids': options}, has_support(source)) run, runid = bidsmap.get_matching_run(datasource, runtime=True) # Check if we should ignore this run