Skip to content

Commit

Permalink
Minor tweaks / cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed May 1, 2024
1 parent d7cfa9f commit 8c86a40
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 31 deletions.
4 changes: 3 additions & 1 deletion bidscoin/bidseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ def show_contextmenu(self, pos):
menu = QtWidgets.QMenu(self)
compare = menu.addAction('Compare')
compare.setEnabled(len(rowindex) > 1)
compare.setToolTip('Compare the BIDS mappings of multiple run-items')
edit = menu.addAction('Edit')
edit.setToolTip('Edit individual items in detail or change the data type')
edit.setToolTip('Edit a single run-item in detail or edit the data type of multiple run-items')
delete = menu.addAction('Remove')
delete.setToolTip('Delete run-items from the bidsmap (expert usage)')
action = menu.exec(table.viewport().mapToGlobal(pos))

if action == delete:
Expand Down
11 changes: 3 additions & 8 deletions bidscoin/plugins/dcm2niix2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,9 @@ def bidscoiner_plugin(session: Path, bidsmap: Bidsmap, bidsses: Path) -> Union[N
"""

# Get the subject identifiers and the BIDS root folder from the bidsses folder
if bidsses.name.startswith('ses-'):
bidsfolder = bidsses.parent.parent
subid = bidsses.parent.name
sesid = bidsses.name
else:
bidsfolder = bidsses.parent
subid = bidsses.name
sesid = ''
subid = bidsses.name if bidsses.name.startswith('sub-') else bidsses.parent.name
sesid = bidsses.name if bidsses.name.startswith('ses-') else ''
bidsfolder = bidsses.parent.parent if sesid else bidsses.parent

# Get started and see what dataformat we have
options: Plugin = bidsmap['Options']['plugins']['dcm2niix2bids']
Expand Down
10 changes: 3 additions & 7 deletions bidscoin/plugins/nibabel2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,9 @@ def bidscoiner_plugin(session: Path, bidsmap: Bidsmap, bidsses: Path) -> None:
:return: Nothing
"""

# Get the subject identifiers and the BIDS root folder from the bidsses folder
if bidsses.name.startswith('ses-'):
subid = bidsses.parent.name
sesid = bidsses.name
else:
subid = bidsses.name
sesid = ''
# Get the subject identifiers from the bidsses folder
subid = bidsses.name if bidsses.name.startswith('sub-') else bidsses.parent.name
sesid = bidsses.name if bidsses.name.startswith('ses-') else ''

# Get started
options = bidsmap['Options']['plugins']['nibabel2bids']
Expand Down
10 changes: 3 additions & 7 deletions bidscoin/plugins/spec2nii2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,9 @@ def bidscoiner_plugin(session: Path, bidsmap: Bidsmap, bidsses: Path) -> Union[N
:return: A dictionary with personal data for the participants.tsv file (such as sex or age)
"""

# Get the subject identifiers and the BIDS root folder from the bidsses folder
if bidsses.name.startswith('ses-'):
subid = bidsses.parent.name
sesid = bidsses.name
else:
subid = bidsses.name
sesid = ''
# Get the subject identifiers from the bidsses folder
subid = bidsses.name if bidsses.name.startswith('sub-') else bidsses.parent.name
sesid = bidsses.name if bidsses.name.startswith('ses-') else ''

# Get started and see what dataformat we have
options = bidsmap['Options']['plugins']['spec2nii2bids']
Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Normally the list of items in the bidsmap is a shortlist that represents the dif

I have duplicate run-items in my bidsmap
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
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

My subject/session labels are wrong
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
14 changes: 7 additions & 7 deletions tests/test_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from nibabel.testing import data_path
from pydicom.data import get_testdata_file
from bidscoin import bcoin, bids, bidsmap_template
from bidscoin.bids import Run, Plugin
from bidscoin.bids import Run, Plugin, Meta

bcoin.setup_logging()

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

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

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

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

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

0 comments on commit 8c86a40

Please sign in to comment.