diff --git a/bidscoin/bids.py b/bidscoin/bids.py index f5b4613e..e9caf614 100644 --- a/bidscoin/bids.py +++ b/bidscoin/bids.py @@ -876,7 +876,7 @@ def __init__(self, yamlfile: Path, folder: Path=templatefolder, plugins: Iterabl has precedence over folder and bidsmap.yaml has precedence over the bidsmap_template. :param yamlfile: The full pathname or basename of the bidsmap yaml-file - :param folder: Used when yamlfile=basename and not in the pwd: yamlfile is then assumed to be in the (bidscoin)folder. A bidsignore file in folder will be added to the bidsmap bidsignore items + :param folder: Used when yamlfile=basename and not in the pwd: yamlfile is then assumed to be in the (bids/code/bidscoin)folder. A bidsignore file in folder will be added to the bidsmap bidsignore items :param plugins: List of plugins to be used (with default options, overrules the plugin list in the study/template bidsmaps). Leave empty to use all plugins in the bidsmap :param checks: Booleans to check if all (bidskeys, bids-suffixes, bids-values) in the run are present according to the BIDS schema specifications """ @@ -893,8 +893,7 @@ def __init__(self, yamlfile: Path, folder: Path=templatefolder, plugins: Iterabl yamlfile = yamlfile.with_suffix('.yaml') # Add a standard file-extension if needed if len(yamlfile.parents) == 1 and not yamlfile.is_file(): yamlfile = folder/yamlfile # Get the full path to the bidsmap yaml-file - yamlfile = yamlfile.resolve() - self.filepath = yamlfile if yamlfile.is_file() else Path() + self.filepath = yamlfile = yamlfile.resolve() """The full path to the bidsmap yaml-file""" if not yamlfile.is_file(): if yamlfile.name: LOGGER.info(f"No bidsmap file found: {yamlfile}") diff --git a/bidscoin/bidsapps/fixmeta.py b/bidscoin/bidsapps/fixmeta.py index 2e5fe86a..cb127961 100755 --- a/bidscoin/bidsapps/fixmeta.py +++ b/bidscoin/bidsapps/fixmeta.py @@ -54,7 +54,7 @@ def fixmeta(bidsfolder: str, pattern: str, metadata: dict, participant: list, bi # Load the bidsmap data (-> plugins) bidsmap = bids.BidsMap(Path(bidsmap or 'bidsmap.yaml'), bidsdir/'code'/'bidscoin', checks=(False, False, False)) - if not bidsmap.filepath: + if not bidsmap.filepath.is_file(): bidsmap = bids.BidsMap(bidsmap_template, checks=(False, False, False)) plugins = bidsmap.plugins provdata = bids.bidsprov(bidsdir) diff --git a/bidscoin/bidseditor.py b/bidscoin/bidseditor.py index beb0c45f..12236106 100755 --- a/bidscoin/bidseditor.py +++ b/bidscoin/bidseditor.py @@ -85,7 +85,7 @@ def __init__(self, bidsfolder: Path, input_bidsmap: BidsMap, template_bidsmap: B self.setWindowIcon(QtGui.QIcon(str(BIDSCOIN_ICON))) self.set_menu_statusbar() - if not input_bidsmap.filepath.name: + if not input_bidsmap.filepath.is_file(): filename, _ = QFileDialog.getOpenFileName(self, 'Open a bidsmap file', str(bidsfolder), 'YAML Files (*.yaml *.yml);;All Files (*)') if filename: input_bidsmap = BidsMap(Path(filename)) @@ -868,7 +868,7 @@ def save_bidsmap(self): """Check and save the bidsmap to file""" for dataformat in self.dataformats: - if 'fmap' in self.output_bidsmap.dataformat(dataformat): + if 'fmap' in self.output_bidsmap.dataformat(dataformat).datatypes: for runitem in self.output_bidsmap.dataformat(dataformat).datatype('fmap').runitems: if not (runitem.meta.get('B0FieldSource') or runitem.meta.get('B0FieldIdentifier') or runitem.meta.get('IntendedFor')): LOGGER.warning(f"B0FieldIdentifier/IntendedFor fieldmap value is empty for {dataformat} run-item: {runitem}") diff --git a/bidscoin/bidsmapper.py b/bidscoin/bidsmapper.py index 70f0a62c..e992b97d 100755 --- a/bidscoin/bidsmapper.py +++ b/bidscoin/bidsmapper.py @@ -73,17 +73,18 @@ def bidsmapper(sourcefolder: str, bidsfolder: str, bidsmap: str, template: str, # Get the heuristics for filling the new bidsmap (NB: plugins are stored in the bidsmaps) bidsmap_old = BidsMap(bidsmapfile, bidscoinfolder, plugins) + bidsmapfile = bidsmap_old.filepath template = BidsMap(templatefile, plugins=plugins, checks=(True, True, False)) template.check_template() # Create the new bidsmap as a copy / bidsmap skeleton with only data types without run-items (i.e. empty lists) - if force and bidsmap_old.filepath.name: + if force and bidsmap_old.filepath.is_file(): LOGGER.info(f"Deleting previous bidsmap: {bidsmap_old.filepath}") bidsmap_old.filepath.unlink() bidsmap_old.filepath = Path() - bidsmap_new = copy.deepcopy(bidsmap_old if bidsmap_old.filepath.name else template) + bidsmap_new = copy.deepcopy(bidsmap_old if bidsmap_old.filepath.is_file() else template) bidsmap_new.delete_runs() - bidsmap_new.filepath = bidsmapfile.resolve() + bidsmap_new.filepath = bidsmapfile template.options = bidsmap_new.options # Always use the options of the new bidsmap template.plugins = bidsmap_new.plugins # Always use the plugins of the new bidsmap if unzip: @@ -95,7 +96,7 @@ def bidsmapper(sourcefolder: str, bidsfolder: str, bidsmap: str, template: str, subprefix, sesprefix = setprefix(bidsmap_new, subprefix, sesprefix, rawfolder, update = not no_update) # Start with an empty skeleton if we don't have an old bidsmap (due to loading failure or deletion by force) - if not bidsmap_old.filepath.name: + if not bidsmap_old.filepath.is_file(): bidsmap_old = copy.deepcopy(bidsmap_new) # Import the data scanning plugins @@ -156,7 +157,7 @@ def bidsmapper(sourcefolder: str, bidsfolder: str, bidsmap: str, template: str, mainwin = bidseditor.MainWindow(bidsfolder, bidsmap_new, template) mainwin.show() - if not bidsmap_new.filepath.name or not uptodate: + if not bidsmap_new.filepath.is_file() or not uptodate: messagebox = QMessageBox(mainwin) messagebox.setText(f"The bidsmapper has finished scanning {rawfolder}\n\n" f"Please carefully check all the different BIDS output names " diff --git a/bidscoin/utilities/bidsparticipants.py b/bidscoin/utilities/bidsparticipants.py index 96e94102..87ec3039 100755 --- a/bidscoin/utilities/bidsparticipants.py +++ b/bidscoin/utilities/bidsparticipants.py @@ -84,7 +84,7 @@ def bidsparticipants(sourcefolder: str, bidsfolder: str, keys: list, bidsmap: st # Get the bidsmap sub-/ses-prefix from the bidsmap YAML-file bidsmap = BidsMap(Path(bidsmap), bidsfolder/'code'/'bidscoin', checks=(False, False, False)) - if not bidsmap.filepath.name: + if not bidsmap.filepath.is_file(): LOGGER.info('Make sure to run "bidsmapper" first, exiting now') return subprefix = bidsmap.options['subprefix']