Skip to content

Commit 18e1b8e

Browse files
committed
Minor fixes
1 parent aec8b47 commit 18e1b8e

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

bidscoin/bids.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,11 +1136,8 @@ def __init__(self, yamlfile: Path, folder: Path=templatefolder, plugins: Iterabl
11361136
if entitykey not in runitem.bids and entitykey not in ('sub', 'ses'):
11371137
LOGGER.info(f"Adding missing {dataformat}>{datatype}>{suffix} bidsmap entity key: {entitykey}")
11381138
runitem.bids[entitykey] = ''
1139-
if entitykey == 'part' and not isinstance(runitem.bids['part'], list):
1140-
if runitem.bids['part'] in ('', 'mag', 'phase', 'real', 'imag', None):
1141-
runitem.bids['part'] = ['', 'mag', 'phase', 'real', 'imag', ('', 'mag', 'phase', 'real', 'imag').index(runitem.bids['part'] or '')]
1142-
else:
1143-
runitem.bids['part'] = ['', 'mag', 'phase', 'real', 'imag', runitem.bids['part'], 5]
1139+
if entitykey == 'part' and not isinstance(runitem.bids['part'], list) and runitem.bids['part'] in ('', 'mag', 'phase', 'real', 'imag', None):
1140+
runitem.bids['part'] = ['', 'mag', 'phase', 'real', 'imag', ('', 'mag', 'phase', 'real', 'imag').index(runitem.bids['part'] or '')]
11441141

11451142
# Validate the bidsmap entries
11461143
self.check(checks)
@@ -1258,7 +1255,7 @@ def validate(self, level: int=1) -> bool:
12581255
ignore = check_ignore(datatype, bidsignore) or check_ignore(bidsname+'.json', bidsignore, 'file')
12591256
ignore_1 = datatype in ignoretypes or ignore
12601257
ignore_2 = datatype in ignoretypes
1261-
for ext in extensions: # NB: `ext` used to be '.json', which is more generic (but see https://github.com/bids-standard/bids-validator/issues/2113)
1258+
for ext in extensions + ['.tsv' if runitem.bids['suffix']=='events' else '.dum']: # NB: `ext` used to be '.json', which is more generic (but see https://github.com/bids-standard/bids-validator/issues/2113)
12621259
if bidstest := bids_validator.BIDSValidator().is_bids(f"/sub-{sanitize(dataformat)}/{datatype}/{bidsname}{ext}"): break
12631260
if level==3 or (abs(level)==2 and not ignore_2) or (-2<level<2 and not ignore_1):
12641261
valid = valid and bidstest

bidscoin/bidseditor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ def accept_run(self):
18081808
bidsvalid = validrun
18091809
datatype = self.target_run.datatype
18101810
if not (bids.check_ignore(datatype,self.bidsignore) or bids.check_ignore(bidsname.name,self.bidsignore,'file') or datatype in self.ignoredatatypes):
1811-
for ext in bids.extensions: # NB: `ext` used to be '.json', which is more generic (but see https://github.com/bids-standard/bids-validator/issues/2113)
1811+
for ext in bids.extensions + ['.tsv' if self.target_run.bids['suffix']=='events' else '.dum']: # NB: `ext` used to be '.json', which is more generic (but see https://github.com/bids-standard/bids-validator/issues/2113)
18121812
if bidsvalid := BIDSValidator().is_bids((Path('/')/self.subid/self.sesid/bidsname).with_suffix(ext).as_posix()): break
18131813

18141814
# If the bidsname is not valid, ask the user if that's OK

bidscoin/bidsmapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ def bidsmapper(sourcefolder: str, bidsfolder: str, bidsmap: str, template: str,
5656
LOGGER.bcdebug(f"Regular expression metacharacters found in {sesprefix}, this may cause errors later on...")
5757
if not rawfolder.is_dir():
5858
raise SystemExit(f"\n[ERROR] Exiting the program because your sourcefolder argument '{sourcefolder}' was not found")
59-
if not templatefile.is_file():
60-
raise SystemExit(f"\n[ERROR] Exiting the program because your template bidsmap '{templatefile}' was not found")
6159

6260
# Start logging
6361
if force:
@@ -75,6 +73,8 @@ def bidsmapper(sourcefolder: str, bidsfolder: str, bidsmap: str, template: str,
7573
bidsmap_old = BidsMap(bidsmapfile, bidscoinfolder, plugins)
7674
bidsmapfile = bidsmap_old.filepath
7775
template = BidsMap(templatefile, plugins=plugins, checks=(True, True, False))
76+
if not template.filepath.is_file():
77+
raise SystemExit(f"\n[ERROR] Exiting the program because your template bidsmap '{templatefile}' was not found")
7878
template.check_template()
7979

8080
# Create the new bidsmap as a copy / bidsmap skeleton with only data types without run-items (i.e. empty lists)

bidscoin/heuristics/bidsmap_bids2bids.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ Nibabel:
471471
dir: <filename:sub-.*_dir-(.*?)_.*\.nii.*>
472472
run: <<>>
473473
echo:
474-
part: ['', mag, phase, real, imag, 0]
474+
part: <filename:sub-.*_part-(.*?)_.*\.nii.*>
475475
suffix: asl
476476
meta: &perf_meta
477477
ArterialSpinLabelingType: "CASL / PCASL / PASL"
@@ -647,7 +647,7 @@ Nibabel:
647647
dir: <filename:sub-.*_dir-(.*?)_.*\.nii.*>
648648
run: <<>>
649649
chunk: <filename:sub-.*_chunk-(.*?)_.*\.nii.*>
650-
part: ['', mag, phase, real, imag, 0]
650+
part: <filename:sub-.*_part-(.*?)_.*\.nii.*>
651651
suffix: epi
652652
meta: *fmap_meta
653653
- properties:

0 commit comments

Comments
 (0)