Skip to content

Commit 8c86a40

Browse files
committed
Minor tweaks / cleanups
1 parent d7cfa9f commit 8c86a40

File tree

6 files changed

+20
-31
lines changed

6 files changed

+20
-31
lines changed

bidscoin/bidseditor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ def show_contextmenu(self, pos):
206206
menu = QtWidgets.QMenu(self)
207207
compare = menu.addAction('Compare')
208208
compare.setEnabled(len(rowindex) > 1)
209+
compare.setToolTip('Compare the BIDS mappings of multiple run-items')
209210
edit = menu.addAction('Edit')
210-
edit.setToolTip('Edit individual items in detail or change the data type')
211+
edit.setToolTip('Edit a single run-item in detail or edit the data type of multiple run-items')
211212
delete = menu.addAction('Remove')
213+
delete.setToolTip('Delete run-items from the bidsmap (expert usage)')
212214
action = menu.exec(table.viewport().mapToGlobal(pos))
213215

214216
if action == delete:

bidscoin/plugins/dcm2niix2bids.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,9 @@ def bidscoiner_plugin(session: Path, bidsmap: Bidsmap, bidsses: Path) -> Union[N
215215
"""
216216

217217
# Get the subject identifiers and the BIDS root folder from the bidsses folder
218-
if bidsses.name.startswith('ses-'):
219-
bidsfolder = bidsses.parent.parent
220-
subid = bidsses.parent.name
221-
sesid = bidsses.name
222-
else:
223-
bidsfolder = bidsses.parent
224-
subid = bidsses.name
225-
sesid = ''
218+
subid = bidsses.name if bidsses.name.startswith('sub-') else bidsses.parent.name
219+
sesid = bidsses.name if bidsses.name.startswith('ses-') else ''
220+
bidsfolder = bidsses.parent.parent if sesid else bidsses.parent
226221

227222
# Get started and see what dataformat we have
228223
options: Plugin = bidsmap['Options']['plugins']['dcm2niix2bids']

bidscoin/plugins/nibabel2bids.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,9 @@ def bidscoiner_plugin(session: Path, bidsmap: Bidsmap, bidsses: Path) -> None:
169169
:return: Nothing
170170
"""
171171

172-
# Get the subject identifiers and the BIDS root folder from the bidsses folder
173-
if bidsses.name.startswith('ses-'):
174-
subid = bidsses.parent.name
175-
sesid = bidsses.name
176-
else:
177-
subid = bidsses.name
178-
sesid = ''
172+
# Get the subject identifiers from the bidsses folder
173+
subid = bidsses.name if bidsses.name.startswith('sub-') else bidsses.parent.name
174+
sesid = bidsses.name if bidsses.name.startswith('ses-') else ''
179175

180176
# Get started
181177
options = bidsmap['Options']['plugins']['nibabel2bids']

bidscoin/plugins/spec2nii2bids.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,9 @@ def bidscoiner_plugin(session: Path, bidsmap: Bidsmap, bidsses: Path) -> Union[N
177177
:return: A dictionary with personal data for the participants.tsv file (such as sex or age)
178178
"""
179179

180-
# Get the subject identifiers and the BIDS root folder from the bidsses folder
181-
if bidsses.name.startswith('ses-'):
182-
subid = bidsses.parent.name
183-
sesid = bidsses.name
184-
else:
185-
subid = bidsses.name
186-
sesid = ''
180+
# Get the subject identifiers from the bidsses folder
181+
subid = bidsses.name if bidsses.name.startswith('sub-') else bidsses.parent.name
182+
sesid = bidsses.name if bidsses.name.startswith('ses-') else ''
187183

188184
# Get started and see what dataformat we have
189185
options = bidsmap['Options']['plugins']['spec2nii2bids']

docs/troubleshooting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Normally the list of items in the bidsmap is a shortlist that represents the dif
5353

5454
I have duplicate run-items in my bidsmap
5555
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56-
There shouldn't be exact duplicates, i.e. there is probably a small difference in the properties or attributes that identify your run-items. To investigate this, you can compare these run-items by selecting their BIDS output names (use shift-/control-click), then right-click them and choose ``compare`` from the context menu
56+
Exact duplicates should not exist, i.e. there is probably a small difference in the properties or attributes that identify your run-items. To investigate this, you can compare these run-items by selecting their BIDS output names (use shift-/control-click), then right-click them and choose ``compare`` from the context menu
5757

5858
My subject/session labels are wrong
5959
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_bids.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from nibabel.testing import data_path
1212
from pydicom.data import get_testdata_file
1313
from bidscoin import bcoin, bids, bidsmap_template
14-
from bidscoin.bids import Run, Plugin
14+
from bidscoin.bids import Run, Plugin, Meta
1515

1616
bcoin.setup_logging()
1717

@@ -614,10 +614,10 @@ def test_updatemetadata(dcm_file, tmp_path):
614614
json.dump({'PatientName': 'SidecarTest'}, fid)
615615

616616
# Create the user metadata
617-
usermeta = {'PatientName': 'UserTest',
618-
'DynamicName': '<<(0010, 0010)>>',
619-
'B0FieldSource': 'Source<<session:[-2:2]>>',
620-
'B0FieldIdentifier': ['Identifier<<session>>', 'Identifier']}
617+
usermeta = Meta({'PatientName': 'UserTest',
618+
'DynamicName': '<<(0010, 0010)>>',
619+
'B0FieldSource': 'Source<<session:[-2:2]>>',
620+
'B0FieldIdentifier': ['Identifier<<session>>', 'Identifier']})
621621

622622
# Test if the user metadata takes precedence
623623
metadata = bids.updatemetadata(extdatasource, sidecar, usermeta, ['.json'])
@@ -628,10 +628,10 @@ def test_updatemetadata(dcm_file, tmp_path):
628628
assert not (outfolder/sourcefile.with_suffix('.jsn').name).is_file()
629629

630630
# Test if the source metadata takes precedence
631-
metadata = bids.updatemetadata(extdatasource, sidecar, {}, ['.jsn', '.json'], sourcefile)
631+
metadata = bids.updatemetadata(extdatasource, sidecar, Meta({}), ['.jsn', '.json'], sourcefile)
632632
assert metadata['PatientName'] == 'SourceTest'
633633
assert (outfolder/sourcefile.with_suffix('.jsn').name).is_file()
634634

635635
# Test if the sidecar metadata takes precedence
636-
metadata = bids.updatemetadata(extdatasource, sidecar, {}, [])
636+
metadata = bids.updatemetadata(extdatasource, sidecar, Meta({}), [])
637637
assert metadata['PatientName'] == 'SidecarTest'

0 commit comments

Comments
 (0)